Staging for cleanup of SkPicture-related headers
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 18 Apr 2014 18:04:41 +0000 (18:04 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 18 Apr 2014 18:04:41 +0000 (18:04 +0000)
https://codereview.chromium.org/243173002

git-svn-id: http://skia.googlecode.com/svn/trunk@14258 2bbb7eff-a529-9590-31e7-b0007b416f81

46 files changed:
bench/PicturePlaybackBench.cpp
bench/PictureRecordBench.cpp
bench/benchmain.cpp
debugger/SkDebugger.cpp
dm/DMReplayTask.cpp
dm/DMTileGridTask.cpp
dm/DMUtil.cpp
gm/distantclip.cpp
gm/gmmain.cpp
gm/optimizations.cpp
gm/pathopsskpclip.cpp
gm/pictureimagefilter.cpp
gm/pictureshader.cpp
gyp/common_conditions.gypi
gyp/core.gypi
gyp/skia_for_chromium_defines.gypi
include/core/SkBBHFactory.h [new file with mode: 0644]
include/core/SkPicture.h
include/core/SkPictureRecorder.h [new file with mode: 0644]
include/core/SkRTreePicture.h
include/core/SkTileGridPicture.h
samplecode/SampleAll.cpp
samplecode/SampleApp.cpp
samplecode/SampleApp.h
samplecode/SamplePictFile.cpp
samplecode/SamplePicture.cpp
samplecode/SampleTiling.cpp
src/core/SkBBHFactory.cpp [new file with mode: 0644]
src/core/SkPicture.cpp
src/core/SkPictureRecorder.cpp [new file with mode: 0644]
src/core/SkQuadTreePicture.cpp
src/core/SkQuadTreePicture.h
src/core/SkRTreePicture.cpp
src/core/SkTileGrid.h
src/core/SkTileGridPicture.cpp
tests/CanvasTest.cpp
tests/ImageFilterTest.cpp
tests/PictureTest.cpp
tests/SerializationTest.cpp
tests/TileGridTest.cpp
tools/PictureRenderer.cpp
tools/PictureRenderer.h
tools/bench_record.cpp
tools/filtermain.cpp
tools/render_pictures_main.cpp
tools/skpmaker.cpp

index 436b652..08c96d5 100644 (file)
@@ -9,6 +9,7 @@
 #include "SkColor.h"
 #include "SkPaint.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkPoint.h"
 #include "SkRect.h"
 #include "SkString.h"
index 62f02b6..0666cc4 100644 (file)
@@ -9,6 +9,7 @@
 #include "SkColor.h"
 #include "SkPaint.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkPoint.h"
 #include "SkRandom.h"
 #include "SkRect.h"
index 4bdc044..9cdaa68 100644 (file)
@@ -20,6 +20,7 @@
 #include "SkImageEncoder.h"
 #include "SkOSFile.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkString.h"
 #include "SkSurface.h"
 
index 164c5d6..f4730d6 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "SkDebugger.h"
+#include "SkPictureRecorder.h"
 #include "SkString.h"
 
 
index 791370d..cea978f 100644 (file)
@@ -2,9 +2,9 @@
 #include "DMWriteTask.h"
 #include "DMUtil.h"
 
+#include "SkBBHFactory.h"
 #include "SkCommandLineFlags.h"
 #include "SkPicture.h"
-#include "SkRTreePicture.h"
 
 DEFINE_bool(replay, true, "If true, run picture replay tests.");
 DEFINE_bool(rtree,  true, "If true, run picture replay tests with an rtree.");
index 9a036bf..4299bd7 100644 (file)
@@ -2,9 +2,9 @@
 #include "DMWriteTask.h"
 #include "DMUtil.h"
 
+#include "SkBBHFactory.h"
 #include "SkCommandLineFlags.h"
 #include "SkPicture.h"
-#include "SkTileGridPicture.h"
 
 // TODO(mtklein): Tile grid tests are currently failing.  (Skia issue 1198).  When fixed, -> true.
 DEFINE_bool(tileGrid, false, "If true, run picture replay tests with a tile grid.");
index bf7fbf9..9a4765a 100644 (file)
@@ -1,6 +1,7 @@
 #include "DMUtil.h"
 
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 
 namespace DM {
 
index 1fcded0..9c2a5b6 100644 (file)
@@ -10,6 +10,7 @@
 #include "gm.h"
 #include "SkCanvas.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 
 namespace skiagm {
 
index f8e55e1..abec105 100644 (file)
 #include "SkOSFile.h"
 #include "SkPDFRasterizer.h"
 #include "SkPicture.h"
-#include "SkQuadTreePicture.h"
+#include "SkPictureRecorder.h"
 #include "SkRefCnt.h"
-#include "SkRTreePicture.h"
 #include "SkScalar.h"
 #include "SkStream.h"
 #include "SkString.h"
 #include "SkSurface.h"
 #include "SkTArray.h"
 #include "SkTDict.h"
-#include "SkTileGridPicture.h"
 #include "SamplePipeControllers.h"
 
 #ifdef SK_DEBUG
index 531a4f3..d810420 100644 (file)
@@ -8,6 +8,7 @@
 #include "gm.h"
 #include "SkDebugCanvas.h"
 #include "SkPictureFlat.h"
+#include "SkPictureRecorder.h"
 
 #define WARN(msg)                                           \
     SkDebugf("%s:%d: %s\n", __FILE__, __LINE__, msg);
index 4a08b31..8346745 100644 (file)
@@ -13,6 +13,7 @@
 #include "SkPath.h"
 #include "SkPathOps.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkRect.h"
 
 namespace skiagm {
index 07d4a06..b0fd057 100644 (file)
@@ -8,6 +8,7 @@
 #include "gm.h"
 
 #include "SkPictureImageFilter.h"
+#include "SkPictureRecorder.h"
 
 // This GM exercises the SkPictureImageFilter ImageFilter class.
 
index 8889a0c..195ee73 100644 (file)
@@ -10,6 +10,7 @@
 #include "SkBitmap.h"
 #include "SkPaint.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkShader.h"
 
 namespace skiagm {
index 567b41b..f312df9 100644 (file)
         'SK_SUPPORT_LEGACY_PICTURE_CAN_RECORD',
         'SK_SUPPORT_DEPRECATED_RECORD_FLAGS',
         'SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES',
+        'SK_SUPPORT_LEGACY_PICTURE_HEADERS',
         'SK_SUPPORT_LEGACY_BLURDRAWLOOPERCONSTRUCTORS',
       ],
     }],
index f1f88f8..1bcde4c 100644 (file)
@@ -13,6 +13,7 @@
         '<(skia_src_path)/core/SkAdvancedTypefaceMetrics.cpp',
         '<(skia_src_path)/core/SkAlphaRuns.cpp',
         '<(skia_src_path)/core/SkAntiRun.h',
+        '<(skia_src_path)/core/SkBBHFactory.cpp',
         '<(skia_src_path)/core/SkBBoxHierarchy.h',
         '<(skia_src_path)/core/SkBBoxRecord.cpp',
         '<(skia_src_path)/core/SkBBoxRecord.h',
         '<(skia_src_path)/core/SkPicturePlayback.h',
         '<(skia_src_path)/core/SkPictureRecord.cpp',
         '<(skia_src_path)/core/SkPictureRecord.h',
+        '<(skia_src_path)/core/SkPictureRecorder.cpp',
         '<(skia_src_path)/core/SkPictureShader.cpp',
         '<(skia_src_path)/core/SkPictureShader.h',
         '<(skia_src_path)/core/SkPictureStateTree.cpp',
         '<(skia_src_path)/pipe/SkGPipeWrite.cpp',
 
         '<(skia_include_path)/core/SkAdvancedTypefaceMetrics.h',
+        '<(skia_include_path)/core/SkBBHFactory.h',
         '<(skia_include_path)/core/SkBitmap.h',
         '<(skia_include_path)/core/SkBitmapDevice.h',
         '<(skia_include_path)/core/SkBlitRow.h',
         '<(skia_include_path)/core/SkPathMeasure.h',
         '<(skia_include_path)/core/SkPathRef.h',
         '<(skia_include_path)/core/SkPicture.h',
+        '<(skia_include_path)/core/SkPictureRecorder.h',
         '<(skia_include_path)/core/SkPixelRef.h',
         '<(skia_include_path)/core/SkPoint.h',
         '<(skia_include_path)/core/SkPreConfig.h',
index cb65861..affd807 100644 (file)
@@ -20,6 +20,7 @@
       'SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES',
       'SK_SUPPORT_LEGACY_N32_NAME',
       'SK_SUPPORT_LEGACY_PROCXFERMODE',
+      'SK_SUPPORT_LEGACY_PICTURE_HEADERS',
     ],
   },
 }
diff --git a/include/core/SkBBHFactory.h b/include/core/SkBBHFactory.h
new file mode 100644 (file)
index 0000000..bd85d94
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkBBHFactory_DEFINED
+#define SkBBHFactory_DEFINED
+
+#include "SkSize.h"
+#include "SkPoint.h"
+
+class SkBBoxHierarchy;
+
+class SkBBHFactory {
+public:
+    /**
+     *  Allocate a new SkBBoxHierarchy. Return NULL on failure.
+     */
+    virtual SkBBoxHierarchy* operator()(int width, int height) const = 0;
+    virtual ~SkBBHFactory() {};
+};
+
+class SkQuadTreeFactory : public SkBBHFactory {
+public:
+    virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
+private:
+    typedef SkBBHFactory INHERITED;
+};
+
+
+class SkRTreeFactory : public SkBBHFactory {
+public:
+    virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
+private:
+    typedef SkBBHFactory INHERITED;
+};
+
+class SkTileGridFactory : public SkBBHFactory {
+public:
+    struct TileGridInfo {
+        /** Tile placement interval */
+        SkISize  fTileInterval;
+
+        /** Pixel coverage overlap between adjacent tiles */
+        SkISize  fMargin;
+
+        /** Offset added to device-space bounding box positions to convert
+          * them to tile-grid space. This can be used to adjust the "phase"
+          * of the tile grid to match probable query rectangles that will be
+          * used to search into the tile grid. As long as the offset is smaller
+          * or equal to the margin, there is no need to extend the domain of
+          * the tile grid to prevent data loss.
+          */
+        SkIPoint fOffset;
+    };
+
+    SkTileGridFactory(const TileGridInfo& info) : fInfo(info) { }
+
+    virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
+
+private:
+    TileGridInfo fInfo;
+
+    typedef SkBBHFactory INHERITED;
+};
+
+#endif
index 14296e9..1f588a4 100644 (file)
@@ -434,106 +434,8 @@ private:
 
 #endif
 
-class SkBBHFactory {
-public:
-    /**
-     *  Allocate a new SkBBoxHierarchy. Return NULL on failure.
-     */
-    virtual SkBBoxHierarchy* operator()(int width, int height) const = 0;
-    virtual ~SkBBHFactory() {};
-};
-
-class SK_API SkPictureRecorder : SkNoncopyable {
-public:
-#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
-
-    SkPictureRecorder(SkPictureFactory* factory = NULL) {
-        fFactory.reset(factory);
-        if (NULL != fFactory.get()) {
-            fFactory.get()->ref();
-        }
-    }
-
-    /** Returns the canvas that records the drawing commands.
-        @param width the base width for the picture, as if the recording
-                     canvas' bitmap had this width.
-        @param height the base width for the picture, as if the recording
-                     canvas' bitmap had this height.
-        @param recordFlags optional flags that control recording.
-        @return the canvas.
-    */
-    SkCanvas* beginRecording(int width, int height, uint32_t recordFlags = 0) {
-        if (NULL != fFactory) {
-            fPicture.reset(fFactory->create(width, height));
-            recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
-        } else {
-            fPicture.reset(SkNEW(SkPicture));
-        }
-
-        return fPicture->beginRecording(width, height, recordFlags);
-    }
+#ifdef SK_SUPPORT_LEGACY_PICTURE_HEADERS
+#include "SkPictureRecorder.h"
 #endif
 
-    /** Returns the canvas that records the drawing commands.
-        @param width the base width for the picture, as if the recording
-                     canvas' bitmap had this width.
-        @param height the base width for the picture, as if the recording
-                     canvas' bitmap had this height.
-        @param bbhFactory factory to create desired acceleration structure
-        @param recordFlags optional flags that control recording.
-        @return the canvas.
-    */
-    // TODO: allow default parameters once the other beginRecoding entry point is gone
-    SkCanvas* beginRecording(int width, int height,
-                             SkBBHFactory* bbhFactory /* = NULL */,
-                             uint32_t recordFlags /* = 0 */) {
-        fPicture.reset(SkNEW(SkPicture));
-        return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
-    }
-
-    /** Returns the recording canvas if one is active, or NULL if recording is
-        not active. This does not alter the refcnt on the canvas (if present).
-    */
-    SkCanvas* getRecordingCanvas() {
-        if (NULL != fPicture.get()) {
-            return fPicture->getRecordingCanvas();
-        }
-        return NULL;
-    }
-
-    /** Signal that the caller is done recording. This invalidates the canvas
-        returned by beginRecording/getRecordingCanvas, and returns the
-        created SkPicture. Note that the returned picture has its creation
-        ref which the caller must take ownership of.
-    */
-    SkPicture* endRecording() {
-        if (NULL != fPicture.get()) {
-            fPicture->endRecording();
-            return fPicture.detach();
-        }
-        return NULL;
-    }
-
-    /** Enable/disable all the picture recording optimizations (i.e.,
-        those in SkPictureRecord). It is mainly intended for testing the
-        existing optimizations (i.e., to actually have the pattern
-        appear in an .skp we have to disable the optimization). Call right
-        after 'beginRecording'.
-    */
-    void internalOnly_EnableOpts(bool enableOpts) {
-        if (NULL != fPicture.get()) {
-            fPicture->internalOnly_EnableOpts(enableOpts);
-        }
-    }
-
-private:
-#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
-    SkAutoTUnref<SkPictureFactory>  fFactory;
-#endif
-
-    SkAutoTUnref<SkPicture>         fPicture;
-
-    typedef SkNoncopyable INHERITED;
-};
-
 #endif
diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h
new file mode 100644 (file)
index 0000000..95ba7b0
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPictureRecorder_DEFINED
+#define SkPictureRecorder_DEFINED
+
+#include "SkBBHFactory.h"
+#include "SkPicture.h"
+#include "SkRefCnt.h"
+
+class SkCanvas;
+
+class SK_API SkPictureRecorder : SkNoncopyable {
+public:
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
+    SkPictureRecorder(SkPictureFactory* factory = NULL) {
+        fFactory.reset(factory);
+        if (NULL != fFactory.get()) {
+            fFactory.get()->ref();
+        }
+    }
+
+    /** Returns the canvas that records the drawing commands.
+        @param width the base width for the picture, as if the recording
+                     canvas' bitmap had this width.
+        @param height the base width for the picture, as if the recording
+                     canvas' bitmap had this height.
+        @param recordFlags optional flags that control recording.
+        @return the canvas.
+    */
+    SkCanvas* beginRecording(int width, int height, uint32_t recordFlags = 0) {
+        if (NULL != fFactory) {
+            fPicture.reset(fFactory->create(width, height));
+            recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag;
+        } else {
+            fPicture.reset(SkNEW(SkPicture));
+        }
+
+        return fPicture->beginRecording(width, height, recordFlags);
+    }
+#endif
+
+    /** Returns the canvas that records the drawing commands.
+        @param width the base width for the picture, as if the recording
+                     canvas' bitmap had this width.
+        @param height the base width for the picture, as if the recording
+                     canvas' bitmap had this height.
+        @param bbhFactory factory to create desired acceleration structure
+        @param recordFlags optional flags that control recording.
+        @return the canvas.
+    */
+    // TODO: allow default parameters once the other beginRecoding entry point is gone
+    SkCanvas* beginRecording(int width, int height,
+                             SkBBHFactory* bbhFactory /* = NULL */,
+                             uint32_t recordFlags /* = 0 */);
+
+    /** Returns the recording canvas if one is active, or NULL if recording is
+        not active. This does not alter the refcnt on the canvas (if present).
+    */
+    SkCanvas* getRecordingCanvas() {
+        if (NULL != fPicture.get()) {
+            return fPicture->getRecordingCanvas();
+        }
+        return NULL;
+    }
+
+    /** Signal that the caller is done recording. This invalidates the canvas
+        returned by beginRecording/getRecordingCanvas, and returns the
+        created SkPicture. Note that the returned picture has its creation
+        ref which the caller must take ownership of.
+    */
+    SkPicture* endRecording() {
+        if (NULL != fPicture.get()) {
+            fPicture->endRecording();
+            return fPicture.detach();
+        }
+        return NULL;
+    }
+
+    /** Enable/disable all the picture recording optimizations (i.e.,
+        those in SkPictureRecord). It is mainly intended for testing the
+        existing optimizations (i.e., to actually have the pattern
+        appear in an .skp we have to disable the optimization). Call right
+        after 'beginRecording'.
+    */
+    void internalOnly_EnableOpts(bool enableOpts) {
+        if (NULL != fPicture.get()) {
+            fPicture->internalOnly_EnableOpts(enableOpts);
+        }
+    }
+
+private:
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+    SkAutoTUnref<SkPictureFactory>  fFactory;
+#endif
+
+    SkAutoTUnref<SkPicture>         fPicture;
+
+    typedef SkNoncopyable INHERITED;
+};
+
+#endif
index 78cb52e..8e8a2aa 100644 (file)
@@ -8,16 +8,14 @@
 #ifndef SkRTreePicture_DEFINED
 #define SkRTreePicture_DEFINED
 
-#include "SkPicture.h"
-
-class SkRTreeFactory : public SkBBHFactory {
-public:
-    virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
-private:
-    typedef SkBBHFactory INHERITED;
-};
+#ifdef SK_SUPPORT_LEGACY_PICTURE_HEADERS
+#include "SkBBHFactory.h"
+#endif
 
 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
+#include "SkPicture.h"
+
 /**
  * Subclass of SkPicture that creates an RTree acceleration structure.
  */
index 6dbe2fc..0196940 100644 (file)
@@ -8,41 +8,16 @@
 #ifndef SkTileGridPicture_DEFINED
 #define SkTileGridPicture_DEFINED
 
+#ifdef SK_SUPPORT_LEGACY_PICTURE_HEADERS
+#include "SkBBHFactory.h"
+#endif
+
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
 #include "SkPicture.h"
 #include "SkPoint.h"
 #include "SkSize.h"
 
-class SkTileGridFactory : public SkBBHFactory {
-public:
-    struct TileGridInfo {
-        /** Tile placement interval */
-        SkISize  fTileInterval;
-
-        /** Pixel coverage overlap between adjacent tiles */
-        SkISize  fMargin;
-
-        /** Offset added to device-space bounding box positions to convert
-          * them to tile-grid space. This can be used to adjust the "phase"
-          * of the tile grid to match probable query rectangles that will be
-          * used to search into the tile grid. As long as the offset is smaller
-          * or equal to the margin, there is no need to extend the domain of
-          * the tile grid to prevent data loss.
-          */
-        SkIPoint fOffset;
-    };
-
-    SkTileGridFactory(const TileGridInfo& info) : fInfo(info) { }
-
-    virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
-
-private:
-    TileGridInfo fInfo;
-
-    typedef SkBBHFactory INHERITED;
-};
-
-#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
-
 /**
  * Subclass of SkPicture that creates an SkTileGrid. The tile grid has lower recording
  * and playback costs then rTree, but is less effective at eliminating extraneous
index 4f4116b..35eeaba 100644 (file)
@@ -26,6 +26,7 @@
 #include "SkLayerRasterizer.h"
 #include "SkMath.h"
 #include "SkPath.h"
+#include "SkPictureRecorder.h"
 #include "SkRegion.h"
 #include "SkShader.h"
 #include "SkComposeShader.h"
index 67be5be..b7cc021 100644 (file)
@@ -14,6 +14,7 @@
 #include "SkImageEncoder.h"
 #include "SkPaint.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkStream.h"
 #include "SkTSort.h"
 #include "SkTime.h"
index 13bc697..fa85901 100644 (file)
@@ -11,6 +11,7 @@
 #include "SkOSMenu.h"
 #include "SkPath.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkScalar.h"
 #include "SkTDArray.h"
 #include "SkTouchGesture.h"
index 59a7f4b..7b9584d 100644 (file)
 #include "SkOSFile.h"
 #include "SkPath.h"
 #include "SkPicture.h"
-#include "SkQuadTreePicture.h"
+#include "SkPictureRecorder.h"
 #include "SkRandom.h"
 #include "SkRegion.h"
-#include "SkRTreePicture.h"
 #include "SkShader.h"
-#include "SkTileGridPicture.h"
 #include "SkUtils.h"
 #include "SkColorPriv.h"
 #include "SkColorFilter.h"
index 202e172..e696903 100644 (file)
@@ -17,6 +17,7 @@
 #include "SkOSFile.h"
 #include "SkPath.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkRandom.h"
 #include "SkRegion.h"
 #include "SkShader.h"
index ffae6a4..cc3b529 100644 (file)
@@ -10,6 +10,7 @@
 #include "SkCanvas.h"
 #include "SkPaint.h"
 #include "SkPath.h"
+#include "SkPictureRecorder.h"
 #include "SkRegion.h"
 #include "SkShader.h"
 #include "SkUtils.h"
diff --git a/src/core/SkBBHFactory.cpp b/src/core/SkBBHFactory.cpp
new file mode 100644 (file)
index 0000000..7411eb3
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBBHFactory.h"
+#include "SkPictureStateTree.h"
+#include "SkQuadTree.h"
+#include "SkRTree.h"
+#include "SkTileGrid.h"
+
+
+SkBBoxHierarchy* SkQuadTreeFactory::operator()(int width, int height) const {
+    return SkNEW_ARGS(SkQuadTree, (SkIRect::MakeWH(width, height)));
+}
+
+SkBBoxHierarchy* SkRTreeFactory::operator()(int width, int height) const {
+    // These values were empirically determined to produce reasonable
+    // performance in most cases.
+    static const int kRTreeMinChildren = 6;
+    static const int kRTreeMaxChildren = 11;
+
+    SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width),
+                                       SkIntToScalar(height));
+    bool sortDraws = false;  // Do not sort draw calls when bulk loading.
+
+    return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren,
+                           aspectRatio, sortDraws);
+}
+
+SkBBoxHierarchy* SkTileGridFactory::operator()(int width, int height) const {
+    SkASSERT(fInfo.fMargin.width() >= 0);
+    SkASSERT(fInfo.fMargin.height() >= 0);
+    // Note: SkIRects are non-inclusive of the right() column and bottom() row.
+    // For example, an SkIRect at 0,0 with a size of (1,1) will only have
+    // content at pixel (0,0) and will report left=0 and right=1, hence the
+    // "-1"s below.
+    int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInterval.width();
+    int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileInterval.height();
+    return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo,
+                                    SkTileGridNextDatum<SkPictureStateTree::Draw>));
+}
index 85e018f..316994a 100644 (file)
@@ -11,6 +11,7 @@
 #include "SkPicturePlayback.h"
 #include "SkPictureRecord.h"
 
+#include "SkBBHFactory.h"
 #include "SkBitmapDevice.h"
 #include "SkCanvas.h"
 #include "SkChunkAlloc.h"
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
new file mode 100644 (file)
index 0000000..a22cf5d
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkPictureRecorder.h"
+
+SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
+                                            SkBBHFactory* bbhFactory /* = NULL */,
+                                            uint32_t recordFlags /* = 0 */) {
+    fPicture.reset(SkNEW(SkPicture));
+    return fPicture->beginRecording(width, height, bbhFactory, recordFlags);
+}
index 36093c6..a76899e 100644 (file)
@@ -5,16 +5,12 @@
  * found in the LICENSE file.
  */
 
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
 #include "SkQuadTreePicture.h"
 
 #include "SkQuadTree.h"
 
-SkBBoxHierarchy* SkQuadTreeFactory::operator()(int width, int height) const {
-    return SkNEW_ARGS(SkQuadTree, (SkIRect::MakeWH(width, height)));
-}
-
-#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
-
 SkBBoxHierarchy* SkQuadTreePicture::createBBoxHierarchy() const {
     return SkNEW_ARGS(SkQuadTree, (fBounds));
 }
index 13d2c3d..5ebbef9 100644 (file)
@@ -8,17 +8,13 @@
 #ifndef SkQuadTreePicture_DEFINED
 #define SkQuadTreePicture_DEFINED
 
-#include "SkPicture.h"
-
-class SkQuadTreeFactory : public SkBBHFactory {
-public:
-    virtual SkBBoxHierarchy* operator()(int width, int height) const SK_OVERRIDE;
-private:
-    typedef SkBBHFactory INHERITED;
-};
+#ifdef SK_SUPPORT_LEGACY_PICTURE_HEADERS
+#include "SkBBHFactory.h"
+#endif
 
 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
 
+#include "SkPicture.h"
 #include "SkRect.h"
 
 /**
index 78b654e..a9118ae 100644 (file)
@@ -5,26 +5,12 @@
  * found in the LICENSE file.
  */
 
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
 #include "SkRTreePicture.h"
 
 #include "SkRTree.h"
 
-SkBBoxHierarchy* SkRTreeFactory::operator()(int width, int height) const {
-    // These values were empirically determined to produce reasonable
-    // performance in most cases.
-    static const int kRTreeMinChildren = 6;
-    static const int kRTreeMaxChildren = 11;
-
-    SkScalar aspectRatio = SkScalarDiv(SkIntToScalar(width),
-                                       SkIntToScalar(height));
-    bool sortDraws = false;  // Do not sort draw calls when bulk loading.
-
-    return SkRTree::Create(kRTreeMinChildren, kRTreeMaxChildren,
-                           aspectRatio, sortDraws);
-}
-
-#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
-
 SkBBoxHierarchy* SkRTreePicture::createBBoxHierarchy() const {
     // These values were empirically determined to produce reasonable
     // performance in most cases.
index 034d28e..0ec5c2c 100644 (file)
@@ -9,9 +9,9 @@
 #ifndef SkTileGrid_DEFINED
 #define SkTileGrid_DEFINED
 
+#include "SkBBHFactory.h"
 #include "SkBBoxHierarchy.h"
 #include "SkPictureStateTree.h"
-#include "SkTileGridPicture.h" // for TileGridInfo
 
 /**
  * Subclass of SkBBoxHierarchy that stores elements in buckets that correspond
index f2f44a0..4a43f8a 100644 (file)
@@ -5,27 +5,13 @@
  * found in the LICENSE file.
  */
 
+#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
+
 #include "SkTileGridPicture.h"
 
 #include "SkPictureStateTree.h"
 #include "SkTileGrid.h"
 
-
-SkBBoxHierarchy* SkTileGridFactory::operator()(int width, int height) const {
-    SkASSERT(fInfo.fMargin.width() >= 0);
-    SkASSERT(fInfo.fMargin.height() >= 0);
-    // Note: SkIRects are non-inclusive of the right() column and bottom() row.
-    // For example, an SkIRect at 0,0 with a size of (1,1) will only have
-    // content at pixel (0,0) and will report left=0 and right=1, hence the
-    // "-1"s below.
-    int xTileCount = (width + fInfo.fTileInterval.width() - 1) / fInfo.fTileInterval.width();
-    int yTileCount = (height + fInfo.fTileInterval.height() - 1) / fInfo.fTileInterval.height();
-    return SkNEW_ARGS(SkTileGrid, (xTileCount, yTileCount, fInfo,
-                                    SkTileGridNextDatum<SkPictureStateTree::Draw>));
-}
-
-#ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
-
 SkTileGridPicture::SkTileGridPicture(int width, int height,
                                      const SkTileGridFactory::TileGridInfo& info) {
     SkASSERT(info.fMargin.width() >= 0);
index da3c136..3b259ab 100644 (file)
@@ -55,6 +55,7 @@
 #include "SkPath.h"
 #include "SkPicture.h"
 #include "SkPictureRecord.h"
+#include "SkPictureRecorder.h"
 #include "SkProxyCanvas.h"
 #include "SkRect.h"
 #include "SkRegion.h"
index a58c3af..f968a4e 100644 (file)
@@ -24,7 +24,7 @@
 #include "SkMorphologyImageFilter.h"
 #include "SkOffsetImageFilter.h"
 #include "SkPicture.h"
-#include "SkRTreePicture.h"
+#include "SkPictureRecorder.h"
 #include "SkRect.h"
 #include "SkTileImageFilter.h"
 #include "SkXfermodeImageFilter.h"
index deeef46..0a1c3c6 100644 (file)
 #include "SkImageGenerator.h"
 #include "SkPaint.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkPictureUtils.h"
-#include "SkQuadTreePicture.h"
 #include "SkRRect.h"
 #include "SkRandom.h"
-#include "SkRTreePicture.h"
 #include "SkShader.h"
 #include "SkStream.h"
-#include "SkTileGrid.h"
 #include "Test.h"
 
 static const int gColorScale = 30;
index b857d32..94d09c0 100644 (file)
@@ -9,6 +9,7 @@
 #include "SkBitmapSource.h"
 #include "SkCanvas.h"
 #include "SkMallocPixelRef.h"
+#include "SkPictureRecorder.h"
 #include "SkTemplates.h"
 #include "SkWriteBuffer.h"
 #include "SkValidatingReadBuffer.h"
index aff4a76..da228a0 100644 (file)
@@ -7,8 +7,8 @@
 
 #include "SkBitmapDevice.h"
 #include "SkCanvas.h"
+#include "SkPictureRecorder.h"
 #include "SkTileGrid.h"
-#include "SkTileGridPicture.h"
 #include "Test.h"
 
 enum Tile {
index cd87f60..e531a30 100644 (file)
 #include "SkMatrix.h"
 #include "SkOSFile.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkPictureUtils.h"
 #include "SkPixelRef.h"
-#include "SkQuadTree.h"
-#include "SkQuadTreePicture.h"
-#include "SkRTreePicture.h"
 #include "SkScalar.h"
 #include "SkStream.h"
 #include "SkString.h"
 #include "SkTemplates.h"
-#include "SkTileGridPicture.h"
 #include "SkTDArray.h"
 #include "SkThreadUtils.h"
 #include "SkTypes.h"
index a8c0cc5..7961628 100644 (file)
 #include "SkMath.h"
 #include "SkPaint.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkRect.h"
 #include "SkRefCnt.h"
 #include "SkRunnable.h"
 #include "SkString.h"
 #include "SkTDArray.h"
 #include "SkThreadPool.h"
-#include "SkTileGridPicture.h"
 #include "SkTypes.h"
 
 #if SK_SUPPORT_GPU
index 65198fa..cff3490 100644 (file)
 #include "SkGraphics.h"
 #include "SkOSFile.h"
 #include "SkPicture.h"
-#include "SkQuadTreePicture.h"
+#include "SkPictureRecorder.h"
 #include "SkRecording.h"
-#include "SkRTreePicture.h"
 #include "SkStream.h"
 #include "SkString.h"
-#include "SkTileGridPicture.h"
 #include "SkTime.h"
 #include "LazyDecodeBitmap.h"
 
index ecd1eee..36b9f92 100644 (file)
@@ -15,6 +15,7 @@
 #include "SkPicture.h"
 #include "SkPicturePlayback.h"
 #include "SkPictureRecord.h"
+#include "SkPictureRecorder.h"
 #include "SkStream.h"
 #include "picture_utils.h"
 #include "path_utils.h"
index 444efd0..352dbf3 100644 (file)
@@ -16,6 +16,7 @@
 #include "SkMath.h"
 #include "SkOSFile.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkStream.h"
 #include "SkString.h"
 #include "PictureRenderer.h"
index 0d46d04..390e5ca 100644 (file)
@@ -12,6 +12,7 @@
 #include "SkCommandLineFlags.h"
 #include "SkPaint.h"
 #include "SkPicture.h"
+#include "SkPictureRecorder.h"
 #include "SkScalar.h"
 #include "SkStream.h"