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

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

Issue 2717533005: cc: RenderSurfaceImpl tile mask layer. (Closed)
Patch Set: Prevent single_texture_mask to multi_texture_mask conversion. Created 3 years, 8 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 | « cc/layers/render_surface_impl_unittest.cc ('k') | cc/output/renderer_pixeltest.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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Whether the original background texture is needed for the mask. 217 // Whether the original background texture is needed for the mask.
218 bool mask_for_background = false; 218 bool mask_for_background = false;
219 219
220 // Whether a color matrix needs to be applied by the shaders when drawing 220 // Whether a color matrix needs to be applied by the shaders when drawing
221 // the RPDQ. 221 // the RPDQ.
222 bool use_color_matrix = false; 222 bool use_color_matrix = false;
223 223
224 gfx::QuadF surface_quad; 224 gfx::QuadF surface_quad;
225 225
226 gfx::Transform contents_device_transform; 226 gfx::Transform contents_device_transform;
227
228 gfx::RectF tex_coord_rect;
227 }; 229 };
228 230
229 static GLint GetActiveTextureUnit(GLES2Interface* gl) { 231 static GLint GetActiveTextureUnit(GLES2Interface* gl) {
230 GLint active_unit = 0; 232 GLint active_unit = 0;
231 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 233 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
232 return active_unit; 234 return active_unit;
233 } 235 }
234 236
235 class GLRenderer::ScopedUseGrContext { 237 class GLRenderer::ScopedUseGrContext {
236 public: 238 public:
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 } 1030 }
1029 1031
1030 void GLRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad, 1032 void GLRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad,
1031 const gfx::QuadF* clip_region) { 1033 const gfx::QuadF* clip_region) {
1032 auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id); 1034 auto bypass = render_pass_bypass_quads_.find(quad->render_pass_id);
1033 DrawRenderPassDrawQuadParams params; 1035 DrawRenderPassDrawQuadParams params;
1034 params.quad = quad; 1036 params.quad = quad;
1035 params.clip_region = clip_region; 1037 params.clip_region = clip_region;
1036 params.window_matrix = current_frame()->window_matrix; 1038 params.window_matrix = current_frame()->window_matrix;
1037 params.projection_matrix = current_frame()->projection_matrix; 1039 params.projection_matrix = current_frame()->projection_matrix;
1040 params.tex_coord_rect = quad->tex_coord_rect;
1038 if (bypass != render_pass_bypass_quads_.end()) { 1041 if (bypass != render_pass_bypass_quads_.end()) {
1039 TileDrawQuad* tile_quad = &bypass->second; 1042 TileDrawQuad* tile_quad = &bypass->second;
1040 // RGBA_8888 here is arbitrary and unused. 1043 // RGBA_8888 here is arbitrary and unused.
1041 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size, 1044 Resource tile_resource(tile_quad->resource_id(), tile_quad->texture_size,
1042 ResourceFormat::RGBA_8888, 1045 ResourceFormat::RGBA_8888,
1043 current_frame()->current_render_pass->color_space); 1046 current_frame()->current_render_pass->color_space);
1044 // The projection matrix used by GLRenderer has a flip. As tile texture 1047 // The projection matrix used by GLRenderer has a flip. As tile texture
1045 // inputs are oriented opposite to framebuffer outputs, don't flip via 1048 // inputs are oriented opposite to framebuffer outputs, don't flip via
1046 // texture coords and let the projection matrix naturallyd o it. 1049 // texture coords and let the projection matrix naturallyd o it.
1047 params.flip_texture = false; 1050 params.flip_texture = false;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 ScopedUseGrContext::Create(this), resource_provider_, src_rect, 1238 ScopedUseGrContext::Create(this), resource_provider_, src_rect,
1236 params->dst_rect, quad->filters_scale, std::move(filter), 1239 params->dst_rect, quad->filters_scale, std::move(filter),
1237 params->contents_texture, &offset, &subset, params->flip_texture, 1240 params->contents_texture, &offset, &subset, params->flip_texture,
1238 quad->filters_origin); 1241 quad->filters_origin);
1239 if (!params->filter_image) 1242 if (!params->filter_image)
1240 return false; 1243 return false;
1241 params->dst_rect = 1244 params->dst_rect =
1242 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY, 1245 gfx::RectF(src_rect.x() + offset.fX, src_rect.y() + offset.fY,
1243 subset.width(), subset.height()); 1246 subset.width(), subset.height());
1244 params->src_offset.SetPoint(subset.x(), subset.y()); 1247 params->src_offset.SetPoint(subset.x(), subset.y());
1248 gfx::RectF tex_rect = gfx::RectF(gfx::PointF(params->src_offset),
1249 params->dst_rect.size());
1250 params->tex_coord_rect = tex_rect;
1245 } 1251 }
1246 } 1252 }
1247 } 1253 }
1248 return true; 1254 return true;
1249 } 1255 }
1250 1256
1251 void GLRenderer::UpdateRPDQTexturesForSampling( 1257 void GLRenderer::UpdateRPDQTexturesForSampling(
1252 DrawRenderPassDrawQuadParams* params) { 1258 DrawRenderPassDrawQuadParams* params) {
1253 if (params->quad->mask_resource_id()) { 1259 if (params->quad->mask_resource_id()) {
1254 params->mask_resource_lock.reset(new ResourceProvider::ScopedSamplerGL( 1260 params->mask_resource_lock.reset(new ResourceProvider::ScopedSamplerGL(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 SetUseProgram(ProgramKey::RenderPass( 1320 SetUseProgram(ProgramKey::RenderPass(
1315 tex_coord_precision, sampler_type, shader_blend_mode, 1321 tex_coord_precision, sampler_type, shader_blend_mode,
1316 params->use_aa ? USE_AA : NO_AA, mask_mode, 1322 params->use_aa ? USE_AA : NO_AA, mask_mode,
1317 mask_for_background, params->use_color_matrix), 1323 mask_for_background, params->use_color_matrix),
1318 params->contents_resource_lock 1324 params->contents_resource_lock
1319 ? params->contents_resource_lock->color_space() 1325 ? params->contents_resource_lock->color_space()
1320 : gfx::ColorSpace()); 1326 : gfx::ColorSpace());
1321 } 1327 }
1322 1328
1323 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) { 1329 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
1324 gfx::RectF tex_rect = params->quad->tex_coord_rect; 1330 gfx::RectF tex_rect = params->tex_coord_rect;
1325 if (tex_rect.IsEmpty()) {
1326 // TODO(sunxd): make this never be empty.
1327 tex_rect =
1328 gfx::RectF(gfx::PointF(params->src_offset), params->dst_rect.size());
1329 }
1330 1331
1331 gfx::Size texture_size; 1332 gfx::Size texture_size;
1332 if (params->filter_image) { 1333 if (params->filter_image) {
1333 texture_size.set_width(params->filter_image->width()); 1334 texture_size.set_width(params->filter_image->width());
1334 texture_size.set_height(params->filter_image->height()); 1335 texture_size.set_height(params->filter_image->height());
1335 } else { 1336 } else {
1336 texture_size = params->contents_texture->size(); 1337 texture_size = params->contents_texture->size();
1337 } 1338 }
1338 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height()); 1339 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height());
1339 1340
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
3323 DCHECK(contents_texture); 3324 DCHECK(contents_texture);
3324 3325
3325 // Configure parameters as if drawing to a framebuffer the size of the 3326 // Configure parameters as if drawing to a framebuffer the size of the
3326 // screen. 3327 // screen.
3327 DrawRenderPassDrawQuadParams params; 3328 DrawRenderPassDrawQuadParams params;
3328 params.quad = ca_layer_overlay->rpdq; 3329 params.quad = ca_layer_overlay->rpdq;
3329 params.flip_texture = true; 3330 params.flip_texture = true;
3330 params.contents_texture = contents_texture; 3331 params.contents_texture = contents_texture;
3331 params.quad_to_target_transform = 3332 params.quad_to_target_transform =
3332 params.quad->shared_quad_state->quad_to_target_transform; 3333 params.quad->shared_quad_state->quad_to_target_transform;
3334 params.tex_coord_rect = params.quad->tex_coord_rect;
3333 3335
3334 // Calculate projection and window matrices using InitializeViewport(). This 3336 // Calculate projection and window matrices using InitializeViewport(). This
3335 // requires creating a dummy DrawingFrame. 3337 // requires creating a dummy DrawingFrame.
3336 { 3338 {
3337 DrawingFrame dummy_frame; 3339 DrawingFrame dummy_frame;
3338 gfx::Rect frame_rect(current_frame()->device_viewport_size); 3340 gfx::Rect frame_rect(current_frame()->device_viewport_size);
3339 force_drawing_frame_framebuffer_unflipped_ = true; 3341 force_drawing_frame_framebuffer_unflipped_ = true;
3340 InitializeViewport(&dummy_frame, frame_rect, frame_rect, frame_rect.size()); 3342 InitializeViewport(&dummy_frame, frame_rect, frame_rect, frame_rect.size());
3341 force_drawing_frame_framebuffer_unflipped_ = false; 3343 force_drawing_frame_framebuffer_unflipped_ = false;
3342 params.projection_matrix = dummy_frame.projection_matrix; 3344 params.projection_matrix = dummy_frame.projection_matrix;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 return; 3596 return;
3595 3597
3596 // Report GPU overdraw as a percentage of |max_result|. 3598 // Report GPU overdraw as a percentage of |max_result|.
3597 TRACE_COUNTER1( 3599 TRACE_COUNTER1(
3598 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3600 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3599 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3601 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3600 max_result); 3602 max_result);
3601 } 3603 }
3602 3604
3603 } // namespace cc 3605 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl_unittest.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698