diff options
author | Stan Iliev <stani@google.com> | 2018-02-07 14:07:30 -0500 |
---|---|---|
committer | Stan Iliev <stani@google.com> | 2018-02-08 19:01:08 +0000 |
commit | 65e678fdb1375fe183e628ff158f66b2f04331d0 (patch) | |
tree | eb90b484d1781974f7e5200e0d4eba87ce367b19 /libs/hwui/VectorDrawable.cpp | |
parent | bc48bd8f6137955b99f51562ab4959783f827e22 (diff) |
Cache VectorDrawable bounds at record time
Cache VectorDrawable bounds at record time, because the same
drawable object may be used several times with different bounds.
Bug: 71737362
Test: Wrote a new unit test, tried sample app attached to the bug
Change-Id: If7be934acf0c16b328cb0f95d849e463dcd3b88b
Diffstat (limited to 'libs/hwui/VectorDrawable.cpp')
-rw-r--r-- | libs/hwui/VectorDrawable.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp index f118e8d0a53e..f662406bdc38 100644 --- a/libs/hwui/VectorDrawable.cpp +++ b/libs/hwui/VectorDrawable.cpp @@ -557,13 +557,12 @@ void Tree::Cache::clear() { mAtlasKey = INVALID_ATLAS_KEY; } -void Tree::draw(SkCanvas* canvas) { +void Tree::draw(SkCanvas* canvas, const SkRect& bounds) { SkRect src; sk_sp<SkSurface> vdSurface = mCache.getSurface(&src); if (vdSurface) { canvas->drawImageRect(vdSurface->makeImageSnapshot().get(), src, - mutateProperties()->getBounds(), getPaint(), - SkCanvas::kFast_SrcRectConstraint); + bounds, getPaint(), SkCanvas::kFast_SrcRectConstraint); } else { // Handle the case when VectorDrawableAtlas has been destroyed, because of memory pressure. // We render the VD into a temporary standalone buffer and mark the frame as dirty. Next @@ -575,8 +574,7 @@ void Tree::draw(SkCanvas* canvas) { int scaledWidth = SkScalarCeilToInt(mProperties.getScaledWidth()); int scaledHeight = SkScalarCeilToInt(mProperties.getScaledHeight()); canvas->drawBitmapRect(skiaBitmap, SkRect::MakeWH(scaledWidth, scaledHeight), - mutateProperties()->getBounds(), getPaint(), - SkCanvas::kFast_SrcRectConstraint); + bounds, getPaint(), SkCanvas::kFast_SrcRectConstraint); mCache.clear(); markDirty(); } |