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
1=== modified file 'plugins/unityshell/src/PanelController.cpp'
2--- plugins/unityshell/src/PanelController.cpp 2011-09-06 18:30:26 +0000
3+++ plugins/unityshell/src/PanelController.cpp 2011-09-07 21:07:07 +0000
4@@ -187,7 +187,7 @@
5 window->SinkReference();
6 window->SetConfigureNotifyCallback(&PanelController::WindowConfigureCallback, window);
7 window->SetLayout(layout);
8- window->SetBackgroundColor(nux::Color(0x00000000));
9+ window->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
10 window->ShowWindow(true);
11 window->EnableInputWindow(true, "panel", false, false);
12 window->InputWindowEnableStruts(true);
13@@ -230,6 +230,11 @@
14 geo = window->GetGeometry();
15 }
16
17+float PanelController::opacity() const
18+{
19+ return _opacity;
20+}
21+
22 const gchar*
23 PanelController::GetName()
24 {
25
26=== modified file 'plugins/unityshell/src/PanelController.h'
27--- plugins/unityshell/src/PanelController.h 2011-09-01 14:24:46 +0000
28+++ plugins/unityshell/src/PanelController.h 2011-09-07 21:07:07 +0000
29@@ -39,6 +39,8 @@
30
31 unsigned int GetTrayXid ();
32
33+ float opacity() const;
34+
35 protected:
36 const gchar* GetName();
37 void AddProperties(GVariantBuilder* builder);
38
39=== modified file 'plugins/unityshell/src/PanelStyle.cpp'
40--- plugins/unityshell/src/PanelStyle.cpp 2011-09-07 12:59:27 +0000
41+++ plugins/unityshell/src/PanelStyle.cpp 2011-09-07 21:07:07 +0000
42@@ -131,12 +131,16 @@
43 self->Refresh();
44 }
45
46-nux::NBitmapData* PanelStyle::GetBackground(int width, int height)
47+nux::NBitmapData* PanelStyle::GetBackground(int width, int height, float opacity)
48 {
49 // TODO: check to see if we can put this on the stack.
50 nux::CairoGraphics* context = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, width, height);
51 // Use the internal context as we know it is good and shiny new.
52- gtk_render_background(_style_context, context->GetInternalContext(), 0, 0, width, height);
53+ cairo_t* cr = context->GetInternalContext();
54+ cairo_push_group(cr);
55+ gtk_render_background(_style_context, cr, 0, 0, width, height);
56+ cairo_pop_group_to_source(cr);
57+ cairo_paint_with_alpha(cr, opacity);
58
59 nux::NBitmapData* bitmap = context->GetBitmap();
60
61
62=== modified file 'plugins/unityshell/src/PanelStyle.h'
63--- plugins/unityshell/src/PanelStyle.h 2011-07-21 14:59:25 +0000
64+++ plugins/unityshell/src/PanelStyle.h 2011-09-07 21:07:07 +0000
65@@ -50,7 +50,7 @@
66
67 GtkStyleContext* GetStyleContext();
68
69- nux::NBitmapData* GetBackground(int width, int height);
70+ nux::NBitmapData* GetBackground(int width, int height, float opacity);
71
72 nux::BaseTexture* GetWindowButton(WindowButtonType type, WindowState state);
73
74
75=== modified file 'plugins/unityshell/src/PanelView.cpp'
76--- plugins/unityshell/src/PanelView.cpp 2011-09-02 16:13:19 +0000
77+++ plugins/unityshell/src/PanelView.cpp 2011-09-07 21:07:07 +0000
78@@ -189,7 +189,7 @@
79
80 GfxContext.PushClippingRectangle(GetGeometry());
81
82- if (BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || _opacity != 1.0f))
83+ if (BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
84 {
85 nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, geo.width, geo.height);
86 bg_blur_texture_ = bg_effect_helper_.GetBlurRegion(blur_geo);
87@@ -243,7 +243,7 @@
88 GfxContext.GetRenderStates().SetBlend(true);
89 GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
90
91- if (bg_blur_texture_.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || _opacity != 1.0f))
92+ if (bg_blur_texture_.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE && (_dash_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
93 {
94 nux::Geometry geo_absolute = GetAbsoluteGeometry ();
95 nux::TexCoordXForm texxform_blur_bg;
96@@ -312,7 +312,7 @@
97 }
98 else
99 {
100- nux::NBitmapData* bitmap = _style->GetBackground(geo.width, geo.height);
101+ nux::NBitmapData* bitmap = _style->GetBackground(geo.width, geo.height, _opacity);
102 nux::BaseTexture* texture2D = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
103 texture2D->Update(bitmap);
104 delete bitmap;
105@@ -328,7 +328,6 @@
106 rop.SrcBlend = GL_ONE;
107 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
108 nux::Color col = nux::color::White;
109- col.alpha = _opacity;
110
111 _bg_layer = new nux::TextureLayer(texture2D->GetDeviceTexture(),
112 texxform,
113
114=== modified file 'plugins/unityshell/src/unityshell.cpp'
115--- plugins/unityshell/src/unityshell.cpp 2011-09-06 15:06:49 +0000
116+++ plugins/unityshell/src/unityshell.cpp 2011-09-07 21:07:07 +0000
117@@ -411,7 +411,7 @@
118 vc[2] = y1;
119 vc[3] = y2;
120
121- if (!dash_is_open_)
122+ if (!dash_is_open_ && panelController->opacity())
123 {
124 foreach(GLTexture * tex, _shadow_texture)
125 {
126
127=== modified file 'services/panel-service.c'
128--- services/panel-service.c 2011-07-29 07:15:54 +0000
129+++ services/panel-service.c 2011-09-07 21:07:07 +0000
130@@ -503,7 +503,7 @@
131 PanelService *self)
132 {
133 gchar *entry_id;
134-
135+
136 g_return_if_fail (PANEL_IS_SERVICE (self));
137 if (entry == NULL)
138 {
139@@ -512,7 +512,7 @@
140 }
141
142 entry_id = g_strdup_printf ("%p", entry);
143-
144+
145 g_signal_emit (self, _service_signals[ENTRY_SHOW_NOW_CHANGED], 0, entry_id, show_now_changed);
146
147 g_free (entry_id);