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

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

Issue 1314943008: cc: Remove implicit conversions from Rect to RectF in src/cc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 const DebugBorderProgram* program = GetDebugBorderProgram(); 571 const DebugBorderProgram* program = GetDebugBorderProgram();
572 DCHECK(program && (program->initialized() || IsContextLost())); 572 DCHECK(program && (program->initialized() || IsContextLost()));
573 SetUseProgram(program->program()); 573 SetUseProgram(program->program());
574 574
575 // Use the full quad_rect for debug quads to not move the edges based on 575 // Use the full quad_rect for debug quads to not move the edges based on
576 // partial swaps. 576 // partial swaps.
577 gfx::Rect layer_rect = quad->rect; 577 gfx::Rect layer_rect = quad->rect;
578 gfx::Transform render_matrix; 578 gfx::Transform render_matrix;
579 QuadRectTransform(&render_matrix, 579 QuadRectTransform(&render_matrix,
580 quad->shared_quad_state->quad_to_target_transform, 580 quad->shared_quad_state->quad_to_target_transform,
581 layer_rect); 581 gfx::RectF(layer_rect));
582 GLRenderer::ToGLMatrix(&gl_matrix[0], 582 GLRenderer::ToGLMatrix(&gl_matrix[0],
583 frame->projection_matrix * render_matrix); 583 frame->projection_matrix * render_matrix);
584 gl_->UniformMatrix4fv(program->vertex_shader().matrix_location(), 1, false, 584 gl_->UniformMatrix4fv(program->vertex_shader().matrix_location(), 1, false,
585 &gl_matrix[0]); 585 &gl_matrix[0]);
586 586
587 SkColor color = quad->color; 587 SkColor color = quad->color;
588 float alpha = SkColorGetA(color) * (1.0f / 255.0f); 588 float alpha = SkColorGetA(color) * (1.0f / 255.0f);
589 589
590 gl_->Uniform4f(program->fragment_shader().color_location(), 590 gl_->Uniform4f(program->fragment_shader().color_location(),
591 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 591 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 const RenderPassDrawQuad* quad, 874 const RenderPassDrawQuad* quad,
875 const gfx::QuadF* clip_region) { 875 const gfx::QuadF* clip_region) {
876 ScopedResource* contents_texture = 876 ScopedResource* contents_texture =
877 render_pass_textures_.get(quad->render_pass_id); 877 render_pass_textures_.get(quad->render_pass_id);
878 DCHECK(contents_texture); 878 DCHECK(contents_texture);
879 DCHECK(contents_texture->id()); 879 DCHECK(contents_texture->id());
880 880
881 gfx::Transform quad_rect_matrix; 881 gfx::Transform quad_rect_matrix;
882 QuadRectTransform(&quad_rect_matrix, 882 QuadRectTransform(&quad_rect_matrix,
883 quad->shared_quad_state->quad_to_target_transform, 883 quad->shared_quad_state->quad_to_target_transform,
884 quad->rect); 884 gfx::RectF(quad->rect));
885 gfx::Transform contents_device_transform = 885 gfx::Transform contents_device_transform =
886 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; 886 frame->window_matrix * frame->projection_matrix * quad_rect_matrix;
887 contents_device_transform.FlattenTo2d(); 887 contents_device_transform.FlattenTo2d();
888 888
889 // Can only draw surface if device matrix is invertible. 889 // Can only draw surface if device matrix is invertible.
890 if (!contents_device_transform.IsInvertible()) 890 if (!contents_device_transform.IsInvertible())
891 return; 891 return;
892 892
893 gfx::QuadF surface_quad = SharedGeometryQuad(); 893 gfx::QuadF surface_quad = SharedGeometryQuad();
894 894
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 GL_TEXTURE0 + last_texture_unit, 1203 GL_TEXTURE0 + last_texture_unit,
1204 GL_LINEAR)); 1204 GL_LINEAR));
1205 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1205 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1206 shader_background_sampler_lock->target()); 1206 shader_background_sampler_lock->target());
1207 } 1207 }
1208 } 1208 }
1209 1209
1210 SetShaderOpacity(quad->shared_quad_state->opacity, locations.alpha); 1210 SetShaderOpacity(quad->shared_quad_state->opacity, locations.alpha);
1211 SetShaderQuadF(surface_quad, locations.quad); 1211 SetShaderQuadF(surface_quad, locations.quad);
1212 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 1212 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
1213 quad->rect, locations.matrix); 1213 gfx::RectF(quad->rect), locations.matrix);
1214 1214
1215 // Flush the compositor context before the filter bitmap goes out of 1215 // Flush the compositor context before the filter bitmap goes out of
1216 // scope, so the draw gets processed before the filter texture gets deleted. 1216 // scope, so the draw gets processed before the filter texture gets deleted.
1217 if (filter_image_id) 1217 if (filter_image_id)
1218 gl_->Flush(); 1218 gl_->Flush();
1219 1219
1220 if (!use_shaders_for_blending) 1220 if (!use_shaders_for_blending)
1221 RestoreBlendFuncToDefault(blend_mode); 1221 RestoreBlendFuncToDefault(blend_mode);
1222 } 1222 }
1223 1223
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 kAntiAliasingEpsilon; 1292 kAntiAliasingEpsilon;
1293 } 1293 }
1294 } // anonymous namespace 1294 } // anonymous namespace
1295 1295
1296 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges( 1296 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges(
1297 const LayerQuad& device_layer_edges, 1297 const LayerQuad& device_layer_edges,
1298 const gfx::Transform& device_transform, 1298 const gfx::Transform& device_transform,
1299 const gfx::QuadF& tile_quad, 1299 const gfx::QuadF& tile_quad,
1300 const gfx::QuadF* clip_region, 1300 const gfx::QuadF* clip_region,
1301 const DrawQuad* quad) { 1301 const DrawQuad* quad) {
1302 gfx::RectF tile_rect = quad->visible_rect; 1302 gfx::RectF tile_rect = gfx::RectF(quad->visible_rect);
1303 1303
1304 gfx::PointF bottom_right = tile_quad.p3(); 1304 gfx::PointF bottom_right = tile_quad.p3();
1305 gfx::PointF bottom_left = tile_quad.p4(); 1305 gfx::PointF bottom_left = tile_quad.p4();
1306 gfx::PointF top_left = tile_quad.p1(); 1306 gfx::PointF top_left = tile_quad.p1();
1307 gfx::PointF top_right = tile_quad.p2(); 1307 gfx::PointF top_right = tile_quad.p2();
1308 bool clipped = false; 1308 bool clipped = false;
1309 1309
1310 // Map points to device space. We ignore |clipped|, since the result of 1310 // Map points to device space. We ignore |clipped|, since the result of
1311 // |MapPoint()| still produces a valid point to draw the quad with. When 1311 // |MapPoint()| still produces a valid point to draw the quad with. When
1312 // clipped, the point will be outside of the viewport. See crbug.com/416367. 1312 // clipped, the point will be outside of the viewport. See crbug.com/416367.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 (is_top(local_clip_region, quad) && is_left(local_clip_region, quad) && 1462 (is_top(local_clip_region, quad) && is_left(local_clip_region, quad) &&
1463 is_bottom(local_clip_region, quad) && is_right(local_clip_region, quad)); 1463 is_bottom(local_clip_region, quad) && is_right(local_clip_region, quad));
1464 1464
1465 bool use_aa_on_all_four_edges = 1465 bool use_aa_on_all_four_edges =
1466 !local_clip_region && region_contains_all_outside_edges; 1466 !local_clip_region && region_contains_all_outside_edges;
1467 1467
1468 gfx::QuadF device_quad; 1468 gfx::QuadF device_quad;
1469 if (use_aa_on_all_four_edges) { 1469 if (use_aa_on_all_four_edges) {
1470 device_quad = device_layer_edges.ToQuadF(); 1470 device_quad = device_layer_edges.ToQuadF();
1471 } else { 1471 } else {
1472 gfx::QuadF tile_quad(local_clip_region ? *local_clip_region 1472 gfx::QuadF tile_quad(local_clip_region
1473 : gfx::QuadF(quad->visible_rect)); 1473 ? *local_clip_region
1474 : gfx::QuadF(gfx::RectF(quad->visible_rect)));
1474 device_quad = GetDeviceQuadWithAntialiasingOnExteriorEdges( 1475 device_quad = GetDeviceQuadWithAntialiasingOnExteriorEdges(
1475 device_layer_edges, device_transform, tile_quad, local_clip_region, 1476 device_layer_edges, device_transform, tile_quad, local_clip_region,
1476 quad); 1477 quad);
1477 } 1478 }
1478 1479
1479 *local_quad = MapQuadToLocalSpace(device_transform, device_quad); 1480 *local_quad = MapQuadToLocalSpace(device_transform, device_quad);
1480 } 1481 }
1481 1482
1482 // static 1483 // static
1483 void GLRenderer::SetupRenderPassQuadForClippingAndAntialiasing( 1484 void GLRenderer::SetupRenderPassQuadForClippingAndAntialiasing(
(...skipping 16 matching lines...) Expand all
1500 return; 1501 return;
1501 } 1502 }
1502 1503
1503 LayerQuad device_layer_edges(*aa_quad); 1504 LayerQuad device_layer_edges(*aa_quad);
1504 InflateAntiAliasingDistances(*aa_quad, &device_layer_edges, edge); 1505 InflateAntiAliasingDistances(*aa_quad, &device_layer_edges, edge);
1505 1506
1506 gfx::QuadF device_quad; 1507 gfx::QuadF device_quad;
1507 1508
1508 // Apply anti-aliasing only to the edges that are not being clipped 1509 // Apply anti-aliasing only to the edges that are not being clipped
1509 if (local_clip_region) { 1510 if (local_clip_region) {
1510 gfx::QuadF tile_quad(quad->visible_rect); 1511 gfx::QuadF tile_quad(gfx::RectF(quad->visible_rect));
1511 GetScaledRegion(quad->rect, local_clip_region, &tile_quad); 1512 GetScaledRegion(quad->rect, local_clip_region, &tile_quad);
1512 device_quad = GetDeviceQuadWithAntialiasingOnExteriorEdges( 1513 device_quad = GetDeviceQuadWithAntialiasingOnExteriorEdges(
1513 device_layer_edges, device_transform, tile_quad, local_clip_region, 1514 device_layer_edges, device_transform, tile_quad, local_clip_region,
1514 quad); 1515 quad);
1515 } else { 1516 } else {
1516 device_quad = device_layer_edges.ToQuadF(); 1517 device_quad = device_layer_edges.ToQuadF();
1517 } 1518 }
1518 1519
1519 *local_quad = MapQuadToLocalSpace(device_transform, device_quad); 1520 *local_quad = MapQuadToLocalSpace(device_transform, device_quad);
1520 } 1521 }
(...skipping 24 matching lines...) Expand all
1545 gfx::QuadF device_layer_quad; 1546 gfx::QuadF device_layer_quad;
1546 bool use_aa = false; 1547 bool use_aa = false;
1547 bool allow_aa = settings_->allow_antialiasing && 1548 bool allow_aa = settings_->allow_antialiasing &&
1548 !quad->force_anti_aliasing_off && quad->IsEdge(); 1549 !quad->force_anti_aliasing_off && quad->IsEdge();
1549 1550
1550 if (allow_aa) { 1551 if (allow_aa) {
1551 bool clipped = false; 1552 bool clipped = false;
1552 bool force_aa = false; 1553 bool force_aa = false;
1553 device_layer_quad = MathUtil::MapQuad( 1554 device_layer_quad = MathUtil::MapQuad(
1554 device_transform, 1555 device_transform,
1555 gfx::QuadF(quad->shared_quad_state->visible_quad_layer_rect), &clipped); 1556 gfx::QuadF(
1557 gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)),
1558 &clipped);
1556 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa); 1559 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa);
1557 } 1560 }
1558 1561
1559 float edge[24]; 1562 float edge[24];
1560 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr; 1563 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr;
1561 SetupQuadForClippingAndAntialiasing(device_transform, quad, aa_quad, 1564 SetupQuadForClippingAndAntialiasing(device_transform, quad, aa_quad,
1562 clip_region, &local_quad, edge); 1565 clip_region, &local_quad, edge);
1563 1566
1564 SolidColorProgramUniforms uniforms; 1567 SolidColorProgramUniforms uniforms;
1565 if (use_aa) { 1568 if (use_aa) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 device_transform.FlattenTo2d(); 1666 device_transform.FlattenTo2d();
1664 1667
1665 gfx::QuadF device_layer_quad; 1668 gfx::QuadF device_layer_quad;
1666 bool use_aa = false; 1669 bool use_aa = false;
1667 bool allow_aa = settings_->allow_antialiasing && quad->IsEdge(); 1670 bool allow_aa = settings_->allow_antialiasing && quad->IsEdge();
1668 if (allow_aa) { 1671 if (allow_aa) {
1669 bool clipped = false; 1672 bool clipped = false;
1670 bool force_aa = false; 1673 bool force_aa = false;
1671 device_layer_quad = MathUtil::MapQuad( 1674 device_layer_quad = MathUtil::MapQuad(
1672 device_transform, 1675 device_transform,
1673 gfx::QuadF(quad->shared_quad_state->visible_quad_layer_rect), &clipped); 1676 gfx::QuadF(
1677 gfx::RectF(quad->shared_quad_state->visible_quad_layer_rect)),
1678 &clipped);
1674 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa); 1679 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa);
1675 } 1680 }
1676 1681
1677 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA 1682 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA
1678 // similar to the way DrawContentQuadNoAA works and then consider 1683 // similar to the way DrawContentQuadNoAA works and then consider
1679 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method. 1684 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method.
1680 if (use_aa) 1685 if (use_aa)
1681 DrawContentQuadAA(frame, quad, resource_id, device_transform, 1686 DrawContentQuadAA(frame, quad, resource_id, device_transform,
1682 device_layer_quad, clip_region); 1687 device_layer_quad, clip_region);
1683 else 1688 else
1684 DrawContentQuadNoAA(frame, quad, resource_id, clip_region); 1689 DrawContentQuadNoAA(frame, quad, resource_id, clip_region);
1685 } 1690 }
1686 1691
1687 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame, 1692 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame,
1688 const ContentDrawQuadBase* quad, 1693 const ContentDrawQuadBase* quad,
1689 ResourceId resource_id, 1694 ResourceId resource_id,
1690 const gfx::Transform& device_transform, 1695 const gfx::Transform& device_transform,
1691 const gfx::QuadF& aa_quad, 1696 const gfx::QuadF& aa_quad,
1692 const gfx::QuadF* clip_region) { 1697 const gfx::QuadF* clip_region) {
1693 if (!device_transform.IsInvertible()) 1698 if (!device_transform.IsInvertible())
1694 return; 1699 return;
1695 1700
1696 gfx::Rect tile_rect = quad->visible_rect; 1701 gfx::Rect tile_rect = quad->visible_rect;
1697 1702
1698 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1703 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1699 quad->tex_coord_rect, quad->rect, tile_rect); 1704 quad->tex_coord_rect, gfx::RectF(quad->rect), gfx::RectF(tile_rect));
1700 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1705 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
1701 float tex_to_geom_scale_y = 1706 float tex_to_geom_scale_y =
1702 quad->rect.height() / quad->tex_coord_rect.height(); 1707 quad->rect.height() / quad->tex_coord_rect.height();
1703 1708
1704 gfx::RectF clamp_geom_rect(tile_rect); 1709 gfx::RectF clamp_geom_rect(tile_rect);
1705 gfx::RectF clamp_tex_rect(tex_coord_rect); 1710 gfx::RectF clamp_tex_rect(tex_coord_rect);
1706 // Clamp texture coordinates to avoid sampling outside the layer 1711 // Clamp texture coordinates to avoid sampling outside the layer
1707 // by deflating the tile region half a texel or half a texel 1712 // by deflating the tile region half a texel or half a texel
1708 // minus epsilon for one pixel layers. The resulting clamp region 1713 // minus epsilon for one pixel layers. The resulting clamp region
1709 // is mapped to the unit square by the vertex shader and mapped 1714 // is mapped to the unit square by the vertex shader and mapped
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 tile_rect.size()); 1808 tile_rect.size());
1804 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 1809 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
1805 centered_rect, uniforms.matrix_location); 1810 centered_rect, uniforms.matrix_location);
1806 } 1811 }
1807 1812
1808 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, 1813 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame,
1809 const ContentDrawQuadBase* quad, 1814 const ContentDrawQuadBase* quad,
1810 ResourceId resource_id, 1815 ResourceId resource_id,
1811 const gfx::QuadF* clip_region) { 1816 const gfx::QuadF* clip_region) {
1812 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1817 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1813 quad->tex_coord_rect, quad->rect, quad->visible_rect); 1818 quad->tex_coord_rect, gfx::RectF(quad->rect),
1819 gfx::RectF(quad->visible_rect));
1814 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); 1820 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width();
1815 float tex_to_geom_scale_y = 1821 float tex_to_geom_scale_y =
1816 quad->rect.height() / quad->tex_coord_rect.height(); 1822 quad->rect.height() / quad->tex_coord_rect.height();
1817 1823
1818 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); 1824 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f);
1819 GLenum filter = (scaled || 1825 GLenum filter = (scaled ||
1820 !quad->shared_quad_state->quad_to_target_transform 1826 !quad->shared_quad_state->quad_to_target_transform
1821 .IsIdentityOrIntegerTranslation()) && 1827 .IsIdentityOrIntegerTranslation()) &&
1822 !quad->nearest_neighbor 1828 !quad->nearest_neighbor
1823 ? GL_LINEAR 1829 ? GL_LINEAR
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 vertex_tex_scale_y); 1879 vertex_tex_scale_y);
1874 1880
1875 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1881 SetBlendEnabled(quad->ShouldDrawWithBlending());
1876 1882
1877 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location); 1883 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location);
1878 1884
1879 // Pass quad coordinates to the uniform in the same order as GeometryBinding 1885 // Pass quad coordinates to the uniform in the same order as GeometryBinding
1880 // does, then vertices will match the texture mapping in the vertex buffer. 1886 // does, then vertices will match the texture mapping in the vertex buffer.
1881 // The method SetShaderQuadF() changes the order of vertices and so it's 1887 // The method SetShaderQuadF() changes the order of vertices and so it's
1882 // not used here. 1888 // not used here.
1883 gfx::QuadF tile_rect(quad->visible_rect); 1889 gfx::QuadF tile_quad(gfx::RectF(quad->visible_rect));
1884 float width = quad->visible_rect.width(); 1890 float width = quad->visible_rect.width();
1885 float height = quad->visible_rect.height(); 1891 float height = quad->visible_rect.height();
1886 gfx::PointF top_left = quad->visible_rect.origin(); 1892 gfx::PointF top_left = quad->visible_rect.origin();
1887 if (clip_region) { 1893 if (clip_region) {
1888 tile_rect = *clip_region; 1894 tile_quad = *clip_region;
1889 float gl_uv[8] = { 1895 float gl_uv[8] = {
1890 (tile_rect.p4().x() - top_left.x()) / width, 1896 (tile_quad.p4().x() - top_left.x()) / width,
1891 (tile_rect.p4().y() - top_left.y()) / height, 1897 (tile_quad.p4().y() - top_left.y()) / height,
1892 (tile_rect.p1().x() - top_left.x()) / width, 1898 (tile_quad.p1().x() - top_left.x()) / width,
1893 (tile_rect.p1().y() - top_left.y()) / height, 1899 (tile_quad.p1().y() - top_left.y()) / height,
1894 (tile_rect.p2().x() - top_left.x()) / width, 1900 (tile_quad.p2().x() - top_left.x()) / width,
1895 (tile_rect.p2().y() - top_left.y()) / height, 1901 (tile_quad.p2().y() - top_left.y()) / height,
1896 (tile_rect.p3().x() - top_left.x()) / width, 1902 (tile_quad.p3().x() - top_left.x()) / width,
1897 (tile_rect.p3().y() - top_left.y()) / height, 1903 (tile_quad.p3().y() - top_left.y()) / height,
1898 }; 1904 };
1899 PrepareGeometry(CLIPPED_BINDING); 1905 PrepareGeometry(CLIPPED_BINDING);
1900 clipped_geometry_->InitializeCustomQuadWithUVs( 1906 clipped_geometry_->InitializeCustomQuadWithUVs(
1901 gfx::QuadF(quad->visible_rect), gl_uv); 1907 gfx::QuadF(gfx::RectF(quad->visible_rect)), gl_uv);
1902 } else { 1908 } else {
1903 PrepareGeometry(SHARED_BINDING); 1909 PrepareGeometry(SHARED_BINDING);
1904 } 1910 }
1905 float gl_quad[8] = { 1911 float gl_quad[8] = {
1906 tile_rect.p4().x(), 1912 tile_quad.p4().x(), tile_quad.p4().y(), tile_quad.p1().x(),
1907 tile_rect.p4().y(), 1913 tile_quad.p1().y(), tile_quad.p2().x(), tile_quad.p2().y(),
1908 tile_rect.p1().x(), 1914 tile_quad.p3().x(), tile_quad.p3().y(),
1909 tile_rect.p1().y(),
1910 tile_rect.p2().x(),
1911 tile_rect.p2().y(),
1912 tile_rect.p3().x(),
1913 tile_rect.p3().y(),
1914 }; 1915 };
1915 gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad); 1916 gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad);
1916 1917
1917 static float gl_matrix[16]; 1918 static float gl_matrix[16];
1918 ToGLMatrix(&gl_matrix[0], 1919 ToGLMatrix(&gl_matrix[0],
1919 frame->projection_matrix * 1920 frame->projection_matrix *
1920 quad->shared_quad_state->quad_to_target_transform); 1921 quad->shared_quad_state->quad_to_target_transform);
1921 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]); 1922 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]);
1922 1923
1923 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); 1924 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 case YUVVideoDrawQuad::JPEG: 2111 case YUVVideoDrawQuad::JPEG:
2111 yuv_to_rgb = yuv_to_rgb_jpeg; 2112 yuv_to_rgb = yuv_to_rgb_jpeg;
2112 yuv_adjust = yuv_adjust_full; 2113 yuv_adjust = yuv_adjust_full;
2113 break; 2114 break;
2114 } 2115 }
2115 2116
2116 // The transform and vertex data are used to figure out the extents that the 2117 // The transform and vertex data are used to figure out the extents that the
2117 // un-antialiased quad should have and which vertex this is and the float 2118 // un-antialiased quad should have and which vertex this is and the float
2118 // quad passed in via uniform is the actual geometry that gets used to draw 2119 // quad passed in via uniform is the actual geometry that gets used to draw
2119 // it. This is why this centered rect is used and not the original quad_rect. 2120 // it. This is why this centered rect is used and not the original quad_rect.
2120 gfx::RectF tile_rect = quad->rect; 2121 gfx::RectF tile_rect = gfx::RectF(quad->rect);
2121 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb); 2122 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb);
2122 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust); 2123 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust);
2123 2124
2124 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location); 2125 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location);
2125 if (!clip_region) { 2126 if (!clip_region) {
2126 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 2127 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
2127 tile_rect, matrix_location); 2128 tile_rect, matrix_location);
2128 } else { 2129 } else {
2129 float uvs[8] = {0}; 2130 float uvs[8] = {0};
2130 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2131 GetScaledUVs(quad->visible_rect, clip_region, uvs);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 quad->resource_id()); 2163 quad->resource_id());
2163 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2164 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2164 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); 2165 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id());
2165 2166
2166 gl_->Uniform1i(program->fragment_shader().sampler_location(), 0); 2167 gl_->Uniform1i(program->fragment_shader().sampler_location(), 0);
2167 2168
2168 SetShaderOpacity(quad->shared_quad_state->opacity, 2169 SetShaderOpacity(quad->shared_quad_state->opacity,
2169 program->fragment_shader().alpha_location()); 2170 program->fragment_shader().alpha_location());
2170 if (!clip_region) { 2171 if (!clip_region) {
2171 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 2172 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
2172 quad->rect, program->vertex_shader().matrix_location()); 2173 gfx::RectF(quad->rect),
2174 program->vertex_shader().matrix_location());
2173 } else { 2175 } else {
2174 gfx::QuadF region_quad(*clip_region); 2176 gfx::QuadF region_quad(*clip_region);
2175 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height()); 2177 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height());
2176 region_quad -= gfx::Vector2dF(0.5f, 0.5f); 2178 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
2177 float uvs[8] = {0}; 2179 float uvs[8] = {0};
2178 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2180 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2179 DrawQuadGeometryClippedByQuadF( 2181 DrawQuadGeometryClippedByQuadF(
2180 frame, quad->shared_quad_state->quad_to_target_transform, quad->rect, 2182 frame, quad->shared_quad_state->quad_to_target_transform,
2181 region_quad, program->vertex_shader().matrix_location(), uvs); 2183 gfx::RectF(quad->rect), region_quad,
2184 program->vertex_shader().matrix_location(), uvs);
2182 } 2185 }
2183 } 2186 }
2184 2187
2185 struct TextureProgramBinding { 2188 struct TextureProgramBinding {
2186 template <class Program> 2189 template <class Program>
2187 void Set(Program* program) { 2190 void Set(Program* program) {
2188 DCHECK(program); 2191 DCHECK(program);
2189 program_id = program->program(); 2192 program_id = program->program();
2190 sampler_location = program->fragment_shader().sampler_location(); 2193 sampler_location = program->fragment_shader().sampler_location();
2191 matrix_location = program->vertex_shader().matrix_location(); 2194 matrix_location = program->vertex_shader().matrix_location();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 const float opacity = quad->shared_quad_state->opacity; 2354 const float opacity = quad->shared_quad_state->opacity;
2352 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); 2355 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity);
2353 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity); 2356 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity);
2354 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity); 2357 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity);
2355 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity); 2358 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity);
2356 2359
2357 // Generate the transform matrix 2360 // Generate the transform matrix
2358 gfx::Transform quad_rect_matrix; 2361 gfx::Transform quad_rect_matrix;
2359 QuadRectTransform(&quad_rect_matrix, 2362 QuadRectTransform(&quad_rect_matrix,
2360 quad->shared_quad_state->quad_to_target_transform, 2363 quad->shared_quad_state->quad_to_target_transform,
2361 quad->rect); 2364 gfx::RectF(quad->rect));
2362 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; 2365 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix;
2363 2366
2364 Float16 m; 2367 Float16 m;
2365 quad_rect_matrix.matrix().asColMajorf(m.data); 2368 quad_rect_matrix.matrix().asColMajorf(m.data);
2366 draw_cache_.matrix_data.push_back(m); 2369 draw_cache_.matrix_data.push_back(m);
2367 2370
2368 if (clip_region) { 2371 if (clip_region) {
2369 gfx::QuadF scaled_region; 2372 gfx::QuadF scaled_region;
2370 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) { 2373 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) {
2371 scaled_region = SharedGeometryQuad().BoundingBox(); 2374 scaled_region = SharedGeometryQuad().BoundingBox();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 quad->shared_quad_state->opacity}; 2420 quad->shared_quad_state->opacity};
2418 gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity); 2421 gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity);
2419 2422
2420 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2423 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2421 quad->io_surface_resource_id()); 2424 quad->io_surface_resource_id());
2422 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2425 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2423 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()); 2426 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id());
2424 2427
2425 if (!clip_region) { 2428 if (!clip_region) {
2426 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 2429 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
2427 quad->rect, binding.matrix_location); 2430 gfx::RectF(quad->rect), binding.matrix_location);
2428 } else { 2431 } else {
2429 float uvs[8] = {0}; 2432 float uvs[8] = {0};
2430 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2433 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2431 DrawQuadGeometryClippedByQuadF( 2434 DrawQuadGeometryClippedByQuadF(
2432 frame, quad->shared_quad_state->quad_to_target_transform, quad->rect, 2435 frame, quad->shared_quad_state->quad_to_target_transform,
2433 *clip_region, binding.matrix_location, uvs); 2436 gfx::RectF(quad->rect), *clip_region, binding.matrix_location, uvs);
2434 } 2437 }
2435 2438
2436 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); 2439 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
2437 } 2440 }
2438 2441
2439 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 2442 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
2440 if (use_sync_query_) { 2443 if (use_sync_query_) {
2441 DCHECK(current_sync_query_); 2444 DCHECK(current_sync_query_);
2442 current_sync_query_->End(); 2445 current_sync_query_->End();
2443 pending_sync_queries_.push_back(current_sync_query_.Pass()); 2446 pending_sync_queries_.push_back(current_sync_query_.Pass());
2444 } 2447 }
2445 2448
2446 current_framebuffer_lock_ = nullptr; 2449 current_framebuffer_lock_ = nullptr;
2447 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); 2450 swap_buffer_rect_.Union(frame->root_damage_rect);
2448 2451
2449 gl_->Disable(GL_BLEND); 2452 gl_->Disable(GL_BLEND);
2450 blend_shadow_ = false; 2453 blend_shadow_ = false;
2451 2454
2452 ScheduleOverlays(frame); 2455 ScheduleOverlays(frame);
2453 } 2456 }
2454 2457
2455 void GLRenderer::FinishDrawingQuadList() { 2458 void GLRenderer::FinishDrawingQuadList() {
2456 FlushTextureQuadCache(SHARED_BINDING); 2459 FlushTextureQuadCache(SHARED_BINDING);
2457 } 2460 }
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 context_support_->ScheduleOverlayPlane( 3528 context_support_->ScheduleOverlayPlane(
3526 overlay.plane_z_order, 3529 overlay.plane_z_order,
3527 overlay.transform, 3530 overlay.transform,
3528 pending_overlay_resources_.back()->texture_id(), 3531 pending_overlay_resources_.back()->texture_id(),
3529 ToNearestRect(overlay.display_rect), 3532 ToNearestRect(overlay.display_rect),
3530 overlay.uv_rect); 3533 overlay.uv_rect);
3531 } 3534 }
3532 } 3535 }
3533 3536
3534 } // namespace cc 3537 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698