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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkImage_Base.h" 10 #include "SkImage_Base.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 default: 268 default:
269 this->recordConcat(matrix); 269 this->recordConcat(matrix);
270 break; 270 break;
271 } 271 }
272 this->INHERITED::didConcat(matrix); 272 this->INHERITED::didConcat(matrix);
273 } 273 }
274 274
275 void SkPictureRecord::recordConcat(const SkMatrix& matrix) { 275 void SkPictureRecord::recordConcat(const SkMatrix& matrix) {
276 this->validate(fWriter.bytesWritten(), 0); 276 this->validate(fWriter.bytesWritten(), 0);
277 // op + matrix 277 // op + matrix
278 size_t size = kUInt32Size + matrix.writeToMemory(NULL); 278 size_t size = kUInt32Size + matrix.writeToMemory(nullptr);
279 size_t initialOffset = this->addDraw(CONCAT, &size); 279 size_t initialOffset = this->addDraw(CONCAT, &size);
280 this->addMatrix(matrix); 280 this->addMatrix(matrix);
281 this->validate(initialOffset, size); 281 this->validate(initialOffset, size);
282 } 282 }
283 283
284 void SkPictureRecord::didSetMatrix(const SkMatrix& matrix) { 284 void SkPictureRecord::didSetMatrix(const SkMatrix& matrix) {
285 this->validate(fWriter.bytesWritten(), 0); 285 this->validate(fWriter.bytesWritten(), 0);
286 // op + matrix 286 // op + matrix
287 size_t size = kUInt32Size + matrix.writeToMemory(NULL); 287 size_t size = kUInt32Size + matrix.writeToMemory(nullptr);
288 size_t initialOffset = this->addDraw(SET_MATRIX, &size); 288 size_t initialOffset = this->addDraw(SET_MATRIX, &size);
289 this->addMatrix(matrix); 289 this->addMatrix(matrix);
290 this->validate(initialOffset, size); 290 this->validate(initialOffset, size);
291 this->INHERITED::didSetMatrix(matrix); 291 this->INHERITED::didSetMatrix(matrix);
292 } 292 }
293 293
294 static bool regionOpExpands(SkRegion::Op op) { 294 static bool regionOpExpands(SkRegion::Op op) {
295 switch (op) { 295 switch (op) {
296 case SkRegion::kUnion_Op: 296 case SkRegion::kUnion_Op:
297 case SkRegion::kXOR_Op: 297 case SkRegion::kXOR_Op:
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 return offset; 433 return offset;
434 } 434 }
435 435
436 void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) { 436 void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) {
437 this->recordClipRegion(region, op); 437 this->recordClipRegion(region, op);
438 this->INHERITED::onClipRegion(region, op); 438 this->INHERITED::onClipRegion(region, op);
439 } 439 }
440 440
441 size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op ) { 441 size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op ) {
442 // op + clip params + region 442 // op + clip params + region
443 size_t size = 2 * kUInt32Size + region.writeToMemory(NULL); 443 size_t size = 2 * kUInt32Size + region.writeToMemory(nullptr);
444 // recordRestoreOffsetPlaceholder doesn't always write an offset 444 // recordRestoreOffsetPlaceholder doesn't always write an offset
445 if (!fRestoreOffsetStack.isEmpty()) { 445 if (!fRestoreOffsetStack.isEmpty()) {
446 // + restore offset 446 // + restore offset
447 size += kUInt32Size; 447 size += kUInt32Size;
448 } 448 }
449 size_t initialOffset = this->addDraw(CLIP_REGION, &size); 449 size_t initialOffset = this->addDraw(CLIP_REGION, &size);
450 this->addRegion(region); 450 this->addRegion(region);
451 this->addInt(ClipParams_pack(op, false)); 451 this->addInt(ClipParams_pack(op, false));
452 size_t offset = this->recordRestoreOffsetPlaceholder(op); 452 size_t offset = this->recordRestoreOffsetPlaceholder(op);
453 453
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 this->addInt(points); 687 this->addInt(points);
688 this->addScalar(constY); 688 this->addScalar(constY);
689 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); 689 fWriter.writeMul4(xpos, points * sizeof(SkScalar));
690 this->validate(initialOffset, size); 690 this->validate(initialOffset, size);
691 } 691 }
692 692
693 void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons t SkPath& path, 693 void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons t SkPath& path,
694 const SkMatrix* matrix, const SkPaint& pa int) { 694 const SkMatrix* matrix, const SkPaint& pa int) {
695 // op + paint index + length + 'length' worth of data + path index + matrix 695 // op + paint index + length + 'length' worth of data + path index + matrix
696 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); 696 const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
697 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write ToMemory(NULL); 697 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write ToMemory(nullptr);
698 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); 698 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size);
699 SkASSERT(initialOffset+get_paint_offset(DRAW_TEXT_ON_PATH, size) == fWriter. bytesWritten()); 699 SkASSERT(initialOffset+get_paint_offset(DRAW_TEXT_ON_PATH, size) == fWriter. bytesWritten());
700 this->addPaint(paint); 700 this->addPaint(paint);
701 this->addText(text, byteLength); 701 this->addText(text, byteLength);
702 this->addPath(path); 702 this->addPath(path);
703 this->addMatrix(m); 703 this->addMatrix(m);
704 this->validate(initialOffset, size); 704 this->validate(initialOffset, size);
705 } 705 }
706 706
707 void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala r y, 707 void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala r y,
(...skipping 11 matching lines...) Expand all
719 719
720 this->validate(initialOffset, size); 720 this->validate(initialOffset, size);
721 } 721 }
722 722
723 void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma trix, 723 void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma trix,
724 const SkPaint* paint) { 724 const SkPaint* paint) {
725 // op + picture index 725 // op + picture index
726 size_t size = 2 * kUInt32Size; 726 size_t size = 2 * kUInt32Size;
727 size_t initialOffset; 727 size_t initialOffset;
728 728
729 if (NULL == matrix && NULL == paint) { 729 if (nullptr == matrix && nullptr == paint) {
730 initialOffset = this->addDraw(DRAW_PICTURE, &size); 730 initialOffset = this->addDraw(DRAW_PICTURE, &size);
731 this->addPicture(picture); 731 this->addPicture(picture);
732 } else { 732 } else {
733 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); 733 const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
734 size += m.writeToMemory(NULL) + kUInt32Size; // matrix + paint 734 size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint
735 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); 735 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size);
736 SkASSERT(initialOffset + get_paint_offset(DRAW_PICTURE_MATRIX_PAINT, siz e) 736 SkASSERT(initialOffset + get_paint_offset(DRAW_PICTURE_MATRIX_PAINT, siz e)
737 == fWriter.bytesWritten()); 737 == fWriter.bytesWritten());
738 this->addPaintPtr(paint); 738 this->addPaintPtr(paint);
739 this->addMatrix(m); 739 this->addMatrix(m);
740 this->addPicture(picture); 740 this->addPicture(picture);
741 } 741 }
742 this->validate(initialOffset, size); 742 this->validate(initialOffset, size);
743 } 743 }
744 744
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 880 }
881 if (cull) { 881 if (cull) {
882 fWriter.write(cull, sizeof(SkRect)); 882 fWriter.write(cull, sizeof(SkRect));
883 } 883 }
884 this->validate(initialOffset, size); 884 this->validate(initialOffset, size);
885 } 885 }
886 886
887 /////////////////////////////////////////////////////////////////////////////// 887 ///////////////////////////////////////////////////////////////////////////////
888 888
889 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac eProps&) { 889 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfac eProps&) {
890 return NULL; 890 return nullptr;
891 } 891 }
892 892
893 // If we already have a stored, can we reuse it instead of also storing b? 893 // If we already have a stored, can we reuse it instead of also storing b?
894 static bool equivalent(const SkBitmap& a, const SkBitmap& b) { 894 static bool equivalent(const SkBitmap& a, const SkBitmap& b) {
895 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) { 895 if (a.info() != b.info() || a.pixelRefOrigin() != b.pixelRefOrigin()) {
896 // Requiring a.info() == b.info() may be overkill in some cases (alphaty pe mismatch), 896 // Requiring a.info() == b.info() may be overkill in some cases (alphaty pe mismatch),
897 // but it sure makes things easier to reason about below. 897 // but it sure makes things easier to reason about below.
898 return false; 898 return false;
899 } 899 }
900 if (a.pixelRef() == b.pixelRef()) { 900 if (a.pixelRef() == b.pixelRef()) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 void SkPictureRecord::addNoOp() { 1021 void SkPictureRecord::addNoOp() {
1022 size_t size = kUInt32Size; // op 1022 size_t size = kUInt32Size; // op
1023 this->addDraw(NOOP, &size); 1023 this->addDraw(NOOP, &size);
1024 } 1024 }
1025 1025
1026 void SkPictureRecord::addRect(const SkRect& rect) { 1026 void SkPictureRecord::addRect(const SkRect& rect) {
1027 fWriter.writeRect(rect); 1027 fWriter.writeRect(rect);
1028 } 1028 }
1029 1029
1030 void SkPictureRecord::addRectPtr(const SkRect* rect) { 1030 void SkPictureRecord::addRectPtr(const SkRect* rect) {
1031 if (fWriter.writeBool(rect != NULL)) { 1031 if (fWriter.writeBool(rect != nullptr)) {
1032 fWriter.writeRect(*rect); 1032 fWriter.writeRect(*rect);
1033 } 1033 }
1034 } 1034 }
1035 1035
1036 void SkPictureRecord::addIRect(const SkIRect& rect) { 1036 void SkPictureRecord::addIRect(const SkIRect& rect) {
1037 fWriter.write(&rect, sizeof(rect)); 1037 fWriter.write(&rect, sizeof(rect));
1038 } 1038 }
1039 1039
1040 void SkPictureRecord::addIRectPtr(const SkIRect* rect) { 1040 void SkPictureRecord::addIRectPtr(const SkIRect* rect) {
1041 if (fWriter.writeBool(rect != NULL)) { 1041 if (fWriter.writeBool(rect != nullptr)) {
1042 *(SkIRect*)fWriter.reserve(sizeof(SkIRect)) = *rect; 1042 *(SkIRect*)fWriter.reserve(sizeof(SkIRect)) = *rect;
1043 } 1043 }
1044 } 1044 }
1045 1045
1046 void SkPictureRecord::addRRect(const SkRRect& rrect) { 1046 void SkPictureRecord::addRRect(const SkRRect& rrect) {
1047 fWriter.writeRRect(rrect); 1047 fWriter.writeRRect(rrect);
1048 } 1048 }
1049 1049
1050 void SkPictureRecord::addRegion(const SkRegion& region) { 1050 void SkPictureRecord::addRegion(const SkRegion& region) {
1051 fWriter.writeRegion(region); 1051 fWriter.writeRegion(region);
1052 } 1052 }
1053 1053
1054 void SkPictureRecord::addText(const void* text, size_t byteLength) { 1054 void SkPictureRecord::addText(const void* text, size_t byteLength) {
1055 fContentInfo.onDrawText(); 1055 fContentInfo.onDrawText();
1056 addInt(SkToInt(byteLength)); 1056 addInt(SkToInt(byteLength));
1057 fWriter.writePad(text, byteLength); 1057 fWriter.writePad(text, byteLength);
1058 } 1058 }
1059 1059
1060 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) { 1060 void SkPictureRecord::addTextBlob(const SkTextBlob *blob) {
1061 int index = fTextBlobRefs.count(); 1061 int index = fTextBlobRefs.count();
1062 *fTextBlobRefs.append() = blob; 1062 *fTextBlobRefs.append() = blob;
1063 blob->ref(); 1063 blob->ref();
1064 // follow the convention of recording a 1-based index 1064 // follow the convention of recording a 1-based index
1065 this->addInt(index + 1); 1065 this->addInt(index + 1);
1066 } 1066 }
1067 1067
1068 /////////////////////////////////////////////////////////////////////////////// 1068 ///////////////////////////////////////////////////////////////////////////////
1069 1069
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698