diff --git a/debugger/SkDrawCommand.cpp b/debugger/SkDrawCommand.cpp index b18559553..89c338d8c 100644 --- a/debugger/SkDrawCommand.cpp +++ b/debugger/SkDrawCommand.cpp @@ -55,6 +55,7 @@ const char* SkDrawCommand::GetCommandString(DrawType type) { case SET_MATRIX: return "Set Matrix"; case SKEW: return "Skew"; case TRANSLATE: return "Translate"; + case NOOP: return "NoOp"; default: SkDebugf("DrawType error 0x%08x\n", type); SkASSERT(0); diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 3e464e0eb..58fc0c33a 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -52,28 +52,39 @@ const char* DrawTypeToString(DrawType drawType) { case CLIP_PATH: return "CLIP_PATH"; case CLIP_REGION: return "CLIP_REGION"; case CLIP_RECT: return "CLIP_RECT"; + case CLIP_RRECT: return "CLIP_RRECT"; case CONCAT: return "CONCAT"; case DRAW_BITMAP: return "DRAW_BITMAP"; case DRAW_BITMAP_MATRIX: return "DRAW_BITMAP_MATRIX"; - case DRAW_BITMAP_RECT: return "DRAW_BITMAP_RECT"; + case DRAW_BITMAP_NINE: return "DRAW_BITMAP_NINE"; + case DRAW_BITMAP_RECT_TO_RECT: return "DRAW_BITMAP_RECT_TO_RECT"; + case DRAW_CLEAR: return "DRAW_CLEAR"; + case DRAW_DATA: return "DRAW_DATA"; + case DRAW_OVAL: return "DRAW_OVAL"; case DRAW_PAINT: return "DRAW_PAINT"; case DRAW_PATH: return "DRAW_PATH"; case DRAW_PICTURE: return "DRAW_PICTURE"; case DRAW_POINTS: return "DRAW_POINTS"; case DRAW_POS_TEXT: return "DRAW_POS_TEXT"; + case DRAW_POS_TEXT_TOP_BOTTOM: return "DRAW_POS_TEXT_TOP_BOTTOM"; case DRAW_POS_TEXT_H: return "DRAW_POS_TEXT_H"; - case DRAW_RECT_GENERAL: return "DRAW_RECT_GENERAL"; - case DRAW_RECT_SIMPLE: return "DRAW_RECT_SIMPLE"; + case DRAW_POS_TEXT_H_TOP_BOTTOM: return "DRAW_POS_TEXT_H_TOP_BOTTOM"; + case DRAW_RECT: return "DRAW_RECT"; + case DRAW_RRECT: return "DRAW_RRECT"; case DRAW_SPRITE: return "DRAW_SPRITE"; case DRAW_TEXT: return "DRAW_TEXT"; case DRAW_TEXT_ON_PATH: return "DRAW_TEXT_ON_PATH"; + case DRAW_TEXT_TOP_BOTTOM: return "DRAW_TEXT_TOP_BOTTOM"; + case DRAW_VERTICES: return "DRAW_VERTICES"; case RESTORE: return "RESTORE"; case ROTATE: return "ROTATE"; case SAVE: return "SAVE"; case SAVE_LAYER: return "SAVE_LAYER"; case SCALE: return "SCALE"; + case SET_MATRIX: return "SET_MATRIX"; case SKEW: return "SKEW"; case TRANSLATE: return "TRANSLATE"; + case NOOP: return "NOOP"; default: SkDebugf("DrawType error 0x%08x\n", drawType); SkASSERT(0); diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h index e577f7934..a9db48d96 100644 --- a/src/core/SkPictureFlat.h +++ b/src/core/SkPictureFlat.h @@ -61,8 +61,9 @@ enum DrawType { SET_MATRIX, SKEW, TRANSLATE, + NOOP, - LAST_DRAWTYPE_ENUM = TRANSLATE + LAST_DRAWTYPE_ENUM = NOOP }; enum DrawVertexFlags { diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index 3b76ab210..c6c26ff3a 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -630,7 +630,11 @@ void SkPicturePlayback::postDraw(size_t offset) { #endif /* - * Read the next op code and chunk size from 'reader' + * Read the next op code and chunk size from 'reader'. The returned size + * is the entire size of the chunk (including the opcode). Thus, the + * offset just prior to calling read_op_and_size + 'size' is the offset + * to the next chunk's op code. This also means that the size of a chunk + * with no arguments (just an opcode) will be 4. */ static DrawType read_op_and_size(SkReader32* reader, uint32_t* size) { uint32_t temp = reader->readInt(); @@ -715,6 +719,12 @@ void SkPicturePlayback::draw(SkCanvas& canvas) { #endif uint32_t size; DrawType op = read_op_and_size(&reader, &size); + if (NOOP == op) { + // NOOPs are to be ignored - do not propagate them any further + reader.setOffset(curOffset+size); + continue; + } + #ifdef SK_DEVELOPER // TODO: once chunk sizes are in all .skps just use "curOffset + size" size_t skipTo = this->preDraw(curOffset, op); diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 5180e5ed6..762c1e76b 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -190,6 +190,39 @@ static bool collapseSaveClipRestore(SkWriter32* writer, int32_t offset) { return true; } +// This function is just a toy example and will not be delivered with this +// CL +static bool noClips(SkWriter32* writer, int32_t offset) { + + int32_t restoreOffset = (int32_t)writer->size(); + + // back up to the save block + while (offset > 0) { + offset = *writer->peek32(offset); + } + + // now offset points to a save + offset = -offset; + uint32_t opSize; + DrawType op = peek_op_and_size(writer, offset, &opSize); + SkASSERT(SAVE == op || SAVE_LAYER == op); + + // Walk forward until until we hit our restore, nuking all clips + // along the way + offset += opSize; + while (offset < restoreOffset) { + op = peek_op_and_size(writer, offset, &opSize); + + if (CLIP_RECT == op || CLIP_RRECT == op) { + uint32_t* ptr = writer->peek32(offset); + *ptr = (*ptr & MASK_24) | (NOOP << 24); + } + offset += opSize; + } + + return true; +} + void SkPictureRecord::restore() { // FIXME: SkDeferredCanvas needs to be refactored to respect // save/restore balancing so that the following test can be @@ -207,6 +240,9 @@ void SkPictureRecord::restore() { fFirstSavedLayerIndex = kNoSavedLayerIndex; } + // This call will not be delivered either + noClips(&fWriter, fRestoreOffsetStack.top()); + uint32_t initialOffset, size; if (!collapseSaveClipRestore(&fWriter, fRestoreOffsetStack.top())) { fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.size());