Merge lp:~3v1n0/unity/overlay-renderer-not-glsl-color-fix into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3576
Proposed branch: lp:~3v1n0/unity/overlay-renderer-not-glsl-color-fix
Merge into: lp:unity
Diff against target: 196 lines (+28/-23)
1 file modified
unity-shared/OverlayRenderer.cpp (+28/-23)
To merge this branch: bzr merge lp:~3v1n0/unity/overlay-renderer-not-glsl-color-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Eleni Maria Stea (community) Approve
Review via email: mp+191963@code.launchpad.net

Commit message

OverlayRenderer: only and correctly initialize the BGLayer when not on GLSL codepath

Make sure we set the initial bg_layer_ value to the average color, and do this only if
really needed.

Description of the change

Initialize the average color correctly when not using GLSL codepath.

Removed some trailing spaces.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

Apart from jenkins failure it looks good to me, it works fine with both llvmpipe and glsl! well done!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-shared/OverlayRenderer.cpp'
2--- unity-shared/OverlayRenderer.cpp 2013-09-25 00:47:31 +0000
3+++ unity-shared/OverlayRenderer.cpp 2013-10-21 10:53:31 +0000
4@@ -89,7 +89,6 @@
5 , parent(parent_)
6 {
7 UpdateTextures();
8- WindowManager::Default().average_color.changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::OnBgColorChanged));
9 }
10
11 void OverlayRendererImpl::OnBgColorChanged(nux::Color const& new_color)
12@@ -111,7 +110,13 @@
13 rop.Blend = true;
14 rop.SrcBlend = GL_ONE;
15 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
16- bg_layer_ = std::make_shared<nux::ColorLayer>(nux::Color(0.0f, 0.0f, 0.0f, 0.9), true, rop);
17+
18+ if (Settings::Instance().GetLowGfxMode() || !nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath())
19+ {
20+ auto& avg_color = WindowManager::Default().average_color;
21+ bg_layer_ = std::make_shared<nux::ColorLayer>(avg_color(), true, rop);
22+ avg_color.changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::OnBgColorChanged));
23+ }
24
25 rop.Blend = true;
26 rop.SrcBlend = GL_ZERO;
27@@ -148,7 +153,7 @@
28
29 void OverlayRendererImpl::InitASMInverseTextureMaskShader()
30 {
31- std::string AsmVtx =
32+ std::string AsmVtx =
33 "!!ARBvp1.0 \n\
34 ATTRIB iPos = vertex.position; \n\
35 ATTRIB iColor = vertex.attrib[3]; \n\
36@@ -165,7 +170,7 @@
37 MOV oTexCoord0, vertex.attrib[8]; \n\
38 END";
39
40- std::string AsmFrg =
41+ std::string AsmFrg =
42 "!!ARBfp1.0 \n\
43 TEMP tex0; \n\
44 TEMP temp0; \n\
45@@ -174,7 +179,7 @@
46 SUB result.color, {1.0, 1.0, 1.0, 1.0}, temp0.aaaa;\n\
47 END";
48
49- std::string AsmFrgRect =
50+ std::string AsmFrgRect =
51 "!!ARBfp1.0 \n\
52 TEMP tex0; \n\
53 TEMP temp0; \n\
54@@ -216,7 +221,7 @@
55
56 CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
57 CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
58-
59+
60 nux::ObjectPtr<nux::IOpenGLAsmShaderProgram> shader_program = inverse_texture_mask_asm_prog_;
61 if (device_texture->Type().IsDerivedFromType(nux::IOpenGLRectangleTexture::StaticObjectType))
62 {
63@@ -274,7 +279,7 @@
64 std::string VSString;
65 std::string PSString;
66
67- VSString =
68+ VSString =
69 NUX_VERTEX_SHADER_HEADER
70 "attribute vec4 AVertex; \n\
71 attribute vec4 MyTextureCoord0; \n\
72@@ -289,7 +294,7 @@
73 varyVertexColor = VertexColor; \n\
74 }";
75
76- PSString =
77+ PSString =
78 NUX_FRAGMENT_SHADER_HEADER
79 "varying vec4 varyTexCoord0; \n\
80 varying vec4 varyVertexColor; \n\
81@@ -443,14 +448,14 @@
82
83 #endif
84 }
85-
86+
87 //Draw the left and top lines.
88 dash::Style& style = dash::Style::Instance();
89-
90+
91 gfx_context.GetRenderStates().SetColorMask(true, true, true, true);
92 gfx_context.GetRenderStates().SetBlend(true);
93 gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
94-
95+
96 const double line_opacity = 0.1f;
97 const int gradient_height = 50;
98 const int vertical_padding = 20;
99@@ -482,10 +487,10 @@
100 bg_darken_layer_->SetGeometry(larger_content_geo);
101 nux::GetPainter().RenderSinglePaintLayer(gfx_context, larger_content_geo, bg_darken_layer_.get());
102
103- if (Settings::Instance().GetLowGfxMode() == false)
104+ if (!Settings::Instance().GetLowGfxMode())
105 {
106 #ifndef NUX_OPENGLES_20
107- if (gfx_context.UsingGLSLCodePath() == false)
108+ if (!gfx_context.UsingGLSLCodePath())
109 {
110 bg_layer_->SetGeometry(larger_content_geo);
111 nux::GetPainter().RenderSinglePaintLayer(gfx_context, larger_content_geo, bg_layer_.get());
112@@ -529,7 +534,7 @@
113 {
114 nux::Geometry geo_border(content_geo.x, content_geo.y, larger_absolute_geo.width - content_geo.x, larger_absolute_geo.height);
115 gfx_context.PushClippingRectangle(geo_border);
116-
117+
118 // Paint the edges
119 {
120 gfx_context.GetRenderStates().SetColorMask(true, true, true, true);
121@@ -556,7 +561,7 @@
122
123 geo.width += corner->GetWidth() - 10;
124 geo.height += corner->GetHeight() - 10;
125- {
126+ {
127 // Corner
128 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
129 texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
130@@ -565,7 +570,7 @@
131 gfx_context.QRP_ColorModTexAlpha(geo.x + (geo.width - corner->GetWidth()),
132 geo.y + (geo.height - corner->GetHeight()),
133 corner->GetWidth(),
134- corner->GetHeight(),
135+ corner->GetHeight(),
136 corner_mask->GetDeviceTexture(),
137 texxform,
138 nux::color::Black);
139@@ -605,7 +610,7 @@
140 gfx_context.QRP_ColorModTexAlpha(left_corner->GetWidth() - left_corner_offset - offset,
141 geo.y + (geo.height - bottom->GetHeight()),
142 real_width + offset,
143- bottom->GetHeight(),
144+ bottom->GetHeight(),
145 bottom_mask->GetDeviceTexture(),
146 texxform,
147 nux::color::Black);
148@@ -642,7 +647,7 @@
149 gfx_context.QRP_ColorModTexAlpha(geo.x - left_corner_offset,
150 geo.y + (geo.height - left_corner->GetHeight()),
151 left_corner->GetWidth(),
152- left_corner->GetHeight(),
153+ left_corner->GetHeight(),
154 left_corner_mask->GetDeviceTexture(),
155 texxform,
156 nux::color::Black);
157@@ -696,7 +701,7 @@
158 gfx_context.QRP_ColorModTexAlpha(geo.x + geo.width - right->GetWidth(),
159 geo.y + top_corner->GetHeight() - top_corner_offset,
160 right->GetWidth(),
161- geo.height - corner->GetHeight() - (top_corner->GetHeight() - top_corner_offset),
162+ geo.height - corner->GetHeight() - (top_corner->GetHeight() - top_corner_offset),
163 right_mask->GetDeviceTexture(),
164 texxform,
165 nux::color::Black);
166@@ -775,7 +780,7 @@
167 nux::color::White);
168 }
169 }
170-
171+
172 gfx_context.PopClippingRectangle();
173 }
174
175@@ -798,7 +803,7 @@
176
177 nux::Geometry larger_absolute_geo = absolute_geo;
178 larger_absolute_geo.OffsetSize(excess_border, excess_border);
179-
180+
181 gfx_context.PushClippingRectangle(larger_geo);
182
183 unsigned int blend_alpha, blend_src, blend_dest = 0;
184@@ -853,10 +858,10 @@
185 bgs++;
186
187 //Only apply shine if we aren't in low gfx mode.
188- if (Settings::Instance().GetLowGfxMode() == false)
189+ if (!Settings::Instance().GetLowGfxMode())
190 {
191 #ifndef NUX_OPENGLES_20
192- if (gfx_context.UsingGLSLCodePath() == false)
193+ if (!gfx_context.UsingGLSLCodePath())
194 {
195 nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_.get());
196 bgs++;