Merge lp:~3v1n0/unity/scale-glow-corners into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2813
Proposed branch: lp:~3v1n0/unity/scale-glow-corners
Merge into: lp:unity
Diff against target: 252 lines (+49/-61)
3 files modified
plugins/unityshell/src/unityshell.cpp (+10/-12)
plugins/unityshell/src/unityshell.h (+1/-1)
plugins/unityshell/src/unityshell_glow.cpp (+38/-48)
To merge this branch: bzr merge lp:~3v1n0/unity/scale-glow-corners
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+128262@code.launchpad.net

Commit message

UnityWindow: draw the glow for scaled windows a little inside their area, to glow rounded corners too

Description of the change

When a selected window in scale is drawn we were drawing its glow outside its shape, however this would make our rounded corners to be wrongly drawn. So now we draw a bigger glow few pixels inside the window, so that the corners will be correctly rendered.

Before this fix: https://launchpadlibrarian.net/118482869/scale-glow-corners.png
After: http://i.imgur.com/vzQ7J.png

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM. Nice fix.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1490/console reported an error when processing this lp:~3v1n0/unity/scale-glow-corners branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/1492/console reported an error when processing this lp:~3v1n0/unity/scale-glow-corners branch.
Not merging it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2012-10-05 01:31:19 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2012-10-05 14:34:24 +0000
4@@ -112,7 +112,7 @@
5 const unsigned CLOSE_SIZE = 19;
6 const unsigned ITEMS_PADDING = 5;
7 const unsigned RADIUS = 8;
8-const unsigned GLOW = 20;
9+const unsigned GLOW = 30;
10 const nux::Color GLOW_COLOR(221, 72, 20);
11 } // decoration namespace
12 } // scale namespace
13@@ -2459,6 +2459,15 @@
14 }
15 }
16
17+ if (WindowManager::Default()->IsScaleActive() && ScaleScreen::get(screen)->getSelectedWindow() == window->id())
18+ {
19+ nux::Geometry scaled_geo = GetScaledGeometry();
20+ int inside_glow = scale::decoration::RADIUS/4;
21+ scaled_geo.Expand(-inside_glow, -inside_glow);
22+ glow::Quads const& quads = computeGlowQuads(scaled_geo, glow_texture_, scale::decoration::GLOW);
23+ paintGlow(matrix, attrib, region, quads, glow_texture_, scale::decoration::GLOW_COLOR, mask);
24+ }
25+
26 return gWindow->glPaint(wAttrib, matrix, region, mask);
27 }
28
29@@ -2520,17 +2529,6 @@
30 uScreen->paintPanelShadow(region);
31 }
32
33- if (WindowManager::Default().IsScaleActive() &&
34- ScaleScreen::get(screen)->getSelectedWindow() == window->id())
35- {
36- if (!region.isEmpty())
37- {
38- double scale = ScaleWindow::get(window)->getCurrentPosition().scale;
39- glow::Quads const& quads = computeGlowQuads(glow_texture_, scale::decoration::GLOW, scale);
40- paintGlow(matrix, attrib, region, quads, glow_texture_, scale::decoration::GLOW_COLOR, mask);
41- }
42- }
43-
44 return ret;
45 }
46
47
48=== modified file 'plugins/unityshell/src/unityshell.h'
49--- plugins/unityshell/src/unityshell.h 2012-10-04 10:56:59 +0000
50+++ plugins/unityshell/src/unityshell.h 2012-10-05 14:34:24 +0000
51@@ -450,7 +450,7 @@
52 void DrawTexture(GLTexture::List const& textures, GLWindowPaintAttrib const&,
53 GLMatrix const&, unsigned mask, int x, int y, double aspect = 1.0f);
54
55- glow::Quads computeGlowQuads(GLTexture::List const& texture, int glow_size, double window_aspect = 1.0f);
56+ glow::Quads computeGlowQuads(nux::Geometry const& geo, GLTexture::List const& texture, int glow_size);
57 void paintGlow(GLMatrix const&, GLWindowPaintAttrib const&, CompRegion const&,
58 glow::Quads const&, GLTexture::List const&, nux::Color const&, unsigned mask);
59
60
61=== modified file 'plugins/unityshell/src/unityshell_glow.cpp'
62--- plugins/unityshell/src/unityshell_glow.cpp 2012-09-27 11:02:07 +0000
63+++ plugins/unityshell/src/unityshell_glow.cpp 2012-10-05 14:34:24 +0000
64@@ -130,7 +130,7 @@
65 * adjusted by the matrix scale factor (matrix->xx and matrix->yy)
66 *
67 */
68-glow::Quads UnityWindow::computeGlowQuads(GLTexture::List const& texture, int glow_size, double window_aspect)
69+glow::Quads UnityWindow::computeGlowQuads(nux::Geometry const& geo, GLTexture::List const& texture, int glow_size)
70 {
71 glow::Quads glow_quads;
72
73@@ -139,13 +139,11 @@
74
75 int x1, x2, y1, y2;
76 int glow_offset;
77- CompRect const& border_rect = window->borderRect();
78 GLTexture::Matrix const& matrix = texture.front()->matrix();
79
80 CompRect *box;
81 GLTexture::Matrix *quadMatrix;
82
83- glow_size /= window_aspect;
84 glow_offset = (glow_size * texture::GLOW_OFFSET / texture::GLOW_SIZE) + 1;
85
86 /* Top left corner */
87@@ -156,8 +154,8 @@
88 /* Set the desired rect dimentions
89 * for the part of the glow we are painting */
90
91- x1 = border_rect.x() - glow_size + glow_offset;
92- y1 = border_rect.y() - glow_size + glow_offset;
93+ x1 = geo.x - glow_size + glow_offset;
94+ y1 = geo.y - glow_size + glow_offset;
95
96 /* 2x2 Matrix here, adjust both x and y scale factors
97 * and the x and y position
98@@ -175,10 +173,8 @@
99 quadMatrix->x0 = -(x1 * quadMatrix->xx);
100 quadMatrix->y0 = -(y1 * quadMatrix->yy);
101
102- x2 = std::min<int>(border_rect.x() + glow_offset,
103- border_rect.x() + (border_rect.width() / 2));
104- y2 = std::min<int>(border_rect.y() + glow_offset,
105- border_rect.y() + (border_rect.height() / 2));
106+ x2 = std::min<int>(geo.x + glow_offset, geo.x + (geo.width / 2));
107+ y2 = std::min<int>(geo.y + glow_offset, geo.y + (geo.height / 2));
108
109 box->setGeometry(x1, y1, x2 - x1, y2 - y1);
110
111@@ -190,9 +186,9 @@
112 /* Set the desired rect dimentions
113 * for the part of the glow we are painting */
114
115- x1 = border_rect.x() + border_rect.width() - glow_offset;
116- y1 = border_rect.y() - glow_size + glow_offset;
117- x2 = border_rect.x() + border_rect.width() + glow_size - glow_offset;
118+ x1 = geo.x + geo.width - glow_offset;
119+ y1 = geo.y - glow_size + glow_offset;
120+ x2 = geo.x + geo.width + glow_size - glow_offset;
121
122 /*
123 * 2x2 Matrix here, adjust both x and y scale factors
124@@ -213,10 +209,8 @@
125 quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx);
126 quadMatrix->y0 = -(y1 * quadMatrix->yy);
127
128- x1 = std::max<int>(border_rect.x() + border_rect.width() - glow_offset,
129- border_rect.x() + (border_rect.width() / 2));
130- y2 = std::min<int>(border_rect.y() + glow_offset,
131- border_rect.y() + (border_rect.height() / 2));
132+ x1 = std::max<int>(geo.x + geo.width - glow_offset, geo.x + (geo.width / 2));
133+ y2 = std::min<int>(geo.y + glow_offset, geo.y + (geo.height / 2));
134
135 box->setGeometry(x1, y1, x2 - x1, y2 - y1);
136
137@@ -225,10 +219,10 @@
138 glow_quads[glow::QuadPos::BOTTOMLEFT].matrix = matrix;
139 quadMatrix = &glow_quads[glow::QuadPos::BOTTOMLEFT].matrix;
140
141- x1 = border_rect.x() - glow_size + glow_offset;
142- y1 = border_rect.y() + border_rect.height() - glow_offset;
143- x2 = border_rect.x() + glow_offset;
144- y2 = border_rect.y() + border_rect.height() + glow_size - glow_offset;
145+ x1 = geo.x - glow_size + glow_offset;
146+ y1 = geo.y + geo.height - glow_offset;
147+ x2 = geo.x + glow_offset;
148+ y2 = geo.y + geo.height + glow_size - glow_offset;
149
150 /* 2x2 Matrix here, adjust both x and y scale factors
151 * and the x and y position
152@@ -248,10 +242,8 @@
153 quadMatrix->x0 = -(x1 * quadMatrix->xx);
154 quadMatrix->y0 = 1.0f - (y1 * quadMatrix->yy);
155
156- y1 = std::max<int>(border_rect.y() + border_rect.height() - glow_offset,
157- border_rect.y() + (border_rect.height() / 2));
158- x2 = std::min<int>(border_rect.x() + glow_offset,
159- border_rect.x() + (border_rect.width() / 2));
160+ y1 = std::max<int>(geo.y + geo.height - glow_offset, geo.y + (geo.height / 2));
161+ x2 = std::min<int>(geo.x + glow_offset, geo.x + (geo.width / 2));
162
163 box->setGeometry(x1, y1, x2 - x1, y2 - y1);
164
165@@ -260,10 +252,10 @@
166 glow_quads[glow::QuadPos::BOTTOMRIGHT].matrix = matrix;
167 quadMatrix = &glow_quads[glow::QuadPos::BOTTOMRIGHT].matrix;
168
169- x1 = border_rect.x() + border_rect.width() - glow_offset;
170- y1 = border_rect.y() + border_rect.height() - glow_offset;
171- x2 = border_rect.x() + border_rect.width() + glow_size - glow_offset;
172- y2 = border_rect.y() + border_rect.height() + glow_size - glow_offset;
173+ x1 = geo.x + geo.width - glow_offset;
174+ y1 = geo.y + geo.height - glow_offset;
175+ x2 = geo.x + geo.width + glow_size - glow_offset;
176+ y2 = geo.y + geo.height + glow_size - glow_offset;
177
178 /* 2x2 Matrix here, adjust both x and y scale factors
179 * and the x and y position
180@@ -281,10 +273,8 @@
181 quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx);
182 quadMatrix->y0 = 1.0 - (y1 * quadMatrix->yy);
183
184- x1 = std::max<int>(border_rect.x() + border_rect.width() - glow_offset,
185- border_rect.x() + (border_rect.width() / 2));
186- y1 = std::max<int>(border_rect.y() + border_rect.height() - glow_offset,
187- border_rect.y() + (border_rect.height() / 2));
188+ x1 = std::max<int>(geo.x + geo.width - glow_offset, geo.x + (geo.width / 2));
189+ y1 = std::max<int>(geo.y + geo.height - glow_offset, geo.y + (geo.height / 2));
190
191 box->setGeometry(x1, y1, x2 - x1, y2 - y1);
192
193@@ -293,10 +283,10 @@
194 glow_quads[glow::QuadPos::TOP].matrix = matrix;
195 quadMatrix = &glow_quads[glow::QuadPos::TOP].matrix;
196
197- x1 = border_rect.x() + glow_offset;
198- y1 = border_rect.y() - glow_size + glow_offset;
199- x2 = border_rect.x() + border_rect.width() - glow_offset;
200- y2 = border_rect.y() + glow_offset;
201+ x1 = geo.x + glow_offset;
202+ y1 = geo.y - glow_size + glow_offset;
203+ x2 = geo.x + geo.width - glow_offset;
204+ y2 = geo.y + glow_offset;
205
206 /* 2x2 Matrix here, adjust both x and y scale factors
207 * and the x and y position
208@@ -321,10 +311,10 @@
209 glow_quads[glow::QuadPos::BOTTOM].matrix = matrix;
210 quadMatrix = &glow_quads[glow::QuadPos::BOTTOM].matrix;
211
212- x1 = border_rect.x() + glow_offset;
213- y1 = border_rect.y() + border_rect.height() - glow_offset;
214- x2 = border_rect.x() + border_rect.width() - glow_offset;
215- y2 = border_rect.y() + border_rect.height() + glow_size - glow_offset;
216+ x1 = geo.x + glow_offset;
217+ y1 = geo.y + geo.height - glow_offset;
218+ x2 = geo.x + geo.width - glow_offset;
219+ y2 = geo.y + geo.height + glow_size - glow_offset;
220
221 /* 2x2 Matrix here, adjust both x and y scale factors
222 * and the x and y position
223@@ -349,10 +339,10 @@
224 glow_quads[glow::QuadPos::LEFT].matrix = matrix;
225 quadMatrix = &glow_quads[glow::QuadPos::LEFT].matrix;
226
227- x1 = border_rect.x() - glow_size + glow_offset;
228- y1 = border_rect.y() + glow_offset;
229- x2 = border_rect.x() + glow_offset;
230- y2 = border_rect.y() + border_rect.height() - glow_offset;
231+ x1 = geo.x - glow_size + glow_offset;
232+ y1 = geo.y + glow_offset;
233+ x2 = geo.x + glow_offset;
234+ y2 = geo.y + geo.height - glow_offset;
235
236 /* 2x2 Matrix here, adjust both x and y scale factors
237 * and the x and y position
238@@ -377,10 +367,10 @@
239 glow_quads[glow::QuadPos::RIGHT].matrix = matrix;
240 quadMatrix = &glow_quads[glow::QuadPos::RIGHT].matrix;
241
242- x1 = border_rect.x() + border_rect.width() - glow_offset;
243- y1 = border_rect.y() + glow_offset;
244- x2 = border_rect.x() + border_rect.width() + glow_size - glow_offset;
245- y2 = border_rect.y() + border_rect.height() - glow_offset;
246+ x1 = geo.x + geo.width - glow_offset;
247+ y1 = geo.y + glow_offset;
248+ x2 = geo.x + geo.width + glow_size - glow_offset;
249+ y2 = geo.y + geo.height - glow_offset;
250
251 /* 2x2 Matrix here, adjust both x and y scale factors
252 * and the x and y position