Merge lp:~njpatel/unity/fix-panel-opacity into lp:unity

Proposed by Neil J. Patel
Status: Merged
Merged at revision: 1517
Proposed branch: lp:~njpatel/unity/fix-panel-opacity
Merge into: lp:unity
Diff against target: 147 lines (+21/-11)
7 files modified
plugins/unityshell/src/PanelController.cpp (+6/-1)
plugins/unityshell/src/PanelController.h (+2/-0)
plugins/unityshell/src/PanelStyle.cpp (+6/-2)
plugins/unityshell/src/PanelStyle.h (+1/-1)
plugins/unityshell/src/PanelView.cpp (+3/-4)
plugins/unityshell/src/unityshell.cpp (+1/-1)
services/panel-service.c (+2/-2)
To merge this branch: bzr merge lp:~njpatel/unity/fix-panel-opacity
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) Approve
Review via email: mp+74519@code.launchpad.net

Description of the change

Fixes the panel opacity to work better with the blending modes we now use (do the opacity at paint time). Also adds a nicety so that we don't paint a shadow/blur if the opacity is 0.0f (which most people are using for an uber-clean look).

The drawing code needs to be cleaned up to not be as crazy, but this branch wasn't meant to do that so will leave it until after release.

To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) wrote :

Seems correctly done to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/PanelController.cpp'
--- plugins/unityshell/src/PanelController.cpp 2011-09-06 18:30:26 +0000
+++ plugins/unityshell/src/PanelController.cpp 2011-09-07 21:07:07 +0000
@@ -187,7 +187,7 @@
187 window->SinkReference();187 window->SinkReference();
188 window->SetConfigureNotifyCallback(&PanelController::WindowConfigureCallback, window);188 window->SetConfigureNotifyCallback(&PanelController::WindowConfigureCallback, window);
189 window->SetLayout(layout);189 window->SetLayout(layout);
190 window->SetBackgroundColor(nux::Color(0x00000000));190 window->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
191 window->ShowWindow(true);191 window->ShowWindow(true);
192 window->EnableInputWindow(true, "panel", false, false);192 window->EnableInputWindow(true, "panel", false, false);
193 window->InputWindowEnableStruts(true);193 window->InputWindowEnableStruts(true);
@@ -230,6 +230,11 @@
230 geo = window->GetGeometry();230 geo = window->GetGeometry();
231}231}
232232
233float PanelController::opacity() const
234{
235 return _opacity;
236}
237
233const gchar*238const gchar*
234PanelController::GetName()239PanelController::GetName()
235{240{
236241
=== modified file 'plugins/unityshell/src/PanelController.h'
--- plugins/unityshell/src/PanelController.h 2011-09-01 14:24:46 +0000
+++ plugins/unityshell/src/PanelController.h 2011-09-07 21:07:07 +0000
@@ -39,6 +39,8 @@
3939
40 unsigned int GetTrayXid ();40 unsigned int GetTrayXid ();
4141
42 float opacity() const;
43
42protected:44protected:
43 const gchar* GetName();45 const gchar* GetName();
44 void AddProperties(GVariantBuilder* builder);46 void AddProperties(GVariantBuilder* builder);
4547
=== modified file 'plugins/unityshell/src/PanelStyle.cpp'
--- plugins/unityshell/src/PanelStyle.cpp 2011-09-07 12:59:27 +0000
+++ plugins/unityshell/src/PanelStyle.cpp 2011-09-07 21:07:07 +0000
@@ -131,12 +131,16 @@
131 self->Refresh();131 self->Refresh();
132}132}
133133
134nux::NBitmapData* PanelStyle::GetBackground(int width, int height)134nux::NBitmapData* PanelStyle::GetBackground(int width, int height, float opacity)
135{135{
136 // TODO: check to see if we can put this on the stack.136 // TODO: check to see if we can put this on the stack.
137 nux::CairoGraphics* context = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, width, height);137 nux::CairoGraphics* context = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, width, height);
138 // Use the internal context as we know it is good and shiny new.138 // Use the internal context as we know it is good and shiny new.
139 gtk_render_background(_style_context, context->GetInternalContext(), 0, 0, width, height);139 cairo_t* cr = context->GetInternalContext();
140 cairo_push_group(cr);
141 gtk_render_background(_style_context, cr, 0, 0, width, height);
142 cairo_pop_group_to_source(cr);
143 cairo_paint_with_alpha(cr, opacity);
140144
141 nux::NBitmapData* bitmap = context->GetBitmap();145 nux::NBitmapData* bitmap = context->GetBitmap();
142146
143147
=== modified file 'plugins/unityshell/src/PanelStyle.h'
--- plugins/unityshell/src/PanelStyle.h 2011-07-21 14:59:25 +0000
+++ plugins/unityshell/src/PanelStyle.h 2011-09-07 21:07:07 +0000
@@ -50,7 +50,7 @@
5050
51 GtkStyleContext* GetStyleContext();51 GtkStyleContext* GetStyleContext();
5252
53 nux::NBitmapData* GetBackground(int width, int height);53 nux::NBitmapData* GetBackground(int width, int height, float opacity);
5454
55 nux::BaseTexture* GetWindowButton(WindowButtonType type, WindowState state);55 nux::BaseTexture* GetWindowButton(WindowButtonType type, WindowState state);
5656
5757
=== modified file 'plugins/unityshell/src/PanelView.cpp'
--- plugins/unityshell/src/PanelView.cpp 2011-09-02 16:13:19 +0000
+++ plugins/unityshell/src/PanelView.cpp 2011-09-07 21:07:07 +0000
@@ -189,7 +189,7 @@
189189
190 GfxContext.PushClippingRectangle(GetGeometry());190 GfxContext.PushClippingRectangle(GetGeometry());
191191
192 if (BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || _opacity != 1.0f))192 if (BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
193 {193 {
194 nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, geo.width, geo.height);194 nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, geo.width, geo.height);
195 bg_blur_texture_ = bg_effect_helper_.GetBlurRegion(blur_geo);195 bg_blur_texture_ = bg_effect_helper_.GetBlurRegion(blur_geo);
@@ -243,7 +243,7 @@
243 GfxContext.GetRenderStates().SetBlend(true);243 GfxContext.GetRenderStates().SetBlend(true);
244 GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);244 GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
245245
246 if (bg_blur_texture_.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || _opacity != 1.0f))246 if (bg_blur_texture_.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
247 {247 {
248 nux::Geometry geo_absolute = GetAbsoluteGeometry ();248 nux::Geometry geo_absolute = GetAbsoluteGeometry ();
249 nux::TexCoordXForm texxform_blur_bg;249 nux::TexCoordXForm texxform_blur_bg;
@@ -312,7 +312,7 @@
312 }312 }
313 else313 else
314 {314 {
315 nux::NBitmapData* bitmap = _style->GetBackground(geo.width, geo.height);315 nux::NBitmapData* bitmap = _style->GetBackground(geo.width, geo.height, _opacity);
316 nux::BaseTexture* texture2D = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();316 nux::BaseTexture* texture2D = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
317 texture2D->Update(bitmap);317 texture2D->Update(bitmap);
318 delete bitmap;318 delete bitmap;
@@ -328,7 +328,6 @@
328 rop.SrcBlend = GL_ONE;328 rop.SrcBlend = GL_ONE;
329 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;329 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
330 nux::Color col = nux::color::White;330 nux::Color col = nux::color::White;
331 col.alpha = _opacity;
332331
333 _bg_layer = new nux::TextureLayer(texture2D->GetDeviceTexture(),332 _bg_layer = new nux::TextureLayer(texture2D->GetDeviceTexture(),
334 texxform,333 texxform,
335334
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2011-09-06 15:06:49 +0000
+++ plugins/unityshell/src/unityshell.cpp 2011-09-07 21:07:07 +0000
@@ -411,7 +411,7 @@
411 vc[2] = y1;411 vc[2] = y1;
412 vc[3] = y2;412 vc[3] = y2;
413413
414 if (!dash_is_open_)414 if (!dash_is_open_ && panelController->opacity())
415 {415 {
416 foreach(GLTexture * tex, _shadow_texture)416 foreach(GLTexture * tex, _shadow_texture)
417 {417 {
418418
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2011-07-29 07:15:54 +0000
+++ services/panel-service.c 2011-09-07 21:07:07 +0000
@@ -503,7 +503,7 @@
503 PanelService *self)503 PanelService *self)
504{504{
505 gchar *entry_id;505 gchar *entry_id;
506 506
507 g_return_if_fail (PANEL_IS_SERVICE (self));507 g_return_if_fail (PANEL_IS_SERVICE (self));
508 if (entry == NULL)508 if (entry == NULL)
509 {509 {
@@ -512,7 +512,7 @@
512 }512 }
513513
514 entry_id = g_strdup_printf ("%p", entry);514 entry_id = g_strdup_printf ("%p", entry);
515515
516 g_signal_emit (self, _service_signals[ENTRY_SHOW_NOW_CHANGED], 0, entry_id, show_now_changed);516 g_signal_emit (self, _service_signals[ENTRY_SHOW_NOW_CHANGED], 0, entry_id, show_now_changed);
517517
518 g_free (entry_id);518 g_free (entry_id);