OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 const char* fText; | 75 const char* fText; |
76 }; | 76 }; |
77 | 77 |
78 void get_text(SkReadBuffer* reader, TextContainer* text) { | 78 void get_text(SkReadBuffer* reader, TextContainer* text) { |
79 size_t length = text->fByteLength = reader->readInt(); | 79 size_t length = text->fByteLength = reader->readInt(); |
80 text->fText = (const char*)reader->skip(length); | 80 text->fText = (const char*)reader->skip(length); |
81 } | 81 } |
82 | 82 |
83 void SkPicturePlayback::draw(SkCanvas* canvas, | 83 void SkPicturePlayback::draw(SkCanvas* canvas, |
84 SkPicture::AbortCallback* callback, | 84 SkPicture::AbortCallback* callback, |
85 const SkReadBuffer* buffer) { | 85 SkReadBuffer* buffer) { |
86 AutoResetOpID aroi(this); | 86 AutoResetOpID aroi(this); |
87 SkASSERT(0 == fCurOffset); | 87 SkASSERT(0 == fCurOffset); |
88 | 88 |
89 SkAutoTDelete<SkReadBuffer> reader; | 89 SkAutoTDelete<SkReadBuffer> reader; |
90 if (buffer) { | 90 if (buffer) { |
91 reader.reset(buffer->clone(fPictureData->opData()->bytes(), | 91 reader.reset(buffer->clone(fPictureData->opData()->bytes(), |
92 fPictureData->opData()->size())); | 92 fPictureData->opData()->size())); |
93 } else { | 93 } else { |
94 reader.reset(new SkReadBuffer(fPictureData->opData()->bytes(), | 94 reader.reset(new SkReadBuffer(fPictureData->opData()->bytes(), |
95 fPictureData->opData()->size())); | 95 fPictureData->opData()->size())); |
(...skipping 11 matching lines...) Expand all Loading... |
107 | 107 |
108 fCurOffset = reader->offset(); | 108 fCurOffset = reader->offset(); |
109 uint32_t size; | 109 uint32_t size; |
110 DrawType op = ReadOpAndSize(reader, &size); | 110 DrawType op = ReadOpAndSize(reader, &size); |
111 if (!reader->validate(op > UNUSED && op <= LAST_DRAWTYPE_ENUM)) { | 111 if (!reader->validate(op > UNUSED && op <= LAST_DRAWTYPE_ENUM)) { |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 this->handleOp(reader, op, size, canvas, initialMatrix); | 115 this->handleOp(reader, op, size, canvas, initialMatrix); |
116 } | 116 } |
| 117 |
| 118 // need to propagate invalid state to the parent reader |
| 119 if (buffer) { |
| 120 buffer->validate(reader->isValid()); |
| 121 } |
117 } | 122 } |
118 | 123 |
119 void SkPicturePlayback::handleOp(SkReadBuffer* reader, | 124 void SkPicturePlayback::handleOp(SkReadBuffer* reader, |
120 DrawType op, | 125 DrawType op, |
121 uint32_t size, | 126 uint32_t size, |
122 SkCanvas* canvas, | 127 SkCanvas* canvas, |
123 const SkMatrix& initialMatrix) { | 128 const SkMatrix& initialMatrix) { |
124 switch (op) { | 129 switch (op) { |
125 case NOOP: { | 130 case NOOP: { |
126 SkASSERT(size >= 4); | 131 SkASSERT(size >= 4); |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 case TRANSLATE_Z: { | 670 case TRANSLATE_Z: { |
666 #ifdef SK_EXPERIMENTAL_SHADOWING | 671 #ifdef SK_EXPERIMENTAL_SHADOWING |
667 SkScalar dz = reader->readScalar(); | 672 SkScalar dz = reader->readScalar(); |
668 canvas->translateZ(dz); | 673 canvas->translateZ(dz); |
669 #endif | 674 #endif |
670 } break; | 675 } break; |
671 default: | 676 default: |
672 SkASSERTF(false, "Unknown draw type: %d", op); | 677 SkASSERTF(false, "Unknown draw type: %d", op); |
673 } | 678 } |
674 } | 679 } |
OLD | NEW |