Changeset View
Changeset View
Standalone View
Standalone View
src/server/outputconfiguration_interface.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 43 | public: | |||
---|---|---|---|---|---|
50 | void clearPendingChanges(); | 50 | void clearPendingChanges(); | ||
51 | 51 | | |||
52 | bool hasPendingChanges(OutputDeviceInterface *outputdevice) const; | 52 | bool hasPendingChanges(OutputDeviceInterface *outputdevice) const; | ||
53 | OutputChangeSet* pendingChanges(OutputDeviceInterface *outputdevice); | 53 | OutputChangeSet* pendingChanges(OutputDeviceInterface *outputdevice); | ||
54 | 54 | | |||
55 | OutputManagementInterface *outputManagement; | 55 | OutputManagementInterface *outputManagement; | ||
56 | QHash<OutputDeviceInterface*, OutputChangeSet*> changes; | 56 | QHash<OutputDeviceInterface*, OutputChangeSet*> changes; | ||
57 | 57 | | |||
58 | static const quint32 s_version = 1; | 58 | static const quint32 s_version = 2; | ||
59 | 59 | | |||
60 | private: | 60 | private: | ||
61 | static void enableCallback(wl_client *client, wl_resource *resource, | 61 | static void enableCallback(wl_client *client, wl_resource *resource, | ||
62 | wl_resource * outputdevice, int32_t enable); | 62 | wl_resource * outputdevice, int32_t enable); | ||
63 | static void modeCallback(wl_client *client, wl_resource *resource, | 63 | static void modeCallback(wl_client *client, wl_resource *resource, | ||
64 | wl_resource * outputdevice, int32_t mode_id); | 64 | wl_resource * outputdevice, int32_t mode_id); | ||
65 | static void transformCallback(wl_client *client, wl_resource *resource, | 65 | static void transformCallback(wl_client *client, wl_resource *resource, | ||
66 | wl_resource * outputdevice, int32_t transform); | 66 | wl_resource * outputdevice, int32_t transform); | ||
67 | static void positionCallback(wl_client *client, wl_resource *resource, | 67 | static void positionCallback(wl_client *client, wl_resource *resource, | ||
68 | wl_resource * outputdevice, int32_t x, int32_t y); | 68 | wl_resource * outputdevice, int32_t x, int32_t y); | ||
69 | static void scaleCallback(wl_client *client, wl_resource *resource, | 69 | static void scaleCallback(wl_client *client, wl_resource *resource, | ||
70 | wl_resource * outputdevice, int32_t scale); | 70 | wl_resource * outputdevice, int32_t scale); | ||
71 | static void applyCallback(wl_client *client, wl_resource *resource); | 71 | static void applyCallback(wl_client *client, wl_resource *resource); | ||
72 | static void colorcurvesCallback(wl_client *client, wl_resource *resource, | ||||
73 | wl_resource * outputdevice, | ||||
74 | wl_array *red, wl_array *green, wl_array *blue); | ||||
72 | 75 | | |||
73 | OutputConfigurationInterface *q_func() { | 76 | OutputConfigurationInterface *q_func() { | ||
74 | return reinterpret_cast<OutputConfigurationInterface *>(q); | 77 | return reinterpret_cast<OutputConfigurationInterface *>(q); | ||
75 | } | 78 | } | ||
76 | 79 | | |||
77 | static const struct org_kde_kwin_outputconfiguration_interface s_interface; | 80 | static const struct org_kde_kwin_outputconfiguration_interface s_interface; | ||
78 | }; | 81 | }; | ||
79 | 82 | | |||
80 | const struct org_kde_kwin_outputconfiguration_interface OutputConfigurationInterface::Private::s_interface = { | 83 | const struct org_kde_kwin_outputconfiguration_interface OutputConfigurationInterface::Private::s_interface = { | ||
81 | enableCallback, | 84 | enableCallback, | ||
82 | modeCallback, | 85 | modeCallback, | ||
83 | transformCallback, | 86 | transformCallback, | ||
84 | positionCallback, | 87 | positionCallback, | ||
85 | scaleCallback, | 88 | scaleCallback, | ||
86 | applyCallback | 89 | applyCallback, | ||
90 | colorcurvesCallback | ||||
87 | }; | 91 | }; | ||
88 | 92 | | |||
89 | OutputConfigurationInterface::OutputConfigurationInterface(OutputManagementInterface* parent, wl_resource* parentResource): Resource(new Private(this, parent, parentResource)) | 93 | OutputConfigurationInterface::OutputConfigurationInterface(OutputManagementInterface* parent, wl_resource* parentResource): Resource(new Private(this, parent, parentResource)) | ||
90 | { | 94 | { | ||
91 | Q_D(); | 95 | Q_D(); | ||
92 | d->outputManagement = parent; | 96 | d->outputManagement = parent; | ||
93 | } | 97 | } | ||
94 | 98 | | |||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | |||||
188 | void OutputConfigurationInterface::Private::applyCallback(wl_client *client, wl_resource *resource) | 192 | void OutputConfigurationInterface::Private::applyCallback(wl_client *client, wl_resource *resource) | ||
189 | { | 193 | { | ||
190 | Q_UNUSED(client); | 194 | Q_UNUSED(client); | ||
191 | auto s = cast<Private>(resource); | 195 | auto s = cast<Private>(resource); | ||
192 | Q_ASSERT(s); | 196 | Q_ASSERT(s); | ||
193 | s->emitConfigurationChangeRequested(); | 197 | s->emitConfigurationChangeRequested(); | ||
194 | } | 198 | } | ||
195 | 199 | | |||
200 | void OutputConfigurationInterface::Private::colorcurvesCallback(wl_client *client, wl_resource *resource, | ||||
201 | wl_resource * outputdevice, | ||||
202 | wl_array *red, wl_array *green, wl_array *blue) | ||||
203 | { | ||||
204 | Q_UNUSED(client); | ||||
205 | OutputDeviceInterface *o = OutputDeviceInterface::get(outputdevice); | ||||
206 | OutputDeviceInterface::ColorCurves oldCc = o->colorCurves(); | ||||
207 | | ||||
208 | auto checkArg = [](wl_array *newColor, const QVector<quint16> &oldColor) { | ||||
zzag: constify newColor?
Also, you could cast oldColor.size() in C++ manner, e.g. static_cast<size_t>… | |||||
209 | return (newColor->size % sizeof(uint16_t) == 0) && | ||||
210 | (newColor->size / sizeof(uint16_t) == (size_t)oldColor.size()); | ||||
211 | }; | ||||
212 | if (!checkArg(red, oldCc.red) || !checkArg(green, oldCc.green) || !checkArg(blue, oldCc.blue)) { | ||||
213 | qCWarning(KWAYLAND_SERVER) << "Requested to change color curves, but have wrong size."; | ||||
214 | return; | ||||
215 | } | ||||
216 | | ||||
217 | auto s = cast<Private>(resource); | ||||
X11 uses 16 bit values even for 24 bit screens, because the actual values that are sent to the DAC can have higher precision than the screen pixmap. I doubt that Wayland has reduced the precision, so I don't think checking values here is right. cfeck: X11 uses 16 bit values even for 24 bit screens, because the actual values that are sent to the… | |||||
I forget to remove this comment. This is not an issue since we can "stretch" the image over the whole uint16_t value domain linearly such that image 1 is associated with the largest uint16_t value. By that we have well defined arguments in any case. The array size though is checked before that in the checkArg call by comparing it with the size set first by the compositor. romangg: I forget to remove this comment. This is not an issue since we can "stretch" the image over the… | |||||
218 | Q_ASSERT(s); | ||||
219 | OutputDeviceInterface::ColorCurves cc; | ||||
220 | | ||||
221 | auto fillVector = [](wl_array *array, QVector<quint16> *v) { | ||||
zzag: constify wl_array?
constify pos, e.g. `uint16_t const *pos`? | |||||
zzag: You can resize v and call memcpy (or use std::copy?) | |||||
222 | uint16_t *pos = (uint16_t*)array->data; | ||||
223 | | ||||
224 | while((char*)pos < (char*)array->data + array->size) { | ||||
225 | v->append(*pos); | ||||
226 | pos++; | ||||
227 | } | ||||
228 | }; | ||||
229 | fillVector(red, &cc.red); | ||||
230 | fillVector(green, &cc.green); | ||||
231 | fillVector(blue, &cc.blue); | ||||
232 | | ||||
233 | s->pendingChanges(o)->d_func()->colorCurves = cc; | ||||
234 | } | ||||
235 | | ||||
196 | void OutputConfigurationInterface::Private::emitConfigurationChangeRequested() const | 236 | void OutputConfigurationInterface::Private::emitConfigurationChangeRequested() const | ||
197 | { | 237 | { | ||
198 | auto configinterface = reinterpret_cast<OutputConfigurationInterface *>(q); | 238 | auto configinterface = reinterpret_cast<OutputConfigurationInterface *>(q); | ||
199 | emit outputManagement->configurationChangeRequested(configinterface); | 239 | emit outputManagement->configurationChangeRequested(configinterface); | ||
200 | } | 240 | } | ||
201 | 241 | | |||
202 | 242 | | |||
203 | OutputConfigurationInterface::Private::Private(OutputConfigurationInterface *q, OutputManagementInterface *c, wl_resource *parentResource) | 243 | OutputConfigurationInterface::Private::Private(OutputConfigurationInterface *q, OutputManagementInterface *c, wl_resource *parentResource) | ||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |
constify newColor?
Also, you could cast oldColor.size() in C++ manner, e.g. static_cast<size_t>(...)?