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

Unified Diff: src/core/SkPictureRecord.cpp

Issue 1557123002: remove now defunct get_paint_offset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecord.cpp
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 36b8d379f536b637feea9d825ad5ddfd0a08c28d..7907ee0d2935f22b30ceca2be899d0b1b5a506e6 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -25,12 +25,6 @@ enum {
// A lot of basic types get stored as a uint32_t: bools, ints, paint indices, etc.
static int const kUInt32Size = 4;
-static const uint32_t kSaveSize = kUInt32Size;
-#ifdef SK_DEBUG
-static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size;
-static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect);
-#endif//SK_DEBUG
-
SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags)
: INHERITED(dimensions.width(), dimensions.height())
, fRecordFlags(flags)
@@ -45,95 +39,6 @@ SkPictureRecord::~SkPictureRecord() {
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_DEBUG
-// Return the offset of the paint inside a given op's byte stream. A zero
-// return value means there is no paint (and you really shouldn't be calling
-// this method)
-static inline size_t get_paint_offset(DrawType op, size_t opSize) {
- // These offsets are where the paint would be if the op size doesn't overflow
- static const uint8_t gPaintOffsets[] = {
- 0, // UNUSED - no paint
- 0, // CLIP_PATH - no paint
- 0, // CLIP_REGION - no paint
- 0, // CLIP_RECT - no paint
- 0, // CLIP_RRECT - no paint
- 0, // CONCAT - no paint
- 1, // DRAW_BITMAP - right after op code
- 1, // DRAW_BITMAP_MATRIX - right after op code, deprecated
- 1, // DRAW_BITMAP_NINE - right after op code
- 1, // DRAW_BITMAP_RECT - right after op code
- 0, // DRAW_CLEAR - no paint
- 0, // DRAW_DATA - no paint
- 1, // DRAW_OVAL - right after op code
- 1, // DRAW_PAINT - right after op code
- 1, // DRAW_PATH - right after op code
- 0, // DRAW_PICTURE - no paint
- 1, // DRAW_POINTS - right after op code
- 1, // DRAW_POS_TEXT - right after op code
- 1, // DRAW_POS_TEXT_TOP_BOTTOM - right after op code
- 1, // DRAW_POS_TEXT_H - right after op code
- 1, // DRAW_POS_TEXT_H_TOP_BOTTOM - right after op code
- 1, // DRAW_RECT - right after op code
- 1, // DRAW_RRECT - right after op code
- 1, // DRAW_SPRITE - right after op code
- 1, // DRAW_TEXT - right after op code
- 1, // DRAW_TEXT_ON_PATH - right after op code
- 1, // DRAW_TEXT_TOP_BOTTOM - right after op code
- 1, // DRAW_VERTICES - right after op code
- 0, // RESTORE - no paint
- 0, // ROTATE - no paint
- 0, // SAVE - no paint
- 0, // SAVE_LAYER_SAVEFLAGS_DEPRECATED - see below - this paint's location varies
- 0, // SCALE - no paint
- 0, // SET_MATRIX - no paint
- 0, // SKEW - no paint
- 0, // TRANSLATE - no paint
- 0, // NOOP - no paint
- 0, // BEGIN_GROUP - no paint
- 0, // COMMENT - no paint
- 0, // END_GROUP - no paint
- 1, // DRAWDRRECT - right after op code
- 0, // PUSH_CULL - no paint
- 0, // POP_CULL - no paint
- 1, // DRAW_PATCH - right after op code
- 1, // DRAW_PICTURE_MATRIX_PAINT - right after op code
- 1, // DRAW_TEXT_BLOB- right after op code
- 1, // DRAW_IMAGE - right after op code
- 1, // DRAW_IMAGE_RECT_STRICT - right after op code
- 1, // DRAW_ATLAS - right after op code
- 1, // DRAW_IMAGE_NINE - right after op code
- 1, // DRAW_IMAGE_RECT - right after op code
- 0, // SAVE_LAYER_SAVELAYERFLAGS - see below - this paint's location varies
- };
-
- static_assert(sizeof(gPaintOffsets) == LAST_DRAWTYPE_ENUM + 1, "need_to_be_in_sync");
- SkASSERT((unsigned)op <= (unsigned)LAST_DRAWTYPE_ENUM);
-
- int overflow = 0;
- if (0 != (opSize & ~MASK_24) || opSize == MASK_24) {
- // This op's size overflows so an extra uint32_t will be written
- // after the op code
- overflow = sizeof(uint32_t);
- }
-
- SkASSERT(SAVE_LAYER_SAVEFLAGS_DEPRECATED != op);
- if (SAVE_LAYER_SAVELAYERFLAGS == op) {
- static const uint32_t kSaveLayerNoBoundsPaintOffset = 2 * kUInt32Size;
- static const uint32_t kSaveLayerWithBoundsPaintOffset = 2 * kUInt32Size + sizeof(SkRect);
-
- if (kSaveLayerNoBoundsSize == opSize) {
- return kSaveLayerNoBoundsPaintOffset + overflow;
- } else {
- SkASSERT(kSaveLayerWithBoundsSize == opSize);
- return kSaveLayerWithBoundsPaintOffset + overflow;
- }
- }
-
- SkASSERT(0 != gPaintOffsets[op]); // really shouldn't be calling this method
- return gPaintOffsets[op] * sizeof(uint32_t) + overflow;
-}
-#endif//SK_DEBUG
-
void SkPictureRecord::willSave() {
// record the offset to us, making it non-positive to distinguish a save
// from a clip entry.
@@ -147,7 +52,7 @@ void SkPictureRecord::recordSave() {
fContentInfo.onSave();
// op only
- size_t size = kSaveSize;
+ size_t size = sizeof(kUInt32Size);
size_t initialOffset = this->addDraw(SAVE, &size);
this->validate(initialOffset, size);
@@ -179,11 +84,8 @@ void SkPictureRecord::recordSaveLayer(const SaveLayerRec& rec) {
// + paint index + flags
size += 2 * kUInt32Size;
- SkASSERT(kSaveLayerNoBoundsSize == size || kSaveLayerWithBoundsSize == size);
-
size_t initialOffset = this->addDraw(SAVE_LAYER_SAVELAYERFLAGS, &size);
this->addRectPtr(rec.fBounds);
- SkASSERT(initialOffset+get_paint_offset(SAVE_LAYER_SAVELAYERFLAGS, size) == fWriter.bytesWritten());
this->addPaintPtr(rec.fPaint);
this->addInt(rec.fSaveLayerFlags);
@@ -460,7 +362,6 @@ void SkPictureRecord::onDrawPaint(const SkPaint& paint) {
// op + paint index
size_t size = 2 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_PAINT, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_PAINT, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->validate(initialOffset, size);
}
@@ -472,7 +373,6 @@ void SkPictureRecord::onDrawPoints(PointMode mode, size_t count, const SkPoint p
// op + paint index + mode + count + point data
size_t size = 4 * kUInt32Size + count * sizeof(SkPoint);
size_t initialOffset = this->addDraw(DRAW_POINTS, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_POINTS, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addInt(mode);
@@ -485,7 +385,6 @@ void SkPictureRecord::onDrawOval(const SkRect& oval, const SkPaint& paint) {
// op + paint index + rect
size_t size = 2 * kUInt32Size + sizeof(oval);
size_t initialOffset = this->addDraw(DRAW_OVAL, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_OVAL, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addRect(oval);
this->validate(initialOffset, size);
@@ -495,7 +394,6 @@ void SkPictureRecord::onDrawRect(const SkRect& rect, const SkPaint& paint) {
// op + paint index + rect
size_t size = 2 * kUInt32Size + sizeof(rect);
size_t initialOffset = this->addDraw(DRAW_RECT, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_RECT, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addRect(rect);
this->validate(initialOffset, size);
@@ -505,7 +403,6 @@ void SkPictureRecord::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
// op + paint index + rrect
size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory;
size_t initialOffset = this->addDraw(DRAW_RRECT, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_RRECT, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addRRect(rrect);
this->validate(initialOffset, size);
@@ -516,7 +413,6 @@ void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
// op + paint index + rrects
size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2;
size_t initialOffset = this->addDraw(DRAW_DRRECT, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_DRRECT, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addRRect(outer);
this->addRRect(inner);
@@ -529,7 +425,6 @@ void SkPictureRecord::onDrawPath(const SkPath& path, const SkPaint& paint) {
// op + paint index + path index
size_t size = 3 * kUInt32Size;
size_t initialOffset = this->addDraw(DRAW_PATH, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_PATH, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addPath(path);
this->validate(initialOffset, size);
@@ -540,7 +435,6 @@ void SkPictureRecord::onDrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScal
// op + paint index + bitmap index + left + top
size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(DRAW_BITMAP, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addBitmap(bitmap);
this->addScalar(left);
@@ -558,7 +452,6 @@ void SkPictureRecord::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src
size += sizeof(dst); // + rect
size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addBitmap(bitmap);
this->addRectPtr(src); // may be null
@@ -572,7 +465,6 @@ void SkPictureRecord::onDrawImage(const SkImage* image, SkScalar x, SkScalar y,
// op + paint_index + image_index + x + y
size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(DRAW_IMAGE, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addImage(image);
this->addScalar(x);
@@ -590,8 +482,6 @@ void SkPictureRecord::onDrawImageRect(const SkImage* image, const SkRect* src, c
size += sizeof(dst); // + rect
size_t initialOffset = this->addDraw(DRAW_IMAGE_RECT, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_RECT, size)
- == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addImage(image);
this->addRectPtr(src); // may be null
@@ -606,7 +496,6 @@ void SkPictureRecord::onDrawImageNine(const SkImage* img, const SkIRect& center,
size_t size = 3 * kUInt32Size + sizeof(SkIRect) + sizeof(SkRect);
size_t initialOffset = this->addDraw(DRAW_IMAGE_NINE, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_IMAGE_NINE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addImage(img);
this->addIRect(center);
@@ -619,7 +508,6 @@ void SkPictureRecord::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& ce
// op + paint index + bitmap id + center + dst rect
size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst);
size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addBitmap(bitmap);
this->addIRect(center);
@@ -634,7 +522,6 @@ void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
DrawType op = DRAW_TEXT;
size_t initialOffset = this->addDraw(op, &size);
- SkASSERT(initialOffset+get_paint_offset(op, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addText(text, byteLength);
this->addScalar(x);
@@ -652,7 +539,6 @@ void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const S
DrawType op = DRAW_POS_TEXT;
size_t initialOffset = this->addDraw(op, &size);
- SkASSERT(initialOffset+get_paint_offset(op, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addText(text, byteLength);
this->addInt(points);
@@ -684,7 +570,6 @@ void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons
const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.writeToMemory(nullptr);
size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_TEXT_ON_PATH, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addText(text, byteLength);
this->addPath(path);
@@ -698,7 +583,6 @@ void SkPictureRecord::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala
// op + paint index + blob index + x/y
size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
size_t initialOffset = this->addDraw(DRAW_TEXT_BLOB, &size);
- SkASSERT(initialOffset + get_paint_offset(DRAW_TEXT_BLOB, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addTextBlob(blob);
@@ -721,8 +605,6 @@ void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma
const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
size += m.writeToMemory(nullptr) + kUInt32Size; // matrix + paint
initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size);
- SkASSERT(initialOffset + get_paint_offset(DRAW_PICTURE_MATRIX_PAINT, size)
- == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addMatrix(m);
this->addPicture(picture);
@@ -769,7 +651,6 @@ void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount,
}
size_t initialOffset = this->addDraw(DRAW_VERTICES, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_VERTICES, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addInt(flags);
this->addInt(vmode);
@@ -816,7 +697,6 @@ void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors
}
size_t initialOffset = this->addDraw(DRAW_PATCH, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_PATCH, size) == fWriter.bytesWritten());
this->addPaint(paint);
this->addPatch(cubics);
this->addInt(flag);
@@ -853,7 +733,6 @@ void SkPictureRecord::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[],
}
size_t initialOffset = this->addDraw(DRAW_ATLAS, &size);
- SkASSERT(initialOffset+get_paint_offset(DRAW_ATLAS, size) == fWriter.bytesWritten());
this->addPaintPtr(paint);
this->addImage(atlas);
this->addInt(flags);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698