summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-07-30 00:07:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-07-30 00:07:43 +0000
commit32e205dc9c0b65e576ba22263052a646943d2f06 (patch)
tree946a8ced6dabbfc0835eda8ef54a3f9f9042acb9 /libs/hwui/pipeline
parent4ef6395690fccb25bc2c61e2ede4159a38bedc20 (diff)
parent694f3e4a5518e8e3fe025a5a04e9088fe41df97d (diff)
Merge "Improve integer aligned coordinate detection"
Diffstat (limited to 'libs/hwui/pipeline')
-rw-r--r--libs/hwui/pipeline/skia/LayerDrawable.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/libs/hwui/pipeline/skia/LayerDrawable.cpp b/libs/hwui/pipeline/skia/LayerDrawable.cpp
index 96b17e1d7975..b0173846e582 100644
--- a/libs/hwui/pipeline/skia/LayerDrawable.cpp
+++ b/libs/hwui/pipeline/skia/LayerDrawable.cpp
@@ -33,6 +33,10 @@ void LayerDrawable::onDraw(SkCanvas* canvas) {
}
}
+static inline SkScalar isIntegerAligned(SkScalar x) {
+ return fabsf(roundf(x) - x) <= NON_ZERO_EPSILON;
+}
+
// Disable filtering when there is no scaling in screen coordinates and the corners have the same
// fraction (for translate) or zero fraction (for any other rect-to-rect transform).
static bool shouldFilterRect(const SkMatrix& matrix, const SkRect& srcRect, const SkRect& dstRect) {
@@ -62,10 +66,10 @@ static bool shouldFilterRect(const SkMatrix& matrix, const SkRect& srcRect, cons
if (requiresIntegerTranslate) {
// Device rect and source rect should be integer aligned to ensure there's no difference
// in how nearest-neighbor sampling is resolved.
- return !(MathUtils::isZero(SkScalarFraction(srcRect.x())) &&
- MathUtils::isZero(SkScalarFraction(srcRect.y())) &&
- MathUtils::isZero(SkScalarFraction(dstDevRect.x())) &&
- MathUtils::isZero(SkScalarFraction(dstDevRect.y())));
+ return !(isIntegerAligned(srcRect.x()) &&
+ isIntegerAligned(srcRect.y()) &&
+ isIntegerAligned(dstDevRect.x()) &&
+ isIntegerAligned(dstDevRect.y()));
} else {
// As long as src and device rects are translated by the same fractional amount,
// filtering won't be needed