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
diff --git a/bench/PictureRecordBench.cpp b/bench/PictureRecordBench.cpp
index ef5361d..50fabe1 100644
--- a/bench/PictureRecordBench.cpp
+++ b/bench/PictureRecordBench.cpp
@@ -53,14 +53,14 @@
protected:
virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
SkPictureRecorder recorder;
- SkCanvas* canvas = NULL;
+ SkCanvas* canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
const SkPoint translateDelta = getTranslateDelta(loops);
for (int i = 0; i < loops; i++) {
if (0 == i % kMaxLoopsPerCanvas) {
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT, NULL, 0);
+ canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
}
SkColor color = SK_ColorYELLOW + (i % 255);
@@ -98,6 +98,7 @@
canvas->restore();
canvas->translate(translateDelta.fX, translateDelta.fY);
}
+ SkAutoTUnref<SkPicture> cleanup(recorder.endRecording());
}
SkPoint getTranslateDelta(int M) {
@@ -122,15 +123,16 @@
SkRandom rand;
SkPaint paint;
SkPictureRecorder recorder;
- SkCanvas* canvas = NULL;
+ SkCanvas* canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
for (int i = 0; i < loops; i++) {
if (0 == i % kMaxLoopsPerCanvas) {
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT, NULL, 0);
+ canvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT);
}
paint.setColor(rand.nextU());
canvas->drawPaint(paint);
}
+ SkAutoTUnref<SkPicture> cleanup(recorder.endRecording());
}
private:
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index c23c5fa..ddf4551 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -272,7 +272,7 @@
void createHeader(SkPictInfo* info) const;
static bool IsValidPictInfo(const SkPictInfo& info);
- friend class SkPictureRecorder; // just for SkPicture-based constructor
+ friend class SkPictureRecorder; // SkRecord-based constructor.
friend class SkGpuDevice; // for fData access
friend class GrLayerHoister; // access to fRecord
friend class CollectLayers; // access to fRecord
@@ -285,6 +285,8 @@
SkPicture(SkScalar width, SkScalar height, SkRecord*, SkBBoxHierarchy*);
// Return as a new SkPicture that's backed by SkRecord.
static SkPicture* Forwardport(const SkPicture&);
+ // Return as a new SkPicture that's backed by the old backend.
+ static SkPicture* Backport(const SkRecord& src, const SkRect& cullRect);
SkAutoTDelete<SkRecord> fRecord;
SkAutoTUnref<SkBBoxHierarchy> fBBH;
diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h
index 8f3afb3..c48f35d 100644
--- a/include/core/SkPictureRecorder.h
+++ b/include/core/SkPictureRecorder.h
@@ -48,18 +48,6 @@
SkBBHFactory* bbhFactory = NULL,
uint32_t recordFlags = 0);
- // As usual, we have a deprecated old version and a maybe almost working
- // new version. We currently point beginRecording() to EXPERIMENTAL_beginRecording().
-
- // Old slower backend.
- SkCanvas* DEPRECATED_beginRecording(SkScalar width, SkScalar height,
- SkBBHFactory* bbhFactory = NULL,
- uint32_t recordFlags = 0);
-
- // New faster backend.
- SkCanvas* EXPERIMENTAL_beginRecording(SkScalar width, SkScalar height,
- SkBBHFactory* bbhFactory = NULL);
-
/** Returns the recording canvas if one is active, or NULL if recording is
not active. This does not alter the refcnt on the canvas (if present).
*/
@@ -87,13 +75,8 @@
SkScalar fCullWidth;
SkScalar fCullHeight;
SkAutoTUnref<SkBBoxHierarchy> fBBH;
-
- // One of these two canvases will be non-NULL.
- SkAutoTUnref<SkPictureRecord> fPictureRecord; // beginRecording()
- SkAutoTUnref<SkRecorder> fRecorder; // EXPERIMENTAL_beginRecording()
-
- // Used by EXPERIMENTAL_beginRecording().
- SkAutoTDelete<SkRecord> fRecord;
+ SkAutoTUnref<SkRecorder> fRecorder;
+ SkAutoTDelete<SkRecord> fRecord;
typedef SkNoncopyable INHERITED;
};
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index def67e6..98c28e6 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -264,12 +264,12 @@
// 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 @@
// 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 @@
// 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 16cb3b5..40ecc6a 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -24,8 +24,10 @@
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 @@
///////////////////////////////////////////////////////////////////////////////
+#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 @@
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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
}
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 @@
}
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 81c39e3..9ae5c21 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 @@
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::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*/);
}
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 216a408..5ec0b8f 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -121,10 +121,6 @@
static const char* const kDefaultAssertMessageFormat = "%s";
static const char* const kCanvasDrawAssertMessageFormat =
"Drawing test step %s with SkCanvas";
-static const char* const kPictureDrawAssertMessageFormat =
- "Drawing test step %s with SkPicture";
-static const char* const kPictureSecondDrawAssertMessageFormat =
- "Duplicate draw of test step %s with SkPicture";
static const char* const kDeferredDrawAssertMessageFormat =
"Drawing test step %s with SkDeferredCanvas";
static const char* const kProxyDrawAssertMessageFormat =
@@ -137,8 +133,6 @@
"test step %s, SkDeferredCanvas playback canvas state consistency after flush";
static const char* const kDeferredPostSilentFlushPlaybackAssertMessageFormat =
"test step %s, SkDeferredCanvas playback canvas state consistency after silent flush";
-static const char* const kPictureResourceReuseMessageFormat =
- "test step %s, SkPicture duplicate flattened object test";
static const char* const kProxyStateAssertMessageFormat =
"test step %s, SkProxyCanvas state consistency";
static const char* const kProxyIndirectStateAssertMessageFormat =
@@ -463,7 +457,7 @@
skiatest::Reporter*,
CanvasTestStep*) {
SkPictureRecorder recorder;
- SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight),
+ SkCanvas* testCanvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntToScalar(kHeight),
NULL, 0);
testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
testCanvas->clipRect(kTestRect);
@@ -678,37 +672,6 @@
*/
}
-
-public:
-
- static void TestPictureFlattenedObjectReuse(skiatest::Reporter* reporter,
- CanvasTestStep* testStep,
- uint32_t recordFlags) {
- // Verify that when a test step is executed twice, no extra resources
- // are flattened during the second execution
- testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat);
- SkPictureRecorder referenceRecorder;
- SkCanvas* referenceCanvas =
- referenceRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
- SkIntToScalar(kHeight),
- NULL, recordFlags);
- testStep->draw(referenceCanvas, reporter);
-
- SkPictureRecorder testRecorder;
- SkCanvas* testCanvas =
- testRecorder.DEPRECATED_beginRecording(SkIntToScalar(kWidth),
- SkIntToScalar(kHeight),
- NULL, recordFlags);
- testStep->draw(testCanvas, reporter);
- testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat);
- testStep->draw(testCanvas, reporter);
-
- SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>(referenceCanvas);
- SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(testCanvas);
- testStep->setAssertMessageFormat(kPictureResourceReuseMessageFormat);
- AssertFlattenedObjectsEqual(referenceRecord, testRecord,
- reporter, testStep);
- }
};
static void TestPdfDevice(skiatest::Reporter* reporter,
@@ -908,8 +871,6 @@
for (int testStep = 0; testStep < testStepArray().count(); testStep++) {
TestOverrideStateConsistency(reporter, testStepArray()[testStep]);
- SkPictureTester::TestPictureFlattenedObjectReuse(reporter,
- testStepArray()[testStep], 0);
if (testStepArray()[testStep]->enablePdfTesting()) {
TestPdfDevice(reporter, testStepArray()[testStep]);
}
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 9cd63df..c41b327 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -579,22 +579,18 @@
}
}
-#define GENERATE_CANVAS(recorder, x) \
- (x) ? recorder.EXPERIMENTAL_beginRecording(100, 100) \
- : recorder. DEPRECATED_beginRecording(100,100);
-
/* Hit a few SkPicture::Analysis cases not handled elsewhere. */
-static void test_analysis(skiatest::Reporter* reporter, bool useNewPath) {
+static void test_analysis(skiatest::Reporter* reporter) {
SkPictureRecorder recorder;
- SkCanvas* canvas = GENERATE_CANVAS(recorder, useNewPath);
+ SkCanvas* canvas = recorder.beginRecording(100, 100);
{
canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ());
}
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps());
- canvas = GENERATE_CANVAS(recorder, useNewPath);
+ canvas = recorder.beginRecording(100, 100);
{
SkPaint paint;
// CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shader
@@ -745,12 +741,10 @@
#if SK_SUPPORT_GPU
-static void test_gpu_veto(skiatest::Reporter* reporter,
- bool useNewPath) {
-
+static void test_gpu_veto(skiatest::Reporter* reporter) {
SkPictureRecorder recorder;
- SkCanvas* canvas = GENERATE_CANVAS(recorder, useNewPath);
+ SkCanvas* canvas = recorder.beginRecording(100, 100);
{
SkPath path;
path.moveTo(0, 0);
@@ -772,7 +766,7 @@
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL, &reason));
REPORTER_ASSERT(reporter, reason);
- canvas = GENERATE_CANVAS(recorder, useNewPath);
+ canvas = recorder.beginRecording(100, 100);
{
SkPath path;
@@ -794,7 +788,7 @@
// A lot of AA concave paths currently render an SkPicture undesireable for GPU rendering
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL));
- canvas = GENERATE_CANVAS(recorder, useNewPath);
+ canvas = recorder.beginRecording(100, 100);
{
SkPath path;
@@ -818,7 +812,7 @@
// hairline stroked AA concave paths are fine for GPU rendering
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(NULL));
- canvas = GENERATE_CANVAS(recorder, useNewPath);
+ canvas = recorder.beginRecording(100, 100);
{
SkPaint paint;
SkScalar intervals [] = { 10, 20 };
@@ -832,7 +826,7 @@
// fast-path dashed effects are fine for GPU rendering ...
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(NULL));
- canvas = GENERATE_CANVAS(recorder, useNewPath);
+ canvas = recorder.beginRecording(100, 100);
{
SkPaint paint;
SkScalar intervals [] = { 10, 20 };
@@ -846,19 +840,14 @@
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL));
// Nest the previous picture inside a new one.
- // This doesn't work in the old backend.
- if (useNewPath) {
- canvas = GENERATE_CANVAS(recorder, useNewPath);
- {
- canvas->drawPicture(picture.get());
- }
- picture.reset(recorder.endRecording());
- REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL));
+ canvas = recorder.beginRecording(100, 100);
+ {
+ canvas->drawPicture(picture.get());
}
+ picture.reset(recorder.endRecording());
+ REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL));
}
-#undef GENERATE_CANVAS
-
static void test_gpu_picture_optimization(skiatest::Reporter* reporter,
GrContextFactory* factory) {
for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
@@ -1072,12 +1061,10 @@
#endif
-static void test_has_text(skiatest::Reporter* reporter, bool useNewPath) {
+static void test_has_text(skiatest::Reporter* reporter) {
SkPictureRecorder recorder;
-#define BEGIN_RECORDING useNewPath ? recorder.EXPERIMENTAL_beginRecording(100, 100) \
- : recorder. DEPRECATED_beginRecording(100, 100)
- SkCanvas* canvas = BEGIN_RECORDING;
+ SkCanvas* canvas = recorder.beginRecording(100,100);
{
canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint());
}
@@ -1085,28 +1072,28 @@
REPORTER_ASSERT(reporter, !picture->hasText());
SkPoint point = SkPoint::Make(10, 10);
- canvas = BEGIN_RECORDING;
+ canvas = recorder.beginRecording(100,100);
{
canvas->drawText("Q", 1, point.fX, point.fY, SkPaint());
}
picture.reset(recorder.endRecording());
REPORTER_ASSERT(reporter, picture->hasText());
- canvas = BEGIN_RECORDING;
+ canvas = recorder.beginRecording(100,100);
{
canvas->drawPosText("Q", 1, &point, SkPaint());
}
picture.reset(recorder.endRecording());
REPORTER_ASSERT(reporter, picture->hasText());
- canvas = BEGIN_RECORDING;
+ canvas = recorder.beginRecording(100,100);
{
canvas->drawPosTextH("Q", 1, &point.fX, point.fY, SkPaint());
}
picture.reset(recorder.endRecording());
REPORTER_ASSERT(reporter, picture->hasText());
- canvas = BEGIN_RECORDING;
+ canvas = recorder.beginRecording(100,100);
{
SkPath path;
path.moveTo(0, 0);
@@ -1117,7 +1104,7 @@
picture.reset(recorder.endRecording());
REPORTER_ASSERT(reporter, picture->hasText());
- canvas = BEGIN_RECORDING;
+ canvas = recorder.beginRecording(100,100);
{
SkPath path;
path.moveTo(0, 0);
@@ -1129,16 +1116,12 @@
REPORTER_ASSERT(reporter, picture->hasText());
// Nest the previous picture inside a new one.
- // This doesn't work in the old backend.
- if (useNewPath) {
- canvas = BEGIN_RECORDING;
- {
- canvas->drawPicture(picture.get());
- }
- picture.reset(recorder.endRecording());
- REPORTER_ASSERT(reporter, picture->hasText());
+ canvas = recorder.beginRecording(100,100);
+ {
+ canvas->drawPicture(picture.get());
}
-#undef BEGIN_RECORDING
+ picture.reset(recorder.endRecording());
+ REPORTER_ASSERT(reporter, picture->hasText());
}
static void set_canvas_to_save_count_4(SkCanvas* canvas) {
@@ -1775,13 +1758,10 @@
test_unbalanced_save_restores(reporter);
test_peephole();
#if SK_SUPPORT_GPU
- test_gpu_veto(reporter, false);
- test_gpu_veto(reporter, true);
+ test_gpu_veto(reporter);
#endif
- test_has_text(reporter, false);
- test_has_text(reporter, true);
- test_analysis(reporter, false);
- test_analysis(reporter, true);
+ test_has_text(reporter);
+ test_analysis(reporter);
test_gatherpixelrefs(reporter);
test_gatherpixelrefsandrects(reporter);
test_bitmap_with_encoded_data(reporter);