summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 02:02:18 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 02:02:18 +0000
commitd79757e3da43f56698b0f3d1aeae71bf80896bd8 (patch)
tree25c29dbd49ff72e7632e421ec4fd0a29b994b896 /cc
parent58622c25c65388dd60b7bdce80f313d054f4f133 (diff)
downloadchromium_src-d79757e3da43f56698b0f3d1aeae71bf80896bd8.zip
chromium_src-d79757e3da43f56698b0f3d1aeae71bf80896bd8.tar.gz
chromium_src-d79757e3da43f56698b0f3d1aeae71bf80896bd8.tar.bz2
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
Diffstat (limited to 'cc')
-rw-r--r--cc/math_util.cc10
-rw-r--r--cc/occlusion_tracker.cc3
2 files changed, 11 insertions, 2 deletions
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<float>(transform.m41()), static_cast<float>(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<LayerType, RenderSurfaceType>::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();