diff options
author | mtklein <mtklein@chromium.org> | 2014-10-01 09:29:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-01 09:29:35 -0700 |
commit | 8e12656096fceeed8b3cc4284d57dea04893b455 (patch) | |
tree | 43b0ae13764b93af263e01d89d269c7bfec84370 /src | |
parent | 23cd4d2d1adecff9c88fa06b7a0a74d52c11fc75 (diff) |
Remove DEPRECATED_beginRecording().
This removes:
1) ability to record old pictures with SkPictureRecorder;
2) a couple tests specific to the old backend.
The functionality of DEPRECATED_beginRecording() now lives in
(private) SkPicture::Backport(), which is the only place we
need it now.
BUG=skia:
TBR=reed@google.com
Review URL: https://codereview.chromium.org/618303002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPicture.cpp | 16 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 46 | ||||
-rw-r--r-- | src/core/SkPictureRecorder.cpp | 52 |
3 files changed, 36 insertions, 78 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index def67e6571..98c28e61af 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -264,12 +264,12 @@ SkPicture::SkPicture(SkScalar width, SkScalar height, // Create an SkPictureData-backed SkPicture from an SkRecord. // This for compatibility with serialization code only. This is not cheap. -static SkPicture* backport(const SkRecord& src, const SkRect& cullRect) { - SkPictureRecorder recorder; - SkRecordDraw(src, - recorder.DEPRECATED_beginRecording(cullRect.width(), cullRect.height()), - NULL/*bbh*/, NULL/*callback*/); - return recorder.endRecording(); +SkPicture* SkPicture::Backport(const SkRecord& src, const SkRect& cullRect) { + SkPictureRecord rec(SkISize::Make(cullRect.width(), cullRect.height()), 0/*flags*/); + rec.beginRecording(); + SkRecordDraw(src, &rec, NULL/*bbh*/, NULL/*callback*/); + rec.endRecording(); + return SkNEW_ARGS(SkPicture, (cullRect.width(), cullRect.height(), rec, false/*deepCopyOps*/)); } // fRecord OK @@ -510,7 +510,7 @@ void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const { // If we're a new-format picture, backport to old format for serialization. SkAutoTDelete<SkPicture> oldFormat; if (NULL == data && fRecord.get()) { - oldFormat.reset(backport(*fRecord, this->cullRect())); + oldFormat.reset(Backport(*fRecord, this->cullRect())); data = oldFormat->fData.get(); SkASSERT(data); } @@ -535,7 +535,7 @@ void SkPicture::flatten(SkWriteBuffer& buffer) const { // If we're a new-format picture, backport to old format for serialization. SkAutoTDelete<SkPicture> oldFormat; if (NULL == data && fRecord.get()) { - oldFormat.reset(backport(*fRecord, this->cullRect())); + oldFormat.reset(Backport(*fRecord, this->cullRect())); data = oldFormat->fData.get(); SkASSERT(data); } diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 16cb3b5a1b..40ecc6a51f 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -24,8 +24,10 @@ enum { 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()) @@ -49,10 +51,11 @@ 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 getPaintOffset(DrawType op, size_t opSize) { +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 @@ -129,6 +132,7 @@ static inline size_t getPaintOffset(DrawType op, size_t opSize) { 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 @@ -184,7 +188,7 @@ void SkPictureRecord::recordSaveLayer(const SkRect* bounds, const SkPaint* paint size_t initialOffset = this->addDraw(SAVE_LAYER, &size); this->addRectPtr(bounds); - SkASSERT(initialOffset+getPaintOffset(SAVE_LAYER, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(SAVE_LAYER, size) == fWriter.bytesWritten()); this->addPaintPtr(paint); this->addInt(flags); @@ -476,7 +480,7 @@ void SkPictureRecord::drawPaint(const SkPaint& paint) { // op + paint index size_t size = 2 * kUInt32Size; size_t initialOffset = this->addDraw(DRAW_PAINT, &size); - SkASSERT(initialOffset+getPaintOffset(DRAW_PAINT, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_PAINT, size) == fWriter.bytesWritten()); this->addPaint(paint); this->validate(initialOffset, size); } @@ -488,7 +492,7 @@ void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts // 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+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_POINTS, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addInt(mode); @@ -501,7 +505,7 @@ void SkPictureRecord::drawOval(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+getPaintOffset(DRAW_OVAL, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_OVAL, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addRect(oval); this->validate(initialOffset, size); @@ -511,7 +515,7 @@ void SkPictureRecord::drawRect(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+getPaintOffset(DRAW_RECT, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_RECT, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addRect(rect); this->validate(initialOffset, size); @@ -521,7 +525,7 @@ void SkPictureRecord::drawRRect(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+getPaintOffset(DRAW_RRECT, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_RRECT, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addRRect(rrect); this->validate(initialOffset, size); @@ -532,7 +536,7 @@ 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+getPaintOffset(DRAW_DRRECT, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_DRRECT, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addRRect(outer); this->addRRect(inner); @@ -545,7 +549,7 @@ void SkPictureRecord::drawPath(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+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_PATH, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addPath(path); this->validate(initialOffset, size); @@ -556,7 +560,7 @@ void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar // 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+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP, size) == fWriter.bytesWritten()); this->addPaintPtr(paint); this->addBitmap(bitmap); this->addScalar(left); @@ -575,7 +579,7 @@ void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* size += sizeof(dst); // + rect size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); - SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size) + SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_RECT_TO_RECT, size) == fWriter.bytesWritten()); this->addPaintPtr(paint); this->addBitmap(bitmap); @@ -590,7 +594,7 @@ void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m // id + paint index + bitmap index + matrix size_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL); size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); - SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_MATRIX, size) == fWriter.bytesWritten()); this->addPaintPtr(paint); this->addBitmap(bitmap); this->addMatrix(matrix); @@ -602,7 +606,7 @@ void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent // 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+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_BITMAP_NINE, size) == fWriter.bytesWritten()); this->addPaintPtr(paint); this->addBitmap(bitmap); this->addIRect(center); @@ -615,7 +619,7 @@ void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top, // op + paint index + bitmap index + left + top size_t size = 5 * kUInt32Size; size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); - SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_SPRITE, size) == fWriter.bytesWritten()); this->addPaintPtr(paint); this->addBitmap(bitmap); this->addInt(left); @@ -630,7 +634,7 @@ void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x DrawType op = DRAW_TEXT; size_t initialOffset = this->addDraw(op, &size); - SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(op, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addText(text, byteLength); this->addScalar(x); @@ -648,7 +652,7 @@ 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+getPaintOffset(op, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(op, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addText(text, byteLength); this->addInt(points); @@ -680,7 +684,7 @@ 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(NULL); size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); - SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_TEXT_ON_PATH, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addText(text, byteLength); this->addPath(path); @@ -694,7 +698,7 @@ 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 + getPaintOffset(DRAW_TEXT_BLOB, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset + get_paint_offset(DRAW_TEXT_BLOB, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addTextBlob(blob); @@ -717,7 +721,7 @@ void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); size += m.writeToMemory(NULL) + kUInt32Size; // matrix + paint initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); - SkASSERT(initialOffset + getPaintOffset(DRAW_PICTURE_MATRIX_PAINT, size) + SkASSERT(initialOffset + get_paint_offset(DRAW_PICTURE_MATRIX_PAINT, size) == fWriter.bytesWritten()); this->addPaintPtr(paint); this->addMatrix(m); @@ -765,7 +769,7 @@ void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount, } size_t initialOffset = this->addDraw(DRAW_VERTICES, &size); - SkASSERT(initialOffset+getPaintOffset(DRAW_VERTICES, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_VERTICES, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addInt(flags); this->addInt(vmode); @@ -812,7 +816,7 @@ void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors } size_t initialOffset = this->addDraw(DRAW_PATCH, &size); - SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWritten()); + SkASSERT(initialOffset+get_paint_offset(DRAW_PATCH, size) == fWriter.bytesWritten()); this->addPaint(paint); this->addPatch(cubics); this->addInt(flag); diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp index 81c39e36f0..9ae5c21484 100644 --- a/src/core/SkPictureRecorder.cpp +++ b/src/core/SkPictureRecorder.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ -#include "SkPictureRecord.h" #include "SkPictureRecorder.h" #include "SkRecord.h" #include "SkRecordDraw.h" @@ -19,24 +18,6 @@ SkPictureRecorder::~SkPictureRecorder() {} SkCanvas* SkPictureRecorder::beginRecording(SkScalar width, SkScalar height, SkBBHFactory* bbhFactory /* = NULL */, uint32_t recordFlags /* = 0 */) { - return EXPERIMENTAL_beginRecording(width, height, bbhFactory); -} - -SkCanvas* SkPictureRecorder::DEPRECATED_beginRecording(SkScalar width, SkScalar height, - SkBBHFactory* bbhFactory /* = NULL */, - uint32_t recordFlags /* = 0 */) { - SkASSERT(!bbhFactory); // No longer suppported with this backend. - - fCullWidth = width; - fCullHeight = height; - fPictureRecord.reset(SkNEW_ARGS(SkPictureRecord, (SkISize::Make(width, height), recordFlags))); - - fPictureRecord->beginRecording(); - return this->getRecordingCanvas(); -} - -SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(SkScalar width, SkScalar height, - SkBBHFactory* bbhFactory /* = NULL */) { fCullWidth = width; fCullHeight = height; @@ -51,43 +32,16 @@ SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(SkScalar width, SkScala } SkCanvas* SkPictureRecorder::getRecordingCanvas() { - if (fRecorder.get()) { - return fRecorder.get(); - } - return fPictureRecord.get(); + return fRecorder.get(); } SkPicture* SkPictureRecorder::endRecording() { - SkPicture* picture = NULL; - - if (fRecord.get()) { - picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, - fRecord.detach(), fBBH.get())); - } - - if (fPictureRecord.get()) { - fPictureRecord->endRecording(); - const bool deepCopyOps = false; - picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, - *fPictureRecord.get(), deepCopyOps)); - } - - return picture; + return SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, fRecord.detach(), fBBH.get())); } void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { if (NULL == canvas) { return; } - - if (fRecord.get()) { - SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/); - } - - if (fPictureRecord.get()) { - const bool deepCopyOps = true; - SkPicture picture(fCullWidth, fCullHeight, - *fPictureRecord.get(), deepCopyOps); - picture.playback(canvas); - } + SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/); } |