Merge lp:~azzar1/unity/fix-989291 into lp:unity

Proposed by Andrea Azzarone on 2012-04-27
Status: Merged
Approved by: Andrea Azzarone on 2012-05-17
Approved revision: 2354
Merged at revision: 2361
Proposed branch: lp:~azzar1/unity/fix-989291
Merge into: lp:unity
Diff against target: 282 lines (+89/-42)
9 files modified
launcher/SwitcherView.h (+1/-3)
manual-tests/ShortcutsOverlay.txt (+1/-0)
shortcuts/ShortcutController.cpp (+1/-0)
shortcuts/ShortcutView.cpp (+8/-0)
shortcuts/ShortcutView.h (+3/-0)
tests/autopilot/unity/emulators/shortcut_hint.py (+6/-0)
tests/autopilot/unity/tests/test_shortcut_hint.py (+6/-0)
unity-shared/UnityWindowView.cpp (+56/-38)
unity-shared/UnityWindowView.h (+7/-1)
To merge this branch: bzr merge lp:~azzar1/unity/fix-989291
Reviewer Review Type Date Requested Status
Alex Launi (community) quality 2012-04-27 Approve on 2012-05-17
Review via email: mp+103853@code.launchpad.net

Commit message

Fix UnityViewWindow background when blur is disabled.

Description of the change

== Problem ==
When blur is disabled, shortcuts overlay and alt+tab switcher is completely transparent.

== Fix ==
Fix UnityWindowView::DrawContent.

== Test ==
Manual test added.

To post a comment you must log in.
Alex Launi (alexlauni) wrote :

If I understand this correctly you should be able to AP test this by putting the blur geometry into introspection and testing the values.

review: Needs Fixing (quality)
Andrea Azzarone (azzar1) wrote :

> If I understand this correctly you should be able to AP test this by putting
> the blur geometry into introspection and testing the values.

AP test added.

Alex Launi (alexlauni) wrote :

AP test looks good to me.

review: Approve (quality)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherView.h'
2--- launcher/SwitcherView.h 2012-05-07 22:28:17 +0000
3+++ launcher/SwitcherView.h 2012-05-17 12:17:34 +0000
4@@ -27,8 +27,6 @@
5 #include "unity-shared/BackgroundEffectHelper.h"
6 #include "unity-shared/UnityWindowView.h"
7
8-#include "unity-shared/Introspectable.h"
9-
10 #include <boost/shared_ptr.hpp>
11 #include <sigc++/sigc++.h>
12
13@@ -48,7 +46,7 @@
14 namespace switcher
15 {
16
17-class SwitcherView : public debug::Introspectable, public ui::UnityWindowView
18+class SwitcherView : public ui::UnityWindowView
19 {
20 NUX_DECLARE_OBJECT_TYPE(SwitcherView, ui::UnityWindowView);
21 public:
22
23=== modified file 'manual-tests/ShortcutsOverlay.txt'
24--- manual-tests/ShortcutsOverlay.txt 2012-04-10 22:23:44 +0000
25+++ manual-tests/ShortcutsOverlay.txt 2012-05-17 12:17:34 +0000
26@@ -12,3 +12,4 @@
27
28 Outcome:
29 The keyboard shortcuts overlay bottom is not truncated.
30+
31
32=== modified file 'shortcuts/ShortcutController.cpp'
33--- shortcuts/ShortcutController.cpp 2012-05-07 22:28:17 +0000
34+++ shortcuts/ShortcutController.cpp 2012-05-17 12:17:34 +0000
35@@ -157,6 +157,7 @@
36 void Controller::ConstructView()
37 {
38 view_ = View::Ptr(new View());
39+ AddChild(view_.GetPointer());
40 view_->SetModel(model_);
41 view_->background_color = bg_color_;
42
43
44=== modified file 'shortcuts/ShortcutView.cpp'
45--- shortcuts/ShortcutView.cpp 2012-05-07 22:28:17 +0000
46+++ shortcuts/ShortcutView.cpp 2012-05-17 12:17:34 +0000
47@@ -287,5 +287,13 @@
48 }
49 }
50
51+//
52+// Introspectable methods
53+//
54+std::string View::GetName() const
55+{
56+ return "ShortcutView";
57+}
58+
59 } // namespace shortcut
60 } // namespace unity
61
62=== modified file 'shortcuts/ShortcutView.h'
63--- shortcuts/ShortcutView.h 2012-05-07 22:28:17 +0000
64+++ shortcuts/ShortcutView.h 2012-05-17 12:17:34 +0000
65@@ -58,6 +58,9 @@
66 void DrawOverlay(nux::GraphicsEngine& GfxContext, bool force_draw, nux::Geometry clip);
67 nux::Geometry GetBackgroundGeometry();
68
69+ // Introspectable methods
70+ std::string GetName() const;
71+
72 private:
73 // Private methods
74 nux::LinearLayout* CreateSectionLayout(const char* section_name);
75
76=== modified file 'tests/autopilot/unity/emulators/shortcut_hint.py'
77--- tests/autopilot/unity/emulators/shortcut_hint.py 2012-05-16 04:13:24 +0000
78+++ tests/autopilot/unity/emulators/shortcut_hint.py 2012-05-17 12:17:34 +0000
79@@ -17,10 +17,16 @@
80
81 logger = logging.getLogger(__name__)
82
83+class ShortcutView(UnityIntrospectionObject):
84+ """Proxy object for the shortcut view child of the controller."""
85
86 class ShortcutController(UnityIntrospectionObject, KeybindingsHelper):
87 """ShortcutController proxy class."""
88
89+ def get_shortcut_view(self):
90+ views = self.get_children_by_type(ShortcutView)
91+ return views[0] if views else None
92+
93 def show(self):
94 """Push the keys necessary to reveal the shortcut hint, but don't block."""
95 logger.debug("Revealing shortcut hint with keyboard.")
96
97=== modified file 'tests/autopilot/unity/tests/test_shortcut_hint.py'
98--- tests/autopilot/unity/tests/test_shortcut_hint.py 2012-05-08 16:13:17 +0000
99+++ tests/autopilot/unity/tests/test_shortcut_hint.py 2012-05-17 12:17:34 +0000
100@@ -86,6 +86,12 @@
101 self.shortcut_hint.cancel()
102 self.assertThat(self.shortcut_hint.visible, Eventually(Equals(False)))
103
104+ def test_shortcut_hint_no_blur(self):
105+ """"""
106+ self.shortcut_hint.ensure_visible()
107+ self.addCleanup(self.shortcut_hint.ensure_hidden)
108+
109+ self.assertThat(self.shortcut_hint.get_shortcut_view().bg_texture_is_valid, Eventually(Equals(True)))
110
111 class ShortcutHintInteractionsTests(BaseShortcutHintTests):
112 """Test the shortcuthint interactions with other Unity parts."""
113
114=== modified file 'unity-shared/UnityWindowView.cpp'
115--- unity-shared/UnityWindowView.cpp 2012-05-07 22:28:17 +0000
116+++ unity-shared/UnityWindowView.cpp 2012-05-17 12:17:34 +0000
117@@ -17,6 +17,8 @@
118 * Authored by: Jason Smith <jason.smith@canonical.com>
119 */
120
121+#include <UnityCore/Variant.h>
122+
123 #include "UnityWindowView.h"
124
125 namespace unity {
126@@ -56,7 +58,7 @@
127 // clear region
128 gPainter.PaintBackground(GfxContext, base);
129
130- nux::Geometry background_geo = GetBackgroundGeometry();
131+ nux::Geometry background_geo(GetBackgroundGeometry());
132 int internal_offset = style()->GetInternalOffset();
133
134 nux::Geometry internal_clip(background_geo.x + internal_offset,
135@@ -65,50 +67,54 @@
136 background_geo.height - internal_offset * 2);
137 GfxContext.PushClippingRectangle(internal_clip);
138
139- nux::Geometry geo_absolute = GetAbsoluteGeometry ();
140+ nux::Geometry const& geo_absolute = GetAbsoluteGeometry();
141+ nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, base.width, base.height);
142
143 if (BackgroundEffectHelper::blur_type != BLUR_NONE)
144 {
145- nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, base.width, base.height);
146- auto blur_texture = bg_helper_.GetBlurRegion(blur_geo);
147-
148- if (blur_texture.IsValid())
149- {
150- nux::TexCoordXForm texxform_blur_bg;
151- texxform_blur_bg.flip_v_coord = true;
152- texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
153- texxform_blur_bg.uoffset = ((float) base.x) / geo_absolute.width;
154- texxform_blur_bg.voffset = ((float) base.y) / geo_absolute.height;
155-
156- nux::ROPConfig rop;
157- rop.Blend = false;
158- rop.SrcBlend = GL_ONE;
159- rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
160+ bg_texture_ = bg_helper_.GetBlurRegion(blur_geo);
161+ }
162+ else
163+ {
164+ bg_texture_ = bg_helper_.GetRegion(blur_geo);
165+ }
166+
167+ if (bg_texture_.IsValid())
168+ {
169+ nux::TexCoordXForm texxform_blur_bg;
170+ texxform_blur_bg.flip_v_coord = true;
171+ texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
172+ texxform_blur_bg.uoffset = ((float) base.x) / geo_absolute.width;
173+ texxform_blur_bg.voffset = ((float) base.y) / geo_absolute.height;
174+
175+ nux::ROPConfig rop;
176+ rop.Blend = false;
177+ rop.SrcBlend = GL_ONE;
178+ rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
179
180 #ifndef NUX_OPENGLES_20
181- if (GfxContext.UsingGLSLCodePath())
182- gPainter.PushDrawCompositionLayer(GfxContext, base,
183- blur_texture,
184- texxform_blur_bg,
185- nux::color::White,
186- background_color, nux::LAYER_BLEND_MODE_OVERLAY,
187- true, rop);
188- else
189- gPainter.PushDrawTextureLayer(GfxContext, base,
190- blur_texture,
191- texxform_blur_bg,
192- nux::color::White,
193- true,
194- rop);
195+ if (GfxContext.UsingGLSLCodePath())
196+ gPainter.PushDrawCompositionLayer(GfxContext, base,
197+ bg_texture_,
198+ texxform_blur_bg,
199+ nux::color::White,
200+ background_color, nux::LAYER_BLEND_MODE_OVERLAY,
201+ true, rop);
202+ else
203+ gPainter.PushDrawTextureLayer(GfxContext, base,
204+ bg_texture_,
205+ texxform_blur_bg,
206+ nux::color::White,
207+ true,
208+ rop);
209 #else
210- gPainter.PushDrawCompositionLayer(GfxContext, base,
211- blur_texture,
212- texxform_blur_bg,
213- nux::color::White,
214- background_color, nux::LAYER_BLEND_MODE_OVERLAY,
215- true, rop);
216+ gPainter.PushDrawCompositionLayer(GfxContext, base,
217+ bg_texture_,
218+ texxform_blur_bg,
219+ nux::color::White,
220+ background_color, nux::LAYER_BLEND_MODE_OVERLAY,
221+ true, rop);
222 #endif
223- }
224 }
225
226 nux::ROPConfig rop;
227@@ -240,6 +246,18 @@
228 GfxContext.GetRenderStates().SetBlend (FALSE);
229 }
230
231+// Introspectable methods
232+std::string UnityWindowView::GetName() const
233+{
234+ return "UnityWindowView";
235+}
236+
237+void UnityWindowView::AddProperties(GVariantBuilder* builder)
238+{
239+ unity::variant::BuilderWrapper(builder)
240+ .add("bg-texture-is-valid", bg_texture_.IsValid());
241+}
242+
243
244 }
245 }
246
247=== modified file 'unity-shared/UnityWindowView.h'
248--- unity-shared/UnityWindowView.h 2012-05-07 22:28:17 +0000
249+++ unity-shared/UnityWindowView.h 2012-05-17 12:17:34 +0000
250@@ -21,6 +21,7 @@
251 #define UNITYWINDOWVIEW_H
252
253 #include "unity-shared/BackgroundEffectHelper.h"
254+#include "Introspectable.h"
255 #include "UnityWindowStyle.h"
256 #include <sigc++/sigc++.h>
257
258@@ -32,7 +33,7 @@
259 namespace unity {
260 namespace ui {
261
262-class UnityWindowView : public nux::View
263+class UnityWindowView : public debug::Introspectable, public nux::View
264 {
265 NUX_DECLARE_OBJECT_TYPE(UnityWindowView, nux::View)
266 public:
267@@ -53,10 +54,15 @@
268 virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw) {};
269 virtual nux::Geometry GetBackgroundGeometry() = 0;
270
271+ // Introspectable methods
272+ std::string GetName() const;
273+ void AddProperties(GVariantBuilder* builder);
274+
275 private:
276 void DrawBackground(nux::GraphicsEngine& GfxContext, nux::Geometry const& geo);
277
278 BackgroundEffectHelper bg_helper_;
279+ nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_texture_;
280 };
281
282 }