summaryrefslogtreecommitdiff
path: root/libs/hwui/RecordingCanvas.cpp
diff options
context:
space:
mode:
authorNathaniel Nifong <nifong@google.com>2019-07-11 16:27:14 -0400
committerNathaniel Nifong <nifong@google.com>2019-07-12 15:14:06 -0400
commit31fee3a24442e42c09f90893702e1e210495166d (patch)
tree22c56b4504d3472b2a14f03a5a17a5f17d7bb118 /libs/hwui/RecordingCanvas.cpp
parent2be379300d7895729bb376edb645cd67351e22a7 (diff)
Resolve drawable when playing back DisplayListData in the RenderThread.
Drawables are mutable, and not expected to produce the same content if retained for longer than the duration of the frame. This becomes relevant when recording multi-frame SKPs because the serialization step forces drawables to be played back long after the frame completed. By resolving the drawable when we are drawing the frame we avoid ref'ing the SkDrawable and do not extend its lifetime beyond the frame. Bug: skia:9234 Test: Captured SKPs on a Pixel 3 Change-Id: I5d317dd14e20be9d5e18675df8667327bd05aff0
Diffstat (limited to 'libs/hwui/RecordingCanvas.cpp')
-rw-r--r--libs/hwui/RecordingCanvas.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index e58fbbe8e667..c8eb1ca55910 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -274,7 +274,12 @@ struct DrawDrawable final : Op {
}
sk_sp<SkDrawable> drawable;
SkMatrix matrix = SkMatrix::I();
- void draw(SkCanvas* c, const SkMatrix&) const { c->drawDrawable(drawable.get(), &matrix); }
+ // It is important that we call drawable->draw(c) here instead of c->drawDrawable(drawable).
+ // Drawables are mutable and in cases, like RenderNodeDrawable, are not expected to produce the
+ // same content if retained outside the duration of the frame. Therefore we resolve
+ // them now and do not allow the canvas to take a reference to the drawable and potentially
+ // keep it alive for longer than the frames duration (e.g. SKP serialization).
+ void draw(SkCanvas* c, const SkMatrix&) const { drawable->draw(c, &matrix); }
};
struct DrawPicture final : Op {
static const auto kType = Type::DrawPicture;