summaryrefslogtreecommitdiffstats
path: root/cc/output/gl_renderer.cc
diff options
context:
space:
mode:
authorenne <enne@chromium.org>2014-10-29 18:32:55 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-30 01:33:32 +0000
commit03dbe8ae71dbf674627acad91fff64a2fa9d4eb6 (patch)
tree01d601efacc1f64706fc3d540bae8fec39480e82 /cc/output/gl_renderer.cc
parentccffe0eebe798b78879894d5ee08dbca10f28a33 (diff)
downloadchromium_src-03dbe8ae71dbf674627acad91fff64a2fa9d4eb6.zip
chromium_src-03dbe8ae71dbf674627acad91fff64a2fa9d4eb6.tar.gz
chromium_src-03dbe8ae71dbf674627acad91fff64a2fa9d4eb6.tar.bz2
cc: Support texture rect targets for masks
Currently, GLRenderer supports tile resources as either texture 2d or texture rectangle. Before this patch, it only supported texture 2d masks. This fills the gap to handle texture rectangle masks. In practice it means that using a zero copy raster worker pool will now not break masks. This in turn enables impl-side painting for layout tests. Unfortunately, there is a lot of indirection between a test saying it wants to test a particular target type and what needs to happen. To make sure that tests are testing the right thing, the creation of the raster worker and resource pools is now virtual so that tests can create them as explicitly as needed. R=danakj@chromium.org,reveman@chromium.org BUG=423533 Review URL: https://codereview.chromium.org/668123003 Cr-Commit-Position: refs/heads/master@{#302010}
Diffstat (limited to 'cc/output/gl_renderer.cc')
-rw-r--r--cc/output/gl_renderer.cc78
1 files changed, 44 insertions, 34 deletions
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 3794ca7..e66cfe2 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_);