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 "SkRSXform.h" |
15 #include "SkTextBlob.h" | 15 #include "SkTextBlob.h" |
16 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
17 #include "SkTypes.h" | 17 #include "SkTypes.h" |
18 | 18 |
| 19 // matches old SkCanvas::SaveFlags |
| 20 enum LegacySaveFlags { |
| 21 kHasAlphaLayer_LegacySaveFlags = 0x04, |
| 22 kClipToLayer_LegacySaveFlags = 0x10, |
| 23 }; |
| 24 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS |
| 25 static_assert(kHasAlphaLayer_LegacySaveFlags == (int)SkCanvas::kHasAlphaLayer_Sa
veFlag, ""); |
| 26 static_assert(kClipToLayer_LegacySaveFlags == (int)SkCanvas::kClipToLayer_SaveFl
ag, ""); |
| 27 #endif |
| 28 |
| 29 SkCanvas::SaveLayerFlags SkCanvas::LegacySaveFlagsToSaveLayerFlags(uint32_t flag
s) { |
| 30 uint32_t layerFlags = 0; |
| 31 |
| 32 if (0 == (flags & kClipToLayer_LegacySaveFlags)) { |
| 33 layerFlags |= SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag; |
| 34 } |
| 35 if (0 == (flags & kHasAlphaLayer_LegacySaveFlags)) { |
| 36 layerFlags |= kIsOpaque_SaveLayerFlag; |
| 37 } |
| 38 return layerFlags; |
| 39 } |
| 40 |
19 /* | 41 /* |
20 * Read the next op code and chunk size from 'reader'. The returned size | 42 * Read the next op code and chunk size from 'reader'. The returned size |
21 * is the entire size of the chunk (including the opcode). Thus, the | 43 * is the entire size of the chunk (including the opcode). Thus, the |
22 * offset just prior to calling ReadOpAndSize + 'size' is the offset | 44 * offset just prior to calling ReadOpAndSize + 'size' is the offset |
23 * to the next chunk's op code. This also means that the size of a chunk | 45 * to the next chunk's op code. This also means that the size of a chunk |
24 * with no arguments (just an opcode) will be 4. | 46 * with no arguments (just an opcode) will be 4. |
25 */ | 47 */ |
26 DrawType SkPicturePlayback::ReadOpAndSize(SkReader32* reader, uint32_t* size) { | 48 DrawType SkPicturePlayback::ReadOpAndSize(SkReader32* reader, uint32_t* size) { |
27 uint32_t temp = reader->readInt(); | 49 uint32_t temp = reader->readInt(); |
28 uint32_t op; | 50 uint32_t op; |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 // SKPs with version < 29 also store a SaveFlags param. | 473 // SKPs with version < 29 also store a SaveFlags param. |
452 if (size > 4) { | 474 if (size > 4) { |
453 SkASSERT(8 == size); | 475 SkASSERT(8 == size); |
454 reader->readInt(); | 476 reader->readInt(); |
455 } | 477 } |
456 canvas->save(); | 478 canvas->save(); |
457 break; | 479 break; |
458 case SAVE_LAYER_SAVEFLAGS_DEPRECATED: { | 480 case SAVE_LAYER_SAVEFLAGS_DEPRECATED: { |
459 const SkRect* boundsPtr = get_rect_ptr(reader); | 481 const SkRect* boundsPtr = get_rect_ptr(reader); |
460 const SkPaint* paint = fPictureData->getPaint(reader); | 482 const SkPaint* paint = fPictureData->getPaint(reader); |
461 const SkCanvas::SaveFlags flags = (SkCanvas::SaveFlags)reader->readI
nt(); | 483 auto flags = SkCanvas::LegacySaveFlagsToSaveLayerFlags(reader->readI
nt()); |
462 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, | 484 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, flags)); |
463 SkCanvas::SaveFlagsToSaveLayerFlags(f
lags))); | |
464 } break; | 485 } break; |
465 case SAVE_LAYER_SAVELAYERFLAGS: { | 486 case SAVE_LAYER_SAVELAYERFLAGS: { |
466 const SkRect* boundsPtr = get_rect_ptr(reader); | 487 const SkRect* boundsPtr = get_rect_ptr(reader); |
467 const SkPaint* paint = fPictureData->getPaint(reader); | 488 const SkPaint* paint = fPictureData->getPaint(reader); |
468 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, reader->r
eadInt())); | 489 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, reader->r
eadInt())); |
469 } break; | 490 } break; |
470 case SCALE: { | 491 case SCALE: { |
471 SkScalar sx = reader->readScalar(); | 492 SkScalar sx = reader->readScalar(); |
472 SkScalar sy = reader->readScalar(); | 493 SkScalar sy = reader->readScalar(); |
473 canvas->scale(sx, sy); | 494 canvas->scale(sx, sy); |
(...skipping 12 matching lines...) Expand all Loading... |
486 case TRANSLATE: { | 507 case TRANSLATE: { |
487 SkScalar dx = reader->readScalar(); | 508 SkScalar dx = reader->readScalar(); |
488 SkScalar dy = reader->readScalar(); | 509 SkScalar dy = reader->readScalar(); |
489 canvas->translate(dx, dy); | 510 canvas->translate(dx, dy); |
490 } break; | 511 } break; |
491 default: | 512 default: |
492 SkASSERTF(false, "Unknown draw type: %d", op); | 513 SkASSERTF(false, "Unknown draw type: %d", op); |
493 } | 514 } |
494 } | 515 } |
495 | 516 |
OLD | NEW |