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

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: 3575
Proposed branch: lp:~3v1n0/unity/overlay-renderer-not-glsl-color-fix-7.1
Merge into: lp:unity/7.1
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-7.1
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Eleni Maria Stea (community) Approve
Review via email: mp+191964@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.

To post a comment you must log in.
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

Well done! I ran the branch using glsl and llvmpipe and it works fine in both cases!

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'unity-shared/OverlayRenderer.cpp'
--- unity-shared/OverlayRenderer.cpp 2013-09-25 00:47:31 +0000
+++ unity-shared/OverlayRenderer.cpp 2013-10-21 11:01:42 +0000
@@ -89,7 +89,6 @@
89 , parent(parent_)89 , parent(parent_)
90{90{
91 UpdateTextures();91 UpdateTextures();
92 WindowManager::Default().average_color.changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::OnBgColorChanged));
93}92}
9493
95void OverlayRendererImpl::OnBgColorChanged(nux::Color const& new_color)94void OverlayRendererImpl::OnBgColorChanged(nux::Color const& new_color)
@@ -111,7 +110,13 @@
111 rop.Blend = true;110 rop.Blend = true;
112 rop.SrcBlend = GL_ONE;111 rop.SrcBlend = GL_ONE;
113 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;112 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
114 bg_layer_ = std::make_shared<nux::ColorLayer>(nux::Color(0.0f, 0.0f, 0.0f, 0.9), true, rop);113
114 if (Settings::Instance().GetLowGfxMode() || !nux::GetWindowThread()->GetGraphicsEngine().UsingGLSLCodePath())
115 {
116 auto& avg_color = WindowManager::Default().average_color;
117 bg_layer_ = std::make_shared<nux::ColorLayer>(avg_color(), true, rop);
118 avg_color.changed.connect(sigc::mem_fun(this, &OverlayRendererImpl::OnBgColorChanged));
119 }
115120
116 rop.Blend = true;121 rop.Blend = true;
117 rop.SrcBlend = GL_ZERO;122 rop.SrcBlend = GL_ZERO;
@@ -148,7 +153,7 @@
148153
149void OverlayRendererImpl::InitASMInverseTextureMaskShader()154void OverlayRendererImpl::InitASMInverseTextureMaskShader()
150{155{
151 std::string AsmVtx = 156 std::string AsmVtx =
152 "!!ARBvp1.0 \n\157 "!!ARBvp1.0 \n\
153 ATTRIB iPos = vertex.position; \n\158 ATTRIB iPos = vertex.position; \n\
154 ATTRIB iColor = vertex.attrib[3]; \n\159 ATTRIB iColor = vertex.attrib[3]; \n\
@@ -165,7 +170,7 @@
165 MOV oTexCoord0, vertex.attrib[8]; \n\170 MOV oTexCoord0, vertex.attrib[8]; \n\
166 END";171 END";
167172
168 std::string AsmFrg = 173 std::string AsmFrg =
169 "!!ARBfp1.0 \n\174 "!!ARBfp1.0 \n\
170 TEMP tex0; \n\175 TEMP tex0; \n\
171 TEMP temp0; \n\176 TEMP temp0; \n\
@@ -174,7 +179,7 @@
174 SUB result.color, {1.0, 1.0, 1.0, 1.0}, temp0.aaaa;\n\179 SUB result.color, {1.0, 1.0, 1.0, 1.0}, temp0.aaaa;\n\
175 END";180 END";
176181
177 std::string AsmFrgRect = 182 std::string AsmFrgRect =
178 "!!ARBfp1.0 \n\183 "!!ARBfp1.0 \n\
179 TEMP tex0; \n\184 TEMP tex0; \n\
180 TEMP temp0; \n\185 TEMP temp0; \n\
@@ -216,7 +221,7 @@
216221
217 CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));222 CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
218 CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));223 CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
219 224
220 nux::ObjectPtr<nux::IOpenGLAsmShaderProgram> shader_program = inverse_texture_mask_asm_prog_;225 nux::ObjectPtr<nux::IOpenGLAsmShaderProgram> shader_program = inverse_texture_mask_asm_prog_;
221 if (device_texture->Type().IsDerivedFromType(nux::IOpenGLRectangleTexture::StaticObjectType))226 if (device_texture->Type().IsDerivedFromType(nux::IOpenGLRectangleTexture::StaticObjectType))
222 {227 {
@@ -274,7 +279,7 @@
274 std::string VSString;279 std::string VSString;
275 std::string PSString;280 std::string PSString;
276281
277 VSString = 282 VSString =
278 NUX_VERTEX_SHADER_HEADER283 NUX_VERTEX_SHADER_HEADER
279 "attribute vec4 AVertex; \n\284 "attribute vec4 AVertex; \n\
280 attribute vec4 MyTextureCoord0; \n\285 attribute vec4 MyTextureCoord0; \n\
@@ -289,7 +294,7 @@
289 varyVertexColor = VertexColor; \n\294 varyVertexColor = VertexColor; \n\
290 }";295 }";
291296
292 PSString = 297 PSString =
293 NUX_FRAGMENT_SHADER_HEADER298 NUX_FRAGMENT_SHADER_HEADER
294 "varying vec4 varyTexCoord0; \n\299 "varying vec4 varyTexCoord0; \n\
295 varying vec4 varyVertexColor; \n\300 varying vec4 varyVertexColor; \n\
@@ -443,14 +448,14 @@
443448
444#endif449#endif
445 }450 }
446 451
447 //Draw the left and top lines.452 //Draw the left and top lines.
448 dash::Style& style = dash::Style::Instance();453 dash::Style& style = dash::Style::Instance();
449 454
450 gfx_context.GetRenderStates().SetColorMask(true, true, true, true);455 gfx_context.GetRenderStates().SetColorMask(true, true, true, true);
451 gfx_context.GetRenderStates().SetBlend(true);456 gfx_context.GetRenderStates().SetBlend(true);
452 gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);457 gfx_context.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
453 458
454 const double line_opacity = 0.1f;459 const double line_opacity = 0.1f;
455 const int gradient_height = 50;460 const int gradient_height = 50;
456 const int vertical_padding = 20;461 const int vertical_padding = 20;
@@ -482,10 +487,10 @@
482 bg_darken_layer_->SetGeometry(larger_content_geo);487 bg_darken_layer_->SetGeometry(larger_content_geo);
483 nux::GetPainter().RenderSinglePaintLayer(gfx_context, larger_content_geo, bg_darken_layer_.get());488 nux::GetPainter().RenderSinglePaintLayer(gfx_context, larger_content_geo, bg_darken_layer_.get());
484489
485 if (Settings::Instance().GetLowGfxMode() == false)490 if (!Settings::Instance().GetLowGfxMode())
486 {491 {
487#ifndef NUX_OPENGLES_20492#ifndef NUX_OPENGLES_20
488 if (gfx_context.UsingGLSLCodePath() == false)493 if (!gfx_context.UsingGLSLCodePath())
489 {494 {
490 bg_layer_->SetGeometry(larger_content_geo);495 bg_layer_->SetGeometry(larger_content_geo);
491 nux::GetPainter().RenderSinglePaintLayer(gfx_context, larger_content_geo, bg_layer_.get());496 nux::GetPainter().RenderSinglePaintLayer(gfx_context, larger_content_geo, bg_layer_.get());
@@ -529,7 +534,7 @@
529 {534 {
530 nux::Geometry geo_border(content_geo.x, content_geo.y, larger_absolute_geo.width - content_geo.x, larger_absolute_geo.height);535 nux::Geometry geo_border(content_geo.x, content_geo.y, larger_absolute_geo.width - content_geo.x, larger_absolute_geo.height);
531 gfx_context.PushClippingRectangle(geo_border);536 gfx_context.PushClippingRectangle(geo_border);
532 537
533 // Paint the edges538 // Paint the edges
534 {539 {
535 gfx_context.GetRenderStates().SetColorMask(true, true, true, true);540 gfx_context.GetRenderStates().SetColorMask(true, true, true, true);
@@ -556,7 +561,7 @@
556561
557 geo.width += corner->GetWidth() - 10;562 geo.width += corner->GetWidth() - 10;
558 geo.height += corner->GetHeight() - 10;563 geo.height += corner->GetHeight() - 10;
559 { 564 {
560 // Corner565 // Corner
561 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);566 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
562 texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);567 texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
@@ -565,7 +570,7 @@
565 gfx_context.QRP_ColorModTexAlpha(geo.x + (geo.width - corner->GetWidth()),570 gfx_context.QRP_ColorModTexAlpha(geo.x + (geo.width - corner->GetWidth()),
566 geo.y + (geo.height - corner->GetHeight()),571 geo.y + (geo.height - corner->GetHeight()),
567 corner->GetWidth(),572 corner->GetWidth(),
568 corner->GetHeight(), 573 corner->GetHeight(),
569 corner_mask->GetDeviceTexture(),574 corner_mask->GetDeviceTexture(),
570 texxform,575 texxform,
571 nux::color::Black);576 nux::color::Black);
@@ -605,7 +610,7 @@
605 gfx_context.QRP_ColorModTexAlpha(left_corner->GetWidth() - left_corner_offset - offset,610 gfx_context.QRP_ColorModTexAlpha(left_corner->GetWidth() - left_corner_offset - offset,
606 geo.y + (geo.height - bottom->GetHeight()),611 geo.y + (geo.height - bottom->GetHeight()),
607 real_width + offset,612 real_width + offset,
608 bottom->GetHeight(), 613 bottom->GetHeight(),
609 bottom_mask->GetDeviceTexture(),614 bottom_mask->GetDeviceTexture(),
610 texxform,615 texxform,
611 nux::color::Black);616 nux::color::Black);
@@ -642,7 +647,7 @@
642 gfx_context.QRP_ColorModTexAlpha(geo.x - left_corner_offset,647 gfx_context.QRP_ColorModTexAlpha(geo.x - left_corner_offset,
643 geo.y + (geo.height - left_corner->GetHeight()),648 geo.y + (geo.height - left_corner->GetHeight()),
644 left_corner->GetWidth(),649 left_corner->GetWidth(),
645 left_corner->GetHeight(), 650 left_corner->GetHeight(),
646 left_corner_mask->GetDeviceTexture(),651 left_corner_mask->GetDeviceTexture(),
647 texxform,652 texxform,
648 nux::color::Black);653 nux::color::Black);
@@ -696,7 +701,7 @@
696 gfx_context.QRP_ColorModTexAlpha(geo.x + geo.width - right->GetWidth(),701 gfx_context.QRP_ColorModTexAlpha(geo.x + geo.width - right->GetWidth(),
697 geo.y + top_corner->GetHeight() - top_corner_offset,702 geo.y + top_corner->GetHeight() - top_corner_offset,
698 right->GetWidth(),703 right->GetWidth(),
699 geo.height - corner->GetHeight() - (top_corner->GetHeight() - top_corner_offset), 704 geo.height - corner->GetHeight() - (top_corner->GetHeight() - top_corner_offset),
700 right_mask->GetDeviceTexture(),705 right_mask->GetDeviceTexture(),
701 texxform,706 texxform,
702 nux::color::Black);707 nux::color::Black);
@@ -775,7 +780,7 @@
775 nux::color::White);780 nux::color::White);
776 }781 }
777 }782 }
778 783
779 gfx_context.PopClippingRectangle();784 gfx_context.PopClippingRectangle();
780 }785 }
781786
@@ -798,7 +803,7 @@
798803
799 nux::Geometry larger_absolute_geo = absolute_geo;804 nux::Geometry larger_absolute_geo = absolute_geo;
800 larger_absolute_geo.OffsetSize(excess_border, excess_border);805 larger_absolute_geo.OffsetSize(excess_border, excess_border);
801 806
802 gfx_context.PushClippingRectangle(larger_geo);807 gfx_context.PushClippingRectangle(larger_geo);
803808
804 unsigned int blend_alpha, blend_src, blend_dest = 0;809 unsigned int blend_alpha, blend_src, blend_dest = 0;
@@ -853,10 +858,10 @@
853 bgs++;858 bgs++;
854859
855 //Only apply shine if we aren't in low gfx mode.860 //Only apply shine if we aren't in low gfx mode.
856 if (Settings::Instance().GetLowGfxMode() == false)861 if (!Settings::Instance().GetLowGfxMode())
857 {862 {
858#ifndef NUX_OPENGLES_20863#ifndef NUX_OPENGLES_20
859 if (gfx_context.UsingGLSLCodePath() == false)864 if (!gfx_context.UsingGLSLCodePath())
860 {865 {
861 nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_.get());866 nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_.get());
862 bgs++;867 bgs++;

Subscribers

People subscribed via source and target branches