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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 4136
Merged at revision: 4124
Proposed branch: lp:~3v1n0/compiz/resize-lowgfx-fixes
Merge into: lp:compiz/0.9.13
Prerequisite: lp:~3v1n0/compiz/grid-lowgfx-fixes
Diff against target: 225 lines (+89/-32)
4 files modified
debian/unity-lowgfx.ini (+1/-0)
plugins/resize/resize.xml.in (+5/-0)
plugins/resize/src/logic/src/resize-logic.cpp (+8/-6)
plugins/resize/src/resize.cpp (+75/-26)
To merge this branch: bzr merge lp:~3v1n0/compiz/resize-lowgfx-fixes
Reviewer Review Type Date Requested Status
Andrea Azzarone Approve
Review via email: mp+326491@code.launchpad.net

Commit message

resize: add support for disabling transparency and avoid over-damaging in outline mode

To post a comment you must log in.
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-06-29 02:14:38 +0000
3+++ debian/unity-lowgfx.ini 2017-06-29 02:14:38 +0000
4@@ -17,6 +17,7 @@
5
6 [resize]
7 s0_mode = 2
8+s0_disable_blend = true
9
10 [opengl]
11 s0_texture_filter = 0
12
13=== modified file 'plugins/resize/resize.xml.in'
14--- plugins/resize/resize.xml.in 2015-10-26 17:15:43 +0000
15+++ plugins/resize/resize.xml.in 2017-06-29 02:14:38 +0000
16@@ -78,6 +78,11 @@
17 <alpha>0x1919</alpha>
18 </default>
19 </option>
20+ <option name="disable_blend" type="bool">
21+ <_short>Disable Transparency</_short>
22+ <_long>Disable blending.</_long>
23+ <default>false</default>
24+ </option>
25 <subgroup>
26 <_short>Specific Window Matches</_short>
27 <option name="normal_match" type="match">
28
29=== modified file 'plugins/resize/src/logic/src/resize-logic.cpp'
30--- plugins/resize/src/logic/src/resize-logic.cpp 2016-03-03 14:22:25 +0000
31+++ plugins/resize/src/logic/src/resize-logic.cpp 2017-06-29 02:14:38 +0000
32@@ -487,13 +487,13 @@
33 che = he;
34
35 if (w->constrainNewWindowSize (wi, he, &cwi, &che) &&
36- mode != ResizeOptions::ModeNormal)
37+ mode != ResizeOptions::ModeNormal &&
38+ mode != ResizeOptions::ModeOutline)
39 {
40 Box box;
41
42 /* Also, damage relevant paint rectangles */
43- if (mode == ResizeOptions::ModeRectangle ||
44- mode == ResizeOptions::ModeOutline)
45+ if (mode == ResizeOptions::ModeRectangle)
46 getPaintRectangle (&box);
47 else if (mode == ResizeOptions::ModeStretch)
48 getStretchRectangle (&box);
49@@ -518,7 +518,8 @@
50 xRoot, yRoot,
51 wX, wY, wWidth, wHeight); /*in*/
52
53- if (mode != ResizeOptions::ModeNormal)
54+ if (mode != ResizeOptions::ModeNormal &&
55+ mode != ResizeOptions::ModeOutline)
56 {
57 if (mode == ResizeOptions::ModeStretch)
58 getStretchRectangle (&box);
59@@ -532,7 +533,8 @@
60
61 computeGeometry (wi, he);
62
63- if (mode != ResizeOptions::ModeNormal)
64+ if (mode != ResizeOptions::ModeNormal &&
65+ mode != ResizeOptions::ModeOutline)
66 {
67 if (mode == ResizeOptions::ModeStretch)
68 getStretchRectangle (&box);
69@@ -541,7 +543,7 @@
70
71 damageRectangle (&box);
72 }
73- else
74+ else if (mode == ResizeOptions::ModeNormal)
75 {
76 updateWindowSize ();
77 }
78
79=== modified file 'plugins/resize/src/resize.cpp'
80--- plugins/resize/src/resize.cpp 2015-10-20 15:01:58 +0000
81+++ plugins/resize/src/resize.cpp 2017-06-29 02:14:38 +0000
82@@ -85,30 +85,44 @@
83 unsigned short *fillColor)
84 {
85 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
86+ const unsigned short MaxUShort = std::numeric_limits <unsigned short>::max ();
87+ const float MaxUShortFloat = MaxUShort;
88
89 BoxRec box;
90+ CompRegion damageRegion;
91 GLMatrix sTransform (transform);
92 GLfloat vertexData [12];
93 GLfloat vertexData2[24];
94 GLint origSrc, origDst;
95 GLushort fc[4], bc[4];
96
97+ bool blend = !optionGetDisableBlend ();
98+
99+ if (blend && borderColor[3] == MaxUShort)
100+ {
101+ if (optionGetMode () == ResizeOptions::ModeOutline || fillColor[3] == MaxUShort)
102+ blend = false;
103+ }
104+
105+ if (blend)
106+ {
107 #ifdef USE_GLES
108- GLint origSrcAlpha, origDstAlpha;
109- glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
110- glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
111- glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
112- glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
113+ GLint origSrcAlpha, origDstAlpha;
114+ glGetIntegerv (GL_BLEND_SRC_RGB, &origSrc);
115+ glGetIntegerv (GL_BLEND_DST_RGB, &origDst);
116+ glGetIntegerv (GL_BLEND_SRC_ALPHA, &origSrcAlpha);
117+ glGetIntegerv (GL_BLEND_DST_ALPHA, &origDstAlpha);
118 #else
119- glGetIntegerv (GL_BLEND_SRC, &origSrc);
120- glGetIntegerv (GL_BLEND_DST, &origDst);
121+ glGetIntegerv (GL_BLEND_SRC, &origSrc);
122+ glGetIntegerv (GL_BLEND_DST, &origDst);
123 #endif
124+ }
125
126 /* Premultiply the alpha values */
127- bc[3] = (float) borderColor[3] / (float) 65535.0f;
128- bc[0] = ((float) borderColor[0] / 65535.0f) * bc[3];
129- bc[1] = ((float) borderColor[1] / 65535.0f) * bc[3];
130- bc[2] = ((float) borderColor[2] / 65535.0f) * bc[3];
131+ bc[3] = blend ? ((float) borderColor[3] / MaxUShortFloat) : MaxUShortFloat;
132+ bc[0] = ((float) borderColor[0] / MaxUShortFloat) * bc[3];
133+ bc[1] = ((float) borderColor[1] / MaxUShortFloat) * bc[3];
134+ bc[2] = ((float) borderColor[2] / MaxUShortFloat) * bc[3];
135
136 logic.getPaintRectangle (&box);
137
138@@ -159,16 +173,19 @@
139
140 sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
141
142- glEnable (GL_BLEND);
143- glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
144+ if (blend)
145+ {
146+ glEnable (GL_BLEND);
147+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
148+ }
149
150 /* fill rectangle */
151 if (fillColor)
152 {
153- fc[3] = fillColor[3];
154- fc[0] = fillColor[0] * (unsigned long)fc[3] / 65535;
155- fc[1] = fillColor[1] * (unsigned long)fc[3] / 65535;
156- fc[2] = fillColor[2] * (unsigned long)fc[3] / 65535;
157+ fc[3] = blend ? fillColor[3] : 0.85f * MaxUShortFloat;
158+ fc[0] = fillColor[0] * (unsigned long) fc[3] / MaxUShortFloat;
159+ fc[1] = fillColor[1] * (unsigned long) fc[3] / MaxUShortFloat;
160+ fc[2] = fillColor[2] * (unsigned long) fc[3] / MaxUShortFloat;
161
162 streamingBuffer->begin (GL_TRIANGLE_STRIP);
163 streamingBuffer->addColors (1, fc);
164@@ -186,20 +203,52 @@
165 streamingBuffer->end ();
166 streamingBuffer->render (sTransform);
167
168- glDisable (GL_BLEND);
169+ if (blend)
170+ {
171+ glDisable (GL_BLEND);
172 #ifdef USE_GLES
173- glBlendFuncSeparate (origSrc, origDst,
174- origSrcAlpha, origDstAlpha);
175+ glBlendFuncSeparate (origSrc, origDst,
176+ origSrcAlpha, origDstAlpha);
177 #else
178- glBlendFunc (origSrc, origDst);
179+ glBlendFunc (origSrc, origDst);
180 #endif
181+ }
182
183 CompositeScreen *cScreen = CompositeScreen::get (screen);
184- CompRect damage (box.x1 - borderWidth,
185- box.y1 - borderWidth,
186- box.x2 - box.x1 + 2 * borderWidth,
187- box.y2 - box.y1 + 2 * borderWidth);
188- cScreen->damageRegion (damage);
189+
190+ if (optionGetMode () == ResizeOptions::ModeOutline)
191+ {
192+ // Top
193+ damageRegion += CompRect (box.x1 - borderWidth,
194+ box.y1 - borderWidth,
195+ box.x2 - box.x1 + borderWidth * 2,
196+ borderWidth + 1);
197+ // Right
198+ damageRegion += CompRect (box.x2 - borderWidth,
199+ box.y1 - borderWidth,
200+ borderWidth + 1,
201+ box.y2 - box.y1 + borderWidth * 2);
202+ // Bottom
203+ damageRegion += CompRect (box.x1 - borderWidth,
204+ box.y2 - borderWidth,
205+ box.x2 - box.x1 + borderWidth * 2,
206+ borderWidth + 1);
207+ // Left
208+ damageRegion += CompRect (box.x1 - borderWidth,
209+ box.y1 - borderWidth,
210+ borderWidth + 1,
211+ box.y2 - box.y1 + borderWidth * 2);
212+ }
213+ else
214+ {
215+ CompRect damage (box.x1 - borderWidth,
216+ box.y1 - borderWidth,
217+ box.x2 - box.x1 + borderWidth * 2,
218+ box.y2 - box.y1 + borderWidth * 2);
219+ damageRegion += damage;
220+ }
221+
222+ cScreen->damageRegion (damageRegion);
223 }
224
225 bool

Subscribers

People subscribed via source and target branches