From d3efd6920e64d0207a0655640297d87d4937ee27 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Mon, 7 May 2012 12:18:19 -0700 Subject: Fix issue where scale-animating text would jump temporarily a few pixels Some logic in the native matrix code would determine that a matrix was 'pureTranslate' based on the scale values of a matrix being close-enough to 1, which was within a very small epsilon. This works in general, because screen space coordinates make that epsilon value irrelevant, so close-enough really is close-enough. However, TextView, when centering text, works in a coordinate system that is quite huge, with left/right values about 500,000. These numbers multiplied times that small epsilon value would give a result that was significant, and would cause a miscalculation of up to 4-5 pixels, causing the snap that we'd see for a couple of frames as the scale got "close enough" to 1. The fix is to remove the optimization of "close enough". What we really need the matrix to do is to identify itself as being translate-only when no scale as been set (which is the default). For the purposes of that check, it is good enough to simply check the values against 1 directly. Similarly, the bounds-check logic needs to check against 0 and 1 directly. Issue #6452687: Glitch when changing scale of a view containing text Change-Id: I167fb45d02201fb879deea0e5a7ca95e38128e17 --- libs/hwui/DisplayListRenderer.h | 2 +- libs/hwui/Matrix.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'libs') diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index a7fc23a..aff68e5 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -255,7 +255,7 @@ public: if (scaleY != mScaleY) { mScaleY = scaleY; mMatrixDirty = true; - if (ALMOST_EQUAL(mScaleX, 1) && ALMOST_EQUAL(mScaleY, 1)) { + if (mScaleX == 1.0f && mScaleY == 1.0f) { mMatrixFlags &= ~SCALE; } else { mMatrixFlags |= SCALE; diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index a8f937d..7348f4d 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -56,16 +56,13 @@ void Matrix4::loadIdentity() { } bool Matrix4::changesBounds() { - return !(ALMOST_EQUAL(data[0], 1.0f) && ALMOST_EQUAL(data[1], 0.0f) && - ALMOST_EQUAL(data[2], 0.0f) && ALMOST_EQUAL(data[4], 0.0f) && - ALMOST_EQUAL(data[5], 1.0f) && ALMOST_EQUAL(data[6], 0.0f) && - ALMOST_EQUAL(data[8], 0.0f) && ALMOST_EQUAL(data[9], 0.0f) && - ALMOST_EQUAL(data[10], 1.0f)); + return !(data[0] == 1.0f && data[1] == 0.0f && data[2] == 0.0f && data[4] == 0.0f && + data[5] == 1.0f && data[6] == 0.0f && data[8] == 0.0f && data[9] == 0.0f && + data[10] == 1.0f); } bool Matrix4::isPureTranslate() { - return mSimpleMatrix && - ALMOST_EQUAL(data[kScaleX], 1.0f) && ALMOST_EQUAL(data[kScaleY], 1.0f); + return mSimpleMatrix && data[kScaleX] == 1.0f && data[kScaleY] == 1.0f; } bool Matrix4::isSimple() { -- cgit v1.1