Merge lp:~3v1n0/unity/cairobaswindow-better-damage into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3545
Proposed branch: lp:~3v1n0/unity/cairobaswindow-better-damage
Merge into: lp:unity
Diff against target: 211 lines (+32/-48)
5 files modified
launcher/CairoBaseWindow.cpp (+20/-14)
launcher/CairoBaseWindow.h (+6/-5)
launcher/QuicklistView.cpp (+1/-14)
launcher/Tooltip.cpp (+4/-9)
plugins/unityshell/src/unityshell.cpp (+1/-6)
To merge this branch: bzr merge lp:~3v1n0/unity/cairobaswindow-better-damage
Reviewer Review Type Date Requested Status
Christopher Townsend (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+188302@code.launchpad.net

Commit message

CairoBaseWindow: only regenerate blur texture when visible and damaged

Description of the change

Recent support to active-blur on tooltips and quicklists lead to a problem that caused the blur texture to be regenerated at every redraw. This is actually not needed and may also cause slow-downs (especially during fade-in/fade-out). We should instead generate it only when showing the window and when the area is damaged.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Very nice! +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/CairoBaseWindow.cpp'
2--- launcher/CairoBaseWindow.cpp 2012-11-06 18:19:09 +0000
3+++ launcher/CairoBaseWindow.cpp 2013-09-30 11:37:05 +0000
4@@ -41,16 +41,22 @@
5 NUX_IMPLEMENT_OBJECT_TYPE(CairoBaseWindow);
6
7 CairoBaseWindow::CairoBaseWindow() :
8- use_blur_(!Settings::Instance().GetLowGfxMode()),
9- _use_blurred_background(use_blur_),
10- _compute_blur_bkg(use_blur_)
11+ use_blurred_background_(!Settings::Instance().GetLowGfxMode()),
12+ compute_blur_bkg_(use_blurred_background_)
13 {
14 SetWindowSizeMatchLayout(true);
15-}
16-
17-CairoBaseWindow::~CairoBaseWindow()
18-{
19- // nothing to do
20+ sigVisible.connect([this] (BaseWindow*) { compute_blur_bkg_ = true; });
21+}
22+
23+bool CairoBaseWindow::HasBlurredBackground() const
24+{
25+ return use_blurred_background_;
26+}
27+
28+void CairoBaseWindow::NeedSoftRedraw()
29+{
30+ compute_blur_bkg_ = true;
31+ QueueDraw();
32 }
33
34 void CairoBaseWindow::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
35@@ -58,7 +64,7 @@
36 nux::Geometry base(GetGeometry());
37
38 // Get the background and apply some blur
39- if (_use_blurred_background && _compute_blur_bkg)
40+ if (use_blurred_background_ && compute_blur_bkg_)
41 {
42 auto current_fbo = nux::GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();
43 nux::GetWindowCompositor ().RestoreMainFramebuffer();
44@@ -83,7 +89,7 @@
45 gfxContext.Push2DWindow(gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
46 gfxContext.ApplyClippingRectangle();
47 }
48- _compute_blur_bkg = false;
49+ compute_blur_bkg_ = false;
50 }
51
52 // the elements position inside the window are referenced to top-left window
53@@ -96,11 +102,11 @@
54 /*"Clear" out the background. Blending is disabled if blur is disabled. This might need to change, but for the moment both classes
55 * which are children of CairoBaseWindow don't have any alpha blending when not using the blurred texture.*/
56 nux::ROPConfig rop;
57- rop.Blend = use_blur_;
58+ rop.Blend = use_blurred_background_;
59 rop.SrcBlend = GL_ONE;
60 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
61
62- nux::ColorLayer layer(nux::Color(0x00000000), use_blur_, rop);
63+ nux::ColorLayer layer(nux::Color(0x00000000), use_blurred_background_, rop);
64 nux::GetPainter().PushDrawLayer(gfxContext, base, &layer);
65
66 nux::TexCoordXForm texxform_bg;
67@@ -110,7 +116,7 @@
68 nux::TexCoordXForm texxform_mask;
69 texxform_mask.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
70 texxform_mask.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
71-
72+
73 nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true);
74 nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
75
76@@ -150,7 +156,7 @@
77 nux::TexCoordXForm texxform;
78 texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
79 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
80-
81+
82 gfxContext.QRP_1Tex(base.x,
83 base.y,
84 base.width,
85
86=== modified file 'launcher/CairoBaseWindow.h'
87--- launcher/CairoBaseWindow.h 2012-11-06 18:19:09 +0000
88+++ launcher/CairoBaseWindow.h 2013-09-30 11:37:05 +0000
89@@ -30,7 +30,10 @@
90 NUX_DECLARE_OBJECT_TYPE(CairoBaseWindow, nux::BaseWindow);
91 public:
92 CairoBaseWindow();
93- virtual ~CairoBaseWindow();
94+ virtual ~CairoBaseWindow() = default;
95+
96+ void NeedSoftRedraw() override;
97+ bool HasBlurredBackground() const;
98
99 protected:
100 void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw);
101@@ -39,11 +42,9 @@
102 nux::ObjectPtr<nux::BaseTexture> texture_mask_;
103 nux::ObjectPtr<nux::BaseTexture> texture_outline_;
104
105- bool use_blur_;
106- bool _use_blurred_background;
107- bool _compute_blur_bkg;
108-
109 private:
110+ bool use_blurred_background_;
111+ bool compute_blur_bkg_;
112 nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_;
113 };
114 }
115
116=== modified file 'launcher/QuicklistView.cpp'
117--- launcher/QuicklistView.cpp 2013-09-09 18:24:39 +0000
118+++ launcher/QuicklistView.cpp 2013-09-30 11:37:05 +0000
119@@ -410,7 +410,6 @@
120
121 void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
122 {
123- _compute_blur_bkg = true;
124 CairoBaseWindow::Draw(gfxContext, forceDraw);
125
126 nux::Geometry base(GetGeometry());
127@@ -1216,24 +1215,12 @@
128 cairo_t* cr_mask = cairo_mask.GetContext();
129 cairo_t* cr_outline = cairo_outline.GetContext();
130
131- float tint_color[4] = {0.0f, 0.0f, 0.0f, 0.60f};
132+ float tint_color[4] = {0.0f, 0.0f, 0.0f, HasBlurredBackground() ? 0.60f : 1.0f};
133 float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.35f};
134 float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.03f};
135 float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};
136 float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.40f};
137 float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};
138-
139- if (Settings::Instance().GetLowGfxMode())
140- {
141- float alpha_value = 1.0f;
142-
143- tint_color[3] = alpha_value;
144- hl_color[3] = 0.2f;
145- dot_color[3] = 0.0f;
146- shadow_color[3] = alpha_value;
147- outline_color[3] = alpha_value;
148- mask_color[3] = alpha_value;
149- }
150
151 ql_tint_dot_hl(cr_bg,
152 width,
153
154=== modified file 'launcher/Tooltip.cpp'
155--- launcher/Tooltip.cpp 2013-09-24 02:03:12 +0000
156+++ launcher/Tooltip.cpp 2013-09-30 11:37:05 +0000
157@@ -112,13 +112,11 @@
158 SetBaseY(y);
159
160 PushToFront();
161-
162 ShowWindow(true);
163 }
164
165 void Tooltip::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
166 {
167- _compute_blur_bkg = true;
168 CairoBaseWindow::Draw(gfxContext, forceDraw);
169 _tooltip_text->ProcessDraw(gfxContext, forceDraw);
170 }
171@@ -470,18 +468,15 @@
172 float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};
173 float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.15f};
174 float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};
175-
176- if (use_blur_ == false)
177+
178+ if (!HasBlurredBackground())
179 {
180 //If low gfx is detected then disable transparency because we're not bluring using our blur anymore.
181- float alpha_value = 1.0f;
182-
183+ const float alpha_value = 1.0f;
184+
185 tint_color[3] = alpha_value;
186 hl_color[3] = alpha_value;
187 dot_color[3] = alpha_value;
188- shadow_color[3] = alpha_value;
189- outline_color[3] = alpha_value;
190- mask_color[3] = alpha_value;
191 }
192
193 tint_dot_hl(cr_bg,
194
195=== modified file 'plugins/unityshell/src/unityshell.cpp'
196--- plugins/unityshell/src/unityshell.cpp 2013-09-26 22:45:58 +0000
197+++ plugins/unityshell/src/unityshell.cpp 2013-09-30 11:37:05 +0000
198@@ -1363,12 +1363,7 @@
199 CompRegion region(geo.x, geo.y, geo.width, geo.height);
200
201 if (damage.intersects(region))
202- {
203- if (view->IsViewWindow())
204- view->QueueDraw();
205- else
206- view->NeedSoftRedraw();
207- }
208+ view->NeedSoftRedraw();
209 }
210
211 void UnityScreen::compizDamageNux(CompRegion const& damage)