Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: src/core/SkPictureRecord.cpp

Issue 2146073003: Creating framework for drawShadowedPicture (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Made changes to better hide changes from public Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_USE_SHADOWS
222 this->validate(fWriter.bytesWritten(), 0); 223 this->validate(fWriter.bytesWritten(), 0);
223 // op + scalar 224 // op + scalar
224 size_t size = 1 * kUInt32Size + 1 * sizeof(SkScalar); 225 size_t size = 1 * kUInt32Size + 1 * sizeof(SkScalar);
225 size_t initialOffset = this->addDraw(TRANSLATE_Z, &size); 226 size_t initialOffset = this->addDraw(TRANSLATE_Z, &size);
226 this->addScalar(z); 227 this->addScalar(z);
227 this->validate(initialOffset, size); 228 this->validate(initialOffset, size);
228 this->INHERITED::didTranslateZ(z); 229 this->INHERITED::didTranslateZ(z);
230 #endif
229 } 231 }
230 232
231 static bool regionOpExpands(SkRegion::Op op) { 233 static bool regionOpExpands(SkRegion::Op op) {
232 switch (op) { 234 switch (op) {
233 case SkRegion::kUnion_Op: 235 case SkRegion::kUnion_Op:
234 case SkRegion::kXOR_Op: 236 case SkRegion::kXOR_Op:
235 case SkRegion::kReverseDifference_Op: 237 case SkRegion::kReverseDifference_Op:
236 case SkRegion::kReplace_Op: 238 case SkRegion::kReplace_Op:
237 return true; 239 return true;
238 case SkRegion::kIntersect_Op: 240 case SkRegion::kIntersect_Op:
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); 667 const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
666 size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint 668 size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint
667 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); 669 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size);
668 this->addPaintPtr(paint); 670 this->addPaintPtr(paint);
669 this->addMatrix(m); 671 this->addMatrix(m);
670 this->addPicture(picture); 672 this->addPicture(picture);
671 } 673 }
672 this->validate(initialOffset, size); 674 this->validate(initialOffset, size);
673 } 675 }
674 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
684 if (nullptr == matrix && nullptr == paint) {
685 initialOffset = this->addDraw(DRAW_PICTURE, &size);
686 this->addPicture(picture);
687 } else {
688 const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
689 size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint
690 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size);
691 this->addPaintPtr(paint);
692 this->addMatrix(m);
693 this->addPicture(picture);
694 }
695 this->validate(initialOffset, size);
696 }
697
675 void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matri x) { 698 void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matri x) {
676 // op + drawable index 699 // op + drawable index
677 size_t size = 2 * kUInt32Size; 700 size_t size = 2 * kUInt32Size;
678 size_t initialOffset; 701 size_t initialOffset;
679 702
680 if (nullptr == matrix) { 703 if (nullptr == matrix) {
681 initialOffset = this->addDraw(DRAW_DRAWABLE, &size); 704 initialOffset = this->addDraw(DRAW_DRAWABLE, &size);
682 this->addDrawable(drawable); 705 this->addDrawable(drawable);
683 } else { 706 } else {
684 size += matrix->writeToMemory(nullptr); // matrix 707 size += matrix->writeToMemory(nullptr); // matrix
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1053
1031 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 1054 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
1032 int index = fTextBlobRefs.count(); 1055 int index = fTextBlobRefs.count();
1033 *fTextBlobRefs.append() = blob; 1056 *fTextBlobRefs.append() = blob;
1034 blob->ref(); 1057 blob->ref();
1035 // follow the convention of recording a 1-based index 1058 // follow the convention of recording a 1-based index
1036 this->addInt(index + 1); 1059 this->addInt(index + 1);
1037 } 1060 }
1038 1061
1039 /////////////////////////////////////////////////////////////////////////////// 1062 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698