diff options
author | Derek Sollenberger <djsollen@google.com> | 2020-11-25 11:49:22 -0500 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2020-11-25 11:49:22 -0500 |
commit | 2960d1693cb3842282663aa395708de788f92ffa (patch) | |
tree | 96d132ee91f77a44cb41559bf759e0e39a8bed9f /libs/hwui/VectorDrawable.cpp | |
parent | 2af48c7f99e2174e8554171b019e46427bca438a (diff) |
Stop copying VectorDrawable pixels when drawing.
Drawing a mutable SkBitmap to an SkCanvas will result in the pixels
being copied and a new genID assigned. This results in both a cpu
and gpu copy every time a VectorDrawable is redrawn.
The solution is to create an SkImage using the flag to instruct it
not to copy the pixels which is what Bitmap::makeImage() does.
Bug: 173732636
Test: captured SKP and verified the genID is consistent between frames
Change-Id: Ie13385e89de51c6b9ee2f2ba31eccbfdf3adac48
Diffstat (limited to 'libs/hwui/VectorDrawable.cpp')
-rw-r--r-- | libs/hwui/VectorDrawable.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp index cd908354aea5..6030c36add7a 100644 --- a/libs/hwui/VectorDrawable.cpp +++ b/libs/hwui/VectorDrawable.cpp @@ -505,13 +505,11 @@ void Tree::draw(SkCanvas* canvas, const SkRect& bounds, const SkPaint& inPaint) SkPaint paint = inPaint; paint.setAlpha(mProperties.getRootAlpha() * 255); - Bitmap& bitmap = getBitmapUpdateIfDirty(); - SkBitmap skiaBitmap; - bitmap.getSkBitmap(&skiaBitmap); + sk_sp<SkImage> cachedBitmap = getBitmapUpdateIfDirty().makeImage(); int scaledWidth = SkScalarCeilToInt(mProperties.getScaledWidth()); int scaledHeight = SkScalarCeilToInt(mProperties.getScaledHeight()); - canvas->drawBitmapRect(skiaBitmap, SkRect::MakeWH(scaledWidth, scaledHeight), bounds, + canvas->drawImageRect(cachedBitmap, SkRect::MakeWH(scaledWidth, scaledHeight), bounds, &paint, SkCanvas::kFast_SrcRectConstraint); } |