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

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

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sizefconvert-gfx: . Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/viewport.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 847 }
848 return device_background_texture.Pass(); 848 return device_background_texture.Pass();
849 } 849 }
850 850
851 skia::RefPtr<SkImage> GLRenderer::ApplyBackgroundFilters( 851 skia::RefPtr<SkImage> GLRenderer::ApplyBackgroundFilters(
852 DrawingFrame* frame, 852 DrawingFrame* frame,
853 const RenderPassDrawQuad* quad, 853 const RenderPassDrawQuad* quad,
854 ScopedResource* background_texture) { 854 ScopedResource* background_texture) {
855 DCHECK(ShouldApplyBackgroundFilters(quad)); 855 DCHECK(ShouldApplyBackgroundFilters(quad));
856 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 856 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
857 quad->background_filters, background_texture->size()); 857 quad->background_filters, gfx::SizeF(background_texture->size()));
858 858
859 skia::RefPtr<SkImage> background_with_filters = ApplyImageFilter( 859 skia::RefPtr<SkImage> background_with_filters = ApplyImageFilter(
860 ScopedUseGrContext::Create(this, frame), resource_provider_, quad->rect, 860 ScopedUseGrContext::Create(this, frame), resource_provider_, quad->rect,
861 quad->filters_scale, filter.get(), background_texture); 861 quad->filters_scale, filter.get(), background_texture);
862 return background_with_filters; 862 return background_with_filters;
863 } 863 }
864 864
865 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 865 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
866 const RenderPassDrawQuad* quad, 866 const RenderPassDrawQuad* quad,
867 const gfx::QuadF* clip_region) { 867 const gfx::QuadF* clip_region) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 (quad->ShouldDrawWithBlending() || !IsDefaultBlendMode(blend_mode))); 963 (quad->ShouldDrawWithBlending() || !IsDefaultBlendMode(blend_mode)));
964 964
965 // TODO(senorblanco): Cache this value so that we don't have to do it for both 965 // TODO(senorblanco): Cache this value so that we don't have to do it for both
966 // the surface and its replica. Apply filters to the contents texture. 966 // the surface and its replica. Apply filters to the contents texture.
967 skia::RefPtr<SkImage> filter_image; 967 skia::RefPtr<SkImage> filter_image;
968 GLuint filter_image_id = 0; 968 GLuint filter_image_id = 0;
969 SkScalar color_matrix[20]; 969 SkScalar color_matrix[20];
970 bool use_color_matrix = false; 970 bool use_color_matrix = false;
971 if (!quad->filters.IsEmpty()) { 971 if (!quad->filters.IsEmpty()) {
972 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter( 972 skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
973 quad->filters, contents_texture->size()); 973 quad->filters, gfx::SizeF(contents_texture->size()));
974 if (filter) { 974 if (filter) {
975 skia::RefPtr<SkColorFilter> cf; 975 skia::RefPtr<SkColorFilter> cf;
976 976
977 { 977 {
978 SkColorFilter* colorfilter_rawptr = NULL; 978 SkColorFilter* colorfilter_rawptr = NULL;
979 filter->asColorFilter(&colorfilter_rawptr); 979 filter->asColorFilter(&colorfilter_rawptr);
980 cf = skia::AdoptRef(colorfilter_rawptr); 980 cf = skia::AdoptRef(colorfilter_rawptr);
981 } 981 }
982 982
983 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) { 983 if (cf && cf->asColorMatrix(color_matrix) && !filter->getInput(0)) {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 kAntiAliasingEpsilon; 1284 kAntiAliasingEpsilon;
1285 } 1285 }
1286 } // anonymous namespace 1286 } // anonymous namespace
1287 1287
1288 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges( 1288 static gfx::QuadF GetDeviceQuadWithAntialiasingOnExteriorEdges(
1289 const LayerQuad& device_layer_edges, 1289 const LayerQuad& device_layer_edges,
1290 const gfx::Transform& device_transform, 1290 const gfx::Transform& device_transform,
1291 const gfx::QuadF& tile_quad, 1291 const gfx::QuadF& tile_quad,
1292 const gfx::QuadF* clip_region, 1292 const gfx::QuadF* clip_region,
1293 const DrawQuad* quad) { 1293 const DrawQuad* quad) {
1294 gfx::RectF tile_rect = gfx::RectF(quad->visible_rect); 1294 auto tile_rect = gfx::RectF(quad->visible_rect);
1295 1295
1296 gfx::PointF bottom_right = tile_quad.p3(); 1296 gfx::PointF bottom_right = tile_quad.p3();
1297 gfx::PointF bottom_left = tile_quad.p4(); 1297 gfx::PointF bottom_left = tile_quad.p4();
1298 gfx::PointF top_left = tile_quad.p1(); 1298 gfx::PointF top_left = tile_quad.p1();
1299 gfx::PointF top_right = tile_quad.p2(); 1299 gfx::PointF top_right = tile_quad.p2();
1300 bool clipped = false; 1300 bool clipped = false;
1301 1301
1302 // Map points to device space. We ignore |clipped|, since the result of 1302 // Map points to device space. We ignore |clipped|, since the result of
1303 // |MapPoint()| still produces a valid point to draw the quad with. When 1303 // |MapPoint()| still produces a valid point to draw the quad with. When
1304 // clipped, the point will be outside of the viewport. See crbug.com/416367. 1304 // clipped, the point will be outside of the viewport. See crbug.com/416367.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 return (clipped_quad->p1() - ideal_rect->p1()).LengthSquared() + 1347 return (clipped_quad->p1() - ideal_rect->p1()).LengthSquared() +
1348 (clipped_quad->p2() - ideal_rect->p2()).LengthSquared() + 1348 (clipped_quad->p2() - ideal_rect->p2()).LengthSquared() +
1349 (clipped_quad->p3() - ideal_rect->p3()).LengthSquared() + 1349 (clipped_quad->p3() - ideal_rect->p3()).LengthSquared() +
1350 (clipped_quad->p4() - ideal_rect->p4()).LengthSquared(); 1350 (clipped_quad->p4() - ideal_rect->p4()).LengthSquared();
1351 } 1351 }
1352 1352
1353 // Attempt to rotate the clipped quad until it lines up the most 1353 // Attempt to rotate the clipped quad until it lines up the most
1354 // correctly. This is necessary because we check the edges of this 1354 // correctly. This is necessary because we check the edges of this
1355 // quad against the expected left/right/top/bottom for anti-aliasing. 1355 // quad against the expected left/right/top/bottom for anti-aliasing.
1356 void AlignQuadToBoundingBox(gfx::QuadF* clipped_quad) { 1356 void AlignQuadToBoundingBox(gfx::QuadF* clipped_quad) {
1357 gfx::QuadF bounding_quad = gfx::QuadF(clipped_quad->BoundingBox()); 1357 auto bounding_quad = gfx::QuadF(clipped_quad->BoundingBox());
1358 gfx::QuadF best_rotation = *clipped_quad; 1358 gfx::QuadF best_rotation = *clipped_quad;
1359 float least_error_amount = GetTotalQuadError(clipped_quad, &bounding_quad); 1359 float least_error_amount = GetTotalQuadError(clipped_quad, &bounding_quad);
1360 for (size_t i = 1; i < 4; ++i) { 1360 for (size_t i = 1; i < 4; ++i) {
1361 clipped_quad->Realign(1); 1361 clipped_quad->Realign(1);
1362 float new_error = GetTotalQuadError(clipped_quad, &bounding_quad); 1362 float new_error = GetTotalQuadError(clipped_quad, &bounding_quad);
1363 if (new_error < least_error_amount) { 1363 if (new_error < least_error_amount) {
1364 least_error_amount = new_error; 1364 least_error_amount = new_error;
1365 best_rotation = *clipped_quad; 1365 best_rotation = *clipped_quad;
1366 } 1366 }
1367 } 1367 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 quad->ShouldDrawWithBlending()) 1526 quad->ShouldDrawWithBlending())
1527 return; 1527 return;
1528 1528
1529 gfx::Transform device_transform = 1529 gfx::Transform device_transform =
1530 frame->window_matrix * frame->projection_matrix * 1530 frame->window_matrix * frame->projection_matrix *
1531 quad->shared_quad_state->quad_to_target_transform; 1531 quad->shared_quad_state->quad_to_target_transform;
1532 device_transform.FlattenTo2d(); 1532 device_transform.FlattenTo2d();
1533 if (!device_transform.IsInvertible()) 1533 if (!device_transform.IsInvertible())
1534 return; 1534 return;
1535 1535
1536 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1536 auto local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1537 1537
1538 gfx::QuadF device_layer_quad; 1538 gfx::QuadF device_layer_quad;
1539 bool use_aa = false; 1539 bool use_aa = false;
1540 bool allow_aa = settings_->allow_antialiasing && 1540 bool allow_aa = settings_->allow_antialiasing &&
1541 !quad->force_anti_aliasing_off && quad->IsEdge(); 1541 !quad->force_anti_aliasing_off && quad->IsEdge();
1542 1542
1543 if (allow_aa) { 1543 if (allow_aa) {
1544 bool clipped = false; 1544 bool clipped = false;
1545 bool force_aa = false; 1545 bool force_aa = false;
1546 device_layer_quad = MathUtil::MapQuad( 1546 device_layer_quad = MathUtil::MapQuad(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 1591
1592 SetShaderQuadF(local_quad, uniforms.quad_location); 1592 SetShaderQuadF(local_quad, uniforms.quad_location);
1593 1593
1594 // The transform and vertex data are used to figure out the extents that the 1594 // The transform and vertex data are used to figure out the extents that the
1595 // un-antialiased quad should have and which vertex this is and the float 1595 // un-antialiased quad should have and which vertex this is and the float
1596 // quad passed in via uniform is the actual geometry that gets used to draw 1596 // quad passed in via uniform is the actual geometry that gets used to draw
1597 // it. This is why this centered rect is used and not the original 1597 // it. This is why this centered rect is used and not the original
1598 // quad_rect. 1598 // quad_rect.
1599 gfx::RectF centered_rect( 1599 gfx::RectF centered_rect(
1600 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1600 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1601 tile_rect.size()); 1601 gfx::SizeF(tile_rect.size()));
1602 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 1602 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
1603 centered_rect, uniforms.matrix_location); 1603 centered_rect, uniforms.matrix_location);
1604 } else { 1604 } else {
1605 PrepareGeometry(SHARED_BINDING); 1605 PrepareGeometry(SHARED_BINDING);
1606 SetShaderQuadF(local_quad, uniforms.quad_location); 1606 SetShaderQuadF(local_quad, uniforms.quad_location);
1607 static float gl_matrix[16]; 1607 static float gl_matrix[16];
1608 ToGLMatrix(&gl_matrix[0], 1608 ToGLMatrix(&gl_matrix[0],
1609 frame->projection_matrix * 1609 frame->projection_matrix *
1610 quad->shared_quad_state->quad_to_target_transform); 1610 quad->shared_quad_state->quad_to_target_transform);
1611 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]); 1611 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 // Map clamping rectangle to unit square. 1722 // Map clamping rectangle to unit square.
1723 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); 1723 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width();
1724 float vertex_tex_translate_y = 1724 float vertex_tex_translate_y =
1725 -clamp_geom_rect.y() / clamp_geom_rect.height(); 1725 -clamp_geom_rect.y() / clamp_geom_rect.height();
1726 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); 1726 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width();
1727 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); 1727 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height();
1728 1728
1729 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1729 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1730 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); 1730 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size);
1731 1731
1732 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); 1732 auto local_quad = gfx::QuadF(gfx::RectF(tile_rect));
1733 float edge[24]; 1733 float edge[24];
1734 SetupQuadForClippingAndAntialiasing(device_transform, quad, &aa_quad, 1734 SetupQuadForClippingAndAntialiasing(device_transform, quad, &aa_quad,
1735 clip_region, &local_quad, edge); 1735 clip_region, &local_quad, edge);
1736 ResourceProvider::ScopedSamplerGL quad_resource_lock( 1736 ResourceProvider::ScopedSamplerGL quad_resource_lock(
1737 resource_provider_, resource_id, 1737 resource_provider_, resource_id,
1738 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR); 1738 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR);
1739 SamplerType sampler = 1739 SamplerType sampler =
1740 SamplerTypeFromTextureTarget(quad_resource_lock.target()); 1740 SamplerTypeFromTextureTarget(quad_resource_lock.target());
1741 1741
1742 float fragment_tex_translate_x = clamp_tex_rect.x(); 1742 float fragment_tex_translate_x = clamp_tex_rect.x();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 1790
1791 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location); 1791 SetShaderOpacity(quad->shared_quad_state->opacity, uniforms.alpha_location);
1792 SetShaderQuadF(local_quad, uniforms.quad_location); 1792 SetShaderQuadF(local_quad, uniforms.quad_location);
1793 1793
1794 // The transform and vertex data are used to figure out the extents that the 1794 // The transform and vertex data are used to figure out the extents that the
1795 // un-antialiased quad should have and which vertex this is and the float 1795 // un-antialiased quad should have and which vertex this is and the float
1796 // quad passed in via uniform is the actual geometry that gets used to draw 1796 // quad passed in via uniform is the actual geometry that gets used to draw
1797 // it. This is why this centered rect is used and not the original quad_rect. 1797 // it. This is why this centered rect is used and not the original quad_rect.
1798 gfx::RectF centered_rect( 1798 gfx::RectF centered_rect(
1799 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), 1799 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()),
1800 tile_rect.size()); 1800 gfx::SizeF(tile_rect.size()));
1801 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 1801 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
1802 centered_rect, uniforms.matrix_location); 1802 centered_rect, uniforms.matrix_location);
1803 } 1803 }
1804 1804
1805 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, 1805 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame,
1806 const ContentDrawQuadBase* quad, 1806 const ContentDrawQuadBase* quad,
1807 ResourceId resource_id, 1807 ResourceId resource_id,
1808 const gfx::QuadF* clip_region) { 1808 const gfx::QuadF* clip_region) {
1809 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( 1809 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional(
1810 quad->tex_coord_rect, gfx::RectF(quad->rect), 1810 quad->tex_coord_rect, gfx::RectF(quad->rect),
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 case YUVVideoDrawQuad::JPEG: 2103 case YUVVideoDrawQuad::JPEG:
2104 yuv_to_rgb = yuv_to_rgb_jpeg; 2104 yuv_to_rgb = yuv_to_rgb_jpeg;
2105 yuv_adjust = yuv_adjust_full; 2105 yuv_adjust = yuv_adjust_full;
2106 break; 2106 break;
2107 } 2107 }
2108 2108
2109 // The transform and vertex data are used to figure out the extents that the 2109 // The transform and vertex data are used to figure out the extents that the
2110 // un-antialiased quad should have and which vertex this is and the float 2110 // un-antialiased quad should have and which vertex this is and the float
2111 // quad passed in via uniform is the actual geometry that gets used to draw 2111 // quad passed in via uniform is the actual geometry that gets used to draw
2112 // it. This is why this centered rect is used and not the original quad_rect. 2112 // it. This is why this centered rect is used and not the original quad_rect.
2113 gfx::RectF tile_rect = gfx::RectF(quad->rect); 2113 auto tile_rect = gfx::RectF(quad->rect);
2114 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb); 2114 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb);
2115 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust); 2115 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust);
2116 2116
2117 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location); 2117 SetShaderOpacity(quad->shared_quad_state->opacity, alpha_location);
2118 if (!clip_region) { 2118 if (!clip_region) {
2119 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, 2119 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform,
2120 tile_rect, matrix_location); 2120 tile_rect, matrix_location);
2121 } else { 2121 } else {
2122 float uvs[8] = {0}; 2122 float uvs[8] = {0};
2123 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2123 GetScaledUVs(quad->visible_rect, clip_region, uvs);
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 texture_id = pending_overlay_resources_.back()->texture_id(); 3530 texture_id = pending_overlay_resources_.back()->texture_id();
3531 } 3531 }
3532 3532
3533 context_support_->ScheduleOverlayPlane( 3533 context_support_->ScheduleOverlayPlane(
3534 overlay.plane_z_order, overlay.transform, texture_id, 3534 overlay.plane_z_order, overlay.transform, texture_id,
3535 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3535 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3536 } 3536 }
3537 } 3537 }
3538 3538
3539 } // namespace cc 3539 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/viewport.cc ('k') | cc/output/renderer_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698