File indexing completed on 2024-04-14 04:16:23
0001 /******************************************************************** 0002 KolorServer - color server based on the X Color Management Specification 0003 This file is part of the KDE project. 0004 0005 Copyright (C) 2012 Casian Andrei <skeletk13@gmail.com> 0006 0007 Redistribution and use in source and binary forms, with or without 0008 modification, are permitted provided that the following conditions 0009 are met: 0010 0011 1. Redistributions of source code must retain the above copyright 0012 notice, this list of conditions and the following disclaimer. 0013 2. Redistributions in binary form must reproduce the above copyright 0014 notice, this list of conditions and the following disclaimer in the 0015 documentation and/or other materials provided with the distribution. 0016 0017 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0018 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0019 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0020 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0021 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0022 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0024 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0025 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0026 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0027 *********************************************************************/ 0028 0029 #ifndef KOLOR_SERVER_OUTPUT_H_ 0030 #define KOLOR_SERVER_OUTPUT_H_ 0031 0032 #include "color-context.h" 0033 #include "x11-helpers.h" 0034 0035 namespace KolorServer 0036 { 0037 0038 class Screen; 0039 0040 /** 0041 * Handles an output color profile. 0042 * Output profiles are currently only fetched using XRandR. 0043 * 0044 * \note PrivColorOutput 0045 */ 0046 class ColorOutput 0047 { 0048 public: 0049 ColorOutput(Screen *parent, int index); 0050 virtual ~ColorOutput(); 0051 0052 /** 0053 * \return The destination profile for this output 0054 */ 0055 oyProfile_s *profile(); 0056 0057 /** 0058 * Set a custom profile for this output (the embedded context's 0059 * destination profile). Any existing profile will be discarded. 0060 */ 0061 void setProfile(oyProfile_s *profile); 0062 0063 /** 0064 * \return Name of the output 0065 */ 0066 const QString& name(); 0067 0068 /** 0069 * \return The color lookup table for this context 0070 */ 0071 const Clut& colorLookupTable() const; 0072 0073 /** 0074 * \note hasScreenProfile 0075 * - get a magic atom name from the output index 0076 * - fetch the data from the atom 0077 * - return true if not empty 0078 * 0079 * Used by: cleanDisplayProfiles 0080 */ 0081 bool hasProfileAtom(); 0082 0083 /** 0084 * \note cleanScreenProfile 0085 * - get a magic atom name from the output index 0086 * - delete the atom 0087 * 0088 * Used by: cleanDisplayProfiles 0089 */ 0090 void cleanProfileAtom(); 0091 0092 /** 0093 * \param init operate in initialization mode 0094 * \param device device (output) to be used for this color output 0095 * In init mode, first grabs the device profile. 0096 * Moves profile atoms according to XCM spec. 0097 * Finally, configures the color lookup table. 0098 */ 0099 void updateConfiguration(oyConfig_s *device, bool init); 0100 0101 /** 0102 * \return The right X11 atom for the output given by \param num. 0103 */ 0104 static X11::Atom iccProfileAtom(X11::Display *display, int num, bool forServer); 0105 0106 private: 0107 /** 0108 * \note getDeviceProfile 0109 * - get some device rectangle and setup the output's rect 0110 * - get the device name and setup the output's name 0111 * - release old cc.dst_profile 0112 * - get the cc.dst_profile from the specified device 0113 * 0114 * Used by: updateOutputConfiguration (on init) 0115 * 0116 * \return true on success 0117 */ 0118 bool getDeviceProfile(oyConfig_s *device); 0119 0120 /** 0121 * \note setupOutputTable 0122 * 0123 * Used by: updateOutputConfiguration for all contexts 0124 */ 0125 void setup(); 0126 0127 /** 0128 * \note moveICCprofileAtoms 0129 * - get magic atom names for both x_base and color_server things 0130 * - on init copy a -> da, else copy da -> a 0131 * - fetch source data from atom 0132 * - fetch dest data from atom 0133 * - on init call updateNetColorDesktopAtom 0134 * - set data in target atom copy from source data 0135 * - on init destabilize source atom with "screen document profile" data 0136 * - else just delete it 0137 * 0138 * Used by: updateOutputConfiguration, pluginFiniScreen (destructor?) 0139 */ 0140 void moveProfileAtoms(bool init); 0141 0142 private: 0143 Screen *m_parent; 0144 int m_index; 0145 QString m_name; 0146 ColorContext m_cc; 0147 QRect m_rect; 0148 int icc_profile_flags; ///< profile selection flags from oyProfile_s.h 0149 }; 0150 0151 } // KolorServer namespace 0152 0153 #endif // KOLOR_SERVER_OUTPUT_H_