diff options
-rw-r--r-- | include/core/SkPicture.h | 11 | ||||
-rw-r--r-- | src/core/SkPicture.cpp | 14 | ||||
-rw-r--r-- | src/core/SkPictureData.cpp | 34 | ||||
-rw-r--r-- | src/core/SkPictureData.h | 30 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 264 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.h | 6 |
6 files changed, 151 insertions, 208 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index d57af50611..6c486c9789 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -14,6 +14,7 @@ #include "SkDrawPictureCallback.h" #include "SkImageDecoder.h" #include "SkRefCnt.h" +#include "SkTDArray.h" #if SK_SUPPORT_GPU class GrContext; @@ -261,15 +262,15 @@ private: // stream along with the CTMs needed for those operation. class OperationList : ::SkNoncopyable { public: - virtual ~OperationList() {} - // The following three entry points should only be accessed if // 'valid' returns true. - virtual int numOps() const { SkASSERT(false); return 0; }; + int numOps() const { return fOps.count(); } // The offset in the picture of the operation to execute. - virtual uint32_t offset(int index) const { SkASSERT(false); return 0; }; + uint32_t offset(int index) const; // The CTM that must be installed for the operation to behave correctly - virtual const SkMatrix& matrix(int index) const { SkASSERT(false); return SkMatrix::I(); } + const SkMatrix& matrix(int index) const; + + SkTDArray<void*> fOps; }; /** PRIVATE / EXPERIMENTAL -- do not call diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index d8b69d4c2b..6c7da8a69b 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -12,6 +12,7 @@ #include "SkPicturePlayback.h" #include "SkPictureRecord.h" #include "SkPictureRecorder.h" +#include "SkPictureStateTree.h" #include "SkBBHFactory.h" #include "SkBitmapDevice.h" @@ -46,9 +47,6 @@ template <typename T> int SafeCount(const T* obj) { #define DUMP_BUFFER_SIZE 65536 -//#define ENABLE_TIME_DRAW // dumps milliseconds for each draw - - #ifdef SK_DEBUG // enable SK_DEBUG_TRACE to trace DrawType elements when // recorded and played back @@ -293,6 +291,16 @@ SkPicture::AccelData::Domain SkPicture::AccelData::GenerateDomain() { /////////////////////////////////////////////////////////////////////////////// +uint32_t SkPicture::OperationList::offset(int index) const { + SkASSERT(index < fOps.count()); + return ((SkPictureStateTree::Draw*)fOps[index])->fOffset; +} + +const SkMatrix& SkPicture::OperationList::matrix(int index) const { + SkASSERT(index < fOps.count()); + return *((SkPictureStateTree::Draw*)fOps[index])->fMatrix; +} + // fRecord TODO const SkPicture::OperationList* SkPicture::EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) const { SkASSERT(NULL != fData.get()); diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp index 15ba45d7d6..2c71eebf2f 100644 --- a/src/core/SkPictureData.cpp +++ b/src/core/SkPictureData.cpp @@ -23,11 +23,6 @@ template <typename T> int SafeCount(const T* obj) { return obj ? obj->count() : 0; } -/* Define this to spew out a debug statement whenever we skip the remainder of - a save/restore block because a clip... command returned false (empty). - */ -#define SPEW_CLIP_SKIPPINGx - SkPictureData::SkPictureData(const SkPictInfo& info) : fInfo(info) { this->init(); @@ -673,39 +668,12 @@ bool SkPictureData::parseBuffer(SkReadBuffer& buffer) { /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -#ifdef SPEW_CLIP_SKIPPING -struct SkipClipRec { - int fCount; - size_t fSize; - - SkipClipRec() { - fCount = 0; - fSize = 0; - } - - void recordSkip(size_t bytes) { - fCount += 1; - fSize += bytes; - } -}; -#endif - -uint32_t SkPictureData::OperationList::offset(int index) const { - SkASSERT(index < fOps.count()); - return ((SkPictureStateTree::Draw*)fOps[index])->fOffset; -} - -const SkMatrix& SkPictureData::OperationList::matrix(int index) const { - SkASSERT(index < fOps.count()); - return *((SkPictureStateTree::Draw*)fOps[index])->fMatrix; -} - const SkPicture::OperationList* SkPictureData::getActiveOps(const SkIRect& query) const { if (NULL == fStateTree || NULL == fBoundingHierarchy) { return NULL; } - OperationList* activeOps = SkNEW(OperationList); + SkPicture::OperationList* activeOps = SkNEW(SkPicture::OperationList); fBoundingHierarchy->search(query, &(activeOps->fOps)); if (0 != activeOps->fOps.count()) { diff --git a/src/core/SkPictureData.h b/src/core/SkPictureData.h index 408d6358c3..01185d644a 100644 --- a/src/core/SkPictureData.h +++ b/src/core/SkPictureData.h @@ -160,8 +160,8 @@ protected: private: - const SkBitmap& getBitmap(SkReader32& reader) const { - const int index = reader.readInt(); + const SkBitmap& getBitmap(SkReader32* reader) const { + const int index = reader->readInt(); if (SkBitmapHeap::INVALID_SLOT == index) { #ifdef SK_DEBUG SkDebugf("An invalid bitmap was recorded!\n"); @@ -171,19 +171,19 @@ private: return (*fBitmaps)[index]; } - const SkPath& getPath(SkReader32& reader) const { - int index = reader.readInt() - 1; + const SkPath& getPath(SkReader32* reader) const { + int index = reader->readInt() - 1; return (*fPathHeap.get())[index]; } - const SkPicture* getPicture(SkReader32& reader) const { - int index = reader.readInt(); + const SkPicture* getPicture(SkReader32* reader) const { + int index = reader->readInt(); SkASSERT(index > 0 && index <= fPictureCount); return fPictureRefs[index - 1]; } - const SkPaint* getPaint(SkReader32& reader) const { - int index = reader.readInt(); + const SkPaint* getPaint(SkReader32* reader) const { + int index = reader->readInt(); if (index == 0) { return NULL; } @@ -269,20 +269,6 @@ private: SkPictureContentInfo fContentInfo; - class OperationList : public SkPicture::OperationList { - public: - OperationList() { } - virtual int numOps() const SK_OVERRIDE { return fOps.count(); } - virtual uint32_t offset(int index) const SK_OVERRIDE; - virtual const SkMatrix& matrix(int index) const SK_OVERRIDE; - - // The operations which are active within 'fCachedQueryRect' - SkTDArray<void*> fOps; - - private: - typedef SkPicture::OperationList INHERITED; - }; - SkTypefacePlayback fTFPlayback; SkFactoryPlayback* fFactoryPlayback; diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index a6e3f0776d..7d9d53bf6b 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -94,9 +94,9 @@ static DrawType read_op_and_size(SkReader32* reader, uint32_t* size) { } -static const SkRect* get_rect_ptr(SkReader32& reader) { - if (reader.readBool()) { - return &reader.skipT<SkRect>(); +static const SkRect* get_rect_ptr(SkReader32* reader) { + if (reader->readBool()) { + return &reader->skipT<SkRect>(); } else { return NULL; } @@ -124,21 +124,11 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) SkAutoResetOpID aroi(this); SkASSERT(0 == fCurOffset); -#ifdef ENABLE_TIME_DRAW - SkAutoTime at("SkPicture::draw", 50); -#endif - -#ifdef SPEW_CLIP_SKIPPING - SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull; - int opCount = 0; -#endif - // kDrawComplete will be the signal that we have reached the end of // the command stream static const uint32_t kDrawComplete = SK_MaxU32; SkReader32 reader(fPictureData->fOpData->bytes(), fPictureData->fOpData->size()); - TextContainer text; SkAutoTDelete<const SkPicture::OperationList> activeOpsList; const SkTDArray<void*>* activeOps = NULL; @@ -158,7 +148,7 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) } // Since the opList is valid we know it is our derived class - activeOps = &((const SkPictureData::OperationList*)activeOpsList.get())->fOps; + activeOps = &(activeOpsList.get()->fOps); } } } @@ -272,10 +262,6 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) } } -#ifdef SPEW_CLIP_SKIPPING - opCount++; -#endif - fCurOffset = reader.offset(); uint32_t size; DrawType op = read_op_and_size(&reader, &size); @@ -309,76 +295,82 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) continue; } - switch (op) { + this->handleOp(&reader, op, size, canvas, initialMatrix); + +#ifdef SK_DEVELOPER + this->postDraw(opIndex); +#endif + + if (it.isValid()) { + uint32_t skipTo = it.nextDraw(); + if (kDrawComplete == skipTo) { + break; + } + reader.setOffset(skipTo); + } + } +} + +void SkPicturePlayback::handleOp(SkReader32* reader, + DrawType op, + uint32_t size, + SkCanvas* canvas, + const SkMatrix& initialMatrix) { + switch (op) { case CLIP_PATH: { const SkPath& path = fPictureData->getPath(reader); - uint32_t packed = reader.readInt(); + uint32_t packed = reader->readInt(); SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); bool doAA = ClipParams_unpackDoAA(packed); - size_t offsetToRestore = reader.readInt(); - SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset()); + size_t offsetToRestore = reader->readInt(); + SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); canvas->clipPath(path, regionOp, doAA); if (canvas->isClipEmpty() && offsetToRestore) { -#ifdef SPEW_CLIP_SKIPPING - skipPath.recordSkip(offsetToRestore - reader.offset()); -#endif - reader.setOffset(offsetToRestore); + reader->setOffset(offsetToRestore); } } break; case CLIP_REGION: { SkRegion region; - reader.readRegion(®ion); - uint32_t packed = reader.readInt(); + reader->readRegion(®ion); + uint32_t packed = reader->readInt(); SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); - size_t offsetToRestore = reader.readInt(); - SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset()); + size_t offsetToRestore = reader->readInt(); + SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); canvas->clipRegion(region, regionOp); if (canvas->isClipEmpty() && offsetToRestore) { -#ifdef SPEW_CLIP_SKIPPING - skipRegion.recordSkip(offsetToRestore - reader.offset()); -#endif - reader.setOffset(offsetToRestore); + reader->setOffset(offsetToRestore); } } break; case CLIP_RECT: { - const SkRect& rect = reader.skipT<SkRect>(); - uint32_t packed = reader.readInt(); + const SkRect& rect = reader->skipT<SkRect>(); + uint32_t packed = reader->readInt(); SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); bool doAA = ClipParams_unpackDoAA(packed); - size_t offsetToRestore = reader.readInt(); - SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset()); + size_t offsetToRestore = reader->readInt(); + SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); canvas->clipRect(rect, regionOp, doAA); if (canvas->isClipEmpty() && offsetToRestore) { -#ifdef SPEW_CLIP_SKIPPING - skipRect.recordSkip(offsetToRestore - reader.offset()); -#endif - reader.setOffset(offsetToRestore); + reader->setOffset(offsetToRestore); } } break; case CLIP_RRECT: { SkRRect rrect; - reader.readRRect(&rrect); - uint32_t packed = reader.readInt(); + reader->readRRect(&rrect); + uint32_t packed = reader->readInt(); SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed); bool doAA = ClipParams_unpackDoAA(packed); - size_t offsetToRestore = reader.readInt(); - SkASSERT(!offsetToRestore || offsetToRestore >= reader.offset()); + size_t offsetToRestore = reader->readInt(); + SkASSERT(!offsetToRestore || offsetToRestore >= reader->offset()); canvas->clipRRect(rrect, regionOp, doAA); if (canvas->isClipEmpty() && offsetToRestore) { -#ifdef SPEW_CLIP_SKIPPING - skipRRect.recordSkip(offsetToRestore - reader.offset()); -#endif - reader.setOffset(offsetToRestore); + reader->setOffset(offsetToRestore); } } break; case PUSH_CULL: { - const SkRect& cullRect = reader.skipT<SkRect>(); - size_t offsetToRestore = reader.readInt(); + const SkRect& cullRect = reader->skipT<SkRect>(); + size_t offsetToRestore = reader->readInt(); if (offsetToRestore && canvas->quickReject(cullRect)) { -#ifdef SPEW_CLIP_SKIPPING - skipCull.recordSkip(offsetToRestore - reader.offset()); -#endif - reader.setOffset(offsetToRestore); + reader->setOffset(offsetToRestore); } else { canvas->pushCull(cullRect); } @@ -388,61 +380,61 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) break; case CONCAT: { SkMatrix matrix; - reader.readMatrix(&matrix); + reader->readMatrix(&matrix); canvas->concat(matrix); break; } case DRAW_BITMAP: { const SkPaint* paint = fPictureData->getPaint(reader); const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)); - const SkPoint& loc = reader.skipT<SkPoint>(); + const SkPoint& loc = reader->skipT<SkPoint>(); canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); } break; case DRAW_BITMAP_RECT_TO_RECT: { const SkPaint* paint = fPictureData->getPaint(reader); const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)); const SkRect* src = get_rect_ptr(reader); // may be null - const SkRect& dst = reader.skipT<SkRect>(); // required + const SkRect& dst = reader->skipT<SkRect>(); // required SkCanvas::DrawBitmapRectFlags flags; - flags = (SkCanvas::DrawBitmapRectFlags) reader.readInt(); + flags = (SkCanvas::DrawBitmapRectFlags) reader->readInt(); canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags); } break; case DRAW_BITMAP_MATRIX: { const SkPaint* paint = fPictureData->getPaint(reader); const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)); SkMatrix matrix; - reader.readMatrix(&matrix); + reader->readMatrix(&matrix); canvas->drawBitmapMatrix(bitmap, matrix, paint); } break; case DRAW_BITMAP_NINE: { const SkPaint* paint = fPictureData->getPaint(reader); const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)); - const SkIRect& src = reader.skipT<SkIRect>(); - const SkRect& dst = reader.skipT<SkRect>(); + const SkIRect& src = reader->skipT<SkIRect>(); + const SkRect& dst = reader->skipT<SkRect>(); canvas->drawBitmapNine(bitmap, src, dst, paint); } break; case DRAW_CLEAR: - canvas->clear(reader.readInt()); + canvas->clear(reader->readInt()); break; case DRAW_DATA: { - size_t length = reader.readInt(); - canvas->drawData(reader.skip(length), length); + size_t length = reader->readInt(); + canvas->drawData(reader->skip(length), length); // skip handles padding the read out to a multiple of 4 } break; case DRAW_DRRECT: { const SkPaint& paint = *fPictureData->getPaint(reader); SkRRect outer, inner; - reader.readRRect(&outer); - reader.readRRect(&inner); + reader->readRRect(&outer); + reader->readRRect(&inner); canvas->drawDRRect(outer, inner, paint); } break; case BEGIN_COMMENT_GROUP: { - const char* desc = reader.readString(); + const char* desc = reader->readString(); canvas->beginCommentGroup(desc); } break; case COMMENT: { - const char* kywd = reader.readString(); - const char* value = reader.readString(); + const char* kywd = reader->readString(); + const char* value = reader->readString(); canvas->addComment(kywd, value); } break; case END_COMMENT_GROUP: { @@ -450,7 +442,7 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) } break; case DRAW_OVAL: { const SkPaint& paint = *fPictureData->getPaint(reader); - canvas->drawOval(reader.skipT<SkRect>(), paint); + canvas->drawOval(reader->skipT<SkRect>(), paint); } break; case DRAW_PAINT: canvas->drawPaint(*fPictureData->getPaint(reader)); @@ -464,42 +456,46 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) break; case DRAW_POINTS: { const SkPaint& paint = *fPictureData->getPaint(reader); - SkCanvas::PointMode mode = (SkCanvas::PointMode)reader.readInt(); - size_t count = reader.readInt(); - const SkPoint* pts = (const SkPoint*)reader.skip(sizeof(SkPoint)* count); + SkCanvas::PointMode mode = (SkCanvas::PointMode)reader->readInt(); + size_t count = reader->readInt(); + const SkPoint* pts = (const SkPoint*)reader->skip(sizeof(SkPoint)* count); canvas->drawPoints(mode, count, pts, paint); } break; case DRAW_POS_TEXT: { const SkPaint& paint = *fPictureData->getPaint(reader); - get_text(&reader, &text); - size_t points = reader.readInt(); - const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkPoint)); + TextContainer text; + get_text(reader, &text); + size_t points = reader->readInt(); + const SkPoint* pos = (const SkPoint*)reader->skip(points * sizeof(SkPoint)); canvas->drawPosText(text.text(), text.length(), pos, paint); } break; case DRAW_POS_TEXT_TOP_BOTTOM: { const SkPaint& paint = *fPictureData->getPaint(reader); - get_text(&reader, &text); - size_t points = reader.readInt(); - const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkPoint)); - const SkScalar top = reader.readScalar(); - const SkScalar bottom = reader.readScalar(); + TextContainer text; + get_text(reader, &text); + size_t points = reader->readInt(); + const SkPoint* pos = (const SkPoint*)reader->skip(points * sizeof(SkPoint)); + const SkScalar top = reader->readScalar(); + const SkScalar bottom = reader->readScalar(); if (!canvas->quickRejectY(top, bottom)) { canvas->drawPosText(text.text(), text.length(), pos, paint); } } break; case DRAW_POS_TEXT_H: { const SkPaint& paint = *fPictureData->getPaint(reader); - get_text(&reader, &text); - size_t xCount = reader.readInt(); - const SkScalar constY = reader.readScalar(); - const SkScalar* xpos = (const SkScalar*)reader.skip(xCount * sizeof(SkScalar)); + TextContainer text; + get_text(reader, &text); + size_t xCount = reader->readInt(); + const SkScalar constY = reader->readScalar(); + const SkScalar* xpos = (const SkScalar*)reader->skip(xCount * sizeof(SkScalar)); canvas->drawPosTextH(text.text(), text.length(), xpos, constY, paint); } break; case DRAW_POS_TEXT_H_TOP_BOTTOM: { const SkPaint& paint = *fPictureData->getPaint(reader); - get_text(&reader, &text); - size_t xCount = reader.readInt(); - const SkScalar* xpos = (const SkScalar*)reader.skip((3 + xCount) * sizeof(SkScalar)); + TextContainer text; + get_text(reader, &text); + size_t xCount = reader->readInt(); + const SkScalar* xpos = (const SkScalar*)reader->skip((3 + xCount) * sizeof(SkScalar)); const SkScalar top = *xpos++; const SkScalar bottom = *xpos++; const SkScalar constY = *xpos++; @@ -509,32 +505,34 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) } break; case DRAW_RECT: { const SkPaint& paint = *fPictureData->getPaint(reader); - canvas->drawRect(reader.skipT<SkRect>(), paint); + canvas->drawRect(reader->skipT<SkRect>(), paint); } break; case DRAW_RRECT: { const SkPaint& paint = *fPictureData->getPaint(reader); SkRRect rrect; - reader.readRRect(&rrect); + reader->readRRect(&rrect); canvas->drawRRect(rrect, paint); } break; case DRAW_SPRITE: { const SkPaint* paint = fPictureData->getPaint(reader); const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)); - int left = reader.readInt(); - int top = reader.readInt(); + int left = reader->readInt(); + int top = reader->readInt(); canvas->drawSprite(bitmap, left, top, paint); } break; case DRAW_TEXT: { const SkPaint& paint = *fPictureData->getPaint(reader); - get_text(&reader, &text); - SkScalar x = reader.readScalar(); - SkScalar y = reader.readScalar(); + TextContainer text; + get_text(reader, &text); + SkScalar x = reader->readScalar(); + SkScalar y = reader->readScalar(); canvas->drawText(text.text(), text.length(), x, y, paint); } break; case DRAW_TEXT_TOP_BOTTOM: { const SkPaint& paint = *fPictureData->getPaint(reader); - get_text(&reader, &text); - const SkScalar* ptr = (const SkScalar*)reader.skip(4 * sizeof(SkScalar)); + TextContainer text; + get_text(reader, &text); + const SkScalar* ptr = (const SkScalar*)reader->skip(4 * sizeof(SkScalar)); // ptr[0] == x // ptr[1] == y // ptr[2] == top @@ -545,35 +543,36 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) } break; case DRAW_TEXT_ON_PATH: { const SkPaint& paint = *fPictureData->getPaint(reader); - get_text(&reader, &text); + TextContainer text; + get_text(reader, &text); const SkPath& path = fPictureData->getPath(reader); SkMatrix matrix; - reader.readMatrix(&matrix); + reader->readMatrix(&matrix); canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, paint); } break; case DRAW_VERTICES: { SkAutoTUnref<SkXfermode> xfer; const SkPaint& paint = *fPictureData->getPaint(reader); - DrawVertexFlags flags = (DrawVertexFlags)reader.readInt(); - SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader.readInt(); - int vCount = reader.readInt(); - const SkPoint* verts = (const SkPoint*)reader.skip(vCount * sizeof(SkPoint)); + DrawVertexFlags flags = (DrawVertexFlags)reader->readInt(); + SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readInt(); + int vCount = reader->readInt(); + const SkPoint* verts = (const SkPoint*)reader->skip(vCount * sizeof(SkPoint)); const SkPoint* texs = NULL; const SkColor* colors = NULL; const uint16_t* indices = NULL; int iCount = 0; if (flags & DRAW_VERTICES_HAS_TEXS) { - texs = (const SkPoint*)reader.skip(vCount * sizeof(SkPoint)); + texs = (const SkPoint*)reader->skip(vCount * sizeof(SkPoint)); } if (flags & DRAW_VERTICES_HAS_COLORS) { - colors = (const SkColor*)reader.skip(vCount * sizeof(SkColor)); + colors = (const SkColor*)reader->skip(vCount * sizeof(SkColor)); } if (flags & DRAW_VERTICES_HAS_INDICES) { - iCount = reader.readInt(); - indices = (const uint16_t*)reader.skip(iCount * sizeof(uint16_t)); + iCount = reader->readInt(); + indices = (const uint16_t*)reader->skip(iCount * sizeof(uint16_t)); } if (flags & DRAW_VERTICES_HAS_XFER) { - int mode = reader.readInt(); + int mode = reader->readInt(); if (mode < 0 || mode > SkXfermode::kLastMode) { mode = SkXfermode::kModulate_Mode; } @@ -585,69 +584,44 @@ void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) canvas->restore(); break; case ROTATE: - canvas->rotate(reader.readScalar()); + canvas->rotate(reader->readScalar()); break; case SAVE: // SKPs with version < 29 also store a SaveFlags param. if (size > 4) { SkASSERT(8 == size); - reader.readInt(); + reader->readInt(); } canvas->save(); break; case SAVE_LAYER: { const SkRect* boundsPtr = get_rect_ptr(reader); const SkPaint* paint = fPictureData->getPaint(reader); - canvas->saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader.readInt()); + canvas->saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader->readInt()); } break; case SCALE: { - SkScalar sx = reader.readScalar(); - SkScalar sy = reader.readScalar(); + SkScalar sx = reader->readScalar(); + SkScalar sy = reader->readScalar(); canvas->scale(sx, sy); } break; case SET_MATRIX: { SkMatrix matrix; - reader.readMatrix(&matrix); + reader->readMatrix(&matrix); matrix.postConcat(initialMatrix); canvas->setMatrix(matrix); } break; case SKEW: { - SkScalar sx = reader.readScalar(); - SkScalar sy = reader.readScalar(); + SkScalar sx = reader->readScalar(); + SkScalar sy = reader->readScalar(); canvas->skew(sx, sy); } break; case TRANSLATE: { - SkScalar dx = reader.readScalar(); - SkScalar dy = reader.readScalar(); + SkScalar dx = reader->readScalar(); + SkScalar dy = reader->readScalar(); canvas->translate(dx, dy); } break; default: SkASSERT(0); - } - -#ifdef SK_DEVELOPER - this->postDraw(opIndex); -#endif - - if (it.isValid()) { - uint32_t skipTo = it.nextDraw(); - if (kDrawComplete == skipTo) { - break; - } - reader.setOffset(skipTo); - } } - -#ifdef SPEW_CLIP_SKIPPING - { - size_t size = skipRect.fSize + skipRRect.fSize + skipPath.fSize + skipRegion.fSize + - skipCull.fSize; - SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d cull:%d\n", - size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount, - skipPath.fCount, skipRegion.fCount, skipCull.fCount); - SkDebugf("--- Total ops: %d\n", opCount); - } -#endif - // this->dumpSize(); } diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h index 251ad3a856..3014b945c1 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPicturePlayback.h @@ -106,6 +106,12 @@ protected: size_t fStop; PlaybackReplacements* fReplacements; + void handleOp(SkReader32* reader, + DrawType op, + uint32_t size, + SkCanvas* canvas, + const SkMatrix& initialMatrix); + #ifdef SK_DEVELOPER virtual bool preDraw(int opIndex, int type) { return false; } virtual void postDraw(int opIndex) { } |