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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2716893002: cc: Reformat renderers to make them work with mask tiling. (Closed)
Patch Set: Rebase 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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/output/software_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 } 1310 }
1311 1311
1312 SetUseProgram(ProgramKey::RenderPass( 1312 SetUseProgram(ProgramKey::RenderPass(
1313 tex_coord_precision, sampler_type, shader_blend_mode, 1313 tex_coord_precision, sampler_type, shader_blend_mode,
1314 params->use_aa ? USE_AA : NO_AA, mask_mode, 1314 params->use_aa ? USE_AA : NO_AA, mask_mode,
1315 mask_for_background, params->use_color_matrix), 1315 mask_for_background, params->use_color_matrix),
1316 current_frame()->current_render_pass->color_space); 1316 current_frame()->current_render_pass->color_space);
1317 } 1317 }
1318 1318
1319 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) { 1319 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
1320 gfx::RectF tex_rect(params->src_offset.x(), params->src_offset.y(), 1320 gfx::RectF tex_rect = params->quad->tex_coord_rect;
1321 params->dst_rect.width(), params->dst_rect.height());
1322 gfx::Size texture_size; 1321 gfx::Size texture_size;
trchen 2017/03/02 00:32:56 nits: move this down right before #1328
sunxd 2017/03/02 17:21:39 Done.
1322 if (tex_rect.IsEmpty()) {
1323 // The tex_coord_rect is not produced in RenderSufaceImpl::AppendQuads.
1324 tex_rect =
1325 gfx::RectF(gfx::PointF(params->src_offset), params->dst_rect.size());
1326 }
1327
1323 if (params->filter_image) { 1328 if (params->filter_image) {
1324 texture_size.set_width(params->filter_image->width()); 1329 texture_size.set_width(params->filter_image->width());
1325 texture_size.set_height(params->filter_image->height()); 1330 texture_size.set_height(params->filter_image->height());
1326 } else { 1331 } else {
1327 texture_size = params->contents_texture->size(); 1332 texture_size = params->contents_texture->size();
1328 } 1333 }
1329 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height()); 1334 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height());
1330 1335
1331 DCHECK(current_program_->vertex_tex_transform_location() != -1 || 1336 DCHECK(current_program_->vertex_tex_transform_location() != -1 ||
1332 IsContextLost()); 1337 IsContextLost());
(...skipping 18 matching lines...) Expand all
1351 DCHECK_NE(current_program_->mask_tex_coord_scale_location(), 1); 1356 DCHECK_NE(current_program_->mask_tex_coord_scale_location(), 1);
1352 DCHECK_NE(current_program_->mask_tex_coord_offset_location(), 1); 1357 DCHECK_NE(current_program_->mask_tex_coord_offset_location(), 1);
1353 gl_->Uniform1i(current_program_->mask_sampler_location(), 1); 1358 gl_->Uniform1i(current_program_->mask_sampler_location(), 1);
1354 1359
1355 gfx::RectF mask_uv_rect = params->quad->mask_uv_rect; 1360 gfx::RectF mask_uv_rect = params->quad->mask_uv_rect;
1356 if (SamplerTypeFromTextureTarget(params->mask_resource_lock->target()) != 1361 if (SamplerTypeFromTextureTarget(params->mask_resource_lock->target()) !=
1357 SAMPLER_TYPE_2D) { 1362 SAMPLER_TYPE_2D) {
1358 mask_uv_rect.Scale(params->quad->mask_texture_size.width(), 1363 mask_uv_rect.Scale(params->quad->mask_texture_size.width(),
1359 params->quad->mask_texture_size.height()); 1364 params->quad->mask_texture_size.height());
1360 } 1365 }
1366
1367 SkMatrix tex_to_mask = SkMatrix::MakeRectToRect(RectFToSkRect(tex_rect),
1368 RectFToSkRect(mask_uv_rect),
1369 SkMatrix::kFill_ScaleToFit);
trchen 2017/03/02 00:32:56 Thanks for saving everyone's brain cells! However
sunxd 2017/03/02 17:21:39 Yes I noticed that this didn't fix the bug in that
trchen 2017/03/04 02:59:39 Alright. I see why. As GLRenderer::UpdateRPDQWithS
1370
1361 if (params->source_needs_flip) { 1371 if (params->source_needs_flip) {
1362 // Mask textures are oriented vertically flipped relative to the 1372 // Mask textures are oriented vertically flipped relative to the
1363 // framebuffer and the RenderPass contents texture, so we flip the tex 1373 // framebuffer and the RenderPass contents texture, so we flip the tex
1364 // coords from the RenderPass texture to find the mask texture coords. 1374 // coords from the RenderPass texture to find the mask texture coords.
1365 gl_->Uniform2f( 1375 tex_to_mask.preTranslate(0, 1);
1366 current_program_->mask_tex_coord_offset_location(), mask_uv_rect.x(), 1376 tex_to_mask.preScale(1, -1);
1367 mask_uv_rect.height() / tex_rect.height() + mask_uv_rect.y());
1368 gl_->Uniform2f(current_program_->mask_tex_coord_scale_location(),
1369 mask_uv_rect.width() / tex_rect.width(),
1370 -mask_uv_rect.height() / tex_rect.height());
1371 } else {
1372 // Tile textures are oriented the same way as mask textures.
1373 gl_->Uniform2f(current_program_->mask_tex_coord_offset_location(),
1374 mask_uv_rect.x(), mask_uv_rect.y());
1375 gl_->Uniform2f(current_program_->mask_tex_coord_scale_location(),
1376 mask_uv_rect.width() / tex_rect.width(),
1377 mask_uv_rect.height() / tex_rect.height());
1378 } 1377 }
1379 1378
1379 gl_->Uniform2f(current_program_->mask_tex_coord_offset_location(),
1380 tex_to_mask.getTranslateX(), tex_to_mask.getTranslateY());
1381 gl_->Uniform2f(current_program_->mask_tex_coord_scale_location(),
1382 tex_to_mask.getScaleX(), tex_to_mask.getScaleY());
1380 last_texture_unit = 1; 1383 last_texture_unit = 1;
1381 } 1384 }
1382 1385
1383 if (current_program_->edge_location() != -1) 1386 if (current_program_->edge_location() != -1)
1384 gl_->Uniform3fv(current_program_->edge_location(), 8, params->edge); 1387 gl_->Uniform3fv(current_program_->edge_location(), 8, params->edge);
1385 1388
1386 if (current_program_->color_matrix_location() != -1) { 1389 if (current_program_->color_matrix_location() != -1) {
1387 float matrix[16]; 1390 float matrix[16];
1388 for (int i = 0; i < 4; ++i) { 1391 for (int i = 0; i < 4; ++i) {
1389 for (int j = 0; j < 4; ++j) 1392 for (int j = 0; j < 4; ++j)
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 return; 3501 return;
3499 3502
3500 // Report GPU overdraw as a percentage of |max_result|. 3503 // Report GPU overdraw as a percentage of |max_result|.
3501 TRACE_COUNTER1( 3504 TRACE_COUNTER1(
3502 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3505 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3503 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3506 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3504 max_result); 3507 max_result);
3505 } 3508 }
3506 3509
3507 } // namespace cc 3510 } // namespace cc
OLDNEW
« 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