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

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

Issue 154083004: SkPictureRecord: silently do nothing for non-drawable SkBitmaps. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: really, last rebase Created 6 years, 10 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/SkCanvas.cpp ('k') | tests/PictureTest.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 "SkTSearch.h" 9 #include "SkTSearch.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 // op + paint index + path index 942 // op + paint index + path index
943 uint32_t size = 3 * kUInt32Size; 943 uint32_t size = 3 * kUInt32Size;
944 size_t initialOffset = this->addDraw(DRAW_PATH, &size); 944 size_t initialOffset = this->addDraw(DRAW_PATH, &size);
945 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt en()); 945 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt en());
946 this->addPaint(paint); 946 this->addPaint(paint);
947 this->addPath(path); 947 this->addPath(path);
948 this->validate(initialOffset, size); 948 this->validate(initialOffset, size);
949 } 949 }
950 950
951 void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 951 void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
952 const SkPaint* paint = NULL) { 952 const SkPaint* paint = NULL) {
953 if (bitmap.drawsNothing()) {
954 return;
955 }
953 // op + paint index + bitmap index + left + top 956 // op + paint index + bitmap index + left + top
954 uint32_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); 957 uint32_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
955 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size); 958 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size);
956 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWri tten()); 959 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWri tten());
957 this->addPaintPtr(paint); 960 this->addPaintPtr(paint);
958 this->addBitmap(bitmap); 961 this->addBitmap(bitmap);
959 this->addScalar(left); 962 this->addScalar(left);
960 this->addScalar(top); 963 this->addScalar(top);
961 this->validate(initialOffset, size); 964 this->validate(initialOffset, size);
962 } 965 }
963 966
964 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 967 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
965 const SkRect& dst, const SkPaint* pai nt, 968 const SkRect& dst, const SkPaint* pai nt,
966 DrawBitmapRectFlags flags) { 969 DrawBitmapRectFlags flags) {
970 if (bitmap.drawsNothing()) {
971 return;
972 }
967 // id + paint index + bitmap index + bool for 'src' + flags 973 // id + paint index + bitmap index + bool for 'src' + flags
968 uint32_t size = 5 * kUInt32Size; 974 uint32_t size = 5 * kUInt32Size;
969 if (NULL != src) { 975 if (NULL != src) {
970 size += sizeof(*src); // + rect 976 size += sizeof(*src); // + rect
971 } 977 }
972 size += sizeof(dst); // + rect 978 size += sizeof(dst); // + rect
973 979
974 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); 980 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size);
975 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size) == fWr iter.bytesWritten()); 981 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size)
982 == fWriter.bytesWritten());
976 this->addPaintPtr(paint); 983 this->addPaintPtr(paint);
977 this->addBitmap(bitmap); 984 this->addBitmap(bitmap);
978 this->addRectPtr(src); // may be null 985 this->addRectPtr(src); // may be null
979 this->addRect(dst); 986 this->addRect(dst);
980 this->addInt(flags); 987 this->addInt(flags);
981 this->validate(initialOffset, size); 988 this->validate(initialOffset, size);
982 } 989 }
983 990
984 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m atrix, 991 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m atrix,
985 const SkPaint* paint) { 992 const SkPaint* paint) {
993 if (bitmap.drawsNothing()) {
994 return;
995 }
986 // id + paint index + bitmap index + matrix 996 // id + paint index + bitmap index + matrix
987 uint32_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL); 997 uint32_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL);
988 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); 998 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size);
989 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.b ytesWritten()); 999 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.b ytesWritten());
990 this->addPaintPtr(paint); 1000 this->addPaintPtr(paint);
991 this->addBitmap(bitmap); 1001 this->addBitmap(bitmap);
992 this->addMatrix(matrix); 1002 this->addMatrix(matrix);
993 this->validate(initialOffset, size); 1003 this->validate(initialOffset, size);
994 } 1004 }
995 1005
996 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent er, 1006 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent er,
997 const SkRect& dst, const SkPaint* paint) { 1007 const SkRect& dst, const SkPaint* paint) {
1008 if (bitmap.drawsNothing()) {
1009 return;
1010 }
998 // op + paint index + bitmap id + center + dst rect 1011 // op + paint index + bitmap id + center + dst rect
999 uint32_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); 1012 uint32_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst);
1000 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); 1013 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size);
1001 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.byt esWritten()); 1014 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.byt esWritten());
1002 this->addPaintPtr(paint); 1015 this->addPaintPtr(paint);
1003 this->addBitmap(bitmap); 1016 this->addBitmap(bitmap);
1004 this->addIRect(center); 1017 this->addIRect(center);
1005 this->addRect(dst); 1018 this->addRect(dst);
1006 this->validate(initialOffset, size); 1019 this->validate(initialOffset, size);
1007 } 1020 }
1008 1021
1009 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top, 1022 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
1010 const SkPaint* paint = NULL) { 1023 const SkPaint* paint = NULL) {
1024 if (bitmap.drawsNothing()) {
1025 return;
1026 }
1011 // op + paint index + bitmap index + left + top 1027 // op + paint index + bitmap index + left + top
1012 uint32_t size = 5 * kUInt32Size; 1028 uint32_t size = 5 * kUInt32Size;
1013 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); 1029 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size);
1014 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWri tten()); 1030 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWri tten());
1015 this->addPaintPtr(paint); 1031 this->addPaintPtr(paint);
1016 this->addBitmap(bitmap); 1032 this->addBitmap(bitmap);
1017 this->addInt(left); 1033 this->addInt(left);
1018 this->addInt(top); 1034 this->addInt(top);
1019 this->validate(initialOffset, size); 1035 this->validate(initialOffset, size);
1020 } 1036 }
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 void SkPictureRecord::validateRegions() const { 1579 void SkPictureRecord::validateRegions() const {
1564 int count = fRegions.count(); 1580 int count = fRegions.count();
1565 SkASSERT((unsigned) count < 0x1000); 1581 SkASSERT((unsigned) count < 0x1000);
1566 for (int index = 0; index < count; index++) { 1582 for (int index = 0; index < count; index++) {
1567 const SkFlatData* region = fRegions[index]; 1583 const SkFlatData* region = fRegions[index];
1568 SkASSERT(region); 1584 SkASSERT(region);
1569 // region->validate(); 1585 // region->validate();
1570 } 1586 }
1571 } 1587 }
1572 #endif 1588 #endif
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698