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

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

Issue 2687653002: cc: Remove more uniform location caching (Closed)
Patch Set: Review feedback Created 3 years, 10 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_draw_cache.h » ('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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 gfx::PointF uv0 = quad->uv_top_left; 76 gfx::PointF uv0 = quad->uv_top_left;
77 gfx::PointF uv1 = quad->uv_bottom_right; 77 gfx::PointF uv1 = quad->uv_bottom_right;
78 Float4 xform = {{uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y()}}; 78 Float4 xform = {{uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y()}};
79 if (quad->y_flipped) { 79 if (quad->y_flipped) {
80 xform.data[1] = 1.0f - xform.data[1]; 80 xform.data[1] = 1.0f - xform.data[1];
81 xform.data[3] = -xform.data[3]; 81 xform.data[3] = -xform.data[3];
82 } 82 }
83 return xform; 83 return xform;
84 } 84 }
85 85
86 Float4 PremultipliedColor(SkColor color) { 86 Float4 PremultipliedColor(SkColor color, float opacity) {
87 const float factor = 1.0f / 255.0f; 87 const float factor = 1.0f / 255.0f;
88 const float alpha = SkColorGetA(color) * factor; 88 const float alpha = opacity * SkColorGetA(color) * factor;
89 89
90 Float4 result = { 90 Float4 result = {
91 {SkColorGetR(color) * factor * alpha, SkColorGetG(color) * factor * alpha, 91 {SkColorGetR(color) * factor * alpha, SkColorGetG(color) * factor * alpha,
92 SkColorGetB(color) * factor * alpha, alpha}}; 92 SkColorGetB(color) * factor * alpha, alpha}};
93 return result; 93 return result;
94 } 94 }
95 95
96 SamplerType SamplerTypeFromTextureTarget(GLenum target) { 96 SamplerType SamplerTypeFromTextureTarget(GLenum target) {
97 switch (target) { 97 switch (target) {
98 case GL_TEXTURE_2D: 98 case GL_TEXTURE_2D:
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 DISALLOW_COPY_AND_ASSIGN(SyncQuery); 373 DISALLOW_COPY_AND_ASSIGN(SyncQuery);
374 }; 374 };
375 375
376 GLRenderer::GLRenderer(const RendererSettings* settings, 376 GLRenderer::GLRenderer(const RendererSettings* settings,
377 OutputSurface* output_surface, 377 OutputSurface* output_surface,
378 ResourceProvider* resource_provider, 378 ResourceProvider* resource_provider,
379 TextureMailboxDeleter* texture_mailbox_deleter, 379 TextureMailboxDeleter* texture_mailbox_deleter,
380 int highp_threshold_min) 380 int highp_threshold_min)
381 : DirectRenderer(settings, output_surface, resource_provider), 381 : DirectRenderer(settings, output_surface, resource_provider),
382 offscreen_framebuffer_id_(0),
383 shared_geometry_quad_(QuadVertexRect()), 382 shared_geometry_quad_(QuadVertexRect()),
384 gl_(output_surface->context_provider()->ContextGL()), 383 gl_(output_surface->context_provider()->ContextGL()),
385 context_support_(output_surface->context_provider()->ContextSupport()), 384 context_support_(output_surface->context_provider()->ContextSupport()),
386 texture_mailbox_deleter_(texture_mailbox_deleter), 385 texture_mailbox_deleter_(texture_mailbox_deleter),
387 is_scissor_enabled_(false),
388 stencil_shadow_(false),
389 blend_shadow_(false),
390 highp_threshold_min_(highp_threshold_min), 386 highp_threshold_min_(highp_threshold_min),
391 highp_threshold_cache_(0),
392 use_sync_query_(false),
393 gl_composited_texture_quad_border_( 387 gl_composited_texture_quad_border_(
394 settings->gl_composited_texture_quad_border), 388 settings->gl_composited_texture_quad_border),
395 bound_geometry_(NO_BINDING), 389 bound_geometry_(NO_BINDING),
396 color_lut_cache_(gl_, 390 color_lut_cache_(gl_,
397 output_surface_->context_provider() 391 output_surface_->context_provider()
398 ->ContextCapabilities() 392 ->ContextCapabilities()
399 .texture_half_float_linear), 393 .texture_half_float_linear),
400 weak_ptr_factory_(this) { 394 weak_ptr_factory_(this) {
401 DCHECK(gl_); 395 DCHECK(gl_);
402 DCHECK(context_support_); 396 DCHECK(context_support_);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 606 }
613 } 607 }
614 608
615 // This function does not handle 3D sorting right now, since the debug border 609 // This function does not handle 3D sorting right now, since the debug border
616 // quads are just drawn as their original quads and not in split pieces. This 610 // quads are just drawn as their original quads and not in split pieces. This
617 // results in some debug border quads drawing over foreground quads. 611 // results in some debug border quads drawing over foreground quads.
618 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, 612 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
619 const DebugBorderDrawQuad* quad) { 613 const DebugBorderDrawQuad* quad) {
620 SetBlendEnabled(quad->ShouldDrawWithBlending()); 614 SetBlendEnabled(quad->ShouldDrawWithBlending());
621 615
622 static float gl_matrix[16];
623 const Program* program = GetProgram(ProgramKey::DebugBorder()); 616 const Program* program = GetProgram(ProgramKey::DebugBorder());
624 DCHECK(program); 617 SetUseProgram(program);
625 DCHECK(program->initialized() || IsContextLost());
626 SetUseProgram(program->program());
627 618
628 // Use the full quad_rect for debug quads to not move the edges based on 619 // Use the full quad_rect for debug quads to not move the edges based on
629 // partial swaps. 620 // partial swaps.
630 gfx::Rect layer_rect = quad->rect; 621 gfx::Rect layer_rect = quad->rect;
631 gfx::Transform render_matrix; 622 gfx::Transform render_matrix;
632 QuadRectTransform(&render_matrix, 623 QuadRectTransform(&render_matrix,
633 quad->shared_quad_state->quad_to_target_transform, 624 quad->shared_quad_state->quad_to_target_transform,
634 gfx::RectF(layer_rect)); 625 gfx::RectF(layer_rect));
635 GLRenderer::ToGLMatrix(&gl_matrix[0], 626 SetShaderMatrix(frame->projection_matrix * render_matrix);
636 frame->projection_matrix * render_matrix); 627 SetShaderColor(quad->color, 1.f);
637 gl_->UniformMatrix4fv(program->matrix_location(), 1, false, &gl_matrix[0]);
638
639 SkColor color = quad->color;
640 float alpha = SkColorGetA(color) * (1.0f / 255.0f);
641
642 gl_->Uniform4f(program->color_location(),
643 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
644 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
645 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, alpha);
646 628
647 gl_->LineWidth(quad->width); 629 gl_->LineWidth(quad->width);
648 630
649 // The indices for the line are stored in the same array as the triangle 631 // The indices for the line are stored in the same array as the triangle
650 // indices. 632 // indices.
651 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0); 633 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0);
652 } 634 }
653 635
654 static sk_sp<SkImage> WrapTexture( 636 static sk_sp<SkImage> WrapTexture(
655 const ResourceProvider::ScopedReadLockGL& lock, 637 const ResourceProvider::ScopedReadLockGL& lock,
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 if (params->mask_resource_lock) { 1320 if (params->mask_resource_lock) {
1339 mask_mode = HAS_MASK; 1321 mask_mode = HAS_MASK;
1340 sampler_type = 1322 sampler_type =
1341 SamplerTypeFromTextureTarget(params->mask_resource_lock->target()); 1323 SamplerTypeFromTextureTarget(params->mask_resource_lock->target());
1342 } 1324 }
1343 1325
1344 params->program = GetProgram(ProgramKey::RenderPass( 1326 params->program = GetProgram(ProgramKey::RenderPass(
1345 tex_coord_precision, sampler_type, shader_blend_mode, 1327 tex_coord_precision, sampler_type, shader_blend_mode,
1346 params->use_aa ? USE_AA : NO_AA, mask_mode, mask_for_background, 1328 params->use_aa ? USE_AA : NO_AA, mask_mode, mask_for_background,
1347 params->use_color_matrix)); 1329 params->use_color_matrix));
1348 SetUseProgram(params->program->program()); 1330 SetUseProgram(params->program);
1349 gl_->Uniform1i(params->program->sampler_location(), 0);
1350 } 1331 }
1351 1332
1352 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) { 1333 void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) {
1353 const Program* program = params->program; 1334 const Program* program = params->program;
1354 1335
1355 gfx::RectF tex_rect(params->src_offset.x(), params->src_offset.y(), 1336 gfx::RectF tex_rect(params->src_offset.x(), params->src_offset.y(),
1356 params->dst_rect.width(), params->dst_rect.height()); 1337 params->dst_rect.width(), params->dst_rect.height());
1357 gfx::Size texture_size; 1338 gfx::Size texture_size;
1358 if (params->filter_image) { 1339 if (params->filter_image) {
1359 texture_size.set_width(params->filter_image->width()); 1340 texture_size.set_width(params->filter_image->width());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 mask_uv_rect.width() / tex_rect.width(), 1389 mask_uv_rect.width() / tex_rect.width(),
1409 mask_uv_rect.height() / tex_rect.height()); 1390 mask_uv_rect.height() / tex_rect.height());
1410 } 1391 }
1411 1392
1412 last_texture_unit = 1; 1393 last_texture_unit = 1;
1413 } 1394 }
1414 1395
1415 if (program->edge_location() != -1) 1396 if (program->edge_location() != -1)
1416 gl_->Uniform3fv(program->edge_location(), 8, params->edge); 1397 gl_->Uniform3fv(program->edge_location(), 8, params->edge);
1417 1398
1418 if (program->viewport_location() != -1) {
1419 float viewport[4] = {
1420 static_cast<float>(current_window_space_viewport_.x()),
1421 static_cast<float>(current_window_space_viewport_.y()),
1422 static_cast<float>(current_window_space_viewport_.width()),
1423 static_cast<float>(current_window_space_viewport_.height()),
1424 };
1425 gl_->Uniform4fv(program->viewport_location(), 1, viewport);
1426 }
1427
1428 if (program->color_matrix_location() != -1) { 1399 if (program->color_matrix_location() != -1) {
1429 float matrix[16]; 1400 float matrix[16];
1430 for (int i = 0; i < 4; ++i) { 1401 for (int i = 0; i < 4; ++i) {
1431 for (int j = 0; j < 4; ++j) 1402 for (int j = 0; j < 4; ++j)
1432 matrix[i * 4 + j] = SkScalarToFloat(params->color_matrix[j * 5 + i]); 1403 matrix[i * 4 + j] = SkScalarToFloat(params->color_matrix[j * 5 + i]);
1433 } 1404 }
1434 gl_->UniformMatrix4fv(program->color_matrix_location(), 1, false, matrix); 1405 gl_->UniformMatrix4fv(program->color_matrix_location(), 1, false, matrix);
1435 } 1406 }
1436 static const float kScale = 1.0f / 255.0f; 1407 static const float kScale = 1.0f / 255.0f;
1437 if (program->color_offset_location() != -1) { 1408 if (program->color_offset_location() != -1) {
(...skipping 27 matching lines...) Expand all
1465 if (params->background_texture) { 1436 if (params->background_texture) {
1466 params->shader_background_sampler_lock = 1437 params->shader_background_sampler_lock =
1467 base::MakeUnique<ResourceProvider::ScopedSamplerGL>( 1438 base::MakeUnique<ResourceProvider::ScopedSamplerGL>(
1468 resource_provider_, params->background_texture->id(), 1439 resource_provider_, params->background_texture->id(),
1469 GL_TEXTURE0 + last_texture_unit, GL_LINEAR); 1440 GL_TEXTURE0 + last_texture_unit, GL_LINEAR);
1470 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1441 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1471 params->shader_background_sampler_lock->target()); 1442 params->shader_background_sampler_lock->target());
1472 } 1443 }
1473 } 1444 }
1474 1445
1475 SetShaderOpacity(params->quad->shared_quad_state->opacity, 1446 SetShaderOpacity(params->quad);
1476 program->alpha_location()); 1447 SetShaderQuadF(params->surface_quad);
1477 SetShaderQuadF(params->surface_quad, program->quad_location());
1478 } 1448 }
1479 1449
1480 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) { 1450 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) {
1481 DrawQuadGeometry(params.projection_matrix, params.quad_to_target_transform, 1451 DrawQuadGeometry(params.projection_matrix, params.quad_to_target_transform,
1482 params.dst_rect, params.program->matrix_location()); 1452 params.dst_rect);
1483 1453
1484 // Flush the compositor context before the filter bitmap goes out of 1454 // Flush the compositor context before the filter bitmap goes out of
1485 // scope, so the draw gets processed before the filter texture gets deleted. 1455 // scope, so the draw gets processed before the filter texture gets deleted.
1486 if (params.filter_image) 1456 if (params.filter_image)
1487 gl_->Flush(); 1457 gl_->Flush();
1488 1458
1489 if (!params.use_shaders_for_blending) 1459 if (!params.use_shaders_for_blending)
1490 RestoreBlendFuncToDefault(params.quad->shared_quad_state->blend_mode); 1460 RestoreBlendFuncToDefault(params.quad->shared_quad_state->blend_mode);
1491 } 1461 }
1492 1462
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa); 1760 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa);
1791 } 1761 }
1792 1762
1793 float edge[24]; 1763 float edge[24];
1794 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr; 1764 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr;
1795 SetupQuadForClippingAndAntialiasing(device_transform, quad, aa_quad, 1765 SetupQuadForClippingAndAntialiasing(device_transform, quad, aa_quad,
1796 clip_region, &local_quad, edge); 1766 clip_region, &local_quad, edge);
1797 1767
1798 const Program* program = 1768 const Program* program =
1799 GetProgram(ProgramKey::SolidColor(use_aa ? USE_AA : NO_AA)); 1769 GetProgram(ProgramKey::SolidColor(use_aa ? USE_AA : NO_AA));
1800 SetUseProgram(program->program()); 1770 SetUseProgram(program);
1771 SetShaderColor(color, opacity);
1801 1772
1802 gl_->Uniform4f(program->color_location(),
1803 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
1804 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
1805 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, alpha);
1806 if (use_aa) { 1773 if (use_aa) {
1807 float viewport[4] = {
1808 static_cast<float>(current_window_space_viewport_.x()),
1809 static_cast<float>(current_window_space_viewport_.y()),
1810 static_cast<float>(current_window_space_viewport_.width()),
1811 static_cast<float>(current_window_space_viewport_.height()),
1812 };
1813 gl_->Uniform4fv(program->viewport_location(), 1, viewport);
1814 gl_->Uniform3fv(program->edge_location(), 8, edge); 1774 gl_->Uniform3fv(program->edge_location(), 8, edge);
1815 } 1775 }
1816 1776
1817 // Enable blending when the quad properties require it or if we decided 1777 // Enable blending when the quad properties require it or if we decided
1818 // to use antialiasing. 1778 // to use antialiasing.
1819 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa); 1779 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
1820 1780
1821 // Antialising requires a normalized quad, but this could lead to floating 1781 // Antialising requires a normalized quad, but this could lead to floating
1822 // point precision errors, so only normalize when antialising is on. 1782 // point precision errors, so only normalize when antialising is on.
1823 if (use_aa) { 1783 if (use_aa) {
1824 // Normalize to tile_rect. 1784 // Normalize to tile_rect.
1825 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1785 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1826 1786
1827 SetShaderQuadF(local_quad, program->quad_location()); 1787 SetShaderQuadF(local_quad);
1828 1788
1829 // The transform and vertex data are used to figure out the extents that the 1789 // The transform and vertex data are used to figure out the extents that the
1830 // un-antialiased quad should have and which vertex this is and the float 1790 // un-antialiased quad should have and which vertex this is and the float
1831 // quad passed in via uniform is the actual geometry that gets used to draw 1791 // quad passed in via uniform is the actual geometry that gets used to draw
1832 // it. This is why this centered rect is used and not the original 1792 // it. This is why this centered rect is used and not the original
1833 // quad_rect. 1793 // quad_rect.
1834 gfx::RectF centered_rect( 1794 gfx::RectF centered_rect(
1835 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1795 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1836 gfx::SizeF(tile_rect.size())); 1796 gfx::SizeF(tile_rect.size()));
1837 DrawQuadGeometry(frame->projection_matrix, 1797 DrawQuadGeometry(frame->projection_matrix,
1838 quad->shared_quad_state->quad_to_target_transform, 1798 quad->shared_quad_state->quad_to_target_transform,
1839 centered_rect, program->matrix_location()); 1799 centered_rect);
1840 } else { 1800 } else {
1841 PrepareGeometry(SHARED_BINDING); 1801 PrepareGeometry(SHARED_BINDING);
1842 SetShaderQuadF(local_quad, program->quad_location()); 1802 SetShaderQuadF(local_quad);
1843 static float gl_matrix[16]; 1803 SetShaderMatrix(frame->projection_matrix *
1844 ToGLMatrix(&gl_matrix[0], 1804 quad->shared_quad_state->quad_to_target_transform);
1845 frame->projection_matrix *
1846 quad->shared_quad_state->quad_to_target_transform);
1847 gl_->UniformMatrix4fv(program->matrix_location(), 1, false, &gl_matrix[0]);
1848
1849 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 1805 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
1850 } 1806 }
1851 } 1807 }
1852 1808
1853 void GLRenderer::DrawTileQuad(const DrawingFrame* frame, 1809 void GLRenderer::DrawTileQuad(const DrawingFrame* frame,
1854 const TileDrawQuad* quad, 1810 const TileDrawQuad* quad,
1855 const gfx::QuadF* clip_region) { 1811 const gfx::QuadF* clip_region) {
1856 DrawContentQuad(frame, quad, quad->resource_id(), clip_region); 1812 DrawContentQuad(frame, quad, quad->resource_id(), clip_region);
1857 } 1813 }
1858 1814
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 fragment_tex_translate_x /= texture_size.width(); 1915 fragment_tex_translate_x /= texture_size.width();
1960 fragment_tex_translate_y /= texture_size.height(); 1916 fragment_tex_translate_y /= texture_size.height();
1961 fragment_tex_scale_x /= texture_size.width(); 1917 fragment_tex_scale_x /= texture_size.width();
1962 fragment_tex_scale_y /= texture_size.height(); 1918 fragment_tex_scale_y /= texture_size.height();
1963 } 1919 }
1964 1920
1965 const Program* program = GetProgram(ProgramKey::Tile( 1921 const Program* program = GetProgram(ProgramKey::Tile(
1966 tex_coord_precision, sampler, USE_AA, 1922 tex_coord_precision, sampler, USE_AA,
1967 quad->swizzle_contents ? DO_SWIZZLE : NO_SWIZZLE, false)); 1923 quad->swizzle_contents ? DO_SWIZZLE : NO_SWIZZLE, false));
1968 1924
1969 SetUseProgram(program->program()); 1925 SetUseProgram(program);
1970 gl_->Uniform1i(program->sampler_location(), 0);
1971 1926
1972 float viewport[4] = {
1973 static_cast<float>(current_window_space_viewport_.x()),
1974 static_cast<float>(current_window_space_viewport_.y()),
1975 static_cast<float>(current_window_space_viewport_.width()),
1976 static_cast<float>(current_window_space_viewport_.height()),
1977 };
1978 gl_->Uniform4fv(program->viewport_location(), 1, viewport);
1979 gl_->Uniform3fv(program->edge_location(), 8, edge); 1927 gl_->Uniform3fv(program->edge_location(), 8, edge);
1980 1928
1981 gl_->Uniform4f(program->vertex_tex_transform_location(), 1929 gl_->Uniform4f(program->vertex_tex_transform_location(),
1982 vertex_tex_translate_x, vertex_tex_translate_y, 1930 vertex_tex_translate_x, vertex_tex_translate_y,
1983 vertex_tex_scale_x, vertex_tex_scale_y); 1931 vertex_tex_scale_x, vertex_tex_scale_y);
1984 gl_->Uniform4f(program->fragment_tex_transform_location(), 1932 gl_->Uniform4f(program->fragment_tex_transform_location(),
1985 fragment_tex_translate_x, fragment_tex_translate_y, 1933 fragment_tex_translate_x, fragment_tex_translate_y,
1986 fragment_tex_scale_x, fragment_tex_scale_y); 1934 fragment_tex_scale_x, fragment_tex_scale_y);
1987 1935
1988 // Blending is required for antialiasing. 1936 // Blending is required for antialiasing.
1989 SetBlendEnabled(true); 1937 SetBlendEnabled(true);
1990 1938
1991 // Normalize to tile_rect. 1939 // Normalize to tile_rect.
1992 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1940 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1993 1941
1994 SetShaderOpacity(quad->shared_quad_state->opacity, program->alpha_location()); 1942 SetShaderOpacity(quad);
1995 SetShaderQuadF(local_quad, program->quad_location()); 1943 SetShaderQuadF(local_quad);
1996 1944
1997 // The transform and vertex data are used to figure out the extents that the 1945 // The transform and vertex data are used to figure out the extents that the
1998 // un-antialiased quad should have and which vertex this is and the float 1946 // un-antialiased quad should have and which vertex this is and the float
1999 // quad passed in via uniform is the actual geometry that gets used to draw 1947 // quad passed in via uniform is the actual geometry that gets used to draw
2000 // it. This is why this centered rect is used and not the original quad_rect. 1948 // it. This is why this centered rect is used and not the original quad_rect.
2001 gfx::RectF centered_rect( 1949 gfx::RectF centered_rect(
2002 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1950 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
2003 gfx::SizeF(tile_rect.size())); 1951 gfx::SizeF(tile_rect.size()));
2004 DrawQuadGeometry(frame->projection_matrix, 1952 DrawQuadGeometry(frame->projection_matrix,
2005 quad->shared_quad_state->quad_to_target_transform, 1953 quad->shared_quad_state->quad_to_target_transform,
2006 centered_rect, program->matrix_location()); 1954 centered_rect);
2007 } 1955 }
2008 1956
2009 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, 1957 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame,
2010 const ContentDrawQuadBase* quad, 1958 const ContentDrawQuadBase* quad,
2011 ResourceId resource_id, 1959 ResourceId resource_id,
2012 const gfx::QuadF* clip_region) { 1960 const gfx::QuadF* clip_region) {
2013 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1961 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
2014 quad->tex_coord_rect, gfx::RectF(quad->rect), 1962 quad->tex_coord_rect, gfx::RectF(quad->rect),
2015 gfx::RectF(quad->visible_rect)); 1963 gfx::RectF(quad->visible_rect));
2016 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1964 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
(...skipping 29 matching lines...) Expand all
2046 } 1994 }
2047 1995
2048 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1996 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2049 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); 1997 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size);
2050 1998
2051 const Program* program = GetProgram( 1999 const Program* program = GetProgram(
2052 ProgramKey::Tile(tex_coord_precision, sampler, NO_AA, 2000 ProgramKey::Tile(tex_coord_precision, sampler, NO_AA,
2053 quad->swizzle_contents ? DO_SWIZZLE : NO_SWIZZLE, 2001 quad->swizzle_contents ? DO_SWIZZLE : NO_SWIZZLE,
2054 !quad->ShouldDrawWithBlending())); 2002 !quad->ShouldDrawWithBlending()));
2055 2003
2056 SetUseProgram(program->program()); 2004 SetUseProgram(program);
2057 gl_->Uniform1i(program->sampler_location(), 0);
2058 2005
2059 gl_->Uniform4f(program->vertex_tex_transform_location(), 2006 gl_->Uniform4f(program->vertex_tex_transform_location(),
2060 vertex_tex_translate_x, vertex_tex_translate_y, 2007 vertex_tex_translate_x, vertex_tex_translate_y,
2061 vertex_tex_scale_x, vertex_tex_scale_y); 2008 vertex_tex_scale_x, vertex_tex_scale_y);
2062 2009
2063 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2010 SetBlendEnabled(quad->ShouldDrawWithBlending());
2064 2011
2065 SetShaderOpacity(quad->shared_quad_state->opacity, program->alpha_location()); 2012 SetShaderOpacity(quad);
2066 2013
2067 // Pass quad coordinates to the uniform in the same order as GeometryBinding 2014 // Pass quad coordinates to the uniform in the same order as GeometryBinding
2068 // does, then vertices will match the texture mapping in the vertex buffer. 2015 // does, then vertices will match the texture mapping in the vertex buffer.
2069 // The method SetShaderQuadF() changes the order of vertices and so it's 2016 // The method SetShaderQuadF() changes the order of vertices and so it's
2070 // not used here. 2017 // not used here.
2071 auto tile_quad = gfx::QuadF(gfx::RectF(quad->visible_rect)); 2018 auto tile_quad = gfx::QuadF(gfx::RectF(quad->visible_rect));
2072 float width = quad->visible_rect.width(); 2019 float width = quad->visible_rect.width();
2073 float height = quad->visible_rect.height(); 2020 float height = quad->visible_rect.height();
2074 auto top_left = gfx::PointF(quad->visible_rect.origin()); 2021 auto top_left = gfx::PointF(quad->visible_rect.origin());
2075 if (clip_region) { 2022 if (clip_region) {
(...skipping 14 matching lines...) Expand all
2090 } else { 2037 } else {
2091 PrepareGeometry(SHARED_BINDING); 2038 PrepareGeometry(SHARED_BINDING);
2092 } 2039 }
2093 float gl_quad[8] = { 2040 float gl_quad[8] = {
2094 tile_quad.p4().x(), tile_quad.p4().y(), tile_quad.p1().x(), 2041 tile_quad.p4().x(), tile_quad.p4().y(), tile_quad.p1().x(),
2095 tile_quad.p1().y(), tile_quad.p2().x(), tile_quad.p2().y(), 2042 tile_quad.p1().y(), tile_quad.p2().x(), tile_quad.p2().y(),
2096 tile_quad.p3().x(), tile_quad.p3().y(), 2043 tile_quad.p3().x(), tile_quad.p3().y(),
2097 }; 2044 };
2098 gl_->Uniform2fv(program->quad_location(), 4, gl_quad); 2045 gl_->Uniform2fv(program->quad_location(), 4, gl_quad);
2099 2046
2100 static float gl_matrix[16]; 2047 SetShaderMatrix(frame->projection_matrix *
2101 ToGLMatrix(&gl_matrix[0], 2048 quad->shared_quad_state->quad_to_target_transform);
2102 frame->projection_matrix *
2103 quad->shared_quad_state->quad_to_target_transform);
2104 gl_->UniformMatrix4fv(program->matrix_location(), 1, false, &gl_matrix[0]);
2105 2049
2106 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 2050 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
2107 } 2051 }
2108 2052
2109 // TODO(ccameron): This has been replicated in ui/gfx/color_transform.cc. Delete 2053 // TODO(ccameron): This has been replicated in ui/gfx/color_transform.cc. Delete
2110 // one of the instances. 2054 // one of the instances.
2111 void ComputeYUVToRGBMatrices(YUVVideoDrawQuad::ColorSpace color_space, 2055 void ComputeYUVToRGBMatrices(YUVVideoDrawQuad::ColorSpace color_space,
2112 uint32_t bits_per_channel, 2056 uint32_t bits_per_channel,
2113 float resource_multiplier, 2057 float resource_multiplier,
2114 float resource_offset, 2058 float resource_offset,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 GL_LINEAR)); 2147 GL_LINEAR));
2204 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target()); 2148 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target());
2205 } 2149 }
2206 2150
2207 // All planes must have the same sampler type. 2151 // All planes must have the same sampler type.
2208 SamplerType sampler = SamplerTypeFromTextureTarget(y_plane_lock.target()); 2152 SamplerType sampler = SamplerTypeFromTextureTarget(y_plane_lock.target());
2209 2153
2210 const Program* program = GetProgram( 2154 const Program* program = GetProgram(
2211 ProgramKey::YUVVideo(tex_coord_precision, sampler, alpha_texture_mode, 2155 ProgramKey::YUVVideo(tex_coord_precision, sampler, alpha_texture_mode,
2212 uv_texture_mode, color_conversion_mode)); 2156 uv_texture_mode, color_conversion_mode));
2213 DCHECK(program && (program->initialized() || IsContextLost())); 2157 SetUseProgram(program);
2214 SetUseProgram(program->program());
2215 2158
2216 gfx::SizeF ya_tex_scale(1.0f, 1.0f); 2159 gfx::SizeF ya_tex_scale(1.0f, 1.0f);
2217 gfx::SizeF uv_tex_scale(1.0f, 1.0f); 2160 gfx::SizeF uv_tex_scale(1.0f, 1.0f);
2218 if (sampler != SAMPLER_TYPE_2D_RECT) { 2161 if (sampler != SAMPLER_TYPE_2D_RECT) {
2219 DCHECK(!quad->ya_tex_size.IsEmpty()); 2162 DCHECK(!quad->ya_tex_size.IsEmpty());
2220 DCHECK(!quad->uv_tex_size.IsEmpty()); 2163 DCHECK(!quad->uv_tex_size.IsEmpty());
2221 ya_tex_scale = gfx::SizeF(1.0f / quad->ya_tex_size.width(), 2164 ya_tex_scale = gfx::SizeF(1.0f / quad->ya_tex_size.width(),
2222 1.0f / quad->ya_tex_size.height()); 2165 1.0f / quad->ya_tex_size.height());
2223 uv_tex_scale = gfx::SizeF(1.0f / quad->uv_tex_size.width(), 2166 uv_tex_scale = gfx::SizeF(1.0f / quad->uv_tex_size.width(),
2224 1.0f / quad->uv_tex_size.height()); 2167 1.0f / quad->uv_tex_size.height());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 color_conversion_mode, yuv_to_rgb_matrix); 2235 color_conversion_mode, yuv_to_rgb_matrix);
2293 gl_->UniformMatrix4fv(program->yuv_and_resource_matrix_location(), 1, 0, 2236 gl_->UniformMatrix4fv(program->yuv_and_resource_matrix_location(), 1, 0,
2294 yuv_to_rgb_matrix); 2237 yuv_to_rgb_matrix);
2295 2238
2296 // The transform and vertex data are used to figure out the extents that the 2239 // The transform and vertex data are used to figure out the extents that the
2297 // un-antialiased quad should have and which vertex this is and the float 2240 // un-antialiased quad should have and which vertex this is and the float
2298 // quad passed in via uniform is the actual geometry that gets used to draw 2241 // quad passed in via uniform is the actual geometry that gets used to draw
2299 // it. This is why this centered rect is used and not the original quad_rect. 2242 // it. This is why this centered rect is used and not the original quad_rect.
2300 auto tile_rect = gfx::RectF(quad->rect); 2243 auto tile_rect = gfx::RectF(quad->rect);
2301 2244
2302 SetShaderOpacity(quad->shared_quad_state->opacity, program->alpha_location()); 2245 SetShaderOpacity(quad);
2303 if (!clip_region) { 2246 if (!clip_region) {
2304 DrawQuadGeometry(frame->projection_matrix, 2247 DrawQuadGeometry(frame->projection_matrix,
2305 quad->shared_quad_state->quad_to_target_transform, 2248 quad->shared_quad_state->quad_to_target_transform,
2306 tile_rect, program->matrix_location()); 2249 tile_rect);
2307 } else { 2250 } else {
2308 float uvs[8] = {0}; 2251 float uvs[8] = {0};
2309 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2252 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2310 gfx::QuadF region_quad = *clip_region; 2253 gfx::QuadF region_quad = *clip_region;
2311 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 2254 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
2312 region_quad -= gfx::Vector2dF(0.5f, 0.5f); 2255 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2313 DrawQuadGeometryClippedByQuadF( 2256 DrawQuadGeometryClippedByQuadF(
2314 frame, quad->shared_quad_state->quad_to_target_transform, tile_rect, 2257 frame, quad->shared_quad_state->quad_to_target_transform, tile_rect,
2315 region_quad, program->matrix_location(), uvs); 2258 region_quad, uvs);
2316 } 2259 }
2317 } 2260 }
2318 2261
2319 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, 2262 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame,
2320 const StreamVideoDrawQuad* quad, 2263 const StreamVideoDrawQuad* quad,
2321 const gfx::QuadF* clip_region) { 2264 const gfx::QuadF* clip_region) {
2322 SetBlendEnabled(quad->ShouldDrawWithBlending()); 2265 SetBlendEnabled(quad->ShouldDrawWithBlending());
2323 2266
2324 static float gl_matrix[16];
2325
2326 DCHECK(output_surface_->context_provider() 2267 DCHECK(output_surface_->context_provider()
2327 ->ContextCapabilities() 2268 ->ContextCapabilities()
2328 .egl_image_external); 2269 .egl_image_external);
2329 2270
2330 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2271 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2331 gl_, &highp_threshold_cache_, highp_threshold_min_, 2272 gl_, &highp_threshold_cache_, highp_threshold_min_,
2332 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); 2273 quad->shared_quad_state->visible_quad_layer_rect.bottom_right());
2333 2274
2334 const Program* program = 2275 const Program* program =
2335 GetProgram(ProgramKey::VideoStream(tex_coord_precision)); 2276 GetProgram(ProgramKey::VideoStream(tex_coord_precision));
2336 SetUseProgram(program->program()); 2277 SetUseProgram(program);
2337
2338 ToGLMatrix(&gl_matrix[0], quad->matrix);
2339 2278
2340 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2279 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2341 quad->resource_id()); 2280 quad->resource_id());
2342 2281
2343 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2282 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2344 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); 2283 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id());
2345 2284
2285 static float gl_matrix[16];
2286 ToGLMatrix(&gl_matrix[0], quad->matrix);
2346 gl_->UniformMatrix4fvStreamTextureMatrixCHROMIUM( 2287 gl_->UniformMatrix4fvStreamTextureMatrixCHROMIUM(
2347 program->tex_matrix_location(), false, gl_matrix); 2288 program->tex_matrix_location(), false, gl_matrix);
2348 2289
2349 gl_->Uniform1i(program->sampler_location(), 0); 2290 SetShaderOpacity(quad);
2350
2351 SetShaderOpacity(quad->shared_quad_state->opacity, program->alpha_location());
2352 if (!clip_region) { 2291 if (!clip_region) {
2353 DrawQuadGeometry(frame->projection_matrix, 2292 DrawQuadGeometry(frame->projection_matrix,
2354 quad->shared_quad_state->quad_to_target_transform, 2293 quad->shared_quad_state->quad_to_target_transform,
2355 gfx::RectF(quad->rect), program->matrix_location()); 2294 gfx::RectF(quad->rect));
2356 } else { 2295 } else {
2357 gfx::QuadF region_quad(*clip_region); 2296 gfx::QuadF region_quad(*clip_region);
2358 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height()); 2297 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height());
2359 region_quad -= gfx::Vector2dF(0.5f, 0.5f); 2298 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2360 float uvs[8] = {0}; 2299 float uvs[8] = {0};
2361 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2300 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2362 DrawQuadGeometryClippedByQuadF( 2301 DrawQuadGeometryClippedByQuadF(
2363 frame, quad->shared_quad_state->quad_to_target_transform, 2302 frame, quad->shared_quad_state->quad_to_target_transform,
2364 gfx::RectF(quad->rect), region_quad, program->matrix_location(), uvs); 2303 gfx::RectF(quad->rect), region_quad, uvs);
2365 } 2304 }
2366 } 2305 }
2367 2306
2368 void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) { 2307 void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
2369 // Check to see if we have anything to draw. 2308 // Check to see if we have anything to draw.
2370 if (draw_cache_.program_id == -1) 2309 if (!draw_cache_.program)
2371 return; 2310 return;
2372 2311
2373 PrepareGeometry(flush_binding); 2312 PrepareGeometry(flush_binding);
2374 2313
2375 // Set the correct blending mode. 2314 // Set the correct blending mode.
2376 SetBlendEnabled(draw_cache_.needs_blending); 2315 SetBlendEnabled(draw_cache_.needs_blending);
2377 2316
2378 // Bind the program to the GL state. 2317 // Bind the program to the GL state.
2379 SetUseProgram(draw_cache_.program_id); 2318 SetUseProgram(draw_cache_.program);
2380
2381 // Bind the correct texture sampler location.
2382 gl_->Uniform1i(draw_cache_.sampler_location, 0);
2383 2319
2384 // Assume the current active textures is 0. 2320 // Assume the current active textures is 0.
2385 ResourceProvider::ScopedSamplerGL locked_quad( 2321 ResourceProvider::ScopedSamplerGL locked_quad(
2386 resource_provider_, 2322 resource_provider_,
2387 draw_cache_.resource_id, 2323 draw_cache_.resource_id,
2388 draw_cache_.nearest_neighbor ? GL_NEAREST : GL_LINEAR); 2324 draw_cache_.nearest_neighbor ? GL_NEAREST : GL_LINEAR);
2389 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2325 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2390 gl_->BindTexture(locked_quad.target(), locked_quad.texture_id()); 2326 gl_->BindTexture(locked_quad.target(), locked_quad.texture_id());
2391 2327
2392 static_assert(sizeof(Float4) == 4 * sizeof(float), 2328 static_assert(sizeof(Float4) == 4 * sizeof(float),
2393 "Float4 struct should be densely packed"); 2329 "Float4 struct should be densely packed");
2394 static_assert(sizeof(Float16) == 16 * sizeof(float), 2330 static_assert(sizeof(Float16) == 16 * sizeof(float),
2395 "Float16 struct should be densely packed"); 2331 "Float16 struct should be densely packed");
2396 2332
2397 // Upload the tranforms for both points and uvs. 2333 // Upload the tranforms for both points and uvs.
2398 gl_->UniformMatrix4fv( 2334 gl_->UniformMatrix4fv(
2399 static_cast<int>(draw_cache_.matrix_location), 2335 draw_cache_.program->matrix_location(),
2400 static_cast<int>(draw_cache_.matrix_data.size()), false, 2336 static_cast<int>(draw_cache_.matrix_data.size()), false,
2401 reinterpret_cast<float*>(&draw_cache_.matrix_data.front())); 2337 reinterpret_cast<float*>(&draw_cache_.matrix_data.front()));
2402 gl_->Uniform4fv(static_cast<int>(draw_cache_.uv_xform_location), 2338 gl_->Uniform4fv(draw_cache_.program->vertex_tex_transform_location(),
2403 static_cast<int>(draw_cache_.uv_xform_data.size()), 2339 static_cast<int>(draw_cache_.uv_xform_data.size()),
2404 reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front())); 2340 reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front()));
2405 2341
2406 if (draw_cache_.background_color != SK_ColorTRANSPARENT) { 2342 if (draw_cache_.background_color != SK_ColorTRANSPARENT) {
2407 Float4 background_color = PremultipliedColor(draw_cache_.background_color); 2343 Float4 background_color =
2408 gl_->Uniform4fv(draw_cache_.background_color_location, 1, 2344 PremultipliedColor(draw_cache_.background_color, 1.f);
2345 gl_->Uniform4fv(draw_cache_.program->background_color_location(), 1,
2409 background_color.data); 2346 background_color.data);
2410 } 2347 }
2411 2348
2412 gl_->Uniform1fv( 2349 gl_->Uniform1fv(
2413 static_cast<int>(draw_cache_.vertex_opacity_location), 2350 draw_cache_.program->vertex_opacity_location(),
2414 static_cast<int>(draw_cache_.vertex_opacity_data.size()), 2351 static_cast<int>(draw_cache_.vertex_opacity_data.size()),
2415 static_cast<float*>(&draw_cache_.vertex_opacity_data.front())); 2352 static_cast<float*>(&draw_cache_.vertex_opacity_data.front()));
2416 2353
2417 DCHECK_LE(draw_cache_.matrix_data.size(), 2354 DCHECK_LE(draw_cache_.matrix_data.size(),
2418 static_cast<size_t>(std::numeric_limits<int>::max()) / 6u); 2355 static_cast<size_t>(std::numeric_limits<int>::max()) / 6u);
2419 // Draw the quads! 2356 // Draw the quads!
2420 gl_->DrawElements(GL_TRIANGLES, 2357 gl_->DrawElements(GL_TRIANGLES,
2421 6 * static_cast<int>(draw_cache_.matrix_data.size()), 2358 6 * static_cast<int>(draw_cache_.matrix_data.size()),
2422 GL_UNSIGNED_SHORT, 0); 2359 GL_UNSIGNED_SHORT, 0);
2423 2360
2424 // Draw the border if requested. 2361 // Draw the border if requested.
2425 if (gl_composited_texture_quad_border_) { 2362 if (gl_composited_texture_quad_border_) {
2426 // When we draw the composited borders we have one flush per quad. 2363 // When we draw the composited borders we have one flush per quad.
2427 DCHECK_EQ(1u, draw_cache_.matrix_data.size()); 2364 DCHECK_EQ(1u, draw_cache_.matrix_data.size());
2428 SetBlendEnabled(false); 2365 SetBlendEnabled(false);
2429 const Program* program = GetProgram(ProgramKey::DebugBorder()); 2366 const Program* program = GetProgram(ProgramKey::DebugBorder());
2430 DCHECK(program); 2367 SetUseProgram(program);
2431 DCHECK(program->initialized() || IsContextLost());
2432 SetUseProgram(program->program());
2433 2368
2434 gl_->UniformMatrix4fv( 2369 gl_->UniformMatrix4fv(
2435 program->matrix_location(), 1, false, 2370 program->matrix_location(), 1, false,
2436 reinterpret_cast<float*>(&draw_cache_.matrix_data.front())); 2371 reinterpret_cast<float*>(&draw_cache_.matrix_data.front()));
2437 2372
2438 // Pick a random color based on the scale on X and Y. 2373 // Pick a random color based on the scale on X and Y.
2439 int colorIndex = static_cast<int>(draw_cache_.matrix_data.front().data[0] * 2374 int colorIndex = static_cast<int>(draw_cache_.matrix_data.front().data[0] *
2440 draw_cache_.matrix_data.front().data[5]); 2375 draw_cache_.matrix_data.front().data[5]);
2441 SkColor color = DebugColors::GLCompositedTextureQuadBorderColor(colorIndex); 2376 SkColor color = DebugColors::GLCompositedTextureQuadBorderColor(colorIndex);
2442 2377 SetShaderColor(color, 1.f);
2443 gl_->Uniform4f(program->color_location(), SkColorGetR(color),
2444 SkColorGetG(color), SkColorGetB(color), 1.0f);
2445 2378
2446 gl_->LineWidth(DebugColors::GLCompositedTextureQuadBoderWidth()); 2379 gl_->LineWidth(DebugColors::GLCompositedTextureQuadBoderWidth());
2447 // The indices for the line are stored in the same array as the triangle 2380 // The indices for the line are stored in the same array as the triangle
2448 // indices. 2381 // indices.
2449 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0); 2382 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0);
2450 } 2383 }
2451 2384
2452 // Clear the cache. 2385 // Clear the cache.
2453 draw_cache_.program_id = -1; 2386 draw_cache_.program = nullptr;
2387 draw_cache_.resource_id = -1;
2454 draw_cache_.uv_xform_data.resize(0); 2388 draw_cache_.uv_xform_data.resize(0);
2455 draw_cache_.vertex_opacity_data.resize(0); 2389 draw_cache_.vertex_opacity_data.resize(0);
2456 draw_cache_.matrix_data.resize(0); 2390 draw_cache_.matrix_data.resize(0);
2457 2391
2458 // If we had a clipped binding, prepare the shared binding for the 2392 // If we had a clipped binding, prepare the shared binding for the
2459 // next inserts. 2393 // next inserts.
2460 if (flush_binding == CLIPPED_BINDING) { 2394 if (flush_binding == CLIPPED_BINDING) {
2461 PrepareGeometry(SHARED_BINDING); 2395 PrepareGeometry(SHARED_BINDING);
2462 } 2396 }
2463 } 2397 }
(...skipping 16 matching lines...) Expand all
2480 2414
2481 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2415 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2482 quad->resource_id()); 2416 quad->resource_id());
2483 const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target()); 2417 const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target());
2484 2418
2485 const Program* program = GetProgram(ProgramKey::Texture( 2419 const Program* program = GetProgram(ProgramKey::Texture(
2486 tex_coord_precision, sampler, 2420 tex_coord_precision, sampler,
2487 quad->premultiplied_alpha ? PREMULTIPLIED_ALPHA : NON_PREMULTIPLIED_ALPHA, 2421 quad->premultiplied_alpha ? PREMULTIPLIED_ALPHA : NON_PREMULTIPLIED_ALPHA,
2488 quad->background_color != SK_ColorTRANSPARENT)); 2422 quad->background_color != SK_ColorTRANSPARENT));
2489 int resource_id = quad->resource_id(); 2423 int resource_id = quad->resource_id();
2490 int program_id = program->program();
2491 2424
2492 size_t max_quads = StaticGeometryBinding::NUM_QUADS; 2425 size_t max_quads = StaticGeometryBinding::NUM_QUADS;
2493 if (draw_cache_.program_id != program_id || 2426 if (draw_cache_.program != program ||
2494 draw_cache_.resource_id != resource_id || 2427 draw_cache_.resource_id != resource_id ||
2495 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || 2428 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() ||
2496 draw_cache_.nearest_neighbor != quad->nearest_neighbor || 2429 draw_cache_.nearest_neighbor != quad->nearest_neighbor ||
2497 draw_cache_.background_color != quad->background_color || 2430 draw_cache_.background_color != quad->background_color ||
2498 draw_cache_.matrix_data.size() >= max_quads) { 2431 draw_cache_.matrix_data.size() >= max_quads) {
2499 FlushTextureQuadCache(SHARED_BINDING); 2432 FlushTextureQuadCache(SHARED_BINDING);
2500 draw_cache_.program_id = program_id; 2433 draw_cache_.program = program;
2501 draw_cache_.resource_id = resource_id; 2434 draw_cache_.resource_id = resource_id;
2502 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); 2435 draw_cache_.needs_blending = quad->ShouldDrawWithBlending();
2503 draw_cache_.nearest_neighbor = quad->nearest_neighbor; 2436 draw_cache_.nearest_neighbor = quad->nearest_neighbor;
2504 draw_cache_.background_color = quad->background_color; 2437 draw_cache_.background_color = quad->background_color;
2505
2506 draw_cache_.uv_xform_location = program->vertex_tex_transform_location();
2507 draw_cache_.background_color_location =
2508 program->background_color_location();
2509 draw_cache_.vertex_opacity_location = program->vertex_opacity_location();
2510 draw_cache_.matrix_location = program->matrix_location();
2511 draw_cache_.sampler_location = program->sampler_location();
2512 } 2438 }
2513 2439
2514 // Generate the uv-transform 2440 // Generate the uv-transform
2515 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; 2441 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}};
2516 if (!clip_region) 2442 if (!clip_region)
2517 uv_transform = UVTransform(quad); 2443 uv_transform = UVTransform(quad);
2518 if (sampler == SAMPLER_TYPE_2D_RECT) { 2444 if (sampler == SAMPLER_TYPE_2D_RECT) {
2519 // Un-normalize the texture coordiantes for rectangle targets. 2445 // Un-normalize the texture coordiantes for rectangle targets.
2520 gfx::Size texture_size = lock.size(); 2446 gfx::Size texture_size = lock.size();
2521 uv_transform.data[0] *= texture_size.width(); 2447 uv_transform.data[0] *= texture_size.width();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 gfx::Rect copy_rect = frame->current_render_pass->output_rect; 2555 gfx::Rect copy_rect = frame->current_render_pass->output_rect;
2630 if (request->has_area()) 2556 if (request->has_area())
2631 copy_rect.Intersect(request->area()); 2557 copy_rect.Intersect(request->area());
2632 GetFramebufferPixelsAsync(frame, copy_rect, std::move(request)); 2558 GetFramebufferPixelsAsync(frame, copy_rect, std::move(request));
2633 } 2559 }
2634 2560
2635 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) { 2561 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) {
2636 transform.matrix().asColMajorf(gl_matrix); 2562 transform.matrix().asColMajorf(gl_matrix);
2637 } 2563 }
2638 2564
2639 void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad, int quad_location) { 2565 void GLRenderer::SetShaderQuadF(const gfx::QuadF& quad) {
2640 if (quad_location == -1) 2566 if (!program_shadow_ || program_shadow_->quad_location() == -1)
2641 return; 2567 return;
2642
2643 float gl_quad[8]; 2568 float gl_quad[8];
2644 gl_quad[0] = quad.p1().x(); 2569 gl_quad[0] = quad.p1().x();
2645 gl_quad[1] = quad.p1().y(); 2570 gl_quad[1] = quad.p1().y();
2646 gl_quad[2] = quad.p2().x(); 2571 gl_quad[2] = quad.p2().x();
2647 gl_quad[3] = quad.p2().y(); 2572 gl_quad[3] = quad.p2().y();
2648 gl_quad[4] = quad.p3().x(); 2573 gl_quad[4] = quad.p3().x();
2649 gl_quad[5] = quad.p3().y(); 2574 gl_quad[5] = quad.p3().y();
2650 gl_quad[6] = quad.p4().x(); 2575 gl_quad[6] = quad.p4().x();
2651 gl_quad[7] = quad.p4().y(); 2576 gl_quad[7] = quad.p4().y();
2652 gl_->Uniform2fv(quad_location, 4, gl_quad); 2577 gl_->Uniform2fv(program_shadow_->quad_location(), 4, gl_quad);
2653 } 2578 }
2654 2579
2655 void GLRenderer::SetShaderOpacity(float opacity, int alpha_location) { 2580 void GLRenderer::SetShaderOpacity(const DrawQuad* quad) {
2656 if (alpha_location != -1) 2581 if (!program_shadow_ || program_shadow_->alpha_location() == -1)
2657 gl_->Uniform1f(alpha_location, opacity); 2582 return;
2583 gl_->Uniform1f(program_shadow_->alpha_location(),
2584 quad->shared_quad_state->opacity);
2585 }
2586
2587 void GLRenderer::SetShaderMatrix(const gfx::Transform& transform) {
2588 if (!program_shadow_ || program_shadow_->matrix_location() == -1)
2589 return;
2590 float gl_matrix[16];
2591 ToGLMatrix(gl_matrix, transform);
2592 gl_->UniformMatrix4fv(program_shadow_->matrix_location(), 1, false,
2593 gl_matrix);
2594 }
2595
2596 void GLRenderer::SetShaderColor(SkColor color, float opacity) {
2597 if (!program_shadow_ || program_shadow_->color_location() == -1)
2598 return;
2599 Float4 float_color = PremultipliedColor(color, opacity);
2600 gl_->Uniform4fv(program_shadow_->color_location(), 1, float_color.data);
2658 } 2601 }
2659 2602
2660 void GLRenderer::SetStencilEnabled(bool enabled) { 2603 void GLRenderer::SetStencilEnabled(bool enabled) {
2661 if (enabled == stencil_shadow_) 2604 if (enabled == stencil_shadow_)
2662 return; 2605 return;
2663 2606
2664 if (enabled) 2607 if (enabled)
2665 gl_->Enable(GL_STENCIL_TEST); 2608 gl_->Enable(GL_STENCIL_TEST);
2666 else 2609 else
2667 gl_->Disable(GL_STENCIL_TEST); 2610 gl_->Disable(GL_STENCIL_TEST);
2668 stencil_shadow_ = enabled; 2611 stencil_shadow_ = enabled;
2669 } 2612 }
2670 2613
2671 void GLRenderer::SetBlendEnabled(bool enabled) { 2614 void GLRenderer::SetBlendEnabled(bool enabled) {
2672 if (enabled == blend_shadow_) 2615 if (enabled == blend_shadow_)
2673 return; 2616 return;
2674 2617
2675 if (enabled) 2618 if (enabled)
2676 gl_->Enable(GL_BLEND); 2619 gl_->Enable(GL_BLEND);
2677 else 2620 else
2678 gl_->Disable(GL_BLEND); 2621 gl_->Disable(GL_BLEND);
2679 blend_shadow_ = enabled; 2622 blend_shadow_ = enabled;
2680 } 2623 }
2681 2624
2682 void GLRenderer::SetUseProgram(unsigned program) { 2625 void GLRenderer::SetUseProgram(const Program* program) {
2626 DCHECK(program);
2627 DCHECK(program->initialized() || IsContextLost());
2683 if (program == program_shadow_) 2628 if (program == program_shadow_)
2684 return; 2629 return;
2685 gl_->UseProgram(program); 2630 gl_->UseProgram(program->program());
2631
2632 // Set uniforms that are common to all programs.
2633 if (program->sampler_location() != -1)
2634 gl_->Uniform1i(program->sampler_location(), 0);
2635 if (program->viewport_location() != -1) {
2636 float viewport[4] = {
2637 static_cast<float>(current_window_space_viewport_.x()),
2638 static_cast<float>(current_window_space_viewport_.y()),
2639 static_cast<float>(current_window_space_viewport_.width()),
2640 static_cast<float>(current_window_space_viewport_.height()),
2641 };
2642 gl_->Uniform4fv(program->viewport_location(), 1, viewport);
2643 }
2686 program_shadow_ = program; 2644 program_shadow_ = program;
2687 } 2645 }
2688 2646
2689 void GLRenderer::DrawQuadGeometryClippedByQuadF( 2647 void GLRenderer::DrawQuadGeometryClippedByQuadF(
2690 const DrawingFrame* frame, 2648 const DrawingFrame* frame,
2691 const gfx::Transform& draw_transform, 2649 const gfx::Transform& draw_transform,
2692 const gfx::RectF& quad_rect, 2650 const gfx::RectF& quad_rect,
2693 const gfx::QuadF& clipping_region_quad, 2651 const gfx::QuadF& clipping_region_quad,
2694 int matrix_location,
2695 const float* uvs) { 2652 const float* uvs) {
2696 PrepareGeometry(CLIPPED_BINDING); 2653 PrepareGeometry(CLIPPED_BINDING);
2697 if (uvs) { 2654 if (uvs) {
2698 clipped_geometry_->InitializeCustomQuadWithUVs(clipping_region_quad, uvs); 2655 clipped_geometry_->InitializeCustomQuadWithUVs(clipping_region_quad, uvs);
2699 } else { 2656 } else {
2700 clipped_geometry_->InitializeCustomQuad(clipping_region_quad); 2657 clipped_geometry_->InitializeCustomQuad(clipping_region_quad);
2701 } 2658 }
2702 gfx::Transform quad_rect_matrix; 2659 gfx::Transform quad_rect_matrix;
2703 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2660 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2704 static float gl_matrix[16]; 2661 SetShaderMatrix(frame->projection_matrix * quad_rect_matrix);
2705 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2706 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]);
2707 2662
2708 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 2663 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,
2709 reinterpret_cast<const void*>(0)); 2664 reinterpret_cast<const void*>(0));
2710 } 2665 }
2711 2666
2712 void GLRenderer::DrawQuadGeometry(const gfx::Transform& projection_matrix, 2667 void GLRenderer::DrawQuadGeometry(const gfx::Transform& projection_matrix,
2713 const gfx::Transform& draw_transform, 2668 const gfx::Transform& draw_transform,
2714 const gfx::RectF& quad_rect, 2669 const gfx::RectF& quad_rect) {
2715 int matrix_location) {
2716 PrepareGeometry(SHARED_BINDING); 2670 PrepareGeometry(SHARED_BINDING);
2717 gfx::Transform quad_rect_matrix; 2671 gfx::Transform quad_rect_matrix;
2718 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2672 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2719 static float gl_matrix[16]; 2673 SetShaderMatrix(projection_matrix * quad_rect_matrix);
2720 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix);
2721 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]);
2722 2674
2723 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 2675 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
2724 } 2676 }
2725 2677
2726 void GLRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) { 2678 void GLRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) {
2727 DCHECK(visible_); 2679 DCHECK(visible_);
2728 2680
2729 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); 2681 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers");
2730 // We're done! Time to swapbuffers! 2682 // We're done! Time to swapbuffers!
2731 2683
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 gl_->DeleteRenderbuffers(1, &offscreen_stencil_renderbuffer_id_); 3103 gl_->DeleteRenderbuffers(1, &offscreen_stencil_renderbuffer_id_);
3152 3104
3153 ReleaseRenderPassTextures(); 3105 ReleaseRenderPassTextures();
3154 } 3106 }
3155 3107
3156 void GLRenderer::ReinitializeGLState() { 3108 void GLRenderer::ReinitializeGLState() {
3157 is_scissor_enabled_ = false; 3109 is_scissor_enabled_ = false;
3158 scissor_rect_ = gfx::Rect(); 3110 scissor_rect_ = gfx::Rect();
3159 stencil_shadow_ = false; 3111 stencil_shadow_ = false;
3160 blend_shadow_ = true; 3112 blend_shadow_ = true;
3161 program_shadow_ = 0; 3113 program_shadow_ = nullptr;
3162 3114
3163 RestoreGLState(); 3115 RestoreGLState();
3164 } 3116 }
3165 3117
3166 void GLRenderer::RestoreGLState() { 3118 void GLRenderer::RestoreGLState() {
3167 // This restores the current GLRenderer state to the GL context. 3119 // This restores the current GLRenderer state to the GL context.
3168 bound_geometry_ = NO_BINDING; 3120 bound_geometry_ = NO_BINDING;
3169 PrepareGeometry(SHARED_BINDING); 3121 PrepareGeometry(SHARED_BINDING);
3170 3122
3171 gl_->Disable(GL_DEPTH_TEST); 3123 gl_->Disable(GL_DEPTH_TEST);
3172 gl_->Disable(GL_CULL_FACE); 3124 gl_->Disable(GL_CULL_FACE);
3173 gl_->ColorMask(true, true, true, true); 3125 gl_->ColorMask(true, true, true, true);
3174 gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 3126 gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
3175 gl_->ActiveTexture(GL_TEXTURE0); 3127 gl_->ActiveTexture(GL_TEXTURE0);
3176 3128
3177 if (program_shadow_) 3129 if (program_shadow_)
3178 gl_->UseProgram(program_shadow_); 3130 gl_->UseProgram(program_shadow_->program());
3179 3131
3180 if (stencil_shadow_) 3132 if (stencil_shadow_)
3181 gl_->Enable(GL_STENCIL_TEST); 3133 gl_->Enable(GL_STENCIL_TEST);
3182 else 3134 else
3183 gl_->Disable(GL_STENCIL_TEST); 3135 gl_->Disable(GL_STENCIL_TEST);
3184 3136
3185 if (blend_shadow_) 3137 if (blend_shadow_)
3186 gl_->Enable(GL_BLEND); 3138 gl_->Enable(GL_BLEND);
3187 else 3139 else
3188 gl_->Disable(GL_BLEND); 3140 gl_->Disable(GL_BLEND);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3495 3447
3496 // Test only, keep everything. 3448 // Test only, keep everything.
3497 gl_->StencilOp(GL_KEEP, GL_KEEP, GL_KEEP); 3449 gl_->StencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
3498 3450
3499 EnsureScissorTestDisabled(); 3451 EnsureScissorTestDisabled();
3500 SetBlendEnabled(true); 3452 SetBlendEnabled(true);
3501 3453
3502 PrepareGeometry(SHARED_BINDING); 3454 PrepareGeometry(SHARED_BINDING);
3503 3455
3504 const Program* program = GetProgram(ProgramKey::DebugBorder()); 3456 const Program* program = GetProgram(ProgramKey::DebugBorder());
3505 DCHECK(program); 3457 SetUseProgram(program);
3506 DCHECK(program->initialized() || IsContextLost());
3507 SetUseProgram(program->program());
3508 3458
3509 gfx::Transform render_matrix; 3459 gfx::Transform render_matrix;
3510 render_matrix.Translate(0.5 * output_rect.width() + output_rect.x(), 3460 render_matrix.Translate(0.5 * output_rect.width() + output_rect.x(),
3511 0.5 * output_rect.height() + output_rect.y()); 3461 0.5 * output_rect.height() + output_rect.y());
3512 render_matrix.Scale(output_rect.width(), output_rect.height()); 3462 render_matrix.Scale(output_rect.width(), output_rect.height());
3513 static float gl_matrix[16]; 3463 SetShaderMatrix(frame->projection_matrix * render_matrix);
3514 GLRenderer::ToGLMatrix(&gl_matrix[0],
3515 frame->projection_matrix * render_matrix);
3516 gl_->UniformMatrix4fv(program->matrix_location(), 1, false, &gl_matrix[0]);
3517 3464
3518 // Produce hinting for the amount of overdraw on screen for each pixel by 3465 // Produce hinting for the amount of overdraw on screen for each pixel by
3519 // drawing hint colors to the framebuffer based on the current stencil value. 3466 // drawing hint colors to the framebuffer based on the current stencil value.
3520 struct { 3467 struct {
3521 int multiplier; 3468 int multiplier;
3522 GLenum func; 3469 GLenum func;
3523 GLint ref; 3470 GLint ref;
3524 SkColor color; 3471 SkColor color;
3525 } stencil_tests[] = { 3472 } stencil_tests[] = {
3526 {1, GL_EQUAL, 2, 0x2f0000ff}, // Blue: Overdrawn once. 3473 {1, GL_EQUAL, 2, 0x2f0000ff}, // Blue: Overdrawn once.
(...skipping 28 matching lines...) Expand all
3555 3502
3556 for (const auto& test : stencil_tests) { 3503 for (const auto& test : stencil_tests) {
3557 GLuint query = 0; 3504 GLuint query = 0;
3558 if (tracing_enabled) { 3505 if (tracing_enabled) {
3559 gl_->GenQueriesEXT(1, &query); 3506 gl_->GenQueriesEXT(1, &query);
3560 gl_->BeginQueryEXT(GL_SAMPLES_PASSED_ARB, query); 3507 gl_->BeginQueryEXT(GL_SAMPLES_PASSED_ARB, query);
3561 } 3508 }
3562 3509
3563 gl_->StencilFunc(test.func, test.ref, 0xffffffff); 3510 gl_->StencilFunc(test.func, test.ref, 0xffffffff);
3564 // Transparent color unless color-coding of overdraw is enabled. 3511 // Transparent color unless color-coding of overdraw is enabled.
3565 Float4 color = 3512 SetShaderColor(settings_->show_overdraw_feedback ? test.color : 0, 1.f);
3566 PremultipliedColor(settings_->show_overdraw_feedback ? test.color : 0);
3567 gl_->Uniform4fv(program->color_location(), 1, color.data);
3568 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 3513 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
3569 3514
3570 if (query) { 3515 if (query) {
3571 gl_->EndQueryEXT(GL_SAMPLES_PASSED_ARB); 3516 gl_->EndQueryEXT(GL_SAMPLES_PASSED_ARB);
3572 context_support_->SignalQuery( 3517 context_support_->SignalQuery(
3573 query, 3518 query,
3574 base::Bind(overdraw_feedback_callback, query, test.multiplier)); 3519 base::Bind(overdraw_feedback_callback, query, test.multiplier));
3575 } 3520 }
3576 } 3521 }
3577 } 3522 }
(...skipping 17 matching lines...) Expand all
3595 return; 3540 return;
3596 3541
3597 // Report GPU overdraw as a percentage of |max_result|. 3542 // Report GPU overdraw as a percentage of |max_result|.
3598 TRACE_COUNTER1( 3543 TRACE_COUNTER1(
3599 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3544 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3600 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3545 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3601 max_result); 3546 max_result);
3602 } 3547 }
3603 3548
3604 } // namespace cc 3549 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_draw_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698