From c9ab987efcb7e8b69237d565f73c28c137610232 Mon Sep 17 00:00:00 2001 From: "djsollen@google.com" Date: Wed, 29 Aug 2012 18:52:07 +0000 Subject: Implement multi-threaded picture playback via cloning. The CL adds SkPicture.clone() which produces a thread-safe copy by creating a shallow copy of the thread-safe data within the picture and a deep copy of the data that is not (e.g. SkPaint). This implementation re-flattens the paints when cloning instead of retaining the flattened paints from the recording process. Changes were also needed to various classes to ensure thread safety Review URL: https://codereview.appspot.com/6459105 git-svn-id: http://skia.googlecode.com/svn/trunk@5335 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/core/SkPictureRecord.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/core/SkPictureRecord.cpp') diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 3d124c4882..afa2debc0d 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -31,12 +31,14 @@ SkPictureRecord::SkPictureRecord(uint32_t flags) : fRestoreOffsetStack.setReserve(32); fInitialSaveCount = kNoInitialSave; - fFlattenableHeap.setBitmapStorage(&fBitmapHeap); + fBitmapHeap = SkNEW(SkBitmapHeap); + fFlattenableHeap.setBitmapStorage(fBitmapHeap); fPathHeap = NULL; // lazy allocate fFirstSavedLayerIndex = kNoSavedLayerIndex; } SkPictureRecord::~SkPictureRecord() { + SkSafeUnref(fBitmapHeap); SkSafeUnref(fPathHeap); fFlattenableHeap.setBitmapStorage(NULL); fPictureRefs.unrefAll(); @@ -521,7 +523,7 @@ void SkPictureRecord::drawData(const void* data, size_t length) { /////////////////////////////////////////////////////////////////////////////// void SkPictureRecord::addBitmap(const SkBitmap& bitmap) { - addInt(fBitmapHeap.insert(bitmap)); + addInt(fBitmapHeap->insert(bitmap)); } void SkPictureRecord::addMatrix(const SkMatrix& matrix) { -- cgit v1.2.3