diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/hwui/DisplayListRenderer.cpp | 16 | ||||
| -rw-r--r-- | libs/hwui/DisplayListRenderer.h | 13 | ||||
| -rw-r--r-- | libs/hwui/Matrix.cpp | 11 |
3 files changed, 32 insertions, 8 deletions
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index 92207b1..f6ca77c 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -184,6 +184,11 @@ void DisplayList::clearResources() { } mPaths.clear(); + for (size_t i = 0; i < mSourcePaths.size(); i++) { + caches.resourceCache.decrementRefcount(mSourcePaths.itemAt(i)); + } + mSourcePaths.clear(); + for (size_t i = 0; i < mMatrices.size(); i++) { delete mMatrices.itemAt(i); } @@ -242,6 +247,12 @@ void DisplayList::initFromDisplayListRenderer(const DisplayListRenderer& recorde mPaths.add(paths.itemAt(i)); } + const SortedVector<SkPath*> &sourcePaths = recorder.getSourcePaths(); + for (size_t i = 0; i < sourcePaths.size(); i++) { + mSourcePaths.add(sourcePaths.itemAt(i)); + caches.resourceCache.incrementRefcount(sourcePaths.itemAt(i)); + } + const Vector<SkMatrix*> &matrices = recorder.getMatrices(); for (size_t i = 0; i < matrices.size(); i++) { mMatrices.add(matrices.itemAt(i)); @@ -1273,6 +1284,11 @@ void DisplayListRenderer::reset() { mShaders.clear(); mShaderMap.clear(); + for (size_t i = 0; i < mSourcePaths.size(); i++) { + caches.resourceCache.decrementRefcount(mSourcePaths.itemAt(i)); + } + mSourcePaths.clear(); + mPaints.clear(); mPaintMap.clear(); diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index a7fc23a..5ce770d 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; @@ -487,6 +487,7 @@ private: Vector<SkPaint*> mPaints; Vector<SkPath*> mPaths; + SortedVector<SkPath*> mSourcePaths; Vector<SkMatrix*> mMatrices; Vector<SkiaShader*> mShaders; @@ -634,6 +635,10 @@ public: return mPaths; } + const SortedVector<SkPath*>& getSourcePaths() const { + return mSourcePaths; + } + const Vector<SkMatrix*>& getMatrices() const { return mMatrices; } @@ -750,6 +755,10 @@ private: mPathMap.replaceValueFor(path, pathCopy); mPaths.add(pathCopy); } + if (mSourcePaths.indexOf(path) < 0) { + Caches::getInstance().resourceCache.incrementRefcount(path); + mSourcePaths.add(path); + } addInt((int) pathCopy); } @@ -830,6 +839,8 @@ private: Vector<SkPath*> mPaths; DefaultKeyedVector<SkPath*, SkPath*> mPathMap; + SortedVector<SkPath*> mSourcePaths; + Vector<SkiaShader*> mShaders; DefaultKeyedVector<SkiaShader*, SkiaShader*> mShaderMap; 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() { |
