Merge lp:~3v1n0/compiz/move-lowgfx-fixes into lp:compiz/0.9.13

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 4129
Merged at revision: 4122
Proposed branch: lp:~3v1n0/compiz/move-lowgfx-fixes
Merge into: lp:compiz/0.9.13
Diff against target: 315 lines (+87/-86)
3 files modified
debian/unity-lowgfx.ini (+1/-0)
plugins/move/src/move.cpp (+82/-86)
plugins/move/src/move.h (+4/-0)
To merge this branch: bzr merge lp:~3v1n0/compiz/move-lowgfx-fixes
Reviewer Review Type Date Requested Status
Andrea Azzarone Approve
Review via email: mp+326451@code.launchpad.net

Commit message

move: damage all the border area in outline mode and ignore transparent colors

Also we don't really need to damage at every X event. It's just about doing it
right the firs time, by including the exceeding space.
Also optimize damanging in outline-mode, by only touching such regions

Plus add some optimizations when not blending, as we don't care about the alpha channel

To post a comment you must log in.
lp:~3v1n0/compiz/move-lowgfx-fixes updated
4129. By Marco Trevisan (Treviño)

move: properly use the blending if enabled

Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/unity-lowgfx.ini'
2--- debian/unity-lowgfx.ini 2017-01-09 15:08:47 +0000
3+++ debian/unity-lowgfx.ini 2017-06-29 01:58:44 +0000
4@@ -50,3 +50,4 @@
5 [move]
6 s0_mode = 1
7 s0_blend = false
8+s0_lazy_positioning = true
9
10=== modified file 'plugins/move/src/move.cpp'
11--- plugins/move/src/move.cpp 2017-04-20 08:03:29 +0000
12+++ plugins/move/src/move.cpp 2017-06-29 01:58:44 +0000
13@@ -34,9 +34,6 @@
14
15 COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)
16
17-static float pos_x, pos_y;
18-static bool paint_rectangle;
19-
20 static bool
21 moveInitiate (CompAction *action,
22 CompAction::State state,
23@@ -49,13 +46,9 @@
24 if (ms->optionGetMode () != MoveOptions::ModeNormal)
25 {
26 ms->gScreen->glPaintOutputSetEnabled (ms, true);
27- paint_rectangle = true;
28- pos_x = pos_y = 0;
29- }
30- else
31- {
32- ms->gScreen->glPaintOutputSetEnabled (ms, false);
33- paint_rectangle = false;
34+ ms->paintRect = true;
35+ ms->rectX = 0;
36+ ms->rectY = 0;
37 }
38
39 Window xid = CompOption::getIntOptionNamed (options, "window");
40@@ -188,26 +181,15 @@
41 {
42 MOVE_SCREEN (screen);
43
44- if (ms->optionGetMode () != MoveOptions::ModeNormal)
45- {
46- ms->gScreen->glPaintOutputSetEnabled (ms, true);
47- paint_rectangle = true;
48- }
49- else
50- {
51- ms->gScreen->glPaintOutputSetEnabled (ms, false);
52- paint_rectangle = false;
53- }
54-
55 if (ms->w)
56 {
57 MOVE_WINDOW (ms->w);
58
59- if (ms->optionGetMode () != MoveOptions::ModeNormal) {
60+ if (ms->paintRect)
61+ {
62+ ms->paintRect = false;
63 ms->gScreen->glPaintOutputSetEnabled (ms, false);
64- paint_rectangle = false;
65-
66- mw->window->move (pos_x, pos_y, true);
67+ mw->window->move (ms->rectX, ms->rectY, true);
68 }
69
70 if (state & CompAction::StateCancel)
71@@ -564,8 +546,8 @@
72 }
73 else
74 {
75- pos_x += wX + dx - w->geometry ().x ();
76- pos_y += wY + dy - w->geometry ().y ();
77+ ms->rectX += wX + dx - w->geometry ().x ();
78+ ms->rectY += wY + dy - w->geometry ().y ();
79 }
80
81 ms->x -= dx;
82@@ -577,10 +559,6 @@
83 void
84 MoveScreen::handleEvent (XEvent *event)
85 {
86- Box box;
87- if (getMovingRectangle (&box))
88- damageMovingRectangle (&box);
89-
90 switch (event->type)
91 {
92 case ButtonPress:
93@@ -757,6 +735,9 @@
94 status (RectangleOut),
95 releaseButton (0),
96 grab (NULL),
97+ paintRect(false),
98+ rectX(0),
99+ rectY(0),
100 hasCompositing (false),
101 yConstrained (false)
102 {
103@@ -784,16 +765,7 @@
104 ScreenInterface::setHandler (screen);
105 GLScreenInterface::setHandler (gScreen);
106
107- if (optionGetMode () != MoveOptions::ModeNormal)
108- {
109- paint_rectangle = true;
110- gScreen->glPaintOutputSetEnabled (this, true);
111- }
112- else
113- {
114- paint_rectangle = false;
115- gScreen->glPaintOutputSetEnabled (this, false);
116- }
117+ gScreen->glPaintOutputSetEnabled (this, false);
118 }
119
120 MoveScreen::~MoveScreen ()
121@@ -805,12 +777,7 @@
122 bool
123 MoveScreen::getMovingRectangle (BoxPtr pBox)
124 {
125- if (optionGetMode () == MoveOptions::ModeNormal)
126- return false;
127-
128 MOVE_SCREEN (screen);
129- if (!ms)
130- return false;
131
132 CompWindow *w = ms->w;
133 if (!w)
134@@ -821,8 +788,8 @@
135 int wWidth = w->geometry ().widthIncBorders () + w->border ().left + w->border ().right;
136 int wHeight = w->geometry ().heightIncBorders () + w->border ().top + w->border ().bottom;
137
138- pBox->x1 = wX + pos_x;
139- pBox->y1 = wY + pos_y;
140+ pBox->x1 = wX + ms->rectX;
141+ pBox->y1 = wY + ms->rectY;
142
143 pBox->x2 = pBox->x1 + wWidth;
144 pBox->y2 = pBox->y1 + wHeight;
145@@ -838,30 +805,20 @@
146 {
147 bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
148
149- if (status && paint_rectangle)
150+ if (status && paintRect)
151 {
152 unsigned short *borderColor = optionGetBorderColor ();
153- unsigned short *fillColor = optionGetFillColor ();
154-
155- return glPaintMovingRectangle (transform, output, borderColor, (optionGetMode() == MoveOptions::ModeRectangle) ? fillColor : NULL);
156+ unsigned short *fillColor = NULL;
157+
158+ if (optionGetMode() == MoveOptions::ModeRectangle)
159+ fillColor = optionGetFillColor ();
160+
161+ return glPaintMovingRectangle (transform, output, borderColor, fillColor);
162 }
163+
164 return status;
165 }
166
167-void
168-MoveScreen::damageMovingRectangle (BoxPtr pBox)
169-{
170- int x1, x2, y1, y2;
171-
172- x1 = pBox->x1 - 1;
173- y1 = pBox->y1 - 1;
174- x2 = pBox->x2 + 1;
175- y2 = pBox->y2 + 1;
176-
177- if (cScreen)
178- cScreen->damageRegion (CompRect (x1, y1, x2 - x1, y2 - y1));
179-}
180-
181 bool
182 MoveScreen::glPaintMovingRectangle (const GLMatrix &transform,
183 CompOutput *output,
184@@ -872,6 +829,8 @@
185 if (!getMovingRectangle(&box))
186 return false;
187
188+ const unsigned short MaxUShort = std::numeric_limits <unsigned short>::max ();
189+ const float MaxUShortFloat = MaxUShort;
190 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
191 GLMatrix sTransform (transform);
192
193@@ -881,6 +840,13 @@
194 GLint origSrc, origDst;
195
196 bool blend = optionGetBlend ();
197+
198+ if (blend && borderColor[3] == MaxUShort)
199+ {
200+ if (optionGetMode () == MoveOptions::ModeOutline || fillColor[3] == MaxUShort)
201+ blend = false;
202+ }
203+
204 if (blend)
205 {
206 #ifdef USE_GLES
207@@ -895,12 +861,10 @@
208 #endif
209 }
210
211- bc[3] = (float) borderColor[3] / (float) 65535.0f;
212- bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];
213- bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];
214- bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];
215- if (!blend)
216- bc[3] = 1;
217+ bc[3] = blend ? ((float) borderColor[3] / MaxUShortFloat) : MaxUShortFloat;
218+ bc[0] = ((float) borderColor[0] / MaxUShortFloat) * bc[3];
219+ bc[1] = ((float) borderColor[1] / MaxUShortFloat) * bc[3];
220+ bc[2] = ((float) borderColor[2] / MaxUShortFloat) * bc[3];
221
222 vertexData[0] = box.x1;
223 vertexData[1] = box.y1;
224@@ -951,12 +915,10 @@
225 /* fill rectangle */
226 if (fillColor)
227 {
228- fc[3] = fillColor[3];
229- fc[0] = fillColor[0] * (unsigned long) fc[3] / 65535;
230- fc[1] = fillColor[1] * (unsigned long) fc[3] / 65535;
231- fc[2] = fillColor[2] * (unsigned long) fc[3] / 65535;
232- if (!blend)
233- fc[3] = 1;
234+ fc[3] = blend ? fillColor[3] : 0.85f * MaxUShortFloat;
235+ fc[0] = fillColor[0] * (unsigned long) fc[3] / MaxUShortFloat;
236+ fc[1] = fillColor[1] * (unsigned long) fc[3] / MaxUShortFloat;
237+ fc[2] = fillColor[2] * (unsigned long) fc[3] / MaxUShortFloat;
238
239 streamingBuffer->begin (GL_TRIANGLE_STRIP);
240 streamingBuffer->addColors (1, fc);
241@@ -977,18 +939,52 @@
242
243 if (blend)
244 {
245- glEnable (GL_BLEND);
246- glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
247+ glDisable (GL_BLEND);
248+#ifdef USE_GLES
249+ glBlendFuncSeparate (origSrc, origDst,
250+ origSrcAlpha, origDstAlpha);
251+#else
252+ glBlendFunc (origSrc, origDst);
253+#endif
254 }
255
256- CompositeScreen *cScreen = CompositeScreen::get (screen);
257 if (cScreen)
258 {
259- CompRect damage (box.x1 - borderWidth,
260- box.y1 - borderWidth,
261- box.x2 - box.x1 + 2,
262- box.y2 - box.y1 + 2);
263- cScreen->damageRegion (damage);
264+ CompRegion damageRegion;
265+
266+ if (optionGetMode () == MoveOptions::ModeOutline)
267+ {
268+ // Top
269+ damageRegion += CompRect (box.x1 - borderWidth,
270+ box.y1 - borderWidth,
271+ box.x2 - box.x1 + borderWidth * 2,
272+ borderWidth + 1);
273+ // Right
274+ damageRegion += CompRect (box.x2 - borderWidth,
275+ box.y1 - borderWidth,
276+ borderWidth + 1,
277+ box.y2 - box.y1 + borderWidth * 2);
278+ // Bottom
279+ damageRegion += CompRect (box.x1 - borderWidth,
280+ box.y2 - borderWidth,
281+ box.x2 - box.x1 + borderWidth * 2,
282+ borderWidth + 1);
283+ // Left
284+ damageRegion += CompRect (box.x1 - borderWidth,
285+ box.y1 - borderWidth,
286+ borderWidth + 1,
287+ box.y2 - box.y1 + borderWidth * 2);
288+ }
289+ else
290+ {
291+ CompRect damage (box.x1 - borderWidth,
292+ box.y1 - borderWidth,
293+ box.x2 - box.x1 + borderWidth * 2,
294+ box.y2 - box.y1 + borderWidth * 2);
295+ damageRegion += damage;
296+ }
297+
298+ cScreen->damageRegion (damageRegion);
299 }
300
301 return true;
302
303=== modified file 'plugins/move/src/move.h'
304--- plugins/move/src/move.h 2016-09-01 13:59:44 +0000
305+++ plugins/move/src/move.h 2017-06-29 01:58:44 +0000
306@@ -95,6 +95,10 @@
307
308 unsigned int origState;
309
310+ bool paintRect;
311+ int rectX;
312+ int rectY;
313+
314 int snapOffX;
315 int snapBackX;
316

Subscribers

People subscribed via source and target branches