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" |
11 #include "SkPicturePlayback.h" | 11 #include "SkPicturePlayback.h" |
12 #include "SkPictureRecord.h" | 12 #include "SkPictureRecord.h" |
13 #include "SkReader32.h" | 13 #include "SkReader32.h" |
| 14 #include "SkRSXform.h" |
14 #include "SkTextBlob.h" | 15 #include "SkTextBlob.h" |
15 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
16 #include "SkTypes.h" | 17 #include "SkTypes.h" |
17 | 18 |
18 /* | 19 /* |
19 * Read the next op code and chunk size from 'reader'. The returned size | 20 * Read the next op code and chunk size from 'reader'. The returned size |
20 * is the entire size of the chunk (including the opcode). Thus, the | 21 * is the entire size of the chunk (including the opcode). Thus, the |
21 * offset just prior to calling ReadOpAndSize + 'size' is the offset | 22 * offset just prior to calling ReadOpAndSize + 'size' is the offset |
22 * to the next chunk's op code. This also means that the size of a chunk | 23 * to the next chunk's op code. This also means that the size of a chunk |
23 * with no arguments (just an opcode) will be 4. | 24 * with no arguments (just an opcode) will be 4. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 150 } |
150 } break; | 151 } break; |
151 case PUSH_CULL: break; // Deprecated, safe to ignore both push and pop. | 152 case PUSH_CULL: break; // Deprecated, safe to ignore both push and pop. |
152 case POP_CULL: break; | 153 case POP_CULL: break; |
153 case CONCAT: { | 154 case CONCAT: { |
154 SkMatrix matrix; | 155 SkMatrix matrix; |
155 reader->readMatrix(&matrix); | 156 reader->readMatrix(&matrix); |
156 canvas->concat(matrix); | 157 canvas->concat(matrix); |
157 break; | 158 break; |
158 } | 159 } |
| 160 case DRAW_ATLAS: { |
| 161 const SkPaint* paint = fPictureData->getPaint(reader); |
| 162 const SkImage* atlas = fPictureData->getImage(reader); |
| 163 const uint32_t flags = reader->readU32(); |
| 164 const int count = reader->readU32(); |
| 165 const SkRSXform* xform = (const SkRSXform*)reader->skip(count * size
of(SkRSXform)); |
| 166 const SkRect* tex = (const SkRect*)reader->skip(count * sizeof(SkRec
t)); |
| 167 const SkColor* colors = NULL; |
| 168 SkXfermode::Mode mode = SkXfermode::kDst_Mode; |
| 169 if (flags & DRAW_ATLAS_HAS_COLORS) { |
| 170 colors = (const SkColor*)reader->skip(count * sizeof(SkColor)); |
| 171 mode = (SkXfermode::Mode)reader->readU32(); |
| 172 } |
| 173 const SkRect* cull = NULL; |
| 174 if (flags & DRAW_ATLAS_HAS_CULL) { |
| 175 cull = (const SkRect*)reader->skip(sizeof(SkRect)); |
| 176 } |
| 177 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, pain
t); |
| 178 } break; |
159 case DRAW_BITMAP: { | 179 case DRAW_BITMAP: { |
160 const SkPaint* paint = fPictureData->getPaint(reader); | 180 const SkPaint* paint = fPictureData->getPaint(reader); |
161 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); | 181 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); |
162 const SkPoint& loc = reader->skipT<SkPoint>(); | 182 const SkPoint& loc = reader->skipT<SkPoint>(); |
163 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); | 183 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); |
164 } break; | 184 } break; |
165 case DRAW_BITMAP_RECT_TO_RECT: { | 185 case DRAW_BITMAP_RECT_TO_RECT: { |
166 const SkPaint* paint = fPictureData->getPaint(reader); | 186 const SkPaint* paint = fPictureData->getPaint(reader); |
167 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); | 187 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); |
168 const SkRect* src = get_rect_ptr(reader); // may be null | 188 const SkRect* src = get_rect_ptr(reader); // may be null |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 case TRANSLATE: { | 466 case TRANSLATE: { |
447 SkScalar dx = reader->readScalar(); | 467 SkScalar dx = reader->readScalar(); |
448 SkScalar dy = reader->readScalar(); | 468 SkScalar dy = reader->readScalar(); |
449 canvas->translate(dx, dy); | 469 canvas->translate(dx, dy); |
450 } break; | 470 } break; |
451 default: | 471 default: |
452 SkASSERTF(false, "Unknown draw type: %d", op); | 472 SkASSERTF(false, "Unknown draw type: %d", op); |
453 } | 473 } |
454 } | 474 } |
455 | 475 |
OLD | NEW |