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 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
=== modified file 'launcher/CairoBaseWindow.cpp'
--- launcher/CairoBaseWindow.cpp 2012-11-06 18:19:09 +0000
+++ launcher/CairoBaseWindow.cpp 2013-09-30 11:37:05 +0000
@@ -41,16 +41,22 @@
41NUX_IMPLEMENT_OBJECT_TYPE(CairoBaseWindow);41NUX_IMPLEMENT_OBJECT_TYPE(CairoBaseWindow);
4242
43CairoBaseWindow::CairoBaseWindow() :43CairoBaseWindow::CairoBaseWindow() :
44 use_blur_(!Settings::Instance().GetLowGfxMode()),44 use_blurred_background_(!Settings::Instance().GetLowGfxMode()),
45 _use_blurred_background(use_blur_),45 compute_blur_bkg_(use_blurred_background_)
46 _compute_blur_bkg(use_blur_)
47{46{
48 SetWindowSizeMatchLayout(true);47 SetWindowSizeMatchLayout(true);
49}48 sigVisible.connect([this] (BaseWindow*) { compute_blur_bkg_ = true; });
5049}
51CairoBaseWindow::~CairoBaseWindow()50
52{51bool CairoBaseWindow::HasBlurredBackground() const
53 // nothing to do52{
53 return use_blurred_background_;
54}
55
56void CairoBaseWindow::NeedSoftRedraw()
57{
58 compute_blur_bkg_ = true;
59 QueueDraw();
54}60}
5561
56void CairoBaseWindow::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)62void CairoBaseWindow::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
@@ -58,7 +64,7 @@
58 nux::Geometry base(GetGeometry());64 nux::Geometry base(GetGeometry());
5965
60 // Get the background and apply some blur66 // Get the background and apply some blur
61 if (_use_blurred_background && _compute_blur_bkg)67 if (use_blurred_background_ && compute_blur_bkg_)
62 {68 {
63 auto current_fbo = nux::GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();69 auto current_fbo = nux::GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();
64 nux::GetWindowCompositor ().RestoreMainFramebuffer();70 nux::GetWindowCompositor ().RestoreMainFramebuffer();
@@ -83,7 +89,7 @@
83 gfxContext.Push2DWindow(gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());89 gfxContext.Push2DWindow(gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
84 gfxContext.ApplyClippingRectangle();90 gfxContext.ApplyClippingRectangle();
85 }91 }
86 _compute_blur_bkg = false;92 compute_blur_bkg_ = false;
87 }93 }
8894
89 // the elements position inside the window are referenced to top-left window95 // the elements position inside the window are referenced to top-left window
@@ -96,11 +102,11 @@
96 /*"Clear" out the background. Blending is disabled if blur is disabled. This might need to change, but for the moment both classes102 /*"Clear" out the background. Blending is disabled if blur is disabled. This might need to change, but for the moment both classes
97 * which are children of CairoBaseWindow don't have any alpha blending when not using the blurred texture.*/103 * which are children of CairoBaseWindow don't have any alpha blending when not using the blurred texture.*/
98 nux::ROPConfig rop;104 nux::ROPConfig rop;
99 rop.Blend = use_blur_;105 rop.Blend = use_blurred_background_;
100 rop.SrcBlend = GL_ONE;106 rop.SrcBlend = GL_ONE;
101 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;107 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
102108
103 nux::ColorLayer layer(nux::Color(0x00000000), use_blur_, rop);109 nux::ColorLayer layer(nux::Color(0x00000000), use_blurred_background_, rop);
104 nux::GetPainter().PushDrawLayer(gfxContext, base, &layer);110 nux::GetPainter().PushDrawLayer(gfxContext, base, &layer);
105111
106 nux::TexCoordXForm texxform_bg;112 nux::TexCoordXForm texxform_bg;
@@ -110,7 +116,7 @@
110 nux::TexCoordXForm texxform_mask;116 nux::TexCoordXForm texxform_mask;
111 texxform_mask.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);117 texxform_mask.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
112 texxform_mask.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);118 texxform_mask.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
113 119
114 nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true);120 nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetBlend(true);
115 nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);121 nux::GetWindowThread()->GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
116122
@@ -150,7 +156,7 @@
150 nux::TexCoordXForm texxform;156 nux::TexCoordXForm texxform;
151 texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);157 texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
152 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);158 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
153 159
154 gfxContext.QRP_1Tex(base.x,160 gfxContext.QRP_1Tex(base.x,
155 base.y,161 base.y,
156 base.width,162 base.width,
157163
=== modified file 'launcher/CairoBaseWindow.h'
--- launcher/CairoBaseWindow.h 2012-11-06 18:19:09 +0000
+++ launcher/CairoBaseWindow.h 2013-09-30 11:37:05 +0000
@@ -30,7 +30,10 @@
30 NUX_DECLARE_OBJECT_TYPE(CairoBaseWindow, nux::BaseWindow);30 NUX_DECLARE_OBJECT_TYPE(CairoBaseWindow, nux::BaseWindow);
31public:31public:
32 CairoBaseWindow();32 CairoBaseWindow();
33 virtual ~CairoBaseWindow();33 virtual ~CairoBaseWindow() = default;
34
35 void NeedSoftRedraw() override;
36 bool HasBlurredBackground() const;
3437
35protected:38protected:
36 void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw);39 void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw);
@@ -39,11 +42,9 @@
39 nux::ObjectPtr<nux::BaseTexture> texture_mask_;42 nux::ObjectPtr<nux::BaseTexture> texture_mask_;
40 nux::ObjectPtr<nux::BaseTexture> texture_outline_;43 nux::ObjectPtr<nux::BaseTexture> texture_outline_;
4144
42 bool use_blur_;
43 bool _use_blurred_background;
44 bool _compute_blur_bkg;
45
46private:45private:
46 bool use_blurred_background_;
47 bool compute_blur_bkg_;
47 nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_;48 nux::ObjectPtr<nux::IOpenGLBaseTexture> bg_blur_texture_;
48};49};
49}50}
5051
=== modified file 'launcher/QuicklistView.cpp'
--- launcher/QuicklistView.cpp 2013-09-09 18:24:39 +0000
+++ launcher/QuicklistView.cpp 2013-09-30 11:37:05 +0000
@@ -410,7 +410,6 @@
410410
411void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)411void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
412{412{
413 _compute_blur_bkg = true;
414 CairoBaseWindow::Draw(gfxContext, forceDraw);413 CairoBaseWindow::Draw(gfxContext, forceDraw);
415414
416 nux::Geometry base(GetGeometry());415 nux::Geometry base(GetGeometry());
@@ -1216,24 +1215,12 @@
1216 cairo_t* cr_mask = cairo_mask.GetContext();1215 cairo_t* cr_mask = cairo_mask.GetContext();
1217 cairo_t* cr_outline = cairo_outline.GetContext();1216 cairo_t* cr_outline = cairo_outline.GetContext();
12181217
1219 float tint_color[4] = {0.0f, 0.0f, 0.0f, 0.60f};1218 float tint_color[4] = {0.0f, 0.0f, 0.0f, HasBlurredBackground() ? 0.60f : 1.0f};
1220 float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.35f};1219 float hl_color[4] = {1.0f, 1.0f, 1.0f, 0.35f};
1221 float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.03f};1220 float dot_color[4] = {1.0f, 1.0f, 1.0f, 0.03f};
1222 float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};1221 float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};
1223 float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.40f};1222 float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.40f};
1224 float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};1223 float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};
1225
1226 if (Settings::Instance().GetLowGfxMode())
1227 {
1228 float alpha_value = 1.0f;
1229
1230 tint_color[3] = alpha_value;
1231 hl_color[3] = 0.2f;
1232 dot_color[3] = 0.0f;
1233 shadow_color[3] = alpha_value;
1234 outline_color[3] = alpha_value;
1235 mask_color[3] = alpha_value;
1236 }
12371224
1238 ql_tint_dot_hl(cr_bg,1225 ql_tint_dot_hl(cr_bg,
1239 width,1226 width,
12401227
=== modified file 'launcher/Tooltip.cpp'
--- launcher/Tooltip.cpp 2013-09-24 02:03:12 +0000
+++ launcher/Tooltip.cpp 2013-09-30 11:37:05 +0000
@@ -112,13 +112,11 @@
112 SetBaseY(y);112 SetBaseY(y);
113113
114 PushToFront();114 PushToFront();
115
116 ShowWindow(true);115 ShowWindow(true);
117}116}
118117
119void Tooltip::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)118void Tooltip::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
120{119{
121 _compute_blur_bkg = true;
122 CairoBaseWindow::Draw(gfxContext, forceDraw);120 CairoBaseWindow::Draw(gfxContext, forceDraw);
123 _tooltip_text->ProcessDraw(gfxContext, forceDraw);121 _tooltip_text->ProcessDraw(gfxContext, forceDraw);
124}122}
@@ -470,18 +468,15 @@
470 float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};468 float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.00f};
471 float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.15f};469 float outline_color[4] = {1.0f, 1.0f, 1.0f, 0.15f};
472 float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};470 float mask_color[4] = {1.0f, 1.0f, 1.0f, 1.00f};
473 471
474 if (use_blur_ == false)472 if (!HasBlurredBackground())
475 {473 {
476 //If low gfx is detected then disable transparency because we're not bluring using our blur anymore.474 //If low gfx is detected then disable transparency because we're not bluring using our blur anymore.
477 float alpha_value = 1.0f;475 const float alpha_value = 1.0f;
478 476
479 tint_color[3] = alpha_value;477 tint_color[3] = alpha_value;
480 hl_color[3] = alpha_value;478 hl_color[3] = alpha_value;
481 dot_color[3] = alpha_value;479 dot_color[3] = alpha_value;
482 shadow_color[3] = alpha_value;
483 outline_color[3] = alpha_value;
484 mask_color[3] = alpha_value;
485 }480 }
486481
487 tint_dot_hl(cr_bg,482 tint_dot_hl(cr_bg,
488483
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2013-09-26 22:45:58 +0000
+++ plugins/unityshell/src/unityshell.cpp 2013-09-30 11:37:05 +0000
@@ -1363,12 +1363,7 @@
1363 CompRegion region(geo.x, geo.y, geo.width, geo.height);1363 CompRegion region(geo.x, geo.y, geo.width, geo.height);
13641364
1365 if (damage.intersects(region))1365 if (damage.intersects(region))
1366 {1366 view->NeedSoftRedraw();
1367 if (view->IsViewWindow())
1368 view->QueueDraw();
1369 else
1370 view->NeedSoftRedraw();
1371 }
1372}1367}
13731368
1374void UnityScreen::compizDamageNux(CompRegion const& damage)1369void UnityScreen::compizDamageNux(CompRegion const& damage)