[go: nahoru, domu]

Staged removal of SkPicture-derived classes

This CL removes the SkPicture-derived classes (with a flag to keeps clients working). In the process it also lightens the recording factory function so it is no longer ref counted).

The only interesting bits are in SkPicture* and Sk*Picture.*

R=reed@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/238273012

git-svn-id: http://skia.googlecode.com/svn/trunk/src@14251 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkPicture.cpp b/core/SkPicture.cpp
index 986dc42..d6f05b1 100644
--- a/core/SkPicture.cpp
+++ b/core/SkPicture.cpp
@@ -222,6 +222,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
 SkCanvas* SkPicture::beginRecording(int width, int height,
                                     uint32_t recordingFlags) {
     if (fPlayback) {
@@ -252,6 +254,43 @@
     return fRecord;
 }
 
+#endif
+
+SkCanvas* SkPicture::beginRecording(int width, int height, 
+                                    SkBBHFactory* bbhFactory,
+                                    uint32_t recordingFlags) {
+    if (fPlayback) {
+        SkDELETE(fPlayback);
+        fPlayback = NULL;
+    }
+    SkSafeUnref(fAccelData);
+    SkSafeSetNull(fRecord);
+
+    this->needsNewGenID();
+
+    fWidth = width;
+    fHeight = height;
+
+    const SkISize size = SkISize::Make(width, height);
+
+    if (NULL != bbhFactory) {
+        SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
+        SkASSERT(NULL != tree);
+        fRecord = SkNEW_ARGS(SkBBoxHierarchyRecord, (size, 
+                                                     recordingFlags|
+                                                     kOptimizeForClippedPlayback_RecordingFlag,
+                                                     tree.get()));
+    } else {
+        fRecord = SkNEW_ARGS(SkPictureRecord, (size, recordingFlags));
+    }
+    fRecord->beginRecording();
+
+    return fRecord;
+}
+
+
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
 SkBBoxHierarchy* SkPicture::createBBoxHierarchy() const {
     // TODO: this code is now replicated in SkRTreePicture. Once all external
     // clients have been weaned off of kOptimizeForClippedPlayback_RecordingFlag,
@@ -270,6 +309,8 @@
                            aspectRatio, sortDraws);
 }
 
+#endif
+
 SkCanvas* SkPicture::getRecordingCanvas() const {
     // will be null if we are not recording
     return fRecord;