Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3384)

Unified Diff: cc/output/gl_renderer.cc

Issue 959283004: Background filters are affected by masks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index b5150e572df69562cccbe2901aff85d22b1002ca..37350a6ab187b2d775a00eca568e869c1123511b 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -938,7 +938,9 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
DCHECK(!background_image);
use_shaders_for_blending = false;
} else if (background_image) {
- background_texture.reset();
+ // Reset original background texture if there is no any mask
enne (OOO) 2015/03/03 23:27:47 grammar nit: no => not
+ if (!quad->mask_resource_id)
+ background_texture.reset();
} else if (CanApplyBlendModeUsingBlendFunc(blend_mode) &&
ShouldApplyBackgroundFilters(frame, quad)) {
// Something went wrong with applying background filters to the backdrop.
@@ -946,7 +948,11 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
background_texture.reset();
}
}
-
+ // Need original background texture for mask?
+ bool mask_for_background =
+ background_texture && // Have original background texture
+ background_image && // Have filtered background texture
+ quad->mask_resource_id; // Have mask texture
SetBlendEnabled(
!use_shaders_for_blending &&
(quad->ShouldDrawWithBlending() || !IsDefaultBlendMode(blend_mode)));
@@ -1025,14 +1031,16 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
if (use_aa && mask_texture_id && !use_color_matrix) {
const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA(
- tex_coord_precision, mask_sampler, shader_blend_mode);
+ tex_coord_precision, mask_sampler,
+ shader_blend_mode, mask_for_background);
SetUseProgram(program->program());
program->vertex_shader().FillLocations(&locations);
program->fragment_shader().FillLocations(&locations);
GLC(gl_, gl_->Uniform1i(locations.sampler, 0));
} else if (!use_aa && mask_texture_id && !use_color_matrix) {
const RenderPassMaskProgram* program = GetRenderPassMaskProgram(
- tex_coord_precision, mask_sampler, shader_blend_mode);
+ tex_coord_precision, mask_sampler,
+ shader_blend_mode, mask_for_background);
SetUseProgram(program->program());
program->vertex_shader().FillLocations(&locations);
program->fragment_shader().FillLocations(&locations);
@@ -1047,7 +1055,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
} else if (use_aa && mask_texture_id && use_color_matrix) {
const RenderPassMaskColorMatrixProgramAA* program =
GetRenderPassMaskColorMatrixProgramAA(
- tex_coord_precision, mask_sampler, shader_blend_mode);
+ tex_coord_precision, mask_sampler,
+ shader_blend_mode, mask_for_background);
SetUseProgram(program->program());
program->vertex_shader().FillLocations(&locations);
program->fragment_shader().FillLocations(&locations);
@@ -1063,7 +1072,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
} else if (!use_aa && mask_texture_id && use_color_matrix) {
const RenderPassMaskColorMatrixProgram* program =
GetRenderPassMaskColorMatrixProgram(
- tex_coord_precision, mask_sampler, shader_blend_mode);
+ tex_coord_precision, mask_sampler,
+ shader_blend_mode, mask_for_background);
SetUseProgram(program->program());
program->vertex_shader().FillLocations(&locations);
program->fragment_shader().FillLocations(&locations);
@@ -1177,7 +1187,11 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit));
gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0));
- } else {
+ if (mask_for_background)
+ GLC(gl_, gl_->Uniform1i(locations.original_backdrop,
+ ++last_texture_unit));
+ }
+ if (background_texture) {
shader_background_sampler_lock = make_scoped_ptr(
new ResourceProvider::ScopedSamplerGL(resource_provider_,
background_texture->id(),
@@ -2693,7 +2707,8 @@ const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA(
const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(
TexCoordPrecision precision,
SamplerType sampler,
- BlendMode blend_mode) {
+ BlendMode blend_mode,
+ bool mask_for_background) {
DCHECK_GE(precision, 0);
DCHECK_LE(precision, LAST_TEX_COORD_PRECISION);
DCHECK_GE(sampler, 0);
@@ -2701,11 +2716,13 @@ const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(
DCHECK_GE(blend_mode, 0);
DCHECK_LE(blend_mode, LAST_BLEND_MODE);
RenderPassMaskProgram* program =
- &render_pass_mask_program_[precision][sampler][blend_mode];
+ &render_pass_mask_program_[precision][sampler][blend_mode]
+ [mask_for_background ? 1 : 0];
if (!program->initialized()) {
TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize");
program->Initialize(
- output_surface_->context_provider(), precision, sampler, blend_mode);
+ output_surface_->context_provider(), precision,
+ sampler, blend_mode, mask_for_background);
}
return program;
}
@@ -2713,7 +2730,8 @@ const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram(
const GLRenderer::RenderPassMaskProgramAA*
GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision,
SamplerType sampler,
- BlendMode blend_mode) {
+ BlendMode blend_mode,
+ bool mask_for_background) {
DCHECK_GE(precision, 0);
DCHECK_LE(precision, LAST_TEX_COORD_PRECISION);
DCHECK_GE(sampler, 0);
@@ -2721,11 +2739,13 @@ GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision,
DCHECK_GE(blend_mode, 0);
DCHECK_LE(blend_mode, LAST_BLEND_MODE);
RenderPassMaskProgramAA* program =
- &render_pass_mask_program_aa_[precision][sampler][blend_mode];
+ &render_pass_mask_program_aa_[precision][sampler][blend_mode]
+ [mask_for_background ? 1 : 0];
if (!program->initialized()) {
TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize");
program->Initialize(
- output_surface_->context_provider(), precision, sampler, blend_mode);
+ output_surface_->context_provider(), precision,
+ sampler, blend_mode, mask_for_background);
}
return program;
}
@@ -2766,9 +2786,11 @@ GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision,
}
const GLRenderer::RenderPassMaskColorMatrixProgram*
-GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision,
- SamplerType sampler,
- BlendMode blend_mode) {
+GLRenderer::GetRenderPassMaskColorMatrixProgram(
+ TexCoordPrecision precision,
+ SamplerType sampler,
+ BlendMode blend_mode,
+ bool mask_for_background) {
DCHECK_GE(precision, 0);
DCHECK_LE(precision, LAST_TEX_COORD_PRECISION);
DCHECK_GE(sampler, 0);
@@ -2776,20 +2798,24 @@ GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision,
DCHECK_GE(blend_mode, 0);
DCHECK_LE(blend_mode, LAST_BLEND_MODE);
RenderPassMaskColorMatrixProgram* program =
- &render_pass_mask_color_matrix_program_[precision][sampler][blend_mode];
+ &render_pass_mask_color_matrix_program_[precision][sampler][blend_mode]
+ [mask_for_background ? 1 : 0];
if (!program->initialized()) {
TRACE_EVENT0("cc",
"GLRenderer::renderPassMaskColorMatrixProgram::initialize");
program->Initialize(
- output_surface_->context_provider(), precision, sampler, blend_mode);
+ output_surface_->context_provider(), precision,
+ sampler, blend_mode, mask_for_background);
}
return program;
}
const GLRenderer::RenderPassMaskColorMatrixProgramAA*
-GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision,
- SamplerType sampler,
- BlendMode blend_mode) {
+GLRenderer::GetRenderPassMaskColorMatrixProgramAA(
+ TexCoordPrecision precision,
+ SamplerType sampler,
+ BlendMode blend_mode,
+ bool mask_for_background) {
DCHECK_GE(precision, 0);
DCHECK_LE(precision, LAST_TEX_COORD_PRECISION);
DCHECK_GE(sampler, 0);
@@ -2797,13 +2823,14 @@ GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision,
DCHECK_GE(blend_mode, 0);
DCHECK_LE(blend_mode, LAST_BLEND_MODE);
RenderPassMaskColorMatrixProgramAA* program =
- &render_pass_mask_color_matrix_program_aa_[precision][sampler]
- [blend_mode];
+ &render_pass_mask_color_matrix_program_aa_[precision][sampler][blend_mode]
+ [mask_for_background ? 1 : 0];
if (!program->initialized()) {
TRACE_EVENT0("cc",
"GLRenderer::renderPassMaskColorMatrixProgramAA::initialize");
program->Initialize(
- output_surface_->context_provider(), precision, sampler, blend_mode);
+ output_surface_->context_provider(), precision,
+ sampler, blend_mode, mask_for_background);
}
return program;
}
@@ -3030,10 +3057,12 @@ void GLRenderer::CleanupSharedObjects() {
tile_program_swizzle_aa_[i][j].Cleanup(gl_);
for (int k = 0; k <= LAST_BLEND_MODE; k++) {
- render_pass_mask_program_[i][j][k].Cleanup(gl_);
- render_pass_mask_program_aa_[i][j][k].Cleanup(gl_);
- render_pass_mask_color_matrix_program_aa_[i][j][k].Cleanup(gl_);
- render_pass_mask_color_matrix_program_[i][j][k].Cleanup(gl_);
+ for (int l = 0; l <= 1; ++l) {
+ render_pass_mask_program_[i][j][k][l].Cleanup(gl_);
+ render_pass_mask_program_aa_[i][j][k][l].Cleanup(gl_);
+ render_pass_mask_color_matrix_program_aa_[i][j][k][l].Cleanup(gl_);
+ render_pass_mask_color_matrix_program_[i][j][k][l].Cleanup(gl_);
+ }
}
}
for (int j = 0; j <= LAST_BLEND_MODE; j++) {

Powered by Google App Engine
This is Rietveld 408576698