From d79757e3da43f56698b0f3d1aeae71bf80896bd8 Mon Sep 17 00:00:00 2001 From: "danakj@chromium.org" Date: Fri, 9 Nov 2012 02:02:18 +0000 Subject: cc: Add some early outs to avoid expensive operations mapHomgenousPoint is not cheap. We can do faster in projectClippedRect similar to mapClippedRect. rectSubtractRegion constructs a Region to do subtraction from. If the subtraction's rvalue is empty, then there is nothing to do and we can avoid creating a Region structure at all. I measured time spent in calculateRenderPasses with a draw-heavy unit test. Baseline: 0.001148 seconds With these changes: 0.001116 seconds So, about 3% reduction in time spent in calculateRenderPasses. R=enne BUG=159718 Review URL: https://chromiumcodereview.appspot.com/11312154 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166841 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/math_util.cc | 10 ++++++++-- cc/occlusion_tracker.cc | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'cc') diff --git a/cc/math_util.cc b/cc/math_util.cc index f18b8401..ecad845 100644 --- a/cc/math_util.cc +++ b/cc/math_util.cc @@ -117,7 +117,7 @@ gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co } // Apply the transform, but retain the result in homogeneous coordinates. - gfx::QuadF q = gfx::QuadF(gfx::RectF(srcRect)); + gfx::QuadF q = gfx::QuadF(srcRect); HomogeneousCoordinate h1 = mapHomogeneousPoint(transform, gfx::Point3F(q.p1())); HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(q.p2())); HomogeneousCoordinate h3 = mapHomogeneousPoint(transform, gfx::Point3F(q.p3())); @@ -128,8 +128,14 @@ gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform, const gfx::RectF& srcRect) { + if (transform.isIdentityOrTranslation()) { + gfx::RectF projectedRect(srcRect); + projectedRect.Offset(static_cast(transform.m41()), static_cast(transform.m42())); + return projectedRect; + } + // Perform the projection, but retain the result in homogeneous coordinates. - gfx::QuadF q = gfx::QuadF(gfx::RectF(srcRect)); + gfx::QuadF q = gfx::QuadF(srcRect); HomogeneousCoordinate h1 = projectHomogeneousPoint(transform, q.p1()); HomogeneousCoordinate h2 = projectHomogeneousPoint(transform, q.p2()); HomogeneousCoordinate h3 = projectHomogeneousPoint(transform, q.p3()); diff --git a/cc/occlusion_tracker.cc b/cc/occlusion_tracker.cc index 9c536d2..c5f7276 100644 --- a/cc/occlusion_tracker.cc +++ b/cc/occlusion_tracker.cc @@ -349,6 +349,9 @@ bool OcclusionTrackerBase::occluded(const LayerTyp // the resulting unoccluded region is not rectangular, we return a rect containing it. static inline gfx::Rect rectSubtractRegion(const gfx::Rect& rect, const Region& region) { + if (region.IsEmpty()) + return rect; + Region rectRegion(rect); rectRegion.Subtract(region); return rectRegion.bounds(); -- cgit v1.1