aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPicturePlayback.h
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-06-11 11:37:55 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-11 11:37:55 -0700
commit0bdbea75ff1a6f3c313c18cab0139728967cb93e (patch)
tree010e60572e146ff0b282d5d7c76fb7d380e135f1 /src/core/SkPicturePlayback.h
parentf0419e96b4b52b85fafd0d589c56944841dcda06 (diff)
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
Diffstat (limited to 'src/core/SkPicturePlayback.h')
-rw-r--r--src/core/SkPicturePlayback.h60
1 files changed, 58 insertions, 2 deletions
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index 9d4c996653..9751e3a5e7 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -62,6 +62,56 @@ struct SkPictInfo {
// Always write this guy last (with no length field afterwards)
#define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ')
+// SkPictureContentInfo is not serialized! It is intended solely for use
+// with suitableForGpuRasterization.
+class SkPictureContentInfo {
+public:
+ SkPictureContentInfo() { this->reset(); }
+
+ SkPictureContentInfo(const SkPictureContentInfo& src) { this->set(src); }
+
+ void set(const SkPictureContentInfo& src) {
+ fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
+ fNumAAConcavePaths = src.fNumAAConcavePaths;
+ fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
+ }
+
+ void reset() {
+ fNumPaintWithPathEffectUses = 0;
+ fNumAAConcavePaths = 0;
+ fNumAAHairlineConcavePaths = 0;
+ }
+
+ void swap(SkPictureContentInfo* other) {
+ SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses);
+ SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
+ SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths);
+ }
+
+ void incPaintWithPathEffectUses() { ++fNumPaintWithPathEffectUses; }
+ int numPaintWithPathEffectUses() const { return fNumPaintWithPathEffectUses; }
+
+ void incAAConcavePaths() { ++fNumAAConcavePaths; }
+ int numAAConcavePaths() const { return fNumAAConcavePaths; }
+
+ void incAAHairlineConcavePaths() {
+ ++fNumAAHairlineConcavePaths;
+ SkASSERT(fNumAAHairlineConcavePaths <= fNumAAConcavePaths);
+ }
+ int numAAHairlineConcavePaths() const { return fNumAAHairlineConcavePaths; }
+
+private:
+ // This field is incremented every time a paint with a path effect is
+ // used (i.e., it is not a de-duplicated count)
+ int fNumPaintWithPathEffectUses;
+ // This field is incremented every time an anti-aliased drawPath call is
+ // issued with a concave path
+ int fNumAAConcavePaths;
+ // This field is incremented every time a drawPath call is
+ // issued for a hairline stroked concave path.
+ int fNumAAHairlineConcavePaths;
+};
+
/**
* Container for data that is needed to deep copy a SkPicture. The container
* enables the data to be generated once and reused for subsequent copies.
@@ -78,8 +128,8 @@ class SkPicturePlayback {
public:
SkPicturePlayback(const SkPicture* picture, const SkPicturePlayback& src,
SkPictCopyInfo* deepCopyInfo = NULL);
- SkPicturePlayback(const SkPicture* picture, const SkPictureRecord& record, const SkPictInfo&,
- bool deepCopyOps);
+ SkPicturePlayback(const SkPicture* picture, const SkPictureRecord& record,
+ const SkPictInfo&, bool deepCopyOps);
static SkPicturePlayback* CreateFromStream(SkPicture* picture,
SkStream*,
const SkPictInfo&,
@@ -222,6 +272,10 @@ public:
void dump() const;
#endif
+#if SK_SUPPORT_GPU
+ bool suitableForGpuRasterization(GrContext* context, const char **reason) const;
+#endif
+
private: // these help us with reading/writing
bool parseStreamTag(SkPicture* picture, SkStream*, uint32_t tag, uint32_t size,
SkPicture::InstallPixelRefProc);
@@ -252,6 +306,8 @@ private:
SkBBoxHierarchy* fBoundingHierarchy;
SkPictureStateTree* fStateTree;
+ SkPictureContentInfo fContentInfo;
+
// Limit the opcode playback to be between the offsets 'start' and 'stop'.
// The opcode at 'start' should be a saveLayer while the opcode at
// 'stop' should be a restore. Neither of those commands will be issued.