summaryrefslogtreecommitdiffstats
path: root/cc/base
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-12 17:30:55 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-12 17:30:55 +0000
commit8a82269dafa5aca936588a6d9a7b74acfc8565c9 (patch)
treeb9bec591201c984a051cf95e1754985b70ee3802 /cc/base
parentf734b224073190d8a32986c6550b7e5492e92735 (diff)
downloadchromium_src-8a82269dafa5aca936588a6d9a7b74acfc8565c9.zip
chromium_src-8a82269dafa5aca936588a6d9a7b74acfc8565c9.tar.gz
chromium_src-8a82269dafa5aca936588a6d9a7b74acfc8565c9.tar.bz2
Avoid int->float->int conversion in OcclusionTracker for int translates.
If the transform on a layer is an integer translation, we can easily avoid converting the query rectangle to floats just to convert them back to integers again. This is super costly. Added a perftest for this. On an N4 the results are Before: 20.553817749023438 us After: 13.440165519714355 us For about 35% reduction in time in this scnario. Also renames MapClippedRect(Rect) to MapEnclosingClippedRect(Rect) to describe what it does better, and audit callsides of MapClippedRect to change any others that then ToEnclosingRect to call the MapEnclosingClippedRect instead. Similar for Project. R=enne BUG=342848 Review URL: https://codereview.chromium.org/143293005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/base')
-rw-r--r--cc/base/math_util.cc24
-rw-r--r--cc/base/math_util.h6
2 files changed, 26 insertions, 4 deletions
diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc
index 72b1e7f..e696ea6 100644
--- a/cc/base/math_util.cc
+++ b/cc/base/math_util.cc
@@ -101,8 +101,15 @@ static inline void AddVertexToClippedQuad(const gfx::PointF& new_vertex,
(*num_vertices_in_clipped_quad)++;
}
-gfx::Rect MathUtil::MapClippedRect(const gfx::Transform& transform,
- const gfx::Rect& src_rect) {
+gfx::Rect MathUtil::MapEnclosingClippedRect(const gfx::Transform& transform,
+ const gfx::Rect& src_rect) {
+ if (transform.IsIdentityOrIntegerTranslation()) {
+ return src_rect +
+ gfx::Vector2d(
+ static_cast<int>(SkMScalarToFloat(transform.matrix().get(0, 3))),
+ static_cast<int>(
+ SkMScalarToFloat(transform.matrix().get(1, 3))));
+ }
return gfx::ToEnclosingRect(MapClippedRect(transform, gfx::RectF(src_rect)));
}
@@ -136,6 +143,19 @@ gfx::RectF MathUtil::MapClippedRect(const gfx::Transform& transform,
return ComputeEnclosingClippedRect(hc0, hc1, hc2, hc3);
}
+gfx::Rect MathUtil::ProjectEnclosingClippedRect(const gfx::Transform& transform,
+ const gfx::Rect& src_rect) {
+ if (transform.IsIdentityOrIntegerTranslation()) {
+ return src_rect +
+ gfx::Vector2d(
+ static_cast<int>(SkMScalarToFloat(transform.matrix().get(0, 3))),
+ static_cast<int>(
+ SkMScalarToFloat(transform.matrix().get(1, 3))));
+ }
+ return gfx::ToEnclosingRect(
+ ProjectClippedRect(transform, gfx::RectF(src_rect)));
+}
+
gfx::RectF MathUtil::ProjectClippedRect(const gfx::Transform& transform,
const gfx::RectF& src_rect) {
if (transform.IsIdentityOrTranslation()) {
diff --git a/cc/base/math_util.h b/cc/base/math_util.h
index fca08ef..9d6364ae 100644
--- a/cc/base/math_util.h
+++ b/cc/base/math_util.h
@@ -99,10 +99,12 @@ class CC_EXPORT MathUtil {
//
// These functions return the axis-aligned rect that encloses the correctly
// clipped, transformed polygon.
- static gfx::Rect MapClippedRect(const gfx::Transform& transform,
- const gfx::Rect& rect);
+ static gfx::Rect MapEnclosingClippedRect(const gfx::Transform& transform,
+ const gfx::Rect& rect);
static gfx::RectF MapClippedRect(const gfx::Transform& transform,
const gfx::RectF& rect);
+ static gfx::Rect ProjectEnclosingClippedRect(const gfx::Transform& transform,
+ const gfx::Rect& rect);
static gfx::RectF ProjectClippedRect(const gfx::Transform& transform,
const gfx::RectF& rect);