Remove picture pre-allocation from SkPictureRecorder

This CL improves the separation of the SkPicture and SkPictureRecord classes. It delays creation of the SkPicture (in SkPictureRecorder) until recording is actually completed. To accomplish this the SkRecord-derived classes now get SkPathHeap and SkPictureContentInfo members that are absorbed by the SkPicture when it is constructed.

As an ancillary change, this CL also moves the SkPictureContentInfo object from SkPicture to SkPicturePlayback. This is intended to centralize all the data in the SkPicturePlayback object.

R=mtklein@google.com, reed@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/324293004
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 1a1aecc..5d2eca7 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -36,7 +36,7 @@
 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size;
 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect);
 
-SkPictureRecord::SkPictureRecord(SkPicture* picture, const SkISize& dimensions, uint32_t flags)
+SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags)
     : INHERITED(dimensions.width(), dimensions.height())
     , fBoundingHierarchy(NULL)
     , fStateTree(NULL)
@@ -49,7 +49,6 @@
     fPointWrites = fRectWrites = fTextWrites = 0;
 #endif
 
-    fPicture = picture;
     fBitmapHeap = SkNEW(SkBitmapHeap);
     fFlattenableHeap.setBitmapStorage(fBitmapHeap);
 
@@ -1066,11 +1065,11 @@
 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) {
 
     if (paint.isAntiAlias() && !path.isConvex()) {
-        fPicture->incAAConcavePaths();
+        fContentInfo.incAAConcavePaths();
 
         if (SkPaint::kStroke_Style == paint.getStyle() &&
             0 == paint.getStrokeWidth()) {
-            fPicture->incAAHairlineConcavePaths();
+            fContentInfo.incAAHairlineConcavePaths();
         }
     }
 
@@ -1589,7 +1588,7 @@
 
 const SkFlatData* SkPictureRecord::addPaintPtr(const SkPaint* paint) {
     if (NULL != paint && NULL != paint->getPathEffect()) {
-        fPicture->incPaintWithPathEffectUses();
+        fContentInfo.incPaintWithPathEffectUses();
     }
 
     const SkFlatData* data = paint ? getFlatPaintData(*paint) : NULL;
@@ -1603,7 +1602,14 @@
 }
 
 int SkPictureRecord::addPathToHeap(const SkPath& path) {
-    return fPicture->addPathToHeap(path);
+    if (NULL == fPathHeap) {
+        fPathHeap.reset(SkNEW(SkPathHeap));
+    }
+#ifdef SK_DEDUP_PICTURE_PATHS
+    return fPathHeap->insert(path);
+#else
+    return fPathHeap->append(path);
+#endif
 }
 
 void SkPictureRecord::addPath(const SkPath& path) {