diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-24 19:40:49 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-24 19:40:49 +0000 |
commit | 75cf29be4d3bcda4ce4118facec574242d4cc106 (patch) | |
tree | 08600c8180ac59af6785cc7fefb0dfb74b122664 | |
parent | 2a8be900db664bb26dca1adcb3a524a1bb1f45e6 (diff) |
Add new experimental API to SkPicture to get "id" of current op
When gathering information about a picture (in the new SkDevice::EXPERIMENTAL_optimize entry point) it is necessary to be able to correlate the gathered information with the command in the SkPicture (so the information can later be combined with the similarly indexed information from the BBH). This entry point exposes that information to friend classes.
R=reed@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/206853003
git-svn-id: http://skia.googlecode.com/svn/trunk@13919 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkPicture.h | 8 | ||||
-rw-r--r-- | src/core/SkPicture.cpp | 7 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 23 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.h | 7 |
4 files changed, 42 insertions, 3 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index ba316ff66b..8053bb2405 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -348,12 +348,20 @@ private: */ const OperationList& EXPERIMENTAL_getActiveOps(const SkIRect& queryRect); + /** PRIVATE / EXPERIMENTAL -- do not call + Return the ID of the operation currently being executed when playing + back. 0 indicates no call is active. + */ + size_t EXPERIMENTAL_curOpID() const; + void createHeader(SkPictInfo* info) const; static bool IsValidPictInfo(const SkPictInfo& info); friend class SkFlatPicture; friend class SkPicturePlayback; friend class SkGpuDevice; + friend class GrGatherDevice; + friend class SkDebugCanvas; typedef SkRefCnt INHERITED; }; diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 41fc374aae..ae0347cf25 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -281,6 +281,13 @@ const SkPicture::OperationList& SkPicture::EXPERIMENTAL_getActiveOps(const SkIRe return OperationList::InvalidList(); } +size_t SkPicture::EXPERIMENTAL_curOpID() const { + if (NULL != fPlayback) { + return fPlayback->curOpID(); + } + return 0; +} + void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) { this->endRecording(); if (NULL != fPlayback) { diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index a570c4c270..8320335e68 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -261,6 +261,7 @@ void SkPicturePlayback::init() { fBoundingHierarchy = NULL; fStateTree = NULL; fCachedActiveOps = NULL; + fCurOffset = 0; } SkPicturePlayback::~SkPicturePlayback() { @@ -838,7 +839,23 @@ const SkPicture::OperationList& SkPicturePlayback::getActiveOps(const SkIRect& q return *fCachedActiveOps; } +class SkAutoResetOpID { +public: + SkAutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { } + ~SkAutoResetOpID() { + if (NULL != fPlayback) { + fPlayback->resetOpID(); + } + } + +private: + SkPicturePlayback* fPlayback; +}; + void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) { + SkAutoResetOpID aroi(this); + SkASSERT(0 == fCurOffset); + #ifdef ENABLE_TIME_DRAW SkAutoTime at("SkPicture::draw", 50); #endif @@ -919,18 +936,18 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) opCount++; #endif - size_t curOffset = reader.offset(); + fCurOffset = reader.offset(); uint32_t size; DrawType op = read_op_and_size(&reader, &size); size_t skipTo = 0; if (NOOP == op) { // NOOPs are to be ignored - do not propagate them any further - skipTo = curOffset + size; + skipTo = fCurOffset + size; #ifdef SK_DEVELOPER } else { opIndex++; if (this->preDraw(opIndex, op)) { - skipTo = curOffset + size; + skipTo = fCurOffset + size; } #endif } diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h index 11624205d4..89d70a1739 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPicturePlayback.h @@ -102,6 +102,9 @@ public: void abort() { fAbortCurrentPlayback = true; } #endif + size_t curOpID() const { return fCurOffset; } + void resetOpID() { fCurOffset = 0; } + protected: bool parseStream(SkStream*, const SkPictInfo&, SkPicture::InstallPixelRefProc); @@ -264,6 +267,10 @@ private: SkTypefacePlayback fTFPlayback; SkFactoryPlayback* fFactoryPlayback; + + // The offset of the current operation when within the draw method + size_t fCurOffset; + #ifdef SK_BUILD_FOR_ANDROID SkMutex fDrawMutex; bool fAbortCurrentPlayback; |