Chromium Code Reviews| 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 | |
|
f(malita)
2015/12/19 18:20:21
Can we static_assert this (while SK_SUPPORT_LEGACY
reed1
2015/12/20 03:05:45
Done.
| |
| 20 enum LegacySaveFlags { | |
| 21 kHasAlphaLayer_LegacySaveFlags = 0x04, | |
| 22 kClipToLayer_LegacySaveFlags = 0x10, | |
| 23 }; | |
| 24 SkCanvas::SaveLayerFlags SkCanvas::LegacySaveFlagsToSaveLayerFlags(uint32_t flag s) { | |
| 25 uint32_t layerFlags = 0; | |
| 26 | |
| 27 if (0 == (flags & kClipToLayer_LegacySaveFlags)) { | |
| 28 layerFlags |= SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag; | |
| 29 } | |
| 30 if (0 == (flags & kHasAlphaLayer_LegacySaveFlags)) { | |
| 31 layerFlags |= kIsOpaque_SaveLayerFlag; | |
| 32 } | |
| 33 return layerFlags; | |
| 34 } | |
| 35 | |
| 19 /* | 36 /* |
| 20 * Read the next op code and chunk size from 'reader'. The returned size | 37 * 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 | 38 * is the entire size of the chunk (including the opcode). Thus, the |
| 22 * offset just prior to calling ReadOpAndSize + 'size' is the offset | 39 * 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 | 40 * 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. | 41 * with no arguments (just an opcode) will be 4. |
| 25 */ | 42 */ |
| 26 DrawType SkPicturePlayback::ReadOpAndSize(SkReader32* reader, uint32_t* size) { | 43 DrawType SkPicturePlayback::ReadOpAndSize(SkReader32* reader, uint32_t* size) { |
| 27 uint32_t temp = reader->readInt(); | 44 uint32_t temp = reader->readInt(); |
| 28 uint32_t op; | 45 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. | 468 // SKPs with version < 29 also store a SaveFlags param. |
| 452 if (size > 4) { | 469 if (size > 4) { |
| 453 SkASSERT(8 == size); | 470 SkASSERT(8 == size); |
| 454 reader->readInt(); | 471 reader->readInt(); |
| 455 } | 472 } |
| 456 canvas->save(); | 473 canvas->save(); |
| 457 break; | 474 break; |
| 458 case SAVE_LAYER_SAVEFLAGS_DEPRECATED: { | 475 case SAVE_LAYER_SAVEFLAGS_DEPRECATED: { |
| 459 const SkRect* boundsPtr = get_rect_ptr(reader); | 476 const SkRect* boundsPtr = get_rect_ptr(reader); |
| 460 const SkPaint* paint = fPictureData->getPaint(reader); | 477 const SkPaint* paint = fPictureData->getPaint(reader); |
| 461 const SkCanvas::SaveFlags flags = (SkCanvas::SaveFlags)reader->readI nt(); | 478 auto flags = SkCanvas::LegacySaveFlagsToSaveLayerFlags(reader->readI nt()); |
| 462 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, | 479 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, flags)); |
| 463 SkCanvas::SaveFlagsToSaveLayerFlags(f lags))); | |
| 464 } break; | 480 } break; |
| 465 case SAVE_LAYER_SAVELAYERFLAGS: { | 481 case SAVE_LAYER_SAVELAYERFLAGS: { |
| 466 const SkRect* boundsPtr = get_rect_ptr(reader); | 482 const SkRect* boundsPtr = get_rect_ptr(reader); |
| 467 const SkPaint* paint = fPictureData->getPaint(reader); | 483 const SkPaint* paint = fPictureData->getPaint(reader); |
| 468 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, reader->r eadInt())); | 484 canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, reader->r eadInt())); |
| 469 } break; | 485 } break; |
| 470 case SCALE: { | 486 case SCALE: { |
| 471 SkScalar sx = reader->readScalar(); | 487 SkScalar sx = reader->readScalar(); |
| 472 SkScalar sy = reader->readScalar(); | 488 SkScalar sy = reader->readScalar(); |
| 473 canvas->scale(sx, sy); | 489 canvas->scale(sx, sy); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 486 case TRANSLATE: { | 502 case TRANSLATE: { |
| 487 SkScalar dx = reader->readScalar(); | 503 SkScalar dx = reader->readScalar(); |
| 488 SkScalar dy = reader->readScalar(); | 504 SkScalar dy = reader->readScalar(); |
| 489 canvas->translate(dx, dy); | 505 canvas->translate(dx, dy); |
| 490 } break; | 506 } break; |
| 491 default: | 507 default: |
| 492 SkASSERTF(false, "Unknown draw type: %d", op); | 508 SkASSERTF(false, "Unknown draw type: %d", op); |
| 493 } | 509 } |
| 494 } | 510 } |
| 495 | 511 |
| OLD | NEW |