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

Unified Diff: cc/output/gl_renderer.cc

Issue 2716893002: cc: Reformat renderers to make them work with mask tiling. (Closed)
Patch Set: Add todos for tex_coord_rect computation. Created 3 years, 9 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
« no previous file with comments | « no previous file | cc/output/software_renderer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 1eac5f85d19fd7268dc7b9c2d33a9288ab115f9b..c8d798ed79f036f5f78fd9514ab007a423867470 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -1317,8 +1317,13 @@ void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params) {
}
void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
- gfx::RectF tex_rect(params->src_offset.x(), params->src_offset.y(),
- params->dst_rect.width(), params->dst_rect.height());
+ gfx::RectF tex_rect = params->quad->tex_coord_rect;
+ if (tex_rect.IsEmpty()) {
+ // TODO(sunxd): make this never be empty.
+ tex_rect =
+ gfx::RectF(gfx::PointF(params->src_offset), params->dst_rect.size());
+ }
+
gfx::Size texture_size;
if (params->filter_image) {
texture_size.set_width(params->filter_image->width());
@@ -1358,25 +1363,23 @@ void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
mask_uv_rect.Scale(params->quad->mask_texture_size.width(),
params->quad->mask_texture_size.height());
}
+
+ SkMatrix tex_to_mask = SkMatrix::MakeRectToRect(RectFToSkRect(tex_rect),
+ RectFToSkRect(mask_uv_rect),
+ SkMatrix::kFill_ScaleToFit);
+
if (params->source_needs_flip) {
// Mask textures are oriented vertically flipped relative to the
// framebuffer and the RenderPass contents texture, so we flip the tex
// coords from the RenderPass texture to find the mask texture coords.
- gl_->Uniform2f(
- current_program_->mask_tex_coord_offset_location(), mask_uv_rect.x(),
- mask_uv_rect.height() / tex_rect.height() + mask_uv_rect.y());
- gl_->Uniform2f(current_program_->mask_tex_coord_scale_location(),
- mask_uv_rect.width() / tex_rect.width(),
- -mask_uv_rect.height() / tex_rect.height());
- } else {
- // Tile textures are oriented the same way as mask textures.
- gl_->Uniform2f(current_program_->mask_tex_coord_offset_location(),
- mask_uv_rect.x(), mask_uv_rect.y());
- gl_->Uniform2f(current_program_->mask_tex_coord_scale_location(),
- mask_uv_rect.width() / tex_rect.width(),
- mask_uv_rect.height() / tex_rect.height());
+ tex_to_mask.preTranslate(0, 1);
+ tex_to_mask.preScale(1, -1);
}
+ gl_->Uniform2f(current_program_->mask_tex_coord_offset_location(),
+ tex_to_mask.getTranslateX(), tex_to_mask.getTranslateY());
+ gl_->Uniform2f(current_program_->mask_tex_coord_scale_location(),
+ tex_to_mask.getScaleX(), tex_to_mask.getScaleY());
last_texture_unit = 1;
}
« no previous file with comments | « no previous file | cc/output/software_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698