Chromium Code Reviews| Index: cc/output/gl_renderer.cc |
| diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
| index 6bb6f439ed849eb831c38c3287eaa776d4160f6d..377aa444147efb39fc1272ceeaff4e1e0edc8898 100644 |
| --- a/cc/output/gl_renderer.cc |
| +++ b/cc/output/gl_renderer.cc |
| @@ -700,6 +700,24 @@ static skia::RefPtr<SkImage> ApplyImageFilter( |
| return image; |
| } |
| +bool GLRenderer::ShouldApplyBlendModeUsingBlendFunc(const DrawQuad* quad) { |
| + SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; |
| + return blend_mode == SkXfermode::kScreen_Mode || |
| + blend_mode == SkXfermode::kSrcOver_Mode; |
| +} |
| + |
| +void GLRenderer::ApplyBlendModeUsingBlendFunc(const DrawQuad* quad) { |
| + DCHECK(ShouldApplyBlendModeUsingBlendFunc(quad)); |
| + if (quad->shared_quad_state->blend_mode == SkXfermode::kScreen_Mode) { |
| + GLC(gl_, gl_->BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE)); |
| + } |
| +} |
| + |
| +void GLRenderer::RestoreBlendFuncToDefault(const DrawQuad* quad) { |
| + DCHECK(ShouldApplyBlendModeUsingBlendFunc(quad)); |
|
enne (OOO)
2014/09/29 18:25:13
I don't think this DCHECK adds much. Can you remo
Erik Dahlström (inactive)
2014/09/30 07:06:07
Done.
|
| + GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| +} |
| + |
| static skia::RefPtr<SkImage> ApplyBlendModeWithBackdrop( |
| scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
| ResourceProvider* resource_provider, |
| @@ -973,7 +991,8 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( |
| void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
| const RenderPassDrawQuad* quad) { |
| - SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| + SetBlendEnabled(quad->ShouldDrawWithBlending() || |
| + ShouldApplyBlendModeUsingBlendFunc(quad)); |
| ScopedResource* contents_texture = |
| render_pass_textures_.get(quad->render_pass_id); |
| @@ -992,9 +1011,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
| if (!contents_device_transform.GetInverse(&contents_device_transform_inverse)) |
| return; |
| - bool need_background_texture = |
| - quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode || |
| - !quad->background_filters.IsEmpty(); |
| + bool need_background_texture = !ShouldApplyBlendModeUsingBlendFunc(quad) || |
| + !quad->background_filters.IsEmpty(); |
| bool background_changed = false; |
| scoped_ptr<ScopedResource> background_texture; |
| if (need_background_texture) { |
| @@ -1048,8 +1066,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
| } |
| } |
| - if (quad->shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode && |
| - background_texture) { |
| + if (background_texture && !ShouldApplyBlendModeUsingBlendFunc(quad)) { |
| filter_bitmap = |
| ApplyBlendModeWithBackdrop(ScopedUseGrContext::Create(this, frame), |
| resource_provider_, |
| @@ -1117,6 +1134,9 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
| contents_resource_lock->target()); |
| } |
| + if (ShouldApplyBlendModeUsingBlendFunc(quad)) |
| + ApplyBlendModeUsingBlendFunc(quad); |
| + |
| TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| gl_, |
| &highp_threshold_cache_, |
| @@ -1363,6 +1383,9 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
| // scope, so the draw gets processed before the filter texture gets deleted. |
| if (filter_bitmap) |
| GLC(gl_, gl_->Flush()); |
| + |
| + if (ShouldApplyBlendModeUsingBlendFunc(quad)) |
| + RestoreBlendFuncToDefault(quad); |
| } |
| struct SolidColorProgramUniforms { |