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

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

Issue 2870253004: Remove |highp_threshold_min| from GLRenderer() (Closed)
Patch Set: Created 3 years, 7 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/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 unsigned query_id_; 368 unsigned query_id_;
369 bool is_pending_; 369 bool is_pending_;
370 base::WeakPtrFactory<SyncQuery> weak_ptr_factory_; 370 base::WeakPtrFactory<SyncQuery> weak_ptr_factory_;
371 371
372 DISALLOW_COPY_AND_ASSIGN(SyncQuery); 372 DISALLOW_COPY_AND_ASSIGN(SyncQuery);
373 }; 373 };
374 374
375 GLRenderer::GLRenderer(const RendererSettings* settings, 375 GLRenderer::GLRenderer(const RendererSettings* settings,
376 OutputSurface* output_surface, 376 OutputSurface* output_surface,
377 ResourceProvider* resource_provider, 377 ResourceProvider* resource_provider,
378 TextureMailboxDeleter* texture_mailbox_deleter, 378 TextureMailboxDeleter* texture_mailbox_deleter)
379 int highp_threshold_min)
380 : DirectRenderer(settings, output_surface, resource_provider), 379 : DirectRenderer(settings, output_surface, resource_provider),
381 shared_geometry_quad_(QuadVertexRect()), 380 shared_geometry_quad_(QuadVertexRect()),
382 gl_(output_surface->context_provider()->ContextGL()), 381 gl_(output_surface->context_provider()->ContextGL()),
383 context_support_(output_surface->context_provider()->ContextSupport()), 382 context_support_(output_surface->context_provider()->ContextSupport()),
384 texture_mailbox_deleter_(texture_mailbox_deleter), 383 texture_mailbox_deleter_(texture_mailbox_deleter),
385 highp_threshold_min_(highp_threshold_min),
386 gl_composited_texture_quad_border_( 384 gl_composited_texture_quad_border_(
387 settings->gl_composited_texture_quad_border), 385 settings->gl_composited_texture_quad_border),
388 bound_geometry_(NO_BINDING), 386 bound_geometry_(NO_BINDING),
389 color_lut_cache_(gl_, 387 color_lut_cache_(gl_,
390 output_surface_->context_provider() 388 output_surface_->context_provider()
391 ->ContextCapabilities() 389 ->ContextCapabilities()
392 .texture_half_float_linear), 390 .texture_half_float_linear),
393 weak_ptr_factory_(this) { 391 weak_ptr_factory_(this) {
394 DCHECK(gl_); 392 DCHECK(gl_);
395 DCHECK(context_support_); 393 DCHECK(context_support_);
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 if (!params->use_shaders_for_blending) { 1299 if (!params->use_shaders_for_blending) {
1302 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) 1300 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_)
1303 gl_->BlendBarrierKHR(); 1301 gl_->BlendBarrierKHR();
1304 1302
1305 ApplyBlendModeUsingBlendFunc(blend_mode); 1303 ApplyBlendModeUsingBlendFunc(blend_mode);
1306 } 1304 }
1307 } 1305 }
1308 1306
1309 void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params) { 1307 void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params) {
1310 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1308 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1311 gl_, &highp_threshold_cache_, highp_threshold_min_, 1309 gl_, &highp_threshold_cache_, settings_->highp_threshold_min,
1312 params->quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); 1310 params->quad->shared_quad_state->visible_quad_layer_rect.bottom_right());
1313 1311
1314 BlendMode shader_blend_mode = 1312 BlendMode shader_blend_mode =
1315 params->use_shaders_for_blending 1313 params->use_shaders_for_blending
1316 ? BlendModeFromSkXfermode(params->quad->shared_quad_state->blend_mode) 1314 ? BlendModeFromSkXfermode(params->quad->shared_quad_state->blend_mode)
1317 : BLEND_MODE_NONE; 1315 : BLEND_MODE_NONE;
1318 1316
1319 SamplerType sampler_type = SAMPLER_TYPE_2D; 1317 SamplerType sampler_type = SAMPLER_TYPE_2D;
1320 MaskMode mask_mode = NO_MASK; 1318 MaskMode mask_mode = NO_MASK;
1321 bool mask_for_background = params->mask_for_background; 1319 bool mask_for_background = params->mask_for_background;
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y); 1884 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y);
1887 1885
1888 // Map clamping rectangle to unit square. 1886 // Map clamping rectangle to unit square.
1889 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); 1887 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width();
1890 float vertex_tex_translate_y = 1888 float vertex_tex_translate_y =
1891 -clamp_geom_rect.y() / clamp_geom_rect.height(); 1889 -clamp_geom_rect.y() / clamp_geom_rect.height();
1892 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); 1890 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width();
1893 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); 1891 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height();
1894 1892
1895 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1893 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1896 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); 1894 gl_, &highp_threshold_cache_, settings_->highp_threshold_min,
1895 quad->texture_size);
1897 1896
1898 auto local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1897 auto local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1899 float edge[24]; 1898 float edge[24];
1900 SetupQuadForClippingAndAntialiasing(device_transform, quad, &aa_quad, 1899 SetupQuadForClippingAndAntialiasing(device_transform, quad, &aa_quad,
1901 clip_region, &local_quad, edge); 1900 clip_region, &local_quad, edge);
1902 ResourceProvider::ScopedSamplerGL quad_resource_lock( 1901 ResourceProvider::ScopedSamplerGL quad_resource_lock(
1903 resource_provider_, resource_id, 1902 resource_provider_, resource_id,
1904 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR); 1903 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR);
1905 SamplerType sampler = 1904 SamplerType sampler =
1906 SamplerTypeFromTextureTarget(quad_resource_lock.target()); 1905 SamplerTypeFromTextureTarget(quad_resource_lock.target());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 if (sampler != SAMPLER_TYPE_2D_RECT) { 1986 if (sampler != SAMPLER_TYPE_2D_RECT) {
1988 gfx::Size texture_size = quad->texture_size; 1987 gfx::Size texture_size = quad->texture_size;
1989 DCHECK(!texture_size.IsEmpty()); 1988 DCHECK(!texture_size.IsEmpty());
1990 vertex_tex_translate_x /= texture_size.width(); 1989 vertex_tex_translate_x /= texture_size.width();
1991 vertex_tex_translate_y /= texture_size.height(); 1990 vertex_tex_translate_y /= texture_size.height();
1992 vertex_tex_scale_x /= texture_size.width(); 1991 vertex_tex_scale_x /= texture_size.width();
1993 vertex_tex_scale_y /= texture_size.height(); 1992 vertex_tex_scale_y /= texture_size.height();
1994 } 1993 }
1995 1994
1996 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1995 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1997 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); 1996 gl_, &highp_threshold_cache_, settings_->highp_threshold_min,
1997 quad->texture_size);
1998 1998
1999 SetUseProgram( 1999 SetUseProgram(
2000 ProgramKey::Tile(tex_coord_precision, sampler, NO_AA, 2000 ProgramKey::Tile(tex_coord_precision, sampler, NO_AA,
2001 quad->swizzle_contents ? DO_SWIZZLE : NO_SWIZZLE, 2001 quad->swizzle_contents ? DO_SWIZZLE : NO_SWIZZLE,
2002 !quad->ShouldDrawWithBlending()), 2002 !quad->ShouldDrawWithBlending()),
2003 quad_resource_lock.color_space()); 2003 quad_resource_lock.color_space());
2004 2004
2005 gl_->Uniform4f(current_program_->vertex_tex_transform_location(), 2005 gl_->Uniform4f(current_program_->vertex_tex_transform_location(),
2006 vertex_tex_translate_x, vertex_tex_translate_y, 2006 vertex_tex_translate_x, vertex_tex_translate_y,
2007 vertex_tex_scale_x, vertex_tex_scale_y); 2007 vertex_tex_scale_x, vertex_tex_scale_y);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 quad->shared_quad_state->quad_to_target_transform); 2047 quad->shared_quad_state->quad_to_target_transform);
2048 2048
2049 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 2049 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
2050 } 2050 }
2051 2051
2052 void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, 2052 void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad,
2053 const gfx::QuadF* clip_region) { 2053 const gfx::QuadF* clip_region) {
2054 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2054 SetBlendEnabled(quad->ShouldDrawWithBlending());
2055 2055
2056 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2056 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2057 gl_, &highp_threshold_cache_, highp_threshold_min_, 2057 gl_, &highp_threshold_cache_, settings_->highp_threshold_min,
2058 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); 2058 quad->shared_quad_state->visible_quad_layer_rect.bottom_right());
2059 YUVAlphaTextureMode alpha_texture_mode = quad->a_plane_resource_id() 2059 YUVAlphaTextureMode alpha_texture_mode = quad->a_plane_resource_id()
2060 ? YUV_HAS_ALPHA_TEXTURE 2060 ? YUV_HAS_ALPHA_TEXTURE
2061 : YUV_NO_ALPHA_TEXTURE; 2061 : YUV_NO_ALPHA_TEXTURE;
2062 UVTextureMode uv_texture_mode = 2062 UVTextureMode uv_texture_mode =
2063 quad->v_plane_resource_id() == quad->u_plane_resource_id() 2063 quad->v_plane_resource_id() == quad->u_plane_resource_id()
2064 ? UV_TEXTURE_MODE_UV 2064 ? UV_TEXTURE_MODE_UV
2065 : UV_TEXTURE_MODE_U_V; 2065 : UV_TEXTURE_MODE_U_V;
2066 2066
2067 // TODO(ccameron): There are currently three sources of the color space: the 2067 // TODO(ccameron): There are currently three sources of the color space: the
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 2218
2219 void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, 2219 void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad,
2220 const gfx::QuadF* clip_region) { 2220 const gfx::QuadF* clip_region) {
2221 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2221 SetBlendEnabled(quad->ShouldDrawWithBlending());
2222 2222
2223 DCHECK(output_surface_->context_provider() 2223 DCHECK(output_surface_->context_provider()
2224 ->ContextCapabilities() 2224 ->ContextCapabilities()
2225 .egl_image_external); 2225 .egl_image_external);
2226 2226
2227 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2227 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2228 gl_, &highp_threshold_cache_, highp_threshold_min_, 2228 gl_, &highp_threshold_cache_, settings_->highp_threshold_min,
2229 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); 2229 quad->shared_quad_state->visible_quad_layer_rect.bottom_right());
2230 2230
2231 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2231 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2232 quad->resource_id()); 2232 quad->resource_id());
2233 2233
2234 SetUseProgram(ProgramKey::VideoStream(tex_coord_precision), 2234 SetUseProgram(ProgramKey::VideoStream(tex_coord_precision),
2235 lock.color_space()); 2235 lock.color_space());
2236 2236
2237 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2237 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2238 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); 2238 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2356 // If we have a clip_region then we have to render the next quad 2356 // If we have a clip_region then we have to render the next quad
2357 // with dynamic geometry, therefore we must flush all pending 2357 // with dynamic geometry, therefore we must flush all pending
2358 // texture quads. 2358 // texture quads.
2359 if (clip_region) { 2359 if (clip_region) {
2360 // We send in false here because we want to flush what's currently in the 2360 // We send in false here because we want to flush what's currently in the
2361 // queue using the shared_geometry and not clipped_geometry 2361 // queue using the shared_geometry and not clipped_geometry
2362 FlushTextureQuadCache(SHARED_BINDING); 2362 FlushTextureQuadCache(SHARED_BINDING);
2363 } 2363 }
2364 2364
2365 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2365 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2366 gl_, &highp_threshold_cache_, highp_threshold_min_, 2366 gl_, &highp_threshold_cache_, settings_->highp_threshold_min,
2367 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); 2367 quad->shared_quad_state->visible_quad_layer_rect.bottom_right());
2368 2368
2369 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2369 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2370 quad->resource_id()); 2370 quad->resource_id());
2371 const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target()); 2371 const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target());
2372 2372
2373 ProgramKey program_key = ProgramKey::Texture( 2373 ProgramKey program_key = ProgramKey::Texture(
2374 tex_coord_precision, sampler, 2374 tex_coord_precision, sampler,
2375 quad->premultiplied_alpha ? PREMULTIPLIED_ALPHA : NON_PREMULTIPLIED_ALPHA, 2375 quad->premultiplied_alpha ? PREMULTIPLIED_ALPHA : NON_PREMULTIPLIED_ALPHA,
2376 quad->background_color != SK_ColorTRANSPARENT); 2376 quad->background_color != SK_ColorTRANSPARENT);
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
3609 return; 3609 return;
3610 3610
3611 // Report GPU overdraw as a percentage of |max_result|. 3611 // Report GPU overdraw as a percentage of |max_result|.
3612 TRACE_COUNTER1( 3612 TRACE_COUNTER1(
3613 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3613 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3614 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3614 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3615 max_result); 3615 max_result);
3616 } 3616 }
3617 3617
3618 } // namespace cc 3618 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698