aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBigPicture.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-05-07 13:41:07 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-07 13:41:07 -0700
commitc92c129ff85b05a714bd1bf921c02d5e14651f8b (patch)
treeea2f915b36a5f6abb746827a4a6f650d5ff13310 /src/core/SkBigPicture.h
parent2fbd4068bde6a9fb50341c0bdfbb8bf18b70d015 (diff)
Sketch splitting SkPicture into an interface and SkBigPicture.
Adds small pictures for drawRect(), drawTextBlob(), and drawPath(). These cover about 89% of draw calls from Blink SKPs, and about 25% of draw calls from our GMs. SkPicture handles: - serialization and deserialization - unique IDs Everything else is left to the subclasses: - playback(), cullRect() - hasBitmap(), hasText(), suitableForGPU(), etc. - LayerInfo / AccelData if applicable. The time to record a 1-op picture improves a good chunk (2 mallocs to 1), and the time to record a 0-op picture greatly improves (2 mallocs to none): picture_overhead_draw: 450ns -> 350ns picture_overhead_nodraw: 300ns -> 90ns BUG=skia: Review URL: https://codereview.chromium.org/1112523006
Diffstat (limited to 'src/core/SkBigPicture.h')
-rw-r--r--src/core/SkBigPicture.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/core/SkBigPicture.h b/src/core/SkBigPicture.h
new file mode 100644
index 0000000000..fb3b62c4c4
--- /dev/null
+++ b/src/core/SkBigPicture.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkBigPicture_DEFINED
+#define SkBigPicture_DEFINED
+
+#include "SkPicture.h"
+
+class SkBBoxHierarchy;
+class SkRecord;
+
+// An implementation of SkPicture supporting an arbitrary number of drawing commands.
+class SkBigPicture final : public SkPicture {
+public:
+ // AccelData provides a base class for device-specific acceleration data.
+ class AccelData : public SkRefCnt { };
+
+ // An array of refcounted const SkPicture pointers.
+ class SnapshotArray : ::SkNoncopyable {
+ public:
+ SnapshotArray(const SkPicture* pics[], int count) : fPics(pics), fCount(count) {}
+ ~SnapshotArray() { for (int i = 0; i < fCount; i++) { fPics[i]->unref(); } }
+
+ const SkPicture* const* begin() const { return fPics; }
+ int count() const { return fCount; }
+ private:
+ SkAutoTMalloc<const SkPicture*> fPics;
+ int fCount;
+ };
+
+ SkBigPicture(const SkRect& cull,
+ SkRecord*, // We take ownership of the caller's ref.
+ SnapshotArray*, // We take exclusive ownership.
+ SkBBoxHierarchy*, // We take ownership of the caller's ref.
+ AccelData*, // We take ownership of the caller's ref.
+ size_t approxBytesUsedBySubPictures);
+
+
+// SkPicture overrides
+ void playback(SkCanvas*, AbortCallback*) const override;
+ SkRect cullRect() const override;
+ bool hasText() const override;
+ bool willPlayBackBitmaps() const override;
+ int approximateOpCount() const override;
+ size_t approximateBytesUsed() const override;
+ bool suitableForGpuRasterization(GrContext*, const char** whyNot) const override;
+ const SkBigPicture* asSkBigPicture() const override { return this; }
+
+// Used by GrLayerHoister
+ void partialPlayback(SkCanvas*,
+ unsigned start,
+ unsigned stop,
+ const SkMatrix& initialCTM) const;
+// Used by GrRecordReplaceDraw
+ const SkBBoxHierarchy* bbh() const { return fBBH; }
+ const SkRecord* record() const { return fRecord; }
+ const AccelData* accelData() const { return fAccelData; }
+
+private:
+ struct Analysis {
+ explicit Analysis(const SkRecord&);
+
+ bool suitableForGpuRasterization(const char** reason) const;
+
+ uint8_t fNumSlowPathsAndDashEffects;
+ bool fWillPlaybackBitmaps : 1;
+ bool fHasText : 1;
+ };
+ struct PathCounter;
+
+ int numSlowPaths() const override;
+
+ int drawableCount() const;
+ SkPicture const* const* drawablePicts() const;
+
+ const SkRect fCullRect;
+ const Analysis fAnalysis;
+ const size_t fApproxBytesUsedBySubPictures;
+ SkAutoTUnref<const SkRecord> fRecord;
+ SkAutoTDelete<const SnapshotArray> fDrawablePicts;
+ SkAutoTUnref<const SkBBoxHierarchy> fBBH;
+ SkAutoTUnref<const AccelData> fAccelData;
+};
+
+#endif//SkBigPicture_DEFINED