Merge lp:~3v1n0/unity/deco-get-proper-shadow-texture into lp:unity

Proposed by Marco Trevisan (Treviño) on 2016-08-01
Status: Merged
Approved by: Andrea Azzarone on 2016-08-01
Approved revision: 4164
Merged at revision: 4164
Proposed branch: lp:~3v1n0/unity/deco-get-proper-shadow-texture
Merge into: lp:unity
Diff against target: 203 lines (+44/-28)
5 files modified
decorations/DecoratedWindow.cpp (+29/-19)
decorations/DecorationsForceQuitDialog.cpp (+0/-1)
decorations/DecorationsPriv.h (+3/-1)
unity-shared/CompizUtils.cpp (+10/-6)
unity-shared/CompizUtils.h (+2/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/deco-get-proper-shadow-texture
Reviewer Review Type Date Requested Status
Andrea Azzarone 2016-08-01 Approve on 2016-08-01
Review via email: mp+301631@code.launchpad.net

Commit message

DecoratedWindow: avoid deferencing an invalid shadow texture ptr, and split functions

To post a comment you must log in.
Andrea Azzarone (azzar1) :
review: Approve
4165. By Marco Trevisan (Treviño) on 2016-08-01

CompizUtils: add add flag to decoration utils for shaped windows

4166. By Marco Trevisan (Treviño) on 2016-08-01

DecoratedWindow: split shadow quads computation based on shaped window state

And reset textures on change

4167. By Marco Trevisan (Treviño) on 2016-08-01

DecorationsForceQuitDialog: remove deprecated definition

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'decorations/DecoratedWindow.cpp'
2--- decorations/DecoratedWindow.cpp 2016-07-27 10:17:42 +0000
3+++ decorations/DecoratedWindow.cpp 2016-08-01 13:49:29 +0000
4@@ -493,6 +493,12 @@
5 return deco_elements_ & cu::DecorationElement::SHADOW;
6 }
7
8+bool Window::Impl::ShapedShadowDecorated() const
9+{
10+ return deco_elements_ & cu::DecorationElement::SHADOW &&
11+ deco_elements_ & cu::DecorationElement::SHAPED;
12+}
13+
14 bool Window::Impl::FullyDecorated() const
15 {
16 return deco_elements_ & cu::DecorationElement::BORDER;
17@@ -503,16 +509,16 @@
18 return (win_->frame() || win_->hasUnmapReference()) && FullyDecorated();
19 }
20
21-bool Window::Impl::IsRectangular() const
22-{
23- return win_->region().numRects() == 1;
24-}
25-
26 GLTexture* Window::Impl::ShadowTexture() const
27 {
28- if (!IsRectangular())
29+ if (shaped_shadow_pixmap_)
30 return shaped_shadow_pixmap_->texture();
31
32+ return SharedShadowTexture();
33+}
34+
35+GLTexture* Window::Impl::SharedShadowTexture() const
36+{
37 auto const& mi = manager_->impl_;
38 if (active() || parent_->scaled())
39 return mi->active_shadow_pixmap_->texture();
40@@ -578,10 +584,22 @@
41 if (!last_shadow_rect_.isEmpty())
42 last_shadow_rect_.setGeometry(0, 0, 0, 0);
43
44- return;
45- }
46+ shaped_shadow_pixmap_.reset();
47+ }
48+ else if (deco_elements_ & cu::DecorationElement::SHAPED)
49+ {
50+ ComputeShapedShadowQuad();
51+ }
52+ else
53+ {
54+ shaped_shadow_pixmap_.reset();
55+ ComputeGenericShadowQuads();
56+ }
57+}
58
59- const auto* texture = ShadowTexture();
60+void Window::Impl::ComputeGenericShadowQuads()
61+{
62+ const auto* texture = SharedShadowTexture();
63
64 if (!texture || !texture->width() || !texture->height())
65 return;
66@@ -707,14 +725,6 @@
67
68 void Window::Impl::ComputeShapedShadowQuad()
69 {
70- if (!(deco_elements_ & cu::DecorationElement::SHADOW))
71- {
72- if (!last_shadow_rect_.isEmpty())
73- last_shadow_rect_.setGeometry(0, 0, 0, 0);
74-
75- return;
76- }
77-
78 nux::Color color = active() ? manager_->active_shadow_color() : manager_->inactive_shadow_color();
79 unsigned int radius = active() ? manager_->active_shadow_radius() : manager_->inactive_shadow_radius();
80
81@@ -793,7 +803,7 @@
82
83 glwin_->vertexBuffer()->begin();
84
85- unsigned int num_quads = IsRectangular() ? shadow_quads_.size() : 1;
86+ unsigned int num_quads = ShapedShadowDecorated() ? 1 : shadow_quads_.size();
87 for (unsigned int i = 0; i < num_quads; ++i)
88 {
89 auto& quad = shadow_quads_[Quads::Pos(i)];
90@@ -1035,7 +1045,7 @@
91 void Window::UpdateDecorationPosition()
92 {
93 impl_->UpdateMonitor();
94- impl_->IsRectangular() ? impl_->ComputeShadowQuads() : impl_->ComputeShapedShadowQuad();
95+ impl_->ComputeShadowQuads();
96 impl_->UpdateWindowEdgesGeo();
97 impl_->UpdateDecorationTextures();
98 impl_->UpdateForceQuitDialogPosition();
99
100=== modified file 'decorations/DecorationsForceQuitDialog.cpp'
101--- decorations/DecorationsForceQuitDialog.cpp 2016-03-22 15:29:31 +0000
102+++ decorations/DecorationsForceQuitDialog.cpp 2016-08-01 13:49:29 +0000
103@@ -384,7 +384,6 @@
104 {
105 auto* self = GTK_WIDGET(g_object_new(close_button_get_type(), nullptr));
106 gtk_button_set_relief(GTK_BUTTON(self), GTK_RELIEF_NONE);
107- gtk_button_set_focus_on_click(GTK_BUTTON(self), FALSE);
108 gtk_widget_set_can_focus(self, FALSE);
109 gtk_widget_set_halign(self, GTK_ALIGN_START);
110
111
112=== modified file 'decorations/DecorationsPriv.h'
113--- decorations/DecorationsPriv.h 2016-07-26 11:33:50 +0000
114+++ decorations/DecorationsPriv.h 2016-08-01 13:49:29 +0000
115@@ -90,6 +90,7 @@
116 bool IsMaximized() const;
117 bool FullyDecorated() const;
118 bool ShadowDecorated() const;
119+ bool ShapedShadowDecorated() const;
120 void RedrawDecorations();
121 void Damage();
122 void SetupAppMenu();
123@@ -118,12 +119,13 @@
124 void SyncXShapeWithFrameRegion();
125 void SyncMenusGeometries() const;
126 bool ShouldBeDecorated() const;
127- bool IsRectangular() const;
128 GLTexture* ShadowTexture() const;
129+ GLTexture* SharedShadowTexture() const;
130 unsigned ShadowRadius() const;
131 std::string const& GetMenusPanelID() const;
132
133 void ComputeShadowQuads();
134+ void ComputeGenericShadowQuads();
135 void ComputeShapedShadowQuad();
136 void UpdateDecorationTextures();
137 void UpdateWindowEdgesGeo();
138
139=== modified file 'unity-shared/CompizUtils.cpp'
140--- unity-shared/CompizUtils.cpp 2016-07-26 11:33:50 +0000
141+++ unity-shared/CompizUtils.cpp 2016-08-01 13:49:29 +0000
142@@ -190,7 +190,11 @@
143 if (win->wmType() & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
144 return elements;
145
146- if (win->alpha())
147+ auto const& region = win->region();
148+ bool rectangular = (region.numRects() == 1);
149+ bool alpha = win->alpha();
150+
151+ if (alpha)
152 {
153 if (wf == WindowFilter::CLIENTSIDE_DECORATED)
154 {
155@@ -201,7 +205,7 @@
156
157 return elements;
158 }
159- else if (win->region().numRects() != 1) // Non-rectangular windows with alpha channel
160+ else if (!rectangular) // Non-rectangular windows with alpha channel
161 {
162 return elements;
163 }
164@@ -209,6 +213,9 @@
165
166 elements |= DecorationElement::SHADOW;
167
168+ if (!rectangular)
169+ elements |= DecorationElement::SHAPED;
170+
171 if (!win->overrideRedirect() &&
172 (win->type() & DECORABLE_WINDOW_TYPES) &&
173 (win->frame() || win->hasUnmapReference() || wf == WindowFilter::UNMAPPED))
174@@ -216,14 +223,11 @@
175 if (win->actions() & CompWindowActionResizeMask)
176 elements |= DecorationElement::EDGE;
177
178- auto const& region = win->region();
179- bool rectangular = (region.numRects() == 1);
180-
181 if (rectangular && (win->mwmDecor() & (MwmDecorAll | MwmDecorTitle)))
182 elements |= DecorationElement::BORDER;
183 }
184
185- if (win->alpha() && !(elements & DecorationElement::BORDER) && !(win->mwmDecor() & MwmDecorBorder))
186+ if (alpha && !(elements & DecorationElement::BORDER) && !(win->mwmDecor() & MwmDecorBorder))
187 elements &= ~DecorationElement::SHADOW;
188
189 return elements;
190
191=== modified file 'unity-shared/CompizUtils.h'
192--- unity-shared/CompizUtils.h 2015-11-02 14:58:01 +0000
193+++ unity-shared/CompizUtils.h 2016-08-01 13:49:29 +0000
194@@ -133,7 +133,8 @@
195 NONE = 0,
196 EDGE = (1 << 0),
197 SHADOW = (1 << 1),
198- BORDER = (1 << 2),
199+ SHAPED = (1 << 2),
200+ BORDER = (1 << 3),
201 FULL = EDGE|SHADOW|BORDER
202 };
203 }