Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 256653006: Move setup of SkPictCopyInfo into SkPicture::clone (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed overlength lines Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicturePlayback.cpp
===================================================================
--- src/core/SkPicturePlayback.cpp (revision 14435)
+++ src/core/SkPicturePlayback.cpp (working copy)
@@ -138,26 +138,6 @@
#endif
}
-static bool needs_deep_copy(const SkPaint& paint) {
- /*
- * These fields are known to be immutable, and so can be shallow-copied
- *
- * getTypeface()
- * getAnnotation()
- * paint.getColorFilter()
- * getXfermode()
- * getPathEffect()
- * getMaskFilter()
- */
-
- return paint.getShader() ||
-#ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
- paint.getRasterizer() ||
-#endif
- paint.getLooper() || // needs to hide its addLayer...
- paint.getImageFilter();
-}
-
SkPicturePlayback::SkPicturePlayback(const SkPicture* picture, const SkPicturePlayback& src,
SkPictCopyInfo* deepCopyInfo)
: fPicture(picture)
@@ -175,53 +155,14 @@
SkSafeRef(fStateTree);
if (deepCopyInfo) {
+ SkASSERT(deepCopyInfo->initialized);
+
int paintCount = SafeCount(src.fPaints);
if (src.fBitmaps) {
fBitmaps = SkTRefArray<SkBitmap>::Create(src.fBitmaps->begin(), src.fBitmaps->count());
}
- if (!deepCopyInfo->initialized) {
- /* The alternative to doing this is to have a clone method on the paint and have it make
- * the deep copy of its internal structures as needed. The holdup to doing that is at
- * this point we would need to pass the SkBitmapHeap so that we don't unnecessarily
- * flatten the pixels in a bitmap shader.
- */
- deepCopyInfo->paintData.setCount(paintCount);
-
- /* 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 < paintCount; i++) {
- if (needs_deep_copy(src.fPaints->at(i))) {
- deepCopyInfo->paintData[i] =
- SkFlatData::Create<SkPaint::FlatteningTraits>(&deepCopyInfo->controller,
- src.fPaints->at(i), 0);
-
- } else {
- // this is our sentinel, which we use in the unflatten loop
- deepCopyInfo->paintData[i] = NULL;
- }
- }
- SkASSERT(SafeCount(fBitmapHeap.get()) == heapSize);
-
- // needed to create typeface playback
- deepCopyInfo->controller.setupPlaybacks();
- deepCopyInfo->initialized = true;
- }
-
fPaints = SkTRefArray<SkPaint>::Create(paintCount);
SkASSERT(deepCopyInfo->paintData.count() == paintCount);
SkBitmapHeap* bmHeap = deepCopyInfo->controller.getBitmapHeap();
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698