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

Unified Diff: cc/output/overlay_strategy_sandwich.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: rectfconvert-cc: rebase-and-sandwich-strategy 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/overlay_strategy_common.cc ('k') | cc/output/overlay_strategy_single_on_top.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/overlay_strategy_sandwich.cc
diff --git a/cc/output/overlay_strategy_sandwich.cc b/cc/output/overlay_strategy_sandwich.cc
index bdcaf29d05039147320e23682f2694046aeb3061..59747882f9ddae47eafdb0c6481f4a92742e45eb 100644
--- a/cc/output/overlay_strategy_sandwich.cc
+++ b/cc/output/overlay_strategy_sandwich.cc
@@ -4,6 +4,7 @@
#include "cc/output/overlay_strategy_sandwich.h"
+#include "cc/base/math_util.h"
#include "cc/base/region.h"
#include "cc/output/overlay_candidate_validator.h"
#include "cc/quads/draw_quad.h"
@@ -15,9 +16,8 @@ namespace {
gfx::Rect AlignPixelRectToDIP(float scale_factor, const gfx::Rect& pixel_rect) {
gfx::Rect dip_rect =
- gfx::ToEnclosingRect(gfx::ScaleRect(pixel_rect, 1.0f / scale_factor));
- gfx::Rect new_pixel_rect =
- gfx::ToEnclosingRect(gfx::ScaleRect(dip_rect, scale_factor));
+ gfx::ScaleToEnclosingRect(pixel_rect, 1.0f / scale_factor);
+ gfx::Rect new_pixel_rect = gfx::ScaleToEnclosingRect(dip_rect, scale_factor);
return new_pixel_rect;
}
@@ -51,12 +51,12 @@ bool OverlayStrategySandwich::TryOverlay(
// Compute the candidate's rect in display space (pixels on the screen). The
// rect needs to be DIP-aligned, or we cannot use it.
- gfx::RectF candidate_pixel_rect_float = candidate_quad->rect;
- candidate_transform.TransformRect(&candidate_pixel_rect_float);
- gfx::Rect candidate_pixel_rect;
- candidate_pixel_rect = gfx::ToEnclosingRect(candidate_pixel_rect_float);
- if (candidate_pixel_rect != candidate_pixel_rect_float)
+ gfx::RectF candidate_pixel_rect_float = MathUtil::MapClippedRect(
+ candidate_transform, gfx::RectF(candidate_quad->rect));
+ if (!candidate_pixel_rect_float.IsExpressibleAsRect())
return false;
+ gfx::Rect candidate_pixel_rect =
+ gfx::ToNearestRect(candidate_pixel_rect_float);
if (!IsPixelRectAlignedToDIP(device_scale_factor, candidate_pixel_rect))
return false;
@@ -69,11 +69,11 @@ bool OverlayStrategySandwich::TryOverlay(
continue;
// Compute the quad's bounds in display space, and ensure that it is rounded
// up to be DIP-aligned.
- gfx::RectF pixel_covered_rect_float = overlap_iter->rect;
- overlap_iter->shared_quad_state->quad_to_target_transform.TransformRect(
- &pixel_covered_rect_float);
- gfx::Rect pixel_covered_rect = AlignPixelRectToDIP(
- device_scale_factor, gfx::ToEnclosingRect(pixel_covered_rect_float));
+ gfx::Rect unaligned_pixel_covered_rect = MathUtil::MapEnclosingClippedRect(
+ overlap_iter->shared_quad_state->quad_to_target_transform,
+ overlap_iter->rect);
+ gfx::Rect pixel_covered_rect =
+ AlignPixelRectToDIP(device_scale_factor, unaligned_pixel_covered_rect);
// Include the intersection of that quad with the candidate's quad in the
// covered region.
@@ -84,7 +84,7 @@ bool OverlayStrategySandwich::TryOverlay(
// Add our primary surface.
OverlayCandidateList new_candidate_list;
OverlayCandidate main_image;
- main_image.display_rect = pixel_bounds;
+ main_image.display_rect = gfx::RectF(pixel_bounds);
new_candidate_list.push_back(main_image);
// Add the candidate's overlay.
@@ -101,8 +101,8 @@ bool OverlayStrategySandwich::TryOverlay(
}
for (const gfx::Rect& pixel_covered_rect : pixel_covered_rects) {
OverlayCandidate main_image_on_top;
- main_image_on_top.display_rect = pixel_covered_rect;
- main_image_on_top.uv_rect = pixel_covered_rect;
+ main_image_on_top.display_rect = gfx::RectF(pixel_covered_rect);
+ main_image_on_top.uv_rect = gfx::RectF(pixel_covered_rect);
main_image_on_top.uv_rect.Scale(1.f / pixel_bounds.width(),
1.f / pixel_bounds.height());
main_image_on_top.plane_z_order = 2;
@@ -138,10 +138,8 @@ bool OverlayStrategySandwich::TryOverlay(
// Cover the region with transparent quads.
for (const gfx::Rect& pixel_covered_rect : pixel_covered_rects) {
- gfx::RectF quad_space_covered_rect_float = pixel_covered_rect;
- candidate_inverse_transform.TransformRect(&quad_space_covered_rect_float);
- gfx::Rect quad_space_covered_rect =
- gfx::ToEnclosingRect(quad_space_covered_rect_float);
+ gfx::Rect quad_space_covered_rect = MathUtil::MapEnclosingClippedRect(
+ candidate_inverse_transform, pixel_covered_rect);
quad_space_covered_rect.Intersect(candidate_rect);
SolidColorDrawQuad* transparent_quad =
« no previous file with comments | « cc/output/overlay_strategy_common.cc ('k') | cc/output/overlay_strategy_single_on_top.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698