| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
| 9 #include "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
| 10 #include "SkPatchUtils.h" | 10 #include "SkPatchUtils.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 this->validate(fWriter.bytesWritten(), 0); | 212 this->validate(fWriter.bytesWritten(), 0); |
| 213 // op + matrix | 213 // op + matrix |
| 214 size_t size = kUInt32Size + matrix.writeToMemory(nullptr); | 214 size_t size = kUInt32Size + matrix.writeToMemory(nullptr); |
| 215 size_t initialOffset = this->addDraw(SET_MATRIX, &size); | 215 size_t initialOffset = this->addDraw(SET_MATRIX, &size); |
| 216 this->addMatrix(matrix); | 216 this->addMatrix(matrix); |
| 217 this->validate(initialOffset, size); | 217 this->validate(initialOffset, size); |
| 218 this->INHERITED::didSetMatrix(matrix); | 218 this->INHERITED::didSetMatrix(matrix); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void SkPictureRecord::didTranslateZ(SkScalar z) { | 221 void SkPictureRecord::didTranslateZ(SkScalar z) { |
| 222 #ifdef SK_EXPERIMENTAL_SHADOWING | |
| 223 this->validate(fWriter.bytesWritten(), 0); | 222 this->validate(fWriter.bytesWritten(), 0); |
| 224 // op + scalar | 223 // op + scalar |
| 225 size_t size = 1 * kUInt32Size + 1 * sizeof(SkScalar); | 224 size_t size = 1 * kUInt32Size + 1 * sizeof(SkScalar); |
| 226 size_t initialOffset = this->addDraw(TRANSLATE_Z, &size); | 225 size_t initialOffset = this->addDraw(TRANSLATE_Z, &size); |
| 227 this->addScalar(z); | 226 this->addScalar(z); |
| 228 this->validate(initialOffset, size); | 227 this->validate(initialOffset, size); |
| 229 this->INHERITED::didTranslateZ(z); | 228 this->INHERITED::didTranslateZ(z); |
| 230 #endif | |
| 231 } | 229 } |
| 232 | 230 |
| 233 static bool regionOpExpands(SkRegion::Op op) { | 231 static bool regionOpExpands(SkRegion::Op op) { |
| 234 switch (op) { | 232 switch (op) { |
| 235 case SkRegion::kUnion_Op: | 233 case SkRegion::kUnion_Op: |
| 236 case SkRegion::kXOR_Op: | 234 case SkRegion::kXOR_Op: |
| 237 case SkRegion::kReverseDifference_Op: | 235 case SkRegion::kReverseDifference_Op: |
| 238 case SkRegion::kReplace_Op: | 236 case SkRegion::kReplace_Op: |
| 239 return true; | 237 return true; |
| 240 case SkRegion::kIntersect_Op: | 238 case SkRegion::kIntersect_Op: |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 this->addScalar(y); | 650 this->addScalar(y); |
| 653 | 651 |
| 654 this->validate(initialOffset, size); | 652 this->validate(initialOffset, size); |
| 655 } | 653 } |
| 656 | 654 |
| 657 void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma
trix, | 655 void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma
trix, |
| 658 const SkPaint* paint) { | 656 const SkPaint* paint) { |
| 659 // op + picture index | 657 // op + picture index |
| 660 size_t size = 2 * kUInt32Size; | 658 size_t size = 2 * kUInt32Size; |
| 661 size_t initialOffset; | 659 size_t initialOffset; |
| 662 | |
| 663 if (nullptr == matrix && nullptr == paint) { | |
| 664 initialOffset = this->addDraw(DRAW_PICTURE, &size); | |
| 665 this->addPicture(picture); | |
| 666 } else { | |
| 667 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); | |
| 668 size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint | |
| 669 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); | |
| 670 this->addPaintPtr(paint); | |
| 671 this->addMatrix(m); | |
| 672 this->addPicture(picture); | |
| 673 } | |
| 674 this->validate(initialOffset, size); | |
| 675 } | |
| 676 | |
| 677 void SkPictureRecord::onDrawShadowedPicture(const SkPicture* picture, | |
| 678 const SkMatrix* matrix, | |
| 679 const SkPaint* paint) { | |
| 680 // op + picture index | |
| 681 size_t size = 2 * kUInt32Size; | |
| 682 size_t initialOffset; | |
| 683 | 660 |
| 684 if (nullptr == matrix && nullptr == paint) { | 661 if (nullptr == matrix && nullptr == paint) { |
| 685 initialOffset = this->addDraw(DRAW_PICTURE, &size); | 662 initialOffset = this->addDraw(DRAW_PICTURE, &size); |
| 686 this->addPicture(picture); | 663 this->addPicture(picture); |
| 687 } else { | 664 } else { |
| 688 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); | 665 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
| 689 size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint | 666 size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint |
| 690 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); | 667 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); |
| 691 this->addPaintPtr(paint); | 668 this->addPaintPtr(paint); |
| 692 this->addMatrix(m); | 669 this->addMatrix(m); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 | 1030 |
| 1054 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { | 1031 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { |
| 1055 int index = fTextBlobRefs.count(); | 1032 int index = fTextBlobRefs.count(); |
| 1056 *fTextBlobRefs.append() = blob; | 1033 *fTextBlobRefs.append() = blob; |
| 1057 blob->ref(); | 1034 blob->ref(); |
| 1058 // follow the convention of recording a 1-based index | 1035 // follow the convention of recording a 1-based index |
| 1059 this->addInt(index + 1); | 1036 this->addInt(index + 1); |
| 1060 } | 1037 } |
| 1061 | 1038 |
| 1062 /////////////////////////////////////////////////////////////////////////////// | 1039 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |