Index: cc/layer_tree_host_common.cc |
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc |
index b9fc38083f32150ab968b4c6e0e2770216c7a2be..87743392760d448095a1be789fff690cf25b57ce 100644 |
--- a/cc/layer_tree_host_common.cc |
+++ b/cc/layer_tree_host_common.cc |
@@ -56,7 +56,8 @@ inline gfx::Rect calculateVisibleRectWithCachedLayerRect(const gfx::Rect& target |
// This bounding rectangle may be larger than it needs to be (being |
// axis-aligned), but is a reasonable filter on the space to consider. |
// Non-invertible transforms will create an empty rect here. |
- const gfx::Transform surfaceToLayer = MathUtil::inverse(transform); |
+ gfx::Transform surfaceToLayer(gfx::Transform::kSkipInitialization); |
+ transform.GetInverse(&surfaceToLayer); |
danakj
2012/12/19 05:23:06
If it's not invertible, should we return layerBoun
|
gfx::Rect layerRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect(surfaceToLayer, gfx::RectF(minimalSurfaceRect))); |
layerRect.Intersect(layerBoundRect); |
return layerRect; |
@@ -321,7 +322,9 @@ gfx::Transform computeScrollCompensationForThisLayer(LayerImpl* scrollingLayer, |
gfx::Transform scrollCompensationForThisLayer = partialLayerOriginTransform; // Step 3 |
scrollCompensationForThisLayer.Translate(scrollingLayer->scrollDelta().x(), scrollingLayer->scrollDelta().y()); // Step 2 |
- scrollCompensationForThisLayer.PreconcatTransform(MathUtil::inverse(partialLayerOriginTransform)); // Step 1 |
+ gfx::Transform inversePartialLayerOriginTransform(gfx::Transform::kSkipInitialization); |
+ partialLayerOriginTransform.GetInverse(&inversePartialLayerOriginTransform); |
danakj
2012/12/19 05:23:06
DCHECK the return value?
|
+ scrollCompensationForThisLayer.PreconcatTransform(inversePartialLayerOriginTransform); // Step 1 |
return scrollCompensationForThisLayer; |
} |
@@ -373,8 +376,11 @@ gfx::Transform computeScrollCompensationMatrixForChildren(LayerImpl* layer, cons |
// Step 1 (right-most in the math): transform from the new surface to the original ancestor surface |
// Step 2: apply the scroll compensation |
// Step 3: transform back to the new surface. |
- if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) |
- nextScrollCompensationMatrix = MathUtil::inverse(layer->renderSurface()->drawTransform()) * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform(); |
+ if (layer->renderSurface() && !nextScrollCompensationMatrix.IsIdentity()) { |
+ gfx::Transform inverseSurfaceDrawTransform(gfx::Transform::kSkipInitialization); |
+ layer->renderSurface()->drawTransform().GetInverse(&inverseSurfaceDrawTransform); |
danakj
2012/12/19 05:23:06
DCHECK the return value? Or should we do something
|
+ nextScrollCompensationMatrix = inverseSurfaceDrawTransform * nextScrollCompensationMatrix * layer->renderSurface()->drawTransform(); |
+ } |
return nextScrollCompensationMatrix; |
} |
@@ -736,7 +742,9 @@ static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo |
renderSurface->setIsClipped(ancestorClipsSubtree); |
if (ancestorClipsSubtree) { |
renderSurface->setClipRect(clipRectFromAncestor); |
- clipRectForSubtreeInDescendantSpace = gfx::ToEnclosingRect(MathUtil::projectClippedRect(MathUtil::inverse(renderSurface->drawTransform()), renderSurface->clipRect())); |
+ gfx::Transform inverseSurfaceDrawTransform(gfx::Transform::kSkipInitialization); |
+ renderSurface->drawTransform().GetInverse(&inverseSurfaceDrawTransform); |
danakj
2012/12/19 05:23:06
DCHECK the return value?
|
+ clipRectForSubtreeInDescendantSpace = gfx::ToEnclosingRect(MathUtil::projectClippedRect(inverseSurfaceDrawTransform, renderSurface->clipRect())); |
} else { |
renderSurface->setClipRect(gfx::Rect()); |
clipRectForSubtreeInDescendantSpace = clipRectFromAncestorInDescendantSpace; |
@@ -998,12 +1006,13 @@ void LayerTreeHostCommon::calculateDrawProperties(LayerImpl* rootLayer, const gf |
static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transform& localSpaceToScreenSpaceTransform, gfx::RectF localSpaceRect) |
{ |
// If the transform is not invertible, then assume that this point doesn't hit this rect. |
- if (!localSpaceToScreenSpaceTransform.IsInvertible()) |
+ gfx::Transform inverseLocalSpaceToScreenSpace(gfx::Transform::kSkipInitialization); |
+ if (!localSpaceToScreenSpaceTransform.GetInverse(&inverseLocalSpaceToScreenSpace)) |
return false; |
// Transform the hit test point from screen space to the local space of the given rect. |
bool clipped = false; |
- gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(MathUtil::inverse(localSpaceToScreenSpaceTransform), screenSpacePoint, clipped); |
+ gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(inverseLocalSpaceToScreenSpace, screenSpacePoint, clipped); |
// If projectPoint could not project to a valid value, then we assume that this point doesn't hit this rect. |
if (clipped) |
@@ -1015,12 +1024,13 @@ static bool pointHitsRect(const gfx::PointF& screenSpacePoint, const gfx::Transf |
static bool pointHitsRegion(gfx::PointF screenSpacePoint, const gfx::Transform& screenSpaceTransform, const Region& layerSpaceRegion, float layerContentScaleX, float layerContentScaleY) |
{ |
// If the transform is not invertible, then assume that this point doesn't hit this region. |
- if (!screenSpaceTransform.IsInvertible()) |
+ gfx::Transform inverseScreenSpaceTransform(gfx::Transform::kSkipInitialization); |
+ if (!screenSpaceTransform.GetInverse(&inverseScreenSpaceTransform)) |
return false; |
// Transform the hit test point from screen space to the local space of the given region. |
bool clipped = false; |
- gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(MathUtil::inverse(screenSpaceTransform), screenSpacePoint, clipped); |
+ gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(inverseScreenSpaceTransform, screenSpacePoint, clipped); |
gfx::PointF hitTestPointInLayerSpace = gfx::ScalePoint(hitTestPointInContentSpace, 1 / layerContentScaleX, 1 / layerContentScaleY); |
// If projectPoint could not project to a valid value, then we assume that this point doesn't hit this region. |