diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-10 18:20:23 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-10 18:20:23 +0000 |
commit | 6f9286202831dd807daf9b1e39271da8f390210e (patch) | |
tree | f7e3b9377b0924346ce6b69fd8b22e2196655783 /src | |
parent | dee54be428017a81f13519291a03baac11d61602 (diff) |
When cloning picture, use a bitmap heap to avoid flattening bitmaps.
When cloning a picture, the paints are reflattened. Use a bitmap
heap so the bitmaps do not get unnecessarily get flattened as well.
For br.337, this speeds up bench_pictures timing the clone
operation (not yet checked in, but currently timing making five
clones) from around 180 ms to around 24ms.
Review URL: https://codereview.appspot.com/6903063
git-svn-id: http://skia.googlecode.com/svn/trunk@6740 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index 3024c22627..9a8f133d8a 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -194,6 +194,20 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInf */ deepCopyInfo->paintData.setCount(src.fPaints->count()); + /* Use an SkBitmapHeap to avoid flattening bitmaps in shaders. If there already is one, + * use it. If this SkPicturePlayback was created from a stream, fBitmapHeap will be + * NULL, so create a new one. + */ + if (fBitmapHeap.get() == NULL) { + // FIXME: Put this on the stack inside SkPicture::clone. Further, is it possible to + // do the rest of this initialization in SkPicture::clone as well? + SkBitmapHeap* heap = SkNEW(SkBitmapHeap); + deepCopyInfo->controller.setBitmapStorage(heap); + heap->unref(); + } else { + deepCopyInfo->controller.setBitmapStorage(fBitmapHeap); + } + SkDEBUGCODE(int heapSize = SafeCount(fBitmapHeap.get());) for (int i = 0; i < src.fPaints->count(); i++) { if (needs_deep_copy(src.fPaints->at(i))) { |