summaryrefslogtreecommitdiffstats
path: root/cc/trees
diff options
context:
space:
mode:
authorshawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 04:37:00 +0000
committershawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-11 04:37:00 +0000
commit3a9a92d0eccb5f751e8ec337a3c2b5ebc4a0c079 (patch)
tree3f93896f29f3c51b6bc2ea8a3cfbe827fb7bb877 /cc/trees
parentbdb571eea5b369439c5924e6a407f51a06c57ce7 (diff)
downloadchromium_src-3a9a92d0eccb5f751e8ec337a3c2b5ebc4a0c079.zip
chromium_src-3a9a92d0eccb5f751e8ec337a3c2b5ebc4a0c079.tar.gz
chromium_src-3a9a92d0eccb5f751e8ec337a3c2b5ebc4a0c079.tar.bz2
Implement preservesAxisAlignment on gfx::Transform
In many cases we would like to check if a rect remains axis-aligned after having a transform applied to it. This is often done by actually applying the transform to the rect and then verifying that it is still rectilinear. This entire map operation can be avoided, instead performing a quicker check over 6 elements of the matrix. Additionally, this patch fixes a bug where we were unnecessarily creating renderSurfaces. This bug was diagnosed and solved by wonsick@chromium.org, but it was appropriate to do the fix in this patch while it lands. BUG=258760 Review URL: https://chromiumcodereview.appspot.com/11576036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211017 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees')
-rw-r--r--cc/trees/layer_tree_host_common.cc2
-rw-r--r--cc/trees/occlusion_tracker.cc13
-rw-r--r--cc/trees/occlusion_tracker_unittest.cc6
3 files changed, 9 insertions, 12 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index b58340a..2efb20f 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -1154,7 +1154,7 @@ static void CalculateDrawPropertiesInternal(
: gfx::Vector2dF(layer_scale_factors, layer_scale_factors);
if (SubtreeShouldRenderToSeparateSurface(
- layer, combined_transform.IsScaleOrTranslation())) {
+ layer, combined_transform.Preserves2dAxisAlignment())) {
// Check back-face visibility before continuing with this surface and its
// subtree
if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
diff --git a/cc/trees/occlusion_tracker.cc b/cc/trees/occlusion_tracker.cc
index 6b6ea5d..08553a8 100644
--- a/cc/trees/occlusion_tracker.cc
+++ b/cc/trees/occlusion_tracker.cc
@@ -83,17 +83,15 @@ static Region TransformSurfaceOpaqueRegion(const Region& region,
// surface after applying |transform|. If this is true, then apply |transform|
// to each rect within |region| in order to transform the entire Region.
- bool clipped;
- gfx::QuadF transformed_bounds_quad =
- MathUtil::MapQuad(transform, gfx::QuadF(region.bounds()), &clipped);
// TODO(danakj): Find a rect interior to each transformed quad.
- if (clipped || !transformed_bounds_quad.IsRectilinear())
+ if (!transform.Preserves2dAxisAlignment())
return Region();
// TODO(danakj): If the Region is too complex, degrade gracefully here by
// skipping rects in it.
Region transformed_region;
for (Region::Iterator rects(region); rects.has_rect(); rects.next()) {
+ bool clipped;
gfx::QuadF transformed_quad =
MathUtil::MapQuad(transform, gfx::QuadF(rects.rect()), &clipped);
gfx::Rect transformed_rect =
@@ -422,11 +420,8 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::
DCHECK(layer->visible_content_rect().Contains(opaque_contents.bounds()));
- bool clipped;
- gfx::QuadF visible_transformed_quad = MathUtil::MapQuad(
- layer->draw_transform(), gfx::QuadF(opaque_contents.bounds()), &clipped);
// TODO(danakj): Find a rect interior to each transformed quad.
- if (clipped || !visible_transformed_quad.IsRectilinear())
+ if (!layer->draw_transform().Preserves2dAxisAlignment())
return;
gfx::Rect clip_rect_in_target = ScreenSpaceClipRectInTargetSurface(
@@ -441,6 +436,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::
for (Region::Iterator opaque_content_rects(opaque_contents);
opaque_content_rects.has_rect();
opaque_content_rects.next()) {
+ bool clipped;
gfx::QuadF transformed_quad = MathUtil::MapQuad(
layer->draw_transform(),
gfx::QuadF(opaque_content_rects.rect()),
@@ -485,6 +481,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::
if (transformed_rect.IsEmpty())
continue;
+ bool clipped;
gfx::QuadF screen_space_quad = MathUtil::MapQuad(
layer->render_target()->render_surface()->screen_space_transform(),
gfx::QuadF(transformed_rect),
diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc
index 956b67b..9a5f839 100644
--- a/cc/trees/occlusion_tracker_unittest.cc
+++ b/cc/trees/occlusion_tracker_unittest.cc
@@ -836,7 +836,7 @@ class OcclusionTrackerTestChildInRotatedChild
typename Types::ContentLayerType* parent = this->CreateRoot(
this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
parent->SetMasksToBounds(true);
- typename Types::LayerType* child = this->CreateLayer(
+ typename Types::LayerType* child = this->CreateSurface(
parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500));
child->SetMasksToBounds(true);
typename Types::ContentLayerType* layer =
@@ -999,7 +999,7 @@ class OcclusionTrackerTestVisitTargetTwoTimes
typename Types::ContentLayerType* parent = this->CreateDrawingLayer(
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
parent->SetMasksToBounds(true);
- typename Types::LayerType* child = this->CreateLayer(
+ typename Types::LayerType* child = this->CreateSurface(
parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500));
child->SetMasksToBounds(true);
typename Types::ContentLayerType* layer =
@@ -1236,7 +1236,7 @@ class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren
root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
parent->SetMasksToBounds(true);
typename Types::ContentLayerType* child =
- this->CreateDrawingLayer(parent,
+ this->CreateDrawingSurface(parent,
child_transform,
gfx::PointF(30.f, 30.f),
gfx::Size(500, 500),