| OLD | NEW |
| 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 static_cast<int>(tile_rect.y() / quad->scale) % kCheckerboardWidth; | 592 static_cast<int>(tile_rect.y() / quad->scale) % kCheckerboardWidth; |
| 593 float tex_scale_x = tile_rect.width() / quad->scale; | 593 float tex_scale_x = tile_rect.width() / quad->scale; |
| 594 float tex_scale_y = tile_rect.height() / quad->scale; | 594 float tex_scale_y = tile_rect.height() / quad->scale; |
| 595 gl_->Uniform4f(program->fragment_shader().tex_transform_location(), | 595 gl_->Uniform4f(program->fragment_shader().tex_transform_location(), |
| 596 tex_offset_x, tex_offset_y, tex_scale_x, tex_scale_y); | 596 tex_offset_x, tex_offset_y, tex_scale_x, tex_scale_y); |
| 597 | 597 |
| 598 gl_->Uniform1f(program->fragment_shader().frequency_location(), frequency); | 598 gl_->Uniform1f(program->fragment_shader().frequency_location(), frequency); |
| 599 | 599 |
| 600 SetShaderOpacity(quad->shared_quad_state->opacity, | 600 SetShaderOpacity(quad->shared_quad_state->opacity, |
| 601 program->fragment_shader().alpha_location()); | 601 program->fragment_shader().alpha_location()); |
| 602 DrawQuadGeometry(frame, quad->shared_quad_state->content_to_target_transform, | 602 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 603 quad->rect, program->vertex_shader().matrix_location()); | 603 quad->rect, program->vertex_shader().matrix_location()); |
| 604 } | 604 } |
| 605 | 605 |
| 606 // This function does not handle 3D sorting right now, since the debug border | 606 // This function does not handle 3D sorting right now, since the debug border |
| 607 // quads are just drawn as their original quads and not in split pieces. This | 607 // quads are just drawn as their original quads and not in split pieces. This |
| 608 // results in some debug border quads drawing over foreground quads. | 608 // results in some debug border quads drawing over foreground quads. |
| 609 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, | 609 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, |
| 610 const DebugBorderDrawQuad* quad) { | 610 const DebugBorderDrawQuad* quad) { |
| 611 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 611 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 612 | 612 |
| 613 static float gl_matrix[16]; | 613 static float gl_matrix[16]; |
| 614 const DebugBorderProgram* program = GetDebugBorderProgram(); | 614 const DebugBorderProgram* program = GetDebugBorderProgram(); |
| 615 DCHECK(program && (program->initialized() || IsContextLost())); | 615 DCHECK(program && (program->initialized() || IsContextLost())); |
| 616 SetUseProgram(program->program()); | 616 SetUseProgram(program->program()); |
| 617 | 617 |
| 618 // Use the full quad_rect for debug quads to not move the edges based on | 618 // Use the full quad_rect for debug quads to not move the edges based on |
| 619 // partial swaps. | 619 // partial swaps. |
| 620 gfx::Rect layer_rect = quad->rect; | 620 gfx::Rect layer_rect = quad->rect; |
| 621 gfx::Transform render_matrix; | 621 gfx::Transform render_matrix; |
| 622 QuadRectTransform(&render_matrix, | 622 QuadRectTransform(&render_matrix, |
| 623 quad->shared_quad_state->content_to_target_transform, | 623 quad->shared_quad_state->quad_to_target_transform, |
| 624 layer_rect); | 624 layer_rect); |
| 625 GLRenderer::ToGLMatrix(&gl_matrix[0], | 625 GLRenderer::ToGLMatrix(&gl_matrix[0], |
| 626 frame->projection_matrix * render_matrix); | 626 frame->projection_matrix * render_matrix); |
| 627 gl_->UniformMatrix4fv(program->vertex_shader().matrix_location(), 1, false, | 627 gl_->UniformMatrix4fv(program->vertex_shader().matrix_location(), 1, false, |
| 628 &gl_matrix[0]); | 628 &gl_matrix[0]); |
| 629 | 629 |
| 630 SkColor color = quad->color; | 630 SkColor color = quad->color; |
| 631 float alpha = SkColorGetA(color) * (1.0f / 255.0f); | 631 float alpha = SkColorGetA(color) * (1.0f / 255.0f); |
| 632 | 632 |
| 633 gl_->Uniform4f(program->fragment_shader().color_location(), | 633 gl_->Uniform4f(program->fragment_shader().color_location(), |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, | 920 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, |
| 921 const RenderPassDrawQuad* quad, | 921 const RenderPassDrawQuad* quad, |
| 922 const gfx::QuadF* clip_region) { | 922 const gfx::QuadF* clip_region) { |
| 923 ScopedResource* contents_texture = | 923 ScopedResource* contents_texture = |
| 924 render_pass_textures_.get(quad->render_pass_id); | 924 render_pass_textures_.get(quad->render_pass_id); |
| 925 DCHECK(contents_texture); | 925 DCHECK(contents_texture); |
| 926 DCHECK(contents_texture->id()); | 926 DCHECK(contents_texture->id()); |
| 927 | 927 |
| 928 gfx::Transform quad_rect_matrix; | 928 gfx::Transform quad_rect_matrix; |
| 929 QuadRectTransform(&quad_rect_matrix, | 929 QuadRectTransform(&quad_rect_matrix, |
| 930 quad->shared_quad_state->content_to_target_transform, | 930 quad->shared_quad_state->quad_to_target_transform, |
| 931 quad->rect); | 931 quad->rect); |
| 932 gfx::Transform contents_device_transform = | 932 gfx::Transform contents_device_transform = |
| 933 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; | 933 frame->window_matrix * frame->projection_matrix * quad_rect_matrix; |
| 934 contents_device_transform.FlattenTo2d(); | 934 contents_device_transform.FlattenTo2d(); |
| 935 | 935 |
| 936 // Can only draw surface if device matrix is invertible. | 936 // Can only draw surface if device matrix is invertible. |
| 937 if (!contents_device_transform.IsInvertible()) | 937 if (!contents_device_transform.IsInvertible()) |
| 938 return; | 938 return; |
| 939 | 939 |
| 940 gfx::QuadF surface_quad = SharedGeometryQuad(); | 940 gfx::QuadF surface_quad = SharedGeometryQuad(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 if (!use_shaders_for_blending) { | 1076 if (!use_shaders_for_blending) { |
| 1077 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) | 1077 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) |
| 1078 gl_->BlendBarrierKHR(); | 1078 gl_->BlendBarrierKHR(); |
| 1079 | 1079 |
| 1080 ApplyBlendModeUsingBlendFunc(blend_mode); | 1080 ApplyBlendModeUsingBlendFunc(blend_mode); |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1083 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 1084 gl_, | 1084 gl_, &highp_threshold_cache_, highp_threshold_min_, |
| 1085 &highp_threshold_cache_, | 1085 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); |
| 1086 highp_threshold_min_, | |
| 1087 quad->shared_quad_state->visible_content_rect.bottom_right()); | |
| 1088 | 1086 |
| 1089 ShaderLocations locations; | 1087 ShaderLocations locations; |
| 1090 | 1088 |
| 1091 DCHECK_EQ(background_texture || background_image_id, | 1089 DCHECK_EQ(background_texture || background_image_id, |
| 1092 use_shaders_for_blending); | 1090 use_shaders_for_blending); |
| 1093 BlendMode shader_blend_mode = use_shaders_for_blending | 1091 BlendMode shader_blend_mode = use_shaders_for_blending |
| 1094 ? BlendModeFromSkXfermode(blend_mode) | 1092 ? BlendModeFromSkXfermode(blend_mode) |
| 1095 : BLEND_MODE_NONE; | 1093 : BLEND_MODE_NONE; |
| 1096 | 1094 |
| 1097 if (use_aa && mask_texture_id && !use_color_matrix) { | 1095 if (use_aa && mask_texture_id && !use_color_matrix) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 background_texture->id(), | 1249 background_texture->id(), |
| 1252 GL_TEXTURE0 + last_texture_unit, | 1250 GL_TEXTURE0 + last_texture_unit, |
| 1253 GL_LINEAR)); | 1251 GL_LINEAR)); |
| 1254 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1252 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1255 shader_background_sampler_lock->target()); | 1253 shader_background_sampler_lock->target()); |
| 1256 } | 1254 } |
| 1257 } | 1255 } |
| 1258 | 1256 |
| 1259 SetShaderOpacity(quad->shared_quad_state->opacity, locations.alpha); | 1257 SetShaderOpacity(quad->shared_quad_state->opacity, locations.alpha); |
| 1260 SetShaderQuadF(surface_quad, locations.quad); | 1258 SetShaderQuadF(surface_quad, locations.quad); |
| 1261 DrawQuadGeometry(frame, quad->shared_quad_state->content_to_target_transform, | 1259 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 1262 quad->rect, locations.matrix); | 1260 quad->rect, locations.matrix); |
| 1263 | 1261 |
| 1264 // Flush the compositor context before the filter bitmap goes out of | 1262 // Flush the compositor context before the filter bitmap goes out of |
| 1265 // scope, so the draw gets processed before the filter texture gets deleted. | 1263 // scope, so the draw gets processed before the filter texture gets deleted. |
| 1266 if (filter_image_id) | 1264 if (filter_image_id) |
| 1267 gl_->Flush(); | 1265 gl_->Flush(); |
| 1268 | 1266 |
| 1269 if (!use_shaders_for_blending) | 1267 if (!use_shaders_for_blending) |
| 1270 RestoreBlendFuncToDefault(blend_mode); | 1268 RestoreBlendFuncToDefault(blend_mode); |
| 1271 } | 1269 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 std::abs(clip_region->p2().y()) < kAntiAliasingEpsilon; | 1301 std::abs(clip_region->p2().y()) < kAntiAliasingEpsilon; |
| 1304 } | 1302 } |
| 1305 | 1303 |
| 1306 bool is_bottom(const gfx::QuadF* clip_region, const DrawQuad* quad) { | 1304 bool is_bottom(const gfx::QuadF* clip_region, const DrawQuad* quad) { |
| 1307 if (!quad->IsBottomEdge()) | 1305 if (!quad->IsBottomEdge()) |
| 1308 return false; | 1306 return false; |
| 1309 if (!clip_region) | 1307 if (!clip_region) |
| 1310 return true; | 1308 return true; |
| 1311 | 1309 |
| 1312 return std::abs(clip_region->p3().y() - | 1310 return std::abs(clip_region->p3().y() - |
| 1313 quad->shared_quad_state->content_bounds.height()) < | 1311 quad->shared_quad_state->quad_layer_bounds.height()) < |
| 1314 kAntiAliasingEpsilon && | 1312 kAntiAliasingEpsilon && |
| 1315 std::abs(clip_region->p4().y() - | 1313 std::abs(clip_region->p4().y() - |
| 1316 quad->shared_quad_state->content_bounds.height()) < | 1314 quad->shared_quad_state->quad_layer_bounds.height()) < |
| 1317 kAntiAliasingEpsilon; | 1315 kAntiAliasingEpsilon; |
| 1318 } | 1316 } |
| 1319 | 1317 |
| 1320 bool is_left(const gfx::QuadF* clip_region, const DrawQuad* quad) { | 1318 bool is_left(const gfx::QuadF* clip_region, const DrawQuad* quad) { |
| 1321 if (!quad->IsLeftEdge()) | 1319 if (!quad->IsLeftEdge()) |
| 1322 return false; | 1320 return false; |
| 1323 if (!clip_region) | 1321 if (!clip_region) |
| 1324 return true; | 1322 return true; |
| 1325 | 1323 |
| 1326 return std::abs(clip_region->p1().x()) < kAntiAliasingEpsilon && | 1324 return std::abs(clip_region->p1().x()) < kAntiAliasingEpsilon && |
| 1327 std::abs(clip_region->p4().x()) < kAntiAliasingEpsilon; | 1325 std::abs(clip_region->p4().x()) < kAntiAliasingEpsilon; |
| 1328 } | 1326 } |
| 1329 | 1327 |
| 1330 bool is_right(const gfx::QuadF* clip_region, const DrawQuad* quad) { | 1328 bool is_right(const gfx::QuadF* clip_region, const DrawQuad* quad) { |
| 1331 if (!quad->IsRightEdge()) | 1329 if (!quad->IsRightEdge()) |
| 1332 return false; | 1330 return false; |
| 1333 if (!clip_region) | 1331 if (!clip_region) |
| 1334 return true; | 1332 return true; |
| 1335 | 1333 |
| 1336 return std::abs(clip_region->p2().x() - | 1334 return std::abs(clip_region->p2().x() - |
| 1337 quad->shared_quad_state->content_bounds.width()) < | 1335 quad->shared_quad_state->quad_layer_bounds.width()) < |
| 1338 kAntiAliasingEpsilon && | 1336 kAntiAliasingEpsilon && |
| 1339 std::abs(clip_region->p3().x() - | 1337 std::abs(clip_region->p3().x() - |
| 1340 quad->shared_quad_state->content_bounds.width()) < | 1338 quad->shared_quad_state->quad_layer_bounds.width()) < |
| 1341 kAntiAliasingEpsilon; | 1339 kAntiAliasingEpsilon; |
| 1342 } | 1340 } |
| 1343 } // anonymous namespace | 1341 } // anonymous namespace |
| 1344 | 1342 |
| 1345 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges( | 1343 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges( |
| 1346 const LayerQuad& device_layer_edges, | 1344 const LayerQuad& device_layer_edges, |
| 1347 const gfx::Transform& device_transform, | 1345 const gfx::Transform& device_transform, |
| 1348 const gfx::QuadF& tile_quad, | 1346 const gfx::QuadF& tile_quad, |
| 1349 const gfx::QuadF* clip_region, | 1347 const gfx::QuadF* clip_region, |
| 1350 const DrawQuad* quad) { | 1348 const DrawQuad* quad) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 float opacity = quad->shared_quad_state->opacity; | 1575 float opacity = quad->shared_quad_state->opacity; |
| 1578 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; | 1576 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; |
| 1579 | 1577 |
| 1580 // Early out if alpha is small enough that quad doesn't contribute to output. | 1578 // Early out if alpha is small enough that quad doesn't contribute to output. |
| 1581 if (alpha < std::numeric_limits<float>::epsilon() && | 1579 if (alpha < std::numeric_limits<float>::epsilon() && |
| 1582 quad->ShouldDrawWithBlending()) | 1580 quad->ShouldDrawWithBlending()) |
| 1583 return; | 1581 return; |
| 1584 | 1582 |
| 1585 gfx::Transform device_transform = | 1583 gfx::Transform device_transform = |
| 1586 frame->window_matrix * frame->projection_matrix * | 1584 frame->window_matrix * frame->projection_matrix * |
| 1587 quad->shared_quad_state->content_to_target_transform; | 1585 quad->shared_quad_state->quad_to_target_transform; |
| 1588 device_transform.FlattenTo2d(); | 1586 device_transform.FlattenTo2d(); |
| 1589 if (!device_transform.IsInvertible()) | 1587 if (!device_transform.IsInvertible()) |
| 1590 return; | 1588 return; |
| 1591 | 1589 |
| 1592 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); | 1590 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); |
| 1593 | 1591 |
| 1594 gfx::QuadF device_layer_quad; | 1592 gfx::QuadF device_layer_quad; |
| 1595 bool use_aa = false; | 1593 bool use_aa = false; |
| 1596 bool allow_aa = settings_->allow_antialiasing && | 1594 bool allow_aa = settings_->allow_antialiasing && |
| 1597 !quad->force_anti_aliasing_off && quad->IsEdge(); | 1595 !quad->force_anti_aliasing_off && quad->IsEdge(); |
| 1598 | 1596 |
| 1599 if (allow_aa) { | 1597 if (allow_aa) { |
| 1600 bool clipped = false; | 1598 bool clipped = false; |
| 1601 bool force_aa = false; | 1599 bool force_aa = false; |
| 1602 device_layer_quad = MathUtil::MapQuad( | 1600 device_layer_quad = MathUtil::MapQuad( |
| 1603 device_transform, | 1601 device_transform, |
| 1604 gfx::QuadF(quad->shared_quad_state->visible_content_rect), &clipped); | 1602 gfx::QuadF(quad->shared_quad_state->visible_quad_layer_rect), &clipped); |
| 1605 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa); | 1603 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa); |
| 1606 } | 1604 } |
| 1607 | 1605 |
| 1608 float edge[24]; | 1606 float edge[24]; |
| 1609 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr; | 1607 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr; |
| 1610 SetupQuadForClippingAndAntialiasing(device_transform, quad, aa_quad, | 1608 SetupQuadForClippingAndAntialiasing(device_transform, quad, aa_quad, |
| 1611 clip_region, &local_quad, edge); | 1609 clip_region, &local_quad, edge); |
| 1612 | 1610 |
| 1613 SolidColorProgramUniforms uniforms; | 1611 SolidColorProgramUniforms uniforms; |
| 1614 if (use_aa) { | 1612 if (use_aa) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1642 | 1640 |
| 1643 SetShaderQuadF(local_quad, uniforms.quad_location); | 1641 SetShaderQuadF(local_quad, uniforms.quad_location); |
| 1644 | 1642 |
| 1645 // The transform and vertex data are used to figure out the extents that the | 1643 // The transform and vertex data are used to figure out the extents that the |
| 1646 // un-antialiased quad should have and which vertex this is and the float | 1644 // un-antialiased quad should have and which vertex this is and the float |
| 1647 // quad passed in via uniform is the actual geometry that gets used to draw | 1645 // quad passed in via uniform is the actual geometry that gets used to draw |
| 1648 // it. This is why this centered rect is used and not the original quad_rect. | 1646 // it. This is why this centered rect is used and not the original quad_rect. |
| 1649 gfx::RectF centered_rect( | 1647 gfx::RectF centered_rect( |
| 1650 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), | 1648 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), |
| 1651 tile_rect.size()); | 1649 tile_rect.size()); |
| 1652 DrawQuadGeometry(frame, quad->shared_quad_state->content_to_target_transform, | 1650 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 1653 centered_rect, uniforms.matrix_location); | 1651 centered_rect, uniforms.matrix_location); |
| 1654 } | 1652 } |
| 1655 | 1653 |
| 1656 struct TileProgramUniforms { | 1654 struct TileProgramUniforms { |
| 1657 unsigned program; | 1655 unsigned program; |
| 1658 unsigned matrix_location; | 1656 unsigned matrix_location; |
| 1659 unsigned viewport_location; | 1657 unsigned viewport_location; |
| 1660 unsigned quad_location; | 1658 unsigned quad_location; |
| 1661 unsigned edge_location; | 1659 unsigned edge_location; |
| 1662 unsigned vertex_tex_transform_location; | 1660 unsigned vertex_tex_transform_location; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1686 const gfx::QuadF* clip_region) { | 1684 const gfx::QuadF* clip_region) { |
| 1687 DrawContentQuad(frame, quad, quad->resource_id(), clip_region); | 1685 DrawContentQuad(frame, quad, quad->resource_id(), clip_region); |
| 1688 } | 1686 } |
| 1689 | 1687 |
| 1690 void GLRenderer::DrawContentQuad(const DrawingFrame* frame, | 1688 void GLRenderer::DrawContentQuad(const DrawingFrame* frame, |
| 1691 const ContentDrawQuadBase* quad, | 1689 const ContentDrawQuadBase* quad, |
| 1692 ResourceId resource_id, | 1690 ResourceId resource_id, |
| 1693 const gfx::QuadF* clip_region) { | 1691 const gfx::QuadF* clip_region) { |
| 1694 gfx::Transform device_transform = | 1692 gfx::Transform device_transform = |
| 1695 frame->window_matrix * frame->projection_matrix * | 1693 frame->window_matrix * frame->projection_matrix * |
| 1696 quad->shared_quad_state->content_to_target_transform; | 1694 quad->shared_quad_state->quad_to_target_transform; |
| 1697 device_transform.FlattenTo2d(); | 1695 device_transform.FlattenTo2d(); |
| 1698 | 1696 |
| 1699 gfx::QuadF device_layer_quad; | 1697 gfx::QuadF device_layer_quad; |
| 1700 bool use_aa = false; | 1698 bool use_aa = false; |
| 1701 bool allow_aa = settings_->allow_antialiasing && quad->IsEdge(); | 1699 bool allow_aa = settings_->allow_antialiasing && quad->IsEdge(); |
| 1702 if (allow_aa) { | 1700 if (allow_aa) { |
| 1703 bool clipped = false; | 1701 bool clipped = false; |
| 1704 bool force_aa = false; | 1702 bool force_aa = false; |
| 1705 device_layer_quad = MathUtil::MapQuad( | 1703 device_layer_quad = MathUtil::MapQuad( |
| 1706 device_transform, | 1704 device_transform, |
| 1707 gfx::QuadF(quad->shared_quad_state->visible_content_rect), &clipped); | 1705 gfx::QuadF(quad->shared_quad_state->visible_quad_layer_rect), &clipped); |
| 1708 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa); | 1706 use_aa = ShouldAntialiasQuad(device_layer_quad, clipped, force_aa); |
| 1709 } | 1707 } |
| 1710 | 1708 |
| 1711 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA | 1709 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA |
| 1712 // similar to the way DrawContentQuadNoAA works and then consider | 1710 // similar to the way DrawContentQuadNoAA works and then consider |
| 1713 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method. | 1711 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method. |
| 1714 if (use_aa) | 1712 if (use_aa) |
| 1715 DrawContentQuadAA(frame, quad, resource_id, device_transform, | 1713 DrawContentQuadAA(frame, quad, resource_id, device_transform, |
| 1716 device_layer_quad, clip_region); | 1714 device_layer_quad, clip_region); |
| 1717 else | 1715 else |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location); | 1826 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location); |
| 1829 SetShaderQuadF(local_quad, uniforms.quad_location); | 1827 SetShaderQuadF(local_quad, uniforms.quad_location); |
| 1830 | 1828 |
| 1831 // The transform and vertex data are used to figure out the extents that the | 1829 // The transform and vertex data are used to figure out the extents that the |
| 1832 // un-antialiased quad should have and which vertex this is and the float | 1830 // un-antialiased quad should have and which vertex this is and the float |
| 1833 // quad passed in via uniform is the actual geometry that gets used to draw | 1831 // quad passed in via uniform is the actual geometry that gets used to draw |
| 1834 // it. This is why this centered rect is used and not the original quad_rect. | 1832 // it. This is why this centered rect is used and not the original quad_rect. |
| 1835 gfx::RectF centered_rect( | 1833 gfx::RectF centered_rect( |
| 1836 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), | 1834 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), |
| 1837 tile_rect.size()); | 1835 tile_rect.size()); |
| 1838 DrawQuadGeometry(frame, quad->shared_quad_state->content_to_target_transform, | 1836 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 1839 centered_rect, uniforms.matrix_location); | 1837 centered_rect, uniforms.matrix_location); |
| 1840 } | 1838 } |
| 1841 | 1839 |
| 1842 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, | 1840 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, |
| 1843 const ContentDrawQuadBase* quad, | 1841 const ContentDrawQuadBase* quad, |
| 1844 ResourceId resource_id, | 1842 ResourceId resource_id, |
| 1845 const gfx::QuadF* clip_region) { | 1843 const gfx::QuadF* clip_region) { |
| 1846 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( | 1844 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( |
| 1847 quad->tex_coord_rect, quad->rect, quad->visible_rect); | 1845 quad->tex_coord_rect, quad->rect, quad->visible_rect); |
| 1848 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); | 1846 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); |
| 1849 float tex_to_geom_scale_y = | 1847 float tex_to_geom_scale_y = |
| 1850 quad->rect.height() / quad->tex_coord_rect.height(); | 1848 quad->rect.height() / quad->tex_coord_rect.height(); |
| 1851 | 1849 |
| 1852 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); | 1850 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); |
| 1853 GLenum filter = (scaled || | 1851 GLenum filter = (scaled || |
| 1854 !quad->shared_quad_state->content_to_target_transform | 1852 !quad->shared_quad_state->quad_to_target_transform |
| 1855 .IsIdentityOrIntegerTranslation()) && | 1853 .IsIdentityOrIntegerTranslation()) && |
| 1856 !quad->nearest_neighbor | 1854 !quad->nearest_neighbor |
| 1857 ? GL_LINEAR | 1855 ? GL_LINEAR |
| 1858 : GL_NEAREST; | 1856 : GL_NEAREST; |
| 1859 | 1857 |
| 1860 ResourceProvider::ScopedSamplerGL quad_resource_lock( | 1858 ResourceProvider::ScopedSamplerGL quad_resource_lock( |
| 1861 resource_provider_, resource_id, filter); | 1859 resource_provider_, resource_id, filter); |
| 1862 SamplerType sampler = | 1860 SamplerType sampler = |
| 1863 SamplerTypeFromTextureTarget(quad_resource_lock.target()); | 1861 SamplerTypeFromTextureTarget(quad_resource_lock.target()); |
| 1864 | 1862 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1944 tile_rect.p2().x(), | 1942 tile_rect.p2().x(), |
| 1945 tile_rect.p2().y(), | 1943 tile_rect.p2().y(), |
| 1946 tile_rect.p3().x(), | 1944 tile_rect.p3().x(), |
| 1947 tile_rect.p3().y(), | 1945 tile_rect.p3().y(), |
| 1948 }; | 1946 }; |
| 1949 gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad); | 1947 gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad); |
| 1950 | 1948 |
| 1951 static float gl_matrix[16]; | 1949 static float gl_matrix[16]; |
| 1952 ToGLMatrix(&gl_matrix[0], | 1950 ToGLMatrix(&gl_matrix[0], |
| 1953 frame->projection_matrix * | 1951 frame->projection_matrix * |
| 1954 quad->shared_quad_state->content_to_target_transform); | 1952 quad->shared_quad_state->quad_to_target_transform); |
| 1955 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]); | 1953 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]); |
| 1956 | 1954 |
| 1957 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); | 1955 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); |
| 1958 } | 1956 } |
| 1959 | 1957 |
| 1960 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, | 1958 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, |
| 1961 const YUVVideoDrawQuad* quad, | 1959 const YUVVideoDrawQuad* quad, |
| 1962 const gfx::QuadF* clip_region) { | 1960 const gfx::QuadF* clip_region) { |
| 1963 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1961 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1964 | 1962 |
| 1965 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1963 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 1966 gl_, | 1964 gl_, &highp_threshold_cache_, highp_threshold_min_, |
| 1967 &highp_threshold_cache_, | 1965 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); |
| 1968 highp_threshold_min_, | |
| 1969 quad->shared_quad_state->visible_content_rect.bottom_right()); | |
| 1970 | 1966 |
| 1971 bool use_alpha_plane = quad->a_plane_resource_id() != 0; | 1967 bool use_alpha_plane = quad->a_plane_resource_id() != 0; |
| 1972 | 1968 |
| 1973 ResourceProvider::ScopedSamplerGL y_plane_lock( | 1969 ResourceProvider::ScopedSamplerGL y_plane_lock( |
| 1974 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR); | 1970 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR); |
| 1975 ResourceProvider::ScopedSamplerGL u_plane_lock( | 1971 ResourceProvider::ScopedSamplerGL u_plane_lock( |
| 1976 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR); | 1972 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR); |
| 1977 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target()); | 1973 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target()); |
| 1978 ResourceProvider::ScopedSamplerGL v_plane_lock( | 1974 ResourceProvider::ScopedSamplerGL v_plane_lock( |
| 1979 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, GL_LINEAR); | 1975 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, GL_LINEAR); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 // The transform and vertex data are used to figure out the extents that the | 2148 // The transform and vertex data are used to figure out the extents that the |
| 2153 // un-antialiased quad should have and which vertex this is and the float | 2149 // un-antialiased quad should have and which vertex this is and the float |
| 2154 // quad passed in via uniform is the actual geometry that gets used to draw | 2150 // quad passed in via uniform is the actual geometry that gets used to draw |
| 2155 // it. This is why this centered rect is used and not the original quad_rect. | 2151 // it. This is why this centered rect is used and not the original quad_rect. |
| 2156 gfx::RectF tile_rect = quad->rect; | 2152 gfx::RectF tile_rect = quad->rect; |
| 2157 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb); | 2153 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb); |
| 2158 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust); | 2154 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust); |
| 2159 | 2155 |
| 2160 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location); | 2156 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location); |
| 2161 if (!clip_region) { | 2157 if (!clip_region) { |
| 2162 DrawQuadGeometry(frame, | 2158 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 2163 quad->shared_quad_state->content_to_target_transform, | |
| 2164 tile_rect, matrix_location); | 2159 tile_rect, matrix_location); |
| 2165 } else { | 2160 } else { |
| 2166 float uvs[8] = {0}; | 2161 float uvs[8] = {0}; |
| 2167 GetScaledUVs(quad->visible_rect, clip_region, uvs); | 2162 GetScaledUVs(quad->visible_rect, clip_region, uvs); |
| 2168 gfx::QuadF region_quad = *clip_region; | 2163 gfx::QuadF region_quad = *clip_region; |
| 2169 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); | 2164 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); |
| 2170 region_quad -= gfx::Vector2dF(0.5f, 0.5f); | 2165 region_quad -= gfx::Vector2dF(0.5f, 0.5f); |
| 2171 DrawQuadGeometryClippedByQuadF( | 2166 DrawQuadGeometryClippedByQuadF( |
| 2172 frame, quad->shared_quad_state->content_to_target_transform, tile_rect, | 2167 frame, quad->shared_quad_state->quad_to_target_transform, tile_rect, |
| 2173 region_quad, matrix_location, uvs); | 2168 region_quad, matrix_location, uvs); |
| 2174 } | 2169 } |
| 2175 } | 2170 } |
| 2176 | 2171 |
| 2177 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, | 2172 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, |
| 2178 const StreamVideoDrawQuad* quad, | 2173 const StreamVideoDrawQuad* quad, |
| 2179 const gfx::QuadF* clip_region) { | 2174 const gfx::QuadF* clip_region) { |
| 2180 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 2175 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 2181 | 2176 |
| 2182 static float gl_matrix[16]; | 2177 static float gl_matrix[16]; |
| 2183 | 2178 |
| 2184 DCHECK(capabilities_.using_egl_image); | 2179 DCHECK(capabilities_.using_egl_image); |
| 2185 | 2180 |
| 2186 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 2181 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 2187 gl_, | 2182 gl_, &highp_threshold_cache_, highp_threshold_min_, |
| 2188 &highp_threshold_cache_, | 2183 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); |
| 2189 highp_threshold_min_, | |
| 2190 quad->shared_quad_state->visible_content_rect.bottom_right()); | |
| 2191 | 2184 |
| 2192 const VideoStreamTextureProgram* program = | 2185 const VideoStreamTextureProgram* program = |
| 2193 GetVideoStreamTextureProgram(tex_coord_precision); | 2186 GetVideoStreamTextureProgram(tex_coord_precision); |
| 2194 SetUseProgram(program->program()); | 2187 SetUseProgram(program->program()); |
| 2195 | 2188 |
| 2196 ToGLMatrix(&gl_matrix[0], quad->matrix); | 2189 ToGLMatrix(&gl_matrix[0], quad->matrix); |
| 2197 gl_->UniformMatrix4fv(program->vertex_shader().tex_matrix_location(), 1, | 2190 gl_->UniformMatrix4fv(program->vertex_shader().tex_matrix_location(), 1, |
| 2198 false, gl_matrix); | 2191 false, gl_matrix); |
| 2199 | 2192 |
| 2200 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 2193 ResourceProvider::ScopedReadLockGL lock(resource_provider_, |
| 2201 quad->resource_id()); | 2194 quad->resource_id()); |
| 2202 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); | 2195 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); |
| 2203 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); | 2196 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); |
| 2204 | 2197 |
| 2205 gl_->Uniform1i(program->fragment_shader().sampler_location(), 0); | 2198 gl_->Uniform1i(program->fragment_shader().sampler_location(), 0); |
| 2206 | 2199 |
| 2207 SetShaderOpacity(quad->shared_quad_state->opacity, | 2200 SetShaderOpacity(quad->shared_quad_state->opacity, |
| 2208 program->fragment_shader().alpha_location()); | 2201 program->fragment_shader().alpha_location()); |
| 2209 if (!clip_region) { | 2202 if (!clip_region) { |
| 2210 DrawQuadGeometry(frame, | 2203 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 2211 quad->shared_quad_state->content_to_target_transform, | |
| 2212 quad->rect, program->vertex_shader().matrix_location()); | 2204 quad->rect, program->vertex_shader().matrix_location()); |
| 2213 } else { | 2205 } else { |
| 2214 gfx::QuadF region_quad(*clip_region); | 2206 gfx::QuadF region_quad(*clip_region); |
| 2215 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height()); | 2207 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height()); |
| 2216 region_quad -= gfx::Vector2dF(0.5f, 0.5f); | 2208 region_quad -= gfx::Vector2dF(0.5f, 0.5f); |
| 2217 float uvs[8] = {0}; | 2209 float uvs[8] = {0}; |
| 2218 GetScaledUVs(quad->visible_rect, clip_region, uvs); | 2210 GetScaledUVs(quad->visible_rect, clip_region, uvs); |
| 2219 DrawQuadGeometryClippedByQuadF( | 2211 DrawQuadGeometryClippedByQuadF( |
| 2220 frame, quad->shared_quad_state->content_to_target_transform, quad->rect, | 2212 frame, quad->shared_quad_state->quad_to_target_transform, quad->rect, |
| 2221 region_quad, program->vertex_shader().matrix_location(), uvs); | 2213 region_quad, program->vertex_shader().matrix_location(), uvs); |
| 2222 } | 2214 } |
| 2223 } | 2215 } |
| 2224 | 2216 |
| 2225 struct TextureProgramBinding { | 2217 struct TextureProgramBinding { |
| 2226 template <class Program> | 2218 template <class Program> |
| 2227 void Set(Program* program) { | 2219 void Set(Program* program) { |
| 2228 DCHECK(program); | 2220 DCHECK(program); |
| 2229 program_id = program->program(); | 2221 program_id = program->program(); |
| 2230 sampler_location = program->fragment_shader().sampler_location(); | 2222 sampler_location = program->fragment_shader().sampler_location(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 // If we have a clip_region then we have to render the next quad | 2318 // If we have a clip_region then we have to render the next quad |
| 2327 // with dynamic geometry, therefore we must flush all pending | 2319 // with dynamic geometry, therefore we must flush all pending |
| 2328 // texture quads. | 2320 // texture quads. |
| 2329 if (clip_region) { | 2321 if (clip_region) { |
| 2330 // We send in false here because we want to flush what's currently in the | 2322 // We send in false here because we want to flush what's currently in the |
| 2331 // queue using the shared_geometry and not clipped_geometry | 2323 // queue using the shared_geometry and not clipped_geometry |
| 2332 FlushTextureQuadCache(SHARED_BINDING); | 2324 FlushTextureQuadCache(SHARED_BINDING); |
| 2333 } | 2325 } |
| 2334 | 2326 |
| 2335 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 2327 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 2336 gl_, | 2328 gl_, &highp_threshold_cache_, highp_threshold_min_, |
| 2337 &highp_threshold_cache_, | 2329 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); |
| 2338 highp_threshold_min_, | |
| 2339 quad->shared_quad_state->visible_content_rect.bottom_right()); | |
| 2340 | 2330 |
| 2341 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 2331 ResourceProvider::ScopedReadLockGL lock(resource_provider_, |
| 2342 quad->resource_id()); | 2332 quad->resource_id()); |
| 2343 const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target()); | 2333 const SamplerType sampler = SamplerTypeFromTextureTarget(lock.target()); |
| 2344 // Choose the correct texture program binding | 2334 // Choose the correct texture program binding |
| 2345 TexTransformTextureProgramBinding binding; | 2335 TexTransformTextureProgramBinding binding; |
| 2346 if (quad->premultiplied_alpha) { | 2336 if (quad->premultiplied_alpha) { |
| 2347 if (quad->background_color == SK_ColorTRANSPARENT) { | 2337 if (quad->background_color == SK_ColorTRANSPARENT) { |
| 2348 binding.Set(GetTextureProgram(tex_coord_precision, sampler)); | 2338 binding.Set(GetTextureProgram(tex_coord_precision, sampler)); |
| 2349 } else { | 2339 } else { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 // Generate the vertex opacity | 2382 // Generate the vertex opacity |
| 2393 const float opacity = quad->shared_quad_state->opacity; | 2383 const float opacity = quad->shared_quad_state->opacity; |
| 2394 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); | 2384 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); |
| 2395 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity); | 2385 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity); |
| 2396 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity); | 2386 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity); |
| 2397 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity); | 2387 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity); |
| 2398 | 2388 |
| 2399 // Generate the transform matrix | 2389 // Generate the transform matrix |
| 2400 gfx::Transform quad_rect_matrix; | 2390 gfx::Transform quad_rect_matrix; |
| 2401 QuadRectTransform(&quad_rect_matrix, | 2391 QuadRectTransform(&quad_rect_matrix, |
| 2402 quad->shared_quad_state->content_to_target_transform, | 2392 quad->shared_quad_state->quad_to_target_transform, |
| 2403 quad->rect); | 2393 quad->rect); |
| 2404 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; | 2394 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; |
| 2405 | 2395 |
| 2406 Float16 m; | 2396 Float16 m; |
| 2407 quad_rect_matrix.matrix().asColMajorf(m.data); | 2397 quad_rect_matrix.matrix().asColMajorf(m.data); |
| 2408 draw_cache_.matrix_data.push_back(m); | 2398 draw_cache_.matrix_data.push_back(m); |
| 2409 | 2399 |
| 2410 if (clip_region) { | 2400 if (clip_region) { |
| 2411 gfx::QuadF scaled_region; | 2401 gfx::QuadF scaled_region; |
| 2412 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) { | 2402 if (!GetScaledRegion(quad->rect, clip_region, &scaled_region)) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2428 FlushTextureQuadCache(CLIPPED_BINDING); | 2418 FlushTextureQuadCache(CLIPPED_BINDING); |
| 2429 } | 2419 } |
| 2430 } | 2420 } |
| 2431 | 2421 |
| 2432 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, | 2422 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, |
| 2433 const IOSurfaceDrawQuad* quad, | 2423 const IOSurfaceDrawQuad* quad, |
| 2434 const gfx::QuadF* clip_region) { | 2424 const gfx::QuadF* clip_region) { |
| 2435 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 2425 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 2436 | 2426 |
| 2437 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 2427 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 2438 gl_, | 2428 gl_, &highp_threshold_cache_, highp_threshold_min_, |
| 2439 &highp_threshold_cache_, | 2429 quad->shared_quad_state->visible_quad_layer_rect.bottom_right()); |
| 2440 highp_threshold_min_, | |
| 2441 quad->shared_quad_state->visible_content_rect.bottom_right()); | |
| 2442 | 2430 |
| 2443 TexTransformTextureProgramBinding binding; | 2431 TexTransformTextureProgramBinding binding; |
| 2444 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); | 2432 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); |
| 2445 | 2433 |
| 2446 SetUseProgram(binding.program_id); | 2434 SetUseProgram(binding.program_id); |
| 2447 gl_->Uniform1i(binding.sampler_location, 0); | 2435 gl_->Uniform1i(binding.sampler_location, 0); |
| 2448 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { | 2436 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { |
| 2449 gl_->Uniform4f( | 2437 gl_->Uniform4f( |
| 2450 binding.tex_transform_location, 0, quad->io_surface_size.height(), | 2438 binding.tex_transform_location, 0, quad->io_surface_size.height(), |
| 2451 quad->io_surface_size.width(), quad->io_surface_size.height() * -1.0f); | 2439 quad->io_surface_size.width(), quad->io_surface_size.height() * -1.0f); |
| 2452 } else { | 2440 } else { |
| 2453 gl_->Uniform4f(binding.tex_transform_location, 0, 0, | 2441 gl_->Uniform4f(binding.tex_transform_location, 0, 0, |
| 2454 quad->io_surface_size.width(), | 2442 quad->io_surface_size.width(), |
| 2455 quad->io_surface_size.height()); | 2443 quad->io_surface_size.height()); |
| 2456 } | 2444 } |
| 2457 | 2445 |
| 2458 const float vertex_opacity[] = {quad->shared_quad_state->opacity, | 2446 const float vertex_opacity[] = {quad->shared_quad_state->opacity, |
| 2459 quad->shared_quad_state->opacity, | 2447 quad->shared_quad_state->opacity, |
| 2460 quad->shared_quad_state->opacity, | 2448 quad->shared_quad_state->opacity, |
| 2461 quad->shared_quad_state->opacity}; | 2449 quad->shared_quad_state->opacity}; |
| 2462 gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity); | 2450 gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity); |
| 2463 | 2451 |
| 2464 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 2452 ResourceProvider::ScopedReadLockGL lock(resource_provider_, |
| 2465 quad->io_surface_resource_id()); | 2453 quad->io_surface_resource_id()); |
| 2466 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); | 2454 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); |
| 2467 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()); | 2455 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()); |
| 2468 | 2456 |
| 2469 if (!clip_region) { | 2457 if (!clip_region) { |
| 2470 DrawQuadGeometry(frame, | 2458 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 2471 quad->shared_quad_state->content_to_target_transform, | |
| 2472 quad->rect, binding.matrix_location); | 2459 quad->rect, binding.matrix_location); |
| 2473 } else { | 2460 } else { |
| 2474 float uvs[8] = {0}; | 2461 float uvs[8] = {0}; |
| 2475 GetScaledUVs(quad->visible_rect, clip_region, uvs); | 2462 GetScaledUVs(quad->visible_rect, clip_region, uvs); |
| 2476 DrawQuadGeometryClippedByQuadF( | 2463 DrawQuadGeometryClippedByQuadF( |
| 2477 frame, quad->shared_quad_state->content_to_target_transform, quad->rect, | 2464 frame, quad->shared_quad_state->quad_to_target_transform, quad->rect, |
| 2478 *clip_region, binding.matrix_location, uvs); | 2465 *clip_region, binding.matrix_location, uvs); |
| 2479 } | 2466 } |
| 2480 | 2467 |
| 2481 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); | 2468 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); |
| 2482 } | 2469 } |
| 2483 | 2470 |
| 2484 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 2471 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { |
| 2485 if (use_sync_query_) { | 2472 if (use_sync_query_) { |
| 2486 DCHECK(current_sync_query_); | 2473 DCHECK(current_sync_query_); |
| 2487 current_sync_query_->End(); | 2474 current_sync_query_->End(); |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3584 context_support_->ScheduleOverlayPlane( | 3571 context_support_->ScheduleOverlayPlane( |
| 3585 overlay.plane_z_order, | 3572 overlay.plane_z_order, |
| 3586 overlay.transform, | 3573 overlay.transform, |
| 3587 pending_overlay_resources_.back()->texture_id(), | 3574 pending_overlay_resources_.back()->texture_id(), |
| 3588 ToNearestRect(overlay.display_rect), | 3575 ToNearestRect(overlay.display_rect), |
| 3589 overlay.uv_rect); | 3576 overlay.uv_rect); |
| 3590 } | 3577 } |
| 3591 } | 3578 } |
| 3592 | 3579 |
| 3593 } // namespace cc | 3580 } // namespace cc |
| OLD | NEW |