diff --git compositing_iosurface_layer_mac.mm compositing_iosurface_layer_mac.mm index 08d3d4d..02467a7 100644 --- compositing_iosurface_layer_mac.mm +++ compositing_iosurface_layer_mac.mm @@ -117,7 +117,7 @@ (context_ && context_->cgl_context() != glContext) || !renderWidgetHostView_ || !renderWidgetHostView_->compositing_iosurface_) { - glClearColor(1, 1, 1, 1); + glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); return; } diff --git compositing_iosurface_mac.mm compositing_iosurface_mac.mm index 45f4758..ed071b2 100644 --- compositing_iosurface_mac.mm +++ compositing_iosurface_mac.mm @@ -362,7 +362,7 @@ bool CompositingIOSurfaceMac::DrawIOSurface( glUseProgram(0); CHECK_AND_SAVE_GL_ERROR(); } else { // Should match the clear color of RenderWidgetHostViewMac. - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); } diff --git compositing_iosurface_shader_programs_mac.cc compositing_iosurface_shader_programs_mac.cc index 753c180..c5f09f1 100644 --- compositing_iosurface_shader_programs_mac.cc +++ compositing_iosurface_shader_programs_mac.cc @@ -11,6 +11,7 @@ #include "base/debug/trace_event.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/strings/stringprintf.h" #include "base/values.h" #include "content/browser/gpu/gpu_data_manager_impl.h" #include "gpu/config/gpu_driver_bug_workaround_type.h" @@ -51,6 +52,7 @@ const char kfsBlit[] = GLSL_PROGRAM_AS_STRING( } ); +float bgcolor[] = {1.0f, 1.0f, 1.0f}; // Only calculates position. const char kvsSolidWhite[] = GLSL_PROGRAM_AS_STRING( @@ -238,6 +240,16 @@ GLuint CompileShaderGLSL(ShaderProgram shader_program, GLenum shader_type, const GLuint shader = glCreateShader(shader_type); DCHECK_NE(shader, 0u); + // Support customization of the background color. + std::string bg_shader; + if (shader_program == SHADER_PROGRAM_SOLID_WHITE && + shader_type == GL_FRAGMENT_SHADER) { + bg_shader = base::StringPrintf( + "void main() { gl_FragColor = vec4(%f, %f, %f, 1.0); }", + bgcolor[0], bgcolor[1], bgcolor[2]); + kFragmentShaderSourceCodeMap[shader_program] = bg_shader.c_str(); + } + // Select and compile the shader program source code. if (shader_type == GL_VERTEX_SHADER) { const GLchar* source_snippets[] = { @@ -412,6 +424,14 @@ void CompositingIOSurfaceShaderPrograms::SetOutputFormatForTesting( Reset(); } +// static +void CompositingIOSurfaceShaderPrograms::SetBackgroundColor( + float r, float g, float b) { + bgcolor[0] = r; + bgcolor[1] = g; + bgcolor[2] = b; +} + GLuint CompositingIOSurfaceShaderPrograms::GetShaderProgram(int which) { if (shader_programs_[which] == 0u) { shader_programs_[which] = diff --git compositing_iosurface_shader_programs_mac.h compositing_iosurface_shader_programs_mac.h index de1987f..d36b988 100644 --- compositing_iosurface_shader_programs_mac.h +++ compositing_iosurface_shader_programs_mac.h @@ -48,6 +48,8 @@ class CompositingIOSurfaceShaderPrograms { return rgb_to_yv12_output_format_; } + static void SetBackgroundColor(float r, float g, float b); + protected: FRIEND_TEST_ALL_PREFIXES(CompositingIOSurfaceTransformerTest, TransformsRGBToYV12); diff --git render_widget_host_view_aura.cc render_widget_host_view_aura.cc index 8493660..ce185939 100644 --- render_widget_host_view_aura.cc +++ render_widget_host_view_aura.cc @@ -2685,8 +2685,14 @@ void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { // For non-opaque windows, we don't draw anything, since we depend on the // canvas coming from the compositor to already be initialized as // transparent. - if (window_->layer()->fills_bounds_opaquely()) - canvas->DrawColor(SK_ColorWHITE); + if (window_->layer()->fills_bounds_opaquely()) { + if (host_->IsRenderView()) { + canvas->DrawColor(GetContentClient()->browser()->GetBaseBackgroundColor( + RenderViewHost::From(host_))); + } else { + canvas->DrawColor(SK_ColorWHITE); + } + } } } diff --git render_widget_host_view_mac.mm render_widget_host_view_mac.mm index 9cdbc07..4f9c19e 100644 --- render_widget_host_view_mac.mm +++ render_widget_host_view_mac.mm @@ -440,7 +440,7 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) use_core_animation_ = true; background_layer_.reset([[CALayer alloc] init]); [background_layer_ - setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; + setBackgroundColor:CGColorGetConstantColor(kCGColorClear)]; [cocoa_view_ setLayer:background_layer_]; [cocoa_view_ setWantsLayer:YES]; } @@ -3108,7 +3108,7 @@ SkBitmap::Config RenderWidgetHostViewMac::PreferredReadbackFormat() { NSRect r = [self flipRectToNSRect:gfx::Rect(x, y, width, height)]; CGContextSetFillColorWithColor(context, - CGColorGetConstantColor(kCGColorWhite)); + CGColorGetConstantColor(kCGColorClear)); CGContextFillRect(context, NSRectToCGRect(r)); } if (damagedRect.bottom() > rect.bottom()) { @@ -3130,7 +3130,7 @@ SkBitmap::Config RenderWidgetHostViewMac::PreferredReadbackFormat() { NSRect r = [self flipRectToNSRect:gfx::Rect(x, y, width, height)]; CGContextSetFillColorWithColor(context, - CGColorGetConstantColor(kCGColorWhite)); + CGColorGetConstantColor(kCGColorClear)); CGContextFillRect(context, NSRectToCGRect(r)); } } @@ -3280,7 +3280,7 @@ SkBitmap::Config RenderWidgetHostViewMac::PreferredReadbackFormat() { } } else { CGContextSetFillColorWithColor(context, - CGColorGetConstantColor(kCGColorWhite)); + CGColorGetConstantColor(kCGColorClear)); CGContextFillRect(context, dirtyRect); if (renderWidgetHostView_->whiteout_start_time_.is_null()) renderWidgetHostView_->whiteout_start_time_ = base::TimeTicks::Now(); @@ -4303,7 +4303,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName; if (self = [super init]) { renderWidgetHostView_ = r; - [self setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; + [self setBackgroundColor:CGColorGetConstantColor(kCGColorClear)]; [self setAnchorPoint:CGPointMake(0, 0)]; // Setting contents gravity is necessary to prevent the layer from being // scaled during dyanmic resizes (especially with devtools open). @@ -4332,7 +4332,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName; inContext:context]; } else { CGContextSetFillColorWithColor(context, - CGColorGetConstantColor(kCGColorWhite)); + CGColorGetConstantColor(kCGColorClear)); CGContextFillRect(context, clipRect); } }