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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
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 (community) Approve
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.
Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'decorations/DecoratedWindow.cpp'
--- decorations/DecoratedWindow.cpp 2016-07-27 10:17:42 +0000
+++ decorations/DecoratedWindow.cpp 2016-08-01 13:49:29 +0000
@@ -493,6 +493,12 @@
493 return deco_elements_ & cu::DecorationElement::SHADOW;493 return deco_elements_ & cu::DecorationElement::SHADOW;
494}494}
495495
496bool Window::Impl::ShapedShadowDecorated() const
497{
498 return deco_elements_ & cu::DecorationElement::SHADOW &&
499 deco_elements_ & cu::DecorationElement::SHAPED;
500}
501
496bool Window::Impl::FullyDecorated() const502bool Window::Impl::FullyDecorated() const
497{503{
498 return deco_elements_ & cu::DecorationElement::BORDER;504 return deco_elements_ & cu::DecorationElement::BORDER;
@@ -503,16 +509,16 @@
503 return (win_->frame() || win_->hasUnmapReference()) && FullyDecorated();509 return (win_->frame() || win_->hasUnmapReference()) && FullyDecorated();
504}510}
505511
506bool Window::Impl::IsRectangular() const
507{
508 return win_->region().numRects() == 1;
509}
510
511GLTexture* Window::Impl::ShadowTexture() const512GLTexture* Window::Impl::ShadowTexture() const
512{513{
513 if (!IsRectangular())514 if (shaped_shadow_pixmap_)
514 return shaped_shadow_pixmap_->texture();515 return shaped_shadow_pixmap_->texture();
515516
517 return SharedShadowTexture();
518}
519
520GLTexture* Window::Impl::SharedShadowTexture() const
521{
516 auto const& mi = manager_->impl_;522 auto const& mi = manager_->impl_;
517 if (active() || parent_->scaled())523 if (active() || parent_->scaled())
518 return mi->active_shadow_pixmap_->texture();524 return mi->active_shadow_pixmap_->texture();
@@ -578,10 +584,22 @@
578 if (!last_shadow_rect_.isEmpty())584 if (!last_shadow_rect_.isEmpty())
579 last_shadow_rect_.setGeometry(0, 0, 0, 0);585 last_shadow_rect_.setGeometry(0, 0, 0, 0);
580586
581 return;587 shaped_shadow_pixmap_.reset();
582 }588 }
589 else if (deco_elements_ & cu::DecorationElement::SHAPED)
590 {
591 ComputeShapedShadowQuad();
592 }
593 else
594 {
595 shaped_shadow_pixmap_.reset();
596 ComputeGenericShadowQuads();
597 }
598}
583599
584 const auto* texture = ShadowTexture();600void Window::Impl::ComputeGenericShadowQuads()
601{
602 const auto* texture = SharedShadowTexture();
585603
586 if (!texture || !texture->width() || !texture->height())604 if (!texture || !texture->width() || !texture->height())
587 return;605 return;
@@ -707,14 +725,6 @@
707725
708void Window::Impl::ComputeShapedShadowQuad()726void Window::Impl::ComputeShapedShadowQuad()
709{727{
710 if (!(deco_elements_ & cu::DecorationElement::SHADOW))
711 {
712 if (!last_shadow_rect_.isEmpty())
713 last_shadow_rect_.setGeometry(0, 0, 0, 0);
714
715 return;
716 }
717
718 nux::Color color = active() ? manager_->active_shadow_color() : manager_->inactive_shadow_color();728 nux::Color color = active() ? manager_->active_shadow_color() : manager_->inactive_shadow_color();
719 unsigned int radius = active() ? manager_->active_shadow_radius() : manager_->inactive_shadow_radius();729 unsigned int radius = active() ? manager_->active_shadow_radius() : manager_->inactive_shadow_radius();
720730
@@ -793,7 +803,7 @@
793803
794 glwin_->vertexBuffer()->begin();804 glwin_->vertexBuffer()->begin();
795805
796 unsigned int num_quads = IsRectangular() ? shadow_quads_.size() : 1;806 unsigned int num_quads = ShapedShadowDecorated() ? 1 : shadow_quads_.size();
797 for (unsigned int i = 0; i < num_quads; ++i)807 for (unsigned int i = 0; i < num_quads; ++i)
798 {808 {
799 auto& quad = shadow_quads_[Quads::Pos(i)];809 auto& quad = shadow_quads_[Quads::Pos(i)];
@@ -1035,7 +1045,7 @@
1035void Window::UpdateDecorationPosition()1045void Window::UpdateDecorationPosition()
1036{1046{
1037 impl_->UpdateMonitor();1047 impl_->UpdateMonitor();
1038 impl_->IsRectangular() ? impl_->ComputeShadowQuads() : impl_->ComputeShapedShadowQuad();1048 impl_->ComputeShadowQuads();
1039 impl_->UpdateWindowEdgesGeo();1049 impl_->UpdateWindowEdgesGeo();
1040 impl_->UpdateDecorationTextures();1050 impl_->UpdateDecorationTextures();
1041 impl_->UpdateForceQuitDialogPosition();1051 impl_->UpdateForceQuitDialogPosition();
10421052
=== modified file 'decorations/DecorationsForceQuitDialog.cpp'
--- decorations/DecorationsForceQuitDialog.cpp 2016-03-22 15:29:31 +0000
+++ decorations/DecorationsForceQuitDialog.cpp 2016-08-01 13:49:29 +0000
@@ -384,7 +384,6 @@
384{384{
385 auto* self = GTK_WIDGET(g_object_new(close_button_get_type(), nullptr));385 auto* self = GTK_WIDGET(g_object_new(close_button_get_type(), nullptr));
386 gtk_button_set_relief(GTK_BUTTON(self), GTK_RELIEF_NONE);386 gtk_button_set_relief(GTK_BUTTON(self), GTK_RELIEF_NONE);
387 gtk_button_set_focus_on_click(GTK_BUTTON(self), FALSE);
388 gtk_widget_set_can_focus(self, FALSE);387 gtk_widget_set_can_focus(self, FALSE);
389 gtk_widget_set_halign(self, GTK_ALIGN_START);388 gtk_widget_set_halign(self, GTK_ALIGN_START);
390389
391390
=== modified file 'decorations/DecorationsPriv.h'
--- decorations/DecorationsPriv.h 2016-07-26 11:33:50 +0000
+++ decorations/DecorationsPriv.h 2016-08-01 13:49:29 +0000
@@ -90,6 +90,7 @@
90 bool IsMaximized() const;90 bool IsMaximized() const;
91 bool FullyDecorated() const;91 bool FullyDecorated() const;
92 bool ShadowDecorated() const;92 bool ShadowDecorated() const;
93 bool ShapedShadowDecorated() const;
93 void RedrawDecorations();94 void RedrawDecorations();
94 void Damage();95 void Damage();
95 void SetupAppMenu();96 void SetupAppMenu();
@@ -118,12 +119,13 @@
118 void SyncXShapeWithFrameRegion();119 void SyncXShapeWithFrameRegion();
119 void SyncMenusGeometries() const;120 void SyncMenusGeometries() const;
120 bool ShouldBeDecorated() const;121 bool ShouldBeDecorated() const;
121 bool IsRectangular() const;
122 GLTexture* ShadowTexture() const;122 GLTexture* ShadowTexture() const;
123 GLTexture* SharedShadowTexture() const;
123 unsigned ShadowRadius() const;124 unsigned ShadowRadius() const;
124 std::string const& GetMenusPanelID() const;125 std::string const& GetMenusPanelID() const;
125126
126 void ComputeShadowQuads();127 void ComputeShadowQuads();
128 void ComputeGenericShadowQuads();
127 void ComputeShapedShadowQuad();129 void ComputeShapedShadowQuad();
128 void UpdateDecorationTextures();130 void UpdateDecorationTextures();
129 void UpdateWindowEdgesGeo();131 void UpdateWindowEdgesGeo();
130132
=== modified file 'unity-shared/CompizUtils.cpp'
--- unity-shared/CompizUtils.cpp 2016-07-26 11:33:50 +0000
+++ unity-shared/CompizUtils.cpp 2016-08-01 13:49:29 +0000
@@ -190,7 +190,11 @@
190 if (win->wmType() & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))190 if (win->wmType() & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
191 return elements;191 return elements;
192192
193 if (win->alpha())193 auto const& region = win->region();
194 bool rectangular = (region.numRects() == 1);
195 bool alpha = win->alpha();
196
197 if (alpha)
194 {198 {
195 if (wf == WindowFilter::CLIENTSIDE_DECORATED)199 if (wf == WindowFilter::CLIENTSIDE_DECORATED)
196 {200 {
@@ -201,7 +205,7 @@
201205
202 return elements;206 return elements;
203 }207 }
204 else if (win->region().numRects() != 1) // Non-rectangular windows with alpha channel208 else if (!rectangular) // Non-rectangular windows with alpha channel
205 {209 {
206 return elements;210 return elements;
207 }211 }
@@ -209,6 +213,9 @@
209213
210 elements |= DecorationElement::SHADOW;214 elements |= DecorationElement::SHADOW;
211215
216 if (!rectangular)
217 elements |= DecorationElement::SHAPED;
218
212 if (!win->overrideRedirect() &&219 if (!win->overrideRedirect() &&
213 (win->type() & DECORABLE_WINDOW_TYPES) &&220 (win->type() & DECORABLE_WINDOW_TYPES) &&
214 (win->frame() || win->hasUnmapReference() || wf == WindowFilter::UNMAPPED))221 (win->frame() || win->hasUnmapReference() || wf == WindowFilter::UNMAPPED))
@@ -216,14 +223,11 @@
216 if (win->actions() & CompWindowActionResizeMask)223 if (win->actions() & CompWindowActionResizeMask)
217 elements |= DecorationElement::EDGE;224 elements |= DecorationElement::EDGE;
218225
219 auto const& region = win->region();
220 bool rectangular = (region.numRects() == 1);
221
222 if (rectangular && (win->mwmDecor() & (MwmDecorAll | MwmDecorTitle)))226 if (rectangular && (win->mwmDecor() & (MwmDecorAll | MwmDecorTitle)))
223 elements |= DecorationElement::BORDER;227 elements |= DecorationElement::BORDER;
224 }228 }
225229
226 if (win->alpha() && !(elements & DecorationElement::BORDER) && !(win->mwmDecor() & MwmDecorBorder))230 if (alpha && !(elements & DecorationElement::BORDER) && !(win->mwmDecor() & MwmDecorBorder))
227 elements &= ~DecorationElement::SHADOW;231 elements &= ~DecorationElement::SHADOW;
228232
229 return elements;233 return elements;
230234
=== modified file 'unity-shared/CompizUtils.h'
--- unity-shared/CompizUtils.h 2015-11-02 14:58:01 +0000
+++ unity-shared/CompizUtils.h 2016-08-01 13:49:29 +0000
@@ -133,7 +133,8 @@
133 NONE = 0,133 NONE = 0,
134 EDGE = (1 << 0),134 EDGE = (1 << 0),
135 SHADOW = (1 << 1),135 SHADOW = (1 << 1),
136 BORDER = (1 << 2),136 SHAPED = (1 << 2),
137 BORDER = (1 << 3),
137 FULL = EDGE|SHADOW|BORDER138 FULL = EDGE|SHADOW|BORDER
138};139};
139}140}