Add NOOP "command" to picture format
https://codereview.appspot.com/7343044/ git-svn-id: http://skia.googlecode.com/svn/trunk@7752 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
aa6470af8e
commit
e4ce5b8262
@ -55,6 +55,7 @@ const char* SkDrawCommand::GetCommandString(DrawType type) {
|
|||||||
case SET_MATRIX: return "Set Matrix";
|
case SET_MATRIX: return "Set Matrix";
|
||||||
case SKEW: return "Skew";
|
case SKEW: return "Skew";
|
||||||
case TRANSLATE: return "Translate";
|
case TRANSLATE: return "Translate";
|
||||||
|
case NOOP: return "NoOp";
|
||||||
default:
|
default:
|
||||||
SkDebugf("DrawType error 0x%08x\n", type);
|
SkDebugf("DrawType error 0x%08x\n", type);
|
||||||
SkASSERT(0);
|
SkASSERT(0);
|
||||||
|
@ -52,28 +52,39 @@ const char* DrawTypeToString(DrawType drawType) {
|
|||||||
case CLIP_PATH: return "CLIP_PATH";
|
case CLIP_PATH: return "CLIP_PATH";
|
||||||
case CLIP_REGION: return "CLIP_REGION";
|
case CLIP_REGION: return "CLIP_REGION";
|
||||||
case CLIP_RECT: return "CLIP_RECT";
|
case CLIP_RECT: return "CLIP_RECT";
|
||||||
|
case CLIP_RRECT: return "CLIP_RRECT";
|
||||||
case CONCAT: return "CONCAT";
|
case CONCAT: return "CONCAT";
|
||||||
case DRAW_BITMAP: return "DRAW_BITMAP";
|
case DRAW_BITMAP: return "DRAW_BITMAP";
|
||||||
case DRAW_BITMAP_MATRIX: return "DRAW_BITMAP_MATRIX";
|
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_PAINT: return "DRAW_PAINT";
|
||||||
case DRAW_PATH: return "DRAW_PATH";
|
case DRAW_PATH: return "DRAW_PATH";
|
||||||
case DRAW_PICTURE: return "DRAW_PICTURE";
|
case DRAW_PICTURE: return "DRAW_PICTURE";
|
||||||
case DRAW_POINTS: return "DRAW_POINTS";
|
case DRAW_POINTS: return "DRAW_POINTS";
|
||||||
case DRAW_POS_TEXT: return "DRAW_POS_TEXT";
|
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_POS_TEXT_H: return "DRAW_POS_TEXT_H";
|
||||||
case DRAW_RECT_GENERAL: return "DRAW_RECT_GENERAL";
|
case DRAW_POS_TEXT_H_TOP_BOTTOM: return "DRAW_POS_TEXT_H_TOP_BOTTOM";
|
||||||
case DRAW_RECT_SIMPLE: return "DRAW_RECT_SIMPLE";
|
case DRAW_RECT: return "DRAW_RECT";
|
||||||
|
case DRAW_RRECT: return "DRAW_RRECT";
|
||||||
case DRAW_SPRITE: return "DRAW_SPRITE";
|
case DRAW_SPRITE: return "DRAW_SPRITE";
|
||||||
case DRAW_TEXT: return "DRAW_TEXT";
|
case DRAW_TEXT: return "DRAW_TEXT";
|
||||||
case DRAW_TEXT_ON_PATH: return "DRAW_TEXT_ON_PATH";
|
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 RESTORE: return "RESTORE";
|
||||||
case ROTATE: return "ROTATE";
|
case ROTATE: return "ROTATE";
|
||||||
case SAVE: return "SAVE";
|
case SAVE: return "SAVE";
|
||||||
case SAVE_LAYER: return "SAVE_LAYER";
|
case SAVE_LAYER: return "SAVE_LAYER";
|
||||||
case SCALE: return "SCALE";
|
case SCALE: return "SCALE";
|
||||||
|
case SET_MATRIX: return "SET_MATRIX";
|
||||||
case SKEW: return "SKEW";
|
case SKEW: return "SKEW";
|
||||||
case TRANSLATE: return "TRANSLATE";
|
case TRANSLATE: return "TRANSLATE";
|
||||||
|
case NOOP: return "NOOP";
|
||||||
default:
|
default:
|
||||||
SkDebugf("DrawType error 0x%08x\n", drawType);
|
SkDebugf("DrawType error 0x%08x\n", drawType);
|
||||||
SkASSERT(0);
|
SkASSERT(0);
|
||||||
|
@ -61,8 +61,9 @@ enum DrawType {
|
|||||||
SET_MATRIX,
|
SET_MATRIX,
|
||||||
SKEW,
|
SKEW,
|
||||||
TRANSLATE,
|
TRANSLATE,
|
||||||
|
NOOP,
|
||||||
|
|
||||||
LAST_DRAWTYPE_ENUM = TRANSLATE
|
LAST_DRAWTYPE_ENUM = NOOP
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DrawVertexFlags {
|
enum DrawVertexFlags {
|
||||||
|
@ -630,7 +630,11 @@ void SkPicturePlayback::postDraw(size_t offset) {
|
|||||||
#endif
|
#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) {
|
static DrawType read_op_and_size(SkReader32* reader, uint32_t* size) {
|
||||||
uint32_t temp = reader->readInt();
|
uint32_t temp = reader->readInt();
|
||||||
@ -715,6 +719,12 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
|
|||||||
#endif
|
#endif
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
DrawType op = read_op_and_size(&reader, &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
|
#ifdef SK_DEVELOPER
|
||||||
// TODO: once chunk sizes are in all .skps just use "curOffset + size"
|
// TODO: once chunk sizes are in all .skps just use "curOffset + size"
|
||||||
size_t skipTo = this->preDraw(curOffset, op);
|
size_t skipTo = this->preDraw(curOffset, op);
|
||||||
|
@ -190,6 +190,39 @@ static bool collapseSaveClipRestore(SkWriter32* writer, int32_t offset) {
|
|||||||
return true;
|
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() {
|
void SkPictureRecord::restore() {
|
||||||
// FIXME: SkDeferredCanvas needs to be refactored to respect
|
// FIXME: SkDeferredCanvas needs to be refactored to respect
|
||||||
// save/restore balancing so that the following test can be
|
// save/restore balancing so that the following test can be
|
||||||
@ -207,6 +240,9 @@ void SkPictureRecord::restore() {
|
|||||||
fFirstSavedLayerIndex = kNoSavedLayerIndex;
|
fFirstSavedLayerIndex = kNoSavedLayerIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This call will not be delivered either
|
||||||
|
noClips(&fWriter, fRestoreOffsetStack.top());
|
||||||
|
|
||||||
uint32_t initialOffset, size;
|
uint32_t initialOffset, size;
|
||||||
if (!collapseSaveClipRestore(&fWriter, fRestoreOffsetStack.top())) {
|
if (!collapseSaveClipRestore(&fWriter, fRestoreOffsetStack.top())) {
|
||||||
fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.size());
|
fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWriter.size());
|
||||||
|
Loading…
Reference in New Issue
Block a user