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

Unified Diff: cc/math_util.cc

Issue 11442020: optimize computing bounds by calling SkMatrix44::map2() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/math_util.cc
===================================================================
--- cc/math_util.cc (revision 170980)
+++ cc/math_util.cc (working copy)
@@ -109,15 +109,32 @@
{
if (transform.IsIdentityOrTranslation())
return srcRect + gfx::Vector2dF(static_cast<float>(transform.matrix().getDouble(0, 3)), static_cast<float>(transform.matrix().getDouble(1, 3)));
-
+
// Apply the transform, but retain the result in homogeneous coordinates.
- 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()));
- HomogeneousCoordinate h4 = mapHomogeneousPoint(transform, gfx::Point3F(q.p4()));
- return computeEnclosingClippedRect(h1, h2, h3, h4);
+ double quad[4 * 2]; // input: 4 x 2D point
+ quad[0] = srcRect.x(); quad[1] = srcRect.y();
shawnsingh 2012/12/06 03:00:55 nit: point --> points
reed1 2012/12/06 05:50:20 Done.
+ quad[2] = srcRect.right(); quad[3] = srcRect.y();
+ quad[4] = srcRect.x(); quad[5] = srcRect.bottom();
+ quad[6] = srcRect.right(); quad[7] = srcRect.bottom();
+
+ double result[4 * 4]; // output: 4 x 4D homogeneous point
+ transform.matrix().map2(quad, 4, result);
+
+ if (!(transform.matrix().getType() & SkMatrix44::kPerspective_Mask)) {
+ const SkPoint pts[] = {
+ { result[0], result[1] }, { result[4], result[5] },
+ { result[8], result[8] }, { result[12], result[13] },
+ };
+ SkRect r;
+ r.set(pts, 4);
+ return gfx::RectF(r.x(), r.y(), r.width(), r.height());
+ }
+
+ return computeEnclosingClippedRect(*(const HomogeneousCoordinate*)&result[0],
+ *(const HomogeneousCoordinate*)&result[4],
+ *(const HomogeneousCoordinate*)&result[8],
+ *(const HomogeneousCoordinate*)&result[12]);
}
gfx::RectF MathUtil::projectClippedRect(const gfx::Transform& transform, const gfx::RectF& srcRect)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698