Index: cc/output/gl_renderer.cc |
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc |
index 3794ca73a4f614a3b7c0b10537156509532939f3..e66cfe24d6407bc3c112eace9863b1771253a03a 100644 |
--- a/cc/output/gl_renderer.cc |
+++ b/cc/output/gl_renderer.cc |
@@ -1159,8 +1159,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
: BlendModeNormal; |
if (use_aa && mask_texture_id && !use_color_matrix) { |
- const RenderPassMaskProgramAA* program = |
- GetRenderPassMaskProgramAA(tex_coord_precision, shader_blend_mode); |
+ const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA( |
+ tex_coord_precision, mask_sampler, shader_blend_mode); |
SetUseProgram(program->program()); |
GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
@@ -1181,8 +1181,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
shader_backdrop_rect_location = |
program->fragment_shader().backdrop_rect_location(); |
} else if (!use_aa && mask_texture_id && !use_color_matrix) { |
- const RenderPassMaskProgram* program = |
- GetRenderPassMaskProgram(tex_coord_precision, shader_blend_mode); |
+ const RenderPassMaskProgram* program = GetRenderPassMaskProgram( |
+ tex_coord_precision, mask_sampler, shader_blend_mode); |
SetUseProgram(program->program()); |
GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
@@ -1217,8 +1217,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
program->fragment_shader().backdrop_rect_location(); |
} else if (use_aa && mask_texture_id && use_color_matrix) { |
const RenderPassMaskColorMatrixProgramAA* program = |
- GetRenderPassMaskColorMatrixProgramAA(tex_coord_precision, |
- shader_blend_mode); |
+ GetRenderPassMaskColorMatrixProgramAA( |
+ tex_coord_precision, mask_sampler, shader_blend_mode); |
SetUseProgram(program->program()); |
GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
@@ -1265,8 +1265,8 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
program->fragment_shader().backdrop_rect_location(); |
} else if (!use_aa && mask_texture_id && use_color_matrix) { |
const RenderPassMaskColorMatrixProgram* program = |
- GetRenderPassMaskColorMatrixProgram(tex_coord_precision, |
- shader_blend_mode); |
+ GetRenderPassMaskColorMatrixProgram( |
+ tex_coord_precision, mask_sampler, shader_blend_mode); |
SetUseProgram(program->program()); |
GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); |
@@ -1337,14 +1337,16 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
-tex_scale_y)); |
GLint last_texture_unit = 0; |
- scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_mask_sampler_lock; |
if (shader_mask_sampler_location != -1) { |
DCHECK_NE(shader_mask_tex_coord_scale_location, 1); |
DCHECK_NE(shader_mask_tex_coord_offset_location, 1); |
- DCHECK_EQ(SamplerType2D, mask_sampler); |
GLC(gl_, gl_->Uniform1i(shader_mask_sampler_location, 1)); |
gfx::RectF mask_uv_rect = quad->MaskUVRect(); |
+ if (mask_sampler != SamplerType2D) { |
+ mask_uv_rect.Scale(quad->mask_texture_size.width(), |
+ quad->mask_texture_size.height()); |
+ } |
// Mask textures are oriented vertically flipped relative to the framebuffer |
// and the RenderPass contents texture, so we flip the tex coords from the |
@@ -2889,38 +2891,40 @@ const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( |
const GLRenderer::RenderPassMaskProgram* GLRenderer::GetRenderPassMaskProgram( |
TexCoordPrecision precision, |
+ SamplerType sampler, |
BlendMode blend_mode) { |
DCHECK_GE(precision, 0); |
DCHECK_LT(precision, NumTexCoordPrecisions); |
+ DCHECK_GE(sampler, 0); |
+ DCHECK_LT(sampler, NumSamplerTypes); |
DCHECK_GE(blend_mode, 0); |
DCHECK_LT(blend_mode, NumBlendModes); |
RenderPassMaskProgram* program = |
- &render_pass_mask_program_[precision][blend_mode]; |
+ &render_pass_mask_program_[precision][sampler][blend_mode]; |
if (!program->initialized()) { |
TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); |
- program->Initialize(output_surface_->context_provider(), |
- precision, |
- SamplerType2D, |
- blend_mode); |
+ program->Initialize( |
+ output_surface_->context_provider(), precision, sampler, blend_mode); |
} |
return program; |
} |
const GLRenderer::RenderPassMaskProgramAA* |
GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision, |
+ SamplerType sampler, |
BlendMode blend_mode) { |
DCHECK_GE(precision, 0); |
DCHECK_LT(precision, NumTexCoordPrecisions); |
+ DCHECK_GE(sampler, 0); |
+ DCHECK_LT(sampler, NumSamplerTypes); |
DCHECK_GE(blend_mode, 0); |
DCHECK_LT(blend_mode, NumBlendModes); |
RenderPassMaskProgramAA* program = |
- &render_pass_mask_program_aa_[precision][blend_mode]; |
+ &render_pass_mask_program_aa_[precision][sampler][blend_mode]; |
if (!program->initialized()) { |
TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); |
- program->Initialize(output_surface_->context_provider(), |
- precision, |
- SamplerType2D, |
- blend_mode); |
+ program->Initialize( |
+ output_surface_->context_provider(), precision, sampler, blend_mode); |
} |
return program; |
} |
@@ -2966,40 +2970,43 @@ GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision, |
const GLRenderer::RenderPassMaskColorMatrixProgram* |
GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision, |
+ SamplerType sampler, |
BlendMode blend_mode) { |
DCHECK_GE(precision, 0); |
DCHECK_LT(precision, NumTexCoordPrecisions); |
+ DCHECK_GE(sampler, 0); |
+ DCHECK_LT(sampler, NumSamplerTypes); |
DCHECK_GE(blend_mode, 0); |
DCHECK_LT(blend_mode, NumBlendModes); |
RenderPassMaskColorMatrixProgram* program = |
- &render_pass_mask_color_matrix_program_[precision][blend_mode]; |
+ &render_pass_mask_color_matrix_program_[precision][sampler][blend_mode]; |
if (!program->initialized()) { |
TRACE_EVENT0("cc", |
"GLRenderer::renderPassMaskColorMatrixProgram::initialize"); |
- program->Initialize(output_surface_->context_provider(), |
- precision, |
- SamplerType2D, |
- blend_mode); |
+ program->Initialize( |
+ output_surface_->context_provider(), precision, sampler, blend_mode); |
} |
return program; |
} |
const GLRenderer::RenderPassMaskColorMatrixProgramAA* |
GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision, |
+ SamplerType sampler, |
BlendMode blend_mode) { |
DCHECK_GE(precision, 0); |
DCHECK_LT(precision, NumTexCoordPrecisions); |
+ DCHECK_GE(sampler, 0); |
+ DCHECK_LT(sampler, NumSamplerTypes); |
DCHECK_GE(blend_mode, 0); |
DCHECK_LT(blend_mode, NumBlendModes); |
RenderPassMaskColorMatrixProgramAA* program = |
- &render_pass_mask_color_matrix_program_aa_[precision][blend_mode]; |
+ &render_pass_mask_color_matrix_program_aa_[precision][sampler] |
+ [blend_mode]; |
if (!program->initialized()) { |
TRACE_EVENT0("cc", |
"GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); |
- program->Initialize(output_surface_->context_provider(), |
- precision, |
- SamplerType2D, |
- blend_mode); |
+ program->Initialize( |
+ output_surface_->context_provider(), precision, sampler, blend_mode); |
} |
return program; |
} |
@@ -3224,16 +3231,19 @@ void GLRenderer::CleanupSharedObjects() { |
tile_program_swizzle_opaque_[i][j].Cleanup(gl_); |
tile_program_aa_[i][j].Cleanup(gl_); |
tile_program_swizzle_aa_[i][j].Cleanup(gl_); |
+ |
+ for (int k = 0; k < NumBlendModes; 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 j = 0; j < NumBlendModes; j++) { |
- render_pass_mask_program_[i][j].Cleanup(gl_); |
render_pass_program_[i][j].Cleanup(gl_); |
- render_pass_mask_program_aa_[i][j].Cleanup(gl_); |
render_pass_program_aa_[i][j].Cleanup(gl_); |
render_pass_color_matrix_program_[i][j].Cleanup(gl_); |
- render_pass_mask_color_matrix_program_aa_[i][j].Cleanup(gl_); |
render_pass_color_matrix_program_aa_[i][j].Cleanup(gl_); |
- render_pass_mask_color_matrix_program_[i][j].Cleanup(gl_); |
} |
texture_program_[i].Cleanup(gl_); |