summaryrefslogtreecommitdiff
path: root/libs/hwui/DamageAccumulator.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-08-12 13:39:11 -0700
committerJohn Reck <jreck@google.com>2015-08-12 13:52:01 -0700
commitc128823940fb0be96eda810fa9f0c75f66d944b0 (patch)
tree80acd00da3cf348f7af45ed1ebda6a1ea302e834 /libs/hwui/DamageAccumulator.cpp
parent2d2ba516e6f1ea9e515f29cdf84e75a17e8fa60b (diff)
Fix bug in calculating perspective damage
Change-Id: Iacab98cf3525f891012087acf85e4205b5e8f0d0
Diffstat (limited to 'libs/hwui/DamageAccumulator.cpp')
-rw-r--r--libs/hwui/DamageAccumulator.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index 9bd3bdc5617e..c2e14a29f29e 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -121,7 +121,14 @@ void DamageAccumulator::popTransform() {
static inline void mapRect(const Matrix4* matrix, const SkRect& in, SkRect* out) {
if (in.isEmpty()) return;
Rect temp(in);
- matrix->mapRect(temp);
+ if (CC_LIKELY(!matrix->isPerspective())) {
+ matrix->mapRect(temp);
+ } else {
+ // Don't attempt to calculate damage for a perspective transform
+ // as the numbers this works with can break the perspective
+ // calculations. Just give up and expand to DIRTY_MIN/DIRTY_MAX
+ temp.set(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
+ }
out->join(RECT_ARGS(temp));
}
@@ -134,7 +141,14 @@ static inline void mapRect(const RenderProperties& props, const SkRect& in, SkRe
const SkMatrix* transform = props.getTransformMatrix();
SkRect temp(in);
if (transform && !transform->isIdentity()) {
- transform->mapRect(&temp);
+ if (CC_LIKELY(!transform->hasPerspective())) {
+ transform->mapRect(&temp);
+ } else {
+ // Don't attempt to calculate damage for a perspective transform
+ // as the numbers this works with can break the perspective
+ // calculations. Just give up and expand to DIRTY_MIN/DIRTY_MAX
+ temp.set(DIRTY_MIN, DIRTY_MIN, DIRTY_MAX, DIRTY_MAX);
+ }
}
temp.offset(props.getLeft(), props.getTop());
out->join(temp);