c->restore();
if (recordPicture) {
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- canvas->drawPicture(picture);
+ canvas->drawPicture(recorder.finishRecordingAsPicture());
}
return pics;
SkCanvas* c = recorder.beginRecording(SkIntToScalar(canvasSize.x()),
SkIntToScalar(canvasSize.y()));
this->doDraw(c);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ (void)recorder.finishRecordingAsPicture();
}
}
SkIntToScalar(canvasSize.y()));
this->doDraw(c);
- fPicture.reset(recorder.endRecording());
+ fPicture = recorder.finishRecordingAsPicture();
}
void onDraw(int loops, SkCanvas* canvas) override {
}
private:
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
typedef PictureNesting INHERITED;
};
if (kDraw) {
rec.getRecordingCanvas()->drawRect(SkRect::MakeXYWH(10, 10, 1000, 1000), SkPaint());
}
- SkAutoTUnref<SkPicture> pic(rec.endRecordingAsPicture());
+ (void)rec.finishRecordingAsPicture();
}
}
};
SkPictureRecorder recorder;
SkCanvas* pCanvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGHT, nullptr, 0);
this->recordCanvas(pCanvas);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
const SkPoint translateDelta = getTranslateDelta(loops);
paint.setAlpha(0xFF);
canvas->drawRect(SkRect::MakeXYWH(x,y,w,h), paint);
}
- fPic.reset(recorder.endRecording());
+ fPic = recorder.finishRecordingAsPicture();
}
void onDraw(int loops, SkCanvas* canvas) override {
}
private:
- BBH fBBH;
- Mode fMode;
- SkString fName;
- SkAutoTUnref<SkPicture> fPic;
+ BBH fBBH;
+ Mode fMode;
+ SkString fName;
+ sk_sp<SkPicture> fPic;
};
DEF_BENCH( return new TiledPlaybackBench(kNone, kRandom); )
for (int i = 0; i < loops; i++) {
SkPictureRecorder recorder;
fSrc->playback(recorder.beginRecording(w, h, fUseBBH ? &factory : nullptr, flags));
- SkSafeUnref(recorder.endRecording());
+ (void)recorder.finishRecordingAsPicture();
}
}
fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes));
}
- static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
+ static sk_sp<SkPicture> ReadPicture(const char* path) {
// Not strictly necessary, as it will be checked again later,
// but helps to avoid a lot of pointless work if we're going to skip it.
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) {
- return false;
+ return nullptr;
}
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
if (stream.get() == nullptr) {
SkDebugf("Could not read %s.\n", path);
- return false;
+ return nullptr;
}
- pic->reset(SkPicture::CreateFromStream(stream.get()));
- if (pic->get() == nullptr) {
- SkDebugf("Could not read %s as an SkPicture.\n", path);
- return false;
- }
- return true;
+ return SkPicture::MakeFromStream(stream.get());
}
Benchmark* next() {
// First add all .skps as RecordingBenches.
while (fCurrentRecording < fSKPs.count()) {
const SkString& path = fSKPs[fCurrentRecording++];
- SkAutoTUnref<SkPicture> pic;
- if (!ReadPicture(path.c_str(), &pic)) {
+ sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+ if (!pic) {
continue;
}
SkString name = SkOSPath::Basename(path.c_str());
fSourceType = "skp";
fBenchType = "recording";
- fSKPBytes = static_cast<double>(SkPictureUtils::ApproximateBytesUsed(pic));
+ fSKPBytes = static_cast<double>(SkPictureUtils::ApproximateBytesUsed(pic.get()));
fSKPOps = pic->approximateOpCount();
return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh);
}
while (fCurrentScale < fScales.count()) {
while (fCurrentSKP < fSKPs.count()) {
const SkString& path = fSKPs[fCurrentSKP];
- SkAutoTUnref<SkPicture> pic;
- if (!ReadPicture(path.c_str(), &pic)) {
+ sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+ if (!pic) {
fCurrentSKP++;
continue;
}
pic->cullRect().height(),
&factory,
fUseMPDs[fCurrentUseMPD] ? kFlags : 0));
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
}
SkString name = SkOSPath::Basename(path.c_str());
fSourceType = "skp";
if (fZoomMax != 1.0f && fZoomPeriodMs > 0) {
while (fCurrentAnimSKP < fSKPs.count()) {
const SkString& path = fSKPs[fCurrentAnimSKP];
- SkAutoTUnref<SkPicture> pic;
- if (!ReadPicture(path.c_str(), &pic)) {
+ sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+ if (!pic) {
fCurrentAnimSKP++;
continue;
}
fLoading = true;
SkAutoTDelete<SkStream> stream(new SkFILEStream(fileName.c_str()));
- SkPicture* picture = SkPicture::CreateFromStream(stream);
+ auto picture = SkPicture::MakeFromStream(stream);
if (nullptr == picture) {
QMessageBox::critical(this, "Error loading file", "Couldn't read file, sorry.");
}
fCanvasWidget.resetWidgetTransform();
- fDebugger.loadPicture(picture);
+ fDebugger.loadPicture(picture.get());
fSkipCommands.setCount(fDebugger.getSize());
for (int i = 0; i < fSkipCommands.count(); ++i) {
fSkipCommands[i] = false;
}
- SkSafeUnref(picture);
+ picture.reset();
/* fDebugCanvas is reinitialized every load picture. Need it to retain value
* of the visibility filter.
if (!stream) {
return SkStringPrintf("Couldn't read %s.", fPath.c_str());
}
- SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream));
+ sk_sp<SkPicture> pic(SkPicture::MakeFromStream(stream));
if (!pic) {
return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str());
}
if (!err.isEmpty()) {
return err;
}
- SkAutoTUnref<SkPicture> pic(recorder.endRecording());
- pic->serialize(dst);
+ recorder.finishRecordingAsPicture()->serialize(dst);
return "";
}
if (!err.isEmpty()) {
return err;
}
- SkAutoTUnref<SkPicture> pic(recorder.endRecording());
+ sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture());
// Serialize it and then deserialize it.
SkDynamicMemoryWStream wStream;
pic->serialize(&wStream);
SkAutoTDelete<SkStream> rStream(wStream.detachAsStream());
- SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rStream));
+ sk_sp<SkPicture> deserialized(SkPicture::MakeFromStream(rStream));
return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) {
canvas->drawPicture(deserialized);
if (!err.isEmpty()) {
return err;
}
- SkAutoTUnref<SkPicture> pic(recorder.endRecordingAsPicture());
+ sk_sp<SkPicture> pic(recorder.finishRecordingAsPicture());
return draw_to_canvas(fSink, bitmap, stream, log, src.size(), [&](SkCanvas* canvas) {
const int xTiles = (size.width() + fW - 1) / fW,
SkCanvas* c = s->getCanvas();
c->translate(SkIntToScalar(-i * fW),
SkIntToScalar(-j * fH)); // Line up the canvas with this tile.
- mpd.add(c, pic);
+ mpd.add(c, pic.get());
}
}
mpd.draw();
auto size = src.size();
return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
SkPictureRecorder recorder;
- SkAutoTUnref<SkPicture> pic;
+ sk_sp<SkPicture> pic;
Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
SkIntToScalar(size.height())));
if (!err.isEmpty()) {
return err;
}
- pic.reset(recorder.endRecordingAsPicture());
+ pic = recorder.finishRecordingAsPicture();
canvas->drawPicture(pic);
return check_against_reference(bitmap, src, fSink);
});
auto size = src.size();
return draw_to_canvas(fSink, bitmap, stream, log, size, [&](SkCanvas* canvas) -> Error {
SkPictureRecorder recorder;
- SkAutoTUnref<SkPicture> pic;
+ sk_sp<SkPicture> pic;
for (int i = 0; i < 2; i++) {
Error err = src.draw(recorder.beginRecording(SkIntToScalar(size.width()),
SkIntToScalar(size.height())));
if (!err.isEmpty()) {
return err;
}
- pic.reset(recorder.endRecordingAsPicture());
+ pic = recorder.finishRecordingAsPicture();
}
canvas->drawPicture(pic);
return check_against_reference(bitmap, src, fSink);
if (!err.isEmpty()) {
return err;
}
- SkAutoTUnref<SkPicture> skPicture(recorder.endRecording());
+ sk_sp<SkPicture> skPicture(recorder.finishRecordingAsPicture());
SkASSERT(skPicture);
SkDynamicMemoryWStream buffer;
}
SkMemoryStream tmpStream(mojoPicture->data.data(),
mojoPicture->data.size());
- skPicture.reset(SkPicture::CreateFromStream(&tmpStream));
+ skPicture = SkPicture::MakeFromStream(&tmpStream);
mojoPicture.reset();
auto fn = [&](SkCanvas* canvas) -> Error {
canvas->drawPicture(skPicture.get());
SK_WHEN(T::kTags & SkRecords::kDraw_Tag, void) operator()(const T& op) {
SkPictureRecorder rec;
this->draw(op, rec.beginRecording(SkRect::MakeLargest()));
- SkAutoTUnref<SkPicture> pic(rec.endRecordingAsPicture());
+ sk_sp<SkPicture> pic(rec.finishRecordingAsPicture());
fCanvas->drawPicture(pic);
}
for (int i = 0; i < skr.count(); i++) {
skr.visit<void>(i, drawsAsSingletonPictures);
}
- SkAutoTUnref<SkPicture> macroPic(macroRec.endRecordingAsPicture());
+ sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
canvas->drawPicture(macroPic);
return check_against_reference(bitmap, src, fSink);
int fuzz_skp(SkData* bytes) {
SkMemoryStream stream(bytes);
SkDebugf("Decoding\n");
- SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(&stream));
+ sk_sp<SkPicture> pic(SkPicture::MakeFromStream(&stream));
if (!pic) {
SkDebugf("[terminated] Couldn't decode as a picture.\n");
return 3;
rec->clipPath(p, SkRegion::kIntersect_Op, true);
rec->drawColor(SK_ColorGREEN);
rec->restore();
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
// Next we play that picture into another picture of the same size.
pict->playback(recorder.beginRecording(pict->cullRect().width(),
pict->cullRect().height(),
nullptr, 0));
- SkAutoTUnref<SkPicture> pict2(recorder.endRecording());
+ sk_sp<SkPicture> pict2(recorder.finishRecordingAsPicture());
// Finally we play the part of that second picture that should be green into the canvas.
canvas->save();
//-----------
// Paints with a PictureImageFilter as a source
- SkAutoTUnref<SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
SkPictureRecorder rec;
SkCanvas* c = rec.beginRecording(10, 10);
c->drawRect(SkRect::MakeWH(10, 10), blackFill);
- pic.reset(rec.endRecording());
+ pic = rec.finishRecordingAsPicture();
}
- SkAutoTUnref<SkImageFilter> pif(SkPictureImageFilter::Create(pic));
+ SkAutoTUnref<SkImageFilter> pif(SkPictureImageFilter::Create(pic.get()));
SkTArray<SkPaint> pifPaints;
create_paints(pif, &pifPaints);
static sk_sp<SkImage> make_picture(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
SkPictureRecorder recorder;
draw(recorder.beginRecording(SkRect::MakeIWH(info.width(), info.height())));
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
- return SkImage::MakeFromPicture(sk_ref_sp(pict.get()), info.dimensions(), nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
+ info.dimensions(), nullptr, nullptr);
}
static sk_sp<SkImage> make_codec(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
static SkImageGenerator* gen_picture(const SkImageInfo& info) {
SkPictureRecorder recorder;
draw_opaque_contents(recorder.beginRecording(SkRect::MakeIWH(info.width(), info.height())));
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
- return SkImageGenerator::NewFromPicture(info.dimensions(), pict, nullptr, nullptr);
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
+ return SkImageGenerator::NewFromPicture(info.dimensions(), pict.get(), nullptr, nullptr);
}
static SkImageGenerator* gen_png(const SkImageInfo& info) {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kSize), SkIntToScalar(kSize));
render_image(canvas);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- return SkImage::MakeFromPicture(sk_ref_sp(picture.get()), SkISize::Make(kSize, kSize),
- nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
+ SkISize::Make(kSize, kSize), nullptr, nullptr);
},
// Create a texture image
[context, render_image]() -> sk_sp<SkImage> {
* (correctly) when it is inside an image.
*/
class ImagePictGM : public skiagm::GM {
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
sk_sp<SkImage> fImage0;
sk_sp<SkImage> fImage1;
public:
const SkRect bounds = SkRect::MakeXYWH(100, 100, 100, 100);
SkPictureRecorder recorder;
draw_something(recorder.beginRecording(bounds), bounds);
- fPicture.reset(recorder.endRecording());
+ fPicture = recorder.finishRecordingAsPicture();
// extract enough just for the oval.
const SkISize size = SkISize::Make(100, 100);
SkMatrix matrix;
matrix.setTranslate(-100, -100);
- fImage0 = SkImage::MakeFromPicture(sk_ref_sp(fPicture.get()), size, &matrix, nullptr);
+ fImage0 = SkImage::MakeFromPicture(fPicture, size, &matrix, nullptr);
matrix.postTranslate(-50, -50);
matrix.postRotate(45);
matrix.postTranslate(50, 50);
- fImage1 = SkImage::MakeFromPicture(sk_ref_sp(fPicture.get()), size, &matrix, nullptr);
+ fImage1 = SkImage::MakeFromPicture(fPicture, size, &matrix, nullptr);
}
void drawSet(SkCanvas* canvas) const {
class ImageCacheratorGM : public skiagm::GM {
SkString fName;
SkImageGenerator* (*fFactory)(GrContext*, SkPicture*);
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
SkAutoTDelete<SkImageCacherator> fCache;
SkAutoTDelete<SkImageCacherator> fCacheSubset;
const SkRect bounds = SkRect::MakeXYWH(100, 100, 100, 100);
SkPictureRecorder recorder;
draw_something(recorder.beginRecording(bounds), bounds);
- fPicture.reset(recorder.endRecording());
+ fPicture = recorder.finishRecordingAsPicture();
}
void makeCaches(GrContext* ctx) {
- auto gen = fFactory(ctx, fPicture);
+ auto gen = fFactory(ctx, fPicture.get());
SkDEBUGCODE(const uint32_t genID = gen->uniqueID();)
fCache.reset(SkImageCacherator::NewFromGenerator(gen));
const SkIRect subset = SkIRect::MakeLTRB(50, 50, 100, 100);
- gen = fFactory(ctx, fPicture);
+ gen = fFactory(ctx, fPicture.get());
SkDEBUGCODE(const uint32_t genSubsetID = gen->uniqueID();)
fCacheSubset.reset(SkImageCacherator::NewFromGenerator(gen, &subset));
* (correctly) when it is inside an image.
*/
class ImageShaderGM : public skiagm::GM {
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
public:
ImageShaderGM() {}
const SkRect bounds = SkRect::MakeWH(100, 100);
SkPictureRecorder recorder;
draw_something(recorder.beginRecording(bounds), bounds);
- fPicture.reset(recorder.endRecording());
+ fPicture = recorder.finishRecordingAsPicture();
}
void testImage(SkCanvas* canvas, SkImage* image) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) {
- sk_sp<SkImage> image(gProcs[i](canvas->getGrContext(), fPicture, info));
+ sk_sp<SkImage> image(gProcs[i](canvas->getGrContext(), fPicture.get(), info));
if (image) {
this->testImage(canvas, image.get());
}
// Make a picture that is a tiling of the plane with stroked hexagons where
// each hexagon is in its own layer. The layers are to exercise Ganesh's
// layer hoisting.
-static const SkPicture* make_hex_plane_picture(SkColor fillColor) {
+static sk_sp<SkPicture> make_hex_plane_picture(SkColor fillColor) {
// Create a hexagon with its center at the origin
SkPath hex = make_hex_path(0, 0);
yPos += 2 * kHexSide * kRoot3Over2;
}
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
// Create a picture that consists of a single large layer that is tiled
// with hexagons.
// This is intended to exercise the layer hoisting code's clip handling (in
// tile mode).
-static const SkPicture* make_single_layer_hex_plane_picture() {
+static sk_sp<SkPicture> make_single_layer_hex_plane_picture() {
// Create a hexagon with its center at the origin
SkPath hex = make_hex_path(0, 0);
canvas->restore();
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
// Make an equilateral triangle path with its top corner at (originX, originY)
return tri;
}
-static const SkPicture* make_tri_picture() {
+static sk_sp<SkPicture> make_tri_picture() {
SkPath tri = make_tri_path(SkScalarHalf(kTriSide), 0);
SkPaint fill;
canvas->drawPath(tri, stroke);
canvas->restore();
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
-static const SkPicture* make_sub_picture(const SkPicture* tri) {
+static sk_sp<SkPicture> make_sub_picture(const SkPicture* tri) {
SkPictureRecorder recorder;
SkRTreeFactory bbhFactory;
canvas->drawPicture(tri);
canvas->restore();
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
// Create a Sierpinkski-like picture that starts with a top row with a picture
// that just contains a triangle. Subsequent rows take the prior row's picture,
// shrinks it and replicates it 3 times then draws and appropriate number of
// copies of it.
-static const SkPicture* make_sierpinski_picture() {
- SkAutoTUnref<const SkPicture> pic(make_tri_picture());
+static sk_sp<SkPicture> make_sierpinski_picture() {
+ sk_sp<SkPicture> pic(make_tri_picture());
SkPictureRecorder recorder;
SkRTreeFactory bbhFactory;
}
canvas->restore();
- pic.reset(make_sub_picture(pic));
+ pic = make_sub_picture(pic.get());
canvas->translate(0, 1.5f * kTriSide / kRoot3);
}
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
static SkSurface* create_compat_surface(SkCanvas* canvas, int width, int height) {
static void create_content(SkMultiPictureDraw* mpd, PFContentMtd pfGen,
const SkPicture* pictures[kNumPictures],
SkCanvas* dest, const SkMatrix& xform) {
- SkAutoTUnref<SkPicture> composite;
+ sk_sp<SkPicture> composite;
{
SkPictureRecorder recorder;
(*pfGen)(pictureCanvas, pictures);
- composite.reset(recorder.endRecording());
+ composite = recorder.finishRecordingAsPicture();
}
- mpd->add(dest, composite, &xform);
+ mpd->add(dest, composite.get(), &xform);
}
typedef void(*PFLayoutMtd)(SkCanvas* finalCanvas, SkMultiPictureDraw* mpd,
const SkPicture* fPictures[kNumPictures];
void onOnceBeforeDraw() override {
- fPictures[0] = make_hex_plane_picture(SK_ColorWHITE);
- fPictures[1] = make_hex_plane_picture(sk_tool_utils::color_to_565(SK_ColorGRAY));
- fPictures[2] = make_sierpinski_picture();
- fPictures[3] = make_single_layer_hex_plane_picture();
+ fPictures[0] = make_hex_plane_picture(SK_ColorWHITE).release();
+ fPictures[1] = make_hex_plane_picture(sk_tool_utils::color_to_565(SK_ColorGRAY)).release();
+ fPictures[2] = make_sierpinski_picture().release();
+ fPictures[3] = make_single_layer_hex_plane_picture().release();
}
void onDraw(SkCanvas* canvas) override {
rec->translate(SkIntToScalar(250), SkIntToScalar(250));
rec->clipPath(p, SkRegion::kIntersect_Op, true);
rec->drawColor(0xffff0000);
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
canvas->setAllowSimplifyClip(true);
canvas->save();
#include "SkPaint.h"
#include "SkPictureRecorder.h"
-static SkPicture* make_picture() {
+static sk_sp<SkPicture> make_picture() {
SkPictureRecorder rec;
SkCanvas* canvas = rec.beginRecording(100, 100);
paint.setXfermodeMode(SkXfermode::kPlus_Mode);
canvas->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint);
- return rec.endRecording();
+ return rec.finishRecordingAsPicture();
}
// Exercise the optional arguments to drawPicture
protected:
void onOnceBeforeDraw() override {
- fPicture.reset(make_picture());
+ fPicture = make_picture();
}
SkString onShortName() override {
}
private:
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
typedef skiagm::GM INHERITED;
};
paint.setTextSize(SkIntToScalar(96));
const char* str = "e";
canvas->drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70), paint);
- fPicture.reset(recorder.endRecording());
+ fPicture = recorder.finishRecordingAsPicture();
}
SkISize onISize() override { return SkISize::Make(600, 300); }
SkRect emptyRect = SkRect::MakeXYWH(20, 20, 0, 0);
SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100);
SkAutoTUnref<SkImageFilter> pictureSource(
- SkPictureImageFilter::Create(fPicture));
+ SkPictureImageFilter::Create(fPicture.get()));
SkAutoTUnref<SkImageFilter> pictureSourceSrcRect(
- SkPictureImageFilter::Create(fPicture, srcRect));
+ SkPictureImageFilter::Create(fPicture.get(), srcRect));
SkAutoTUnref<SkImageFilter> pictureSourceEmptyRect(
- SkPictureImageFilter::Create(fPicture, emptyRect));
+ SkPictureImageFilter::Create(fPicture.get(), emptyRect));
SkAutoTUnref<SkImageFilter> pictureSourceResampled(
- SkPictureImageFilter::CreateForLocalSpace(fPicture, fPicture->cullRect(),
+ SkPictureImageFilter::CreateForLocalSpace(fPicture.get(), fPicture->cullRect(),
kLow_SkFilterQuality));
SkAutoTUnref<SkImageFilter> pictureSourcePixelated(
- SkPictureImageFilter::CreateForLocalSpace(fPicture, fPicture->cullRect(),
+ SkPictureImageFilter::CreateForLocalSpace(fPicture.get(), fPicture->cullRect(),
kNone_SkFilterQuality));
canvas->save();
}
private:
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
typedef GM INHERITED;
};
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(rect);
draw_vector_logo(canvas, rect);
- fPicture.reset(recorder.endRecording());
+ fPicture = recorder.finishRecordingAsPicture();
}
void onDraw(SkCanvas* canvas) override {
}
private:
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
const SkScalar kPictureWidth = 200;
const SkScalar kPictureHeight = 100;
SkPictureRecorder recorder;
SkCanvas* pictureCanvas = recorder.beginRecording(fTileSize, fTileSize, nullptr, 0);
this->drawTile(pictureCanvas);
- fPicture.reset(recorder.endRecording());
+ fPicture = recorder.finishRecordingAsPicture();
// Build a reference bitmap.
fBitmap.allocN32Pixels(SkScalarCeilToInt(fTileSize), SkScalarCeilToInt(fTileSize));
p.setStrokeWidth(10);
c->drawLine(20, 20, 80, 80, p);
- sk_sp<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
sk_sp<SkShader> shader(SkShader::MakePictureShader(picture, SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode,
nullptr, nullptr));
SkPictureRecorder recorder;
SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPictureSize);
draw_scene(pictureCanvas, kPictureSize);
- sk_sp<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkPoint offset = SkPoint::Make(100, 100);
pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), offset.y(),
kPictureSize, kPictureSize));
pictureCanvas->translate(offset.x(), offset.y());
draw_scene(pictureCanvas, kPictureSize);
- sk_sp<SkPicture> offsetPicture(recorder.endRecording());
+ sk_sp<SkPicture> offsetPicture(recorder.finishRecordingAsPicture());
for (unsigned i = 0; i < SK_ARRAY_COUNT(tiles); ++i) {
SkRect tile = SkRect::MakeXYWH(tiles[i].x * kPictureSize,
InstallDetectorFunc installDetector) {
SkRect targetRect(SkRect::MakeWH(SkIntToScalar(kTestRectSize), SkIntToScalar(kTestRectSize)));
- SkAutoTUnref<SkPicture> shape;
+ sk_sp<SkPicture> shape;
{
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kTestRectSize + 2),
SkPaint shapePaint;
shapePaint.setColor(shapeColor);
canvas->drawRect(targetRect, shapePaint);
- shape.reset(recorder.endRecordingAsPicture());
+ shape = recorder.finishRecordingAsPicture();
}
SkPaint layerPaint;
canvas->save();
canvas->clipRect(targetRect);
SkPaint drawPaint;
- drawPaint.setImageFilter(SkPictureImageFilter::Create(shape))->unref();
+ drawPaint.setImageFilter(SkPictureImageFilter::Create(shape.get()))->unref();
installDetector(&drawPaint);
canvas->saveLayer(&targetRect, &drawPaint);
canvas->restore();
drawTestSequence(recorder.beginRecording(SkIntToScalar(kTestRectSize),
SkIntToScalar(kTestRectSize)),
shapeColor, no_detector_install);
- SkAutoTUnref<SkPicture> optimizedPicture(recorder.endRecordingAsPicture());
- optimizedPicture->playback(canvas);
+ recorder.finishRecordingAsPicture()->playback(canvas);
canvas->flush();
}
canvas->restore();
drawTestSequence(recorder.beginRecording(SkIntToScalar(kTestRectSize),
SkIntToScalar(kTestRectSize)),
shapeColor, detectorInstallFunc);
- SkAutoTUnref<SkPicture> optimizedPicture(recorder.endRecordingAsPicture());
- optimizedPicture->playback(canvas);
+ recorder.finishRecordingAsPicture()->playback(canvas);
canvas->flush();
}
static sk_sp<SkImage> make_picture_image(int width, int height, SkColor colors[2]) {
SkPictureRecorder recorder;
draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height, colors);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- return SkImage::MakeFromPicture(sk_ref_sp(picture.get()), SkISize::Make(width, height),
- nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
+ SkISize::Make(width, height), nullptr, nullptr);
}
typedef sk_sp<SkImage> (*ImageMakerProc)(int width, int height, SkColor colors[2]);
void drawPicture(const SkPicture* picture) {
this->drawPicture(picture, NULL, NULL);
}
- void drawPicture(sk_sp<SkPicture>& picture) {
+ void drawPicture(const sk_sp<SkPicture>& picture) {
this->drawPicture(picture.get());
}
* saveLayer(paint)/drawPicture/restore
*/
void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* paint);
- void drawPicture(sk_sp<SkPicture>& picture, const SkMatrix* matrix, const SkPaint* paint) {
+ void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, const SkPaint* paint) {
this->drawPicture(picture.get(), matrix, paint);
}
class SkWStream;
struct SkPictInfo;
+#define SK_SUPPORT_LEGACY_PICTURE_PTR
+
/** \class SkPicture
An SkPicture records drawing commands made to a canvas to be played back at a later time.
* @return A new SkPicture representing the serialized data, or NULL if the stream is
* invalid.
*/
- static SkPicture* CreateFromStream(SkStream*, InstallPixelRefProc proc);
+ static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc proc);
/**
* Recreate a picture that was serialized into a stream.
* @return A new SkPicture representing the serialized data, or NULL if the stream is
* invalid.
*/
- static SkPicture* CreateFromStream(SkStream*);
+ static sk_sp<SkPicture> MakeFromStream(SkStream*);
/**
* Recreate a picture that was serialized into a buffer. If the creation requires bitmap
* @return A new SkPicture representing the serialized data, or NULL if the buffer is
* invalid.
*/
- static SkPicture* CreateFromBuffer(SkReadBuffer&);
+ static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer&);
/**
* Subclasses of this can be passed to playback(). During the playback
static void SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set);
static bool PictureIOSecurityPrecautionsEnabled();
+#ifdef SK_SUPPORT_LEGACY_PICTURE_PTR
+ static SkPicture* CreateFromStream(SkStream* stream, InstallPixelRefProc proc) {
+ return MakeFromStream(stream, proc).release();
+ }
+ static SkPicture* CreateFromStream(SkStream* stream) {
+ return MakeFromStream(stream).release();
+ }
+ static SkPicture* CreateFromBuffer(SkReadBuffer& rbuf) {
+ return MakeFromBuffer(rbuf).release();
+ }
+#endif
+
private:
// Subclass whitelist.
SkPicture();
template <typename> friend class SkMiniPicture;
void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const;
- static SkPicture* CreateFromStream(SkStream*,
- InstallPixelRefProc proc,
- SkTypefacePlayback*);
+ static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc, SkTypefacePlayback*);
friend class SkPictureData;
virtual int numSlowPaths() const = 0;
"Remove SkBitmapSourceDeserializer.");
static bool IsValidPictInfo(const SkPictInfo& info);
- static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*);
+ static sk_sp<SkPicture> Forwardport(const SkPictInfo&, const SkPictureData*);
SkPictInfo createHeader() const;
SkPictureData* backport() const;
* reflect their current state, but will not contain a live reference to the drawables
* themselves.
*/
- SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture();
+ sk_sp<SkPicture> finishRecordingAsPicture();
/**
* Signal that the caller is done recording, and update the cull rect to use for bounding
* and subsequent culling operations.
* @return the picture containing the recorded content.
*/
- SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture(const SkRect& cullRect);
+ sk_sp<SkPicture> finishRecordingAsPictureWithCull(const SkRect& cullRect);
/**
* Signal that the caller is done recording. This invalidates the canvas returned by
* and therefore this drawable will reflect the current state of those nested drawables anytime
* it is drawn or a new picture is snapped from it (by calling drawable->newPictureSnapshot()).
*/
- SkDrawable* SK_WARN_UNUSED_RESULT endRecordingAsDrawable();
+ sk_sp<SkDrawable> finishRecordingAsDrawable();
- // Legacy API -- use endRecordingAsPicture instead.
+#ifdef SK_SUPPORT_LEGACY_PICTURE_PTR
+ SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture() {
+ return this->finishRecordingAsPicture().release();
+ }
+ SkPicture* SK_WARN_UNUSED_RESULT endRecordingAsPicture(const SkRect& cullRect) {
+ return this->finishRecordingAsPictureWithCull(cullRect).release();
+ }
+ SkDrawable* SK_WARN_UNUSED_RESULT endRecordingAsDrawable() {
+ return this->finishRecordingAsDrawable().release();
+ }
SkPicture* SK_WARN_UNUSED_RESULT endRecording() { return this->endRecordingAsPicture(); }
+#endif
private:
void reset();
bool drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&);
// Detach anything we've recorded as a picture, resetting this SkMiniRecorder.
- SkPicture* detachAsPicture(const SkRect& cull);
+ sk_sp<SkPicture> detachAsPicture(const SkRect& cull);
// Flush anything we've recorded to the canvas, resetting this SkMiniRecorder.
// This is logically the same as but rather more efficient than:
SkCanvas* record = recorder.beginRecording(320, 480, nullptr, 0);
this->drawPicture(record, 120);
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
canvas->translate(0, SkIntToScalar(120));
}
if (fSaveToSKP) {
- SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
+ sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
SkFILEWStream stream("sample_app.skp");
picture->serialize(&stream);
fSaveToSKP = false;
}
if (fUsePicture) {
- SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
+ sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
// serialize/deserialize?
if (false) {
picture->serialize(&wstream);
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
- picture.reset(SkPicture::CreateFromStream(rstream));
+ picture = SkPicture::MakeFromStream(rstream);
}
- orig->drawPicture(picture);
+ orig->drawPicture(picture.get());
}
// Do this after presentGL and other finishing, rather than in afterChild
public:
SkRect fRect;
- MyDrawable* fAnimatingDrawable;
- SkDrawable* fRootDrawable;
+ sk_sp<MyDrawable> fAnimatingDrawable;
+ sk_sp<SkDrawable> fRootDrawable;
ArcsView() {
testparse();
fRect.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
fRect.offset(SkIntToScalar(20), SkIntToScalar(20));
- fAnimatingDrawable = new MyDrawable(fRect);
+ fAnimatingDrawable = sk_make_sp<MyDrawable>(fRect);
SkPictureRecorder recorder;
this->drawRoot(recorder.beginRecording(SkRect::MakeWH(800, 500)));
- fRootDrawable = recorder.endRecordingAsDrawable();
- }
-
- ~ArcsView() override {
- fAnimatingDrawable->unref();
- fRootDrawable->unref();
+ fRootDrawable = recorder.finishRecordingAsDrawable();
}
protected:
DrawRectWithLines(canvas, fRect, paint);
- canvas->drawDrawable(fAnimatingDrawable);
+ canvas->drawDrawable(fAnimatingDrawable.get());
DrawArcs(canvas);
}
void onDrawContent(SkCanvas* canvas) override {
- canvas->drawDrawable(fRootDrawable);
+ canvas->drawDrawable(fRootDrawable.get());
}
bool onAnimate(const SkAnimTimer& timer) override {
SkIntToScalar(kBitmapSize),
&factory, 0);
drawSomething(recordingCanvas);
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
filter = SkPictureImageFilter::Create(pict.get(), make_rect());
}
break;
HTDrawable* fDrawable;
};
Rec fArray[N];
- SkAutoTUnref<SkDrawable> fRoot;
+ sk_sp<SkDrawable> fRoot;
SkMSec fTime;
HTView() {
canvas->drawDrawable(fArray[i].fDrawable);
fArray[i].fDrawable->unref();
}
- fRoot.reset(recorder.endRecordingAsDrawable());
+ fRoot = recorder.finishRecordingAsDrawable();
}
protected:
}
void onDrawContent(SkCanvas* canvas) override {
- canvas->drawDrawable(fRoot);
+ canvas->drawDrawable(fRoot.get());
}
bool onAnimate(const SkAnimTimer& timer) override {
#endif
if (!*picture) {
- *picture = LoadPicture(fFilename.c_str(), fBBox);
+ *picture = LoadPicture(fFilename.c_str(), fBBox).release();
}
if (*picture) {
SkCounterDrawFilter filter(fCount);
SkSize fTileSize;
int fCount;
- SkPicture* LoadPicture(const char path[], BBoxType bbox) {
- SkAutoTUnref<SkPicture> pic;
+ sk_sp<SkPicture> LoadPicture(const char path[], BBoxType bbox) {
+ sk_sp<SkPicture> pic;
SkBitmap bm;
if (SkImageDecoder::DecodeFile(path, &bm)) {
SkIntToScalar(bm.height()),
nullptr, 0);
can->drawBitmap(bm, 0, 0, nullptr);
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
} else {
SkFILEStream stream(path);
if (stream.isValid()) {
- pic.reset(SkPicture::CreateFromStream(&stream));
+ pic = SkPicture::MakeFromStream(&stream);
} else {
SkDebugf("coun't load picture at \"path\"\n", path);
}
pic->playback(recorder.beginRecording(pic->cullRect().width(),
pic->cullRect().height(),
nullptr, 0));
- SkAutoTUnref<SkPicture> p2(recorder.endRecording());
+ sk_sp<SkPicture> p2(recorder.finishRecordingAsPicture());
SkString path2(path);
path2.append(".new.skp");
switch (bbox) {
case kNo_BBoxType:
// no bbox playback necessary
- return pic.release();
+ return std::move(pic);
case kRTree_BBoxType:
factory.reset(new SkRTreeFactory);
break;
pic->playback(recorder.beginRecording(pic->cullRect().width(),
pic->cullRect().height(),
factory.get(), 0));
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
typedef SampleView INHERITED;
static const int gHeight = 32;
class TilingView : public SampleView {
- SkAutoTUnref<SkPicture> fTextPicture;
+ sk_sp<SkPicture> fTextPicture;
SkAutoTUnref<SkDrawLooper> fLooper;
public:
TilingView()
if (textCanvas) {
SkASSERT(nullptr == fTextPicture);
- fTextPicture.reset(recorder.endRecording());
+ fTextPicture = recorder.finishRecordingAsPicture();
}
SkASSERT(fTextPicture);
- canvas->drawPicture(fTextPicture);
+ canvas->drawPicture(fTextPicture.get());
}
private:
}
sk_picture_t* sk_picture_recorder_end_recording(sk_picture_recorder_t* crec) {
- return ToPicture(AsPictureRecorder(crec)->endRecording());
+ return ToPicture(AsPictureRecorder(crec)->finishRecordingAsPicture().release());
}
void sk_picture_ref(sk_picture_t* cpic) {
if (false) {
draw_bbox(canvas, bounds);
}
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture().release();
}
if (fState != State::kEmpty) {
// We have internal state pending.
// Detaching then deleting a picture is an easy way to clean up.
- delete this->detachAsPicture(SkRect::MakeEmpty());
+ (void)this->detachAsPicture(SkRect::MakeEmpty());
}
SkASSERT(fState == State::kEmpty);
}
#undef TRY_TO_STORE
-SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
+sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect& cull) {
#define CASE(Type) \
case State::k##Type: \
fState = State::kEmpty; \
- return new SkMiniPicture<Type>(cull, reinterpret_cast<Type*>(fBuffer.get()))
+ return sk_make_sp<SkMiniPicture<Type>>(cull, reinterpret_cast<Type*>(fBuffer.get()))
switch (fState) {
- case State::kEmpty: return SkRef(gEmptyPicture.get([]{ return new SkEmptyPicture; }));
+ case State::kEmpty: return sk_ref_sp(gEmptyPicture.get([]{ return new SkEmptyPicture; }));
CASE(DrawBitmapRectFixedSize);
CASE(DrawPath);
CASE(DrawRect);
return false;
}
-SkPicture* SkPicture::Forwardport(const SkPictInfo& info, const SkPictureData* data) {
+sk_sp<SkPicture> SkPicture::Forwardport(const SkPictInfo& info, const SkPictureData* data) {
if (!data) {
return nullptr;
}
SkPicturePlayback playback(data);
SkPictureRecorder r;
playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/);
- return r.endRecording();
+ return r.finishRecordingAsPicture();
}
static bool default_install(const void* src, size_t length, SkBitmap* dst) {
SkImageGenerator::NewFromEncoded(encoded.get()), dst);
}
-SkPicture* SkPicture::CreateFromStream(SkStream* stream) {
- return CreateFromStream(stream, &default_install, nullptr);
+sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream) {
+ return MakeFromStream(stream, &default_install, nullptr);
}
-SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc proc) {
- return CreateFromStream(stream, proc, nullptr);
+sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc proc) {
+ return MakeFromStream(stream, proc, nullptr);
}
-SkPicture* SkPicture::CreateFromStream(SkStream* stream,
- InstallPixelRefProc proc,
- SkTypefacePlayback* typefaces) {
+sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc proc,
+ SkTypefacePlayback* typefaces) {
SkPictInfo info;
if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) {
return nullptr;
return Forwardport(info, data);
}
-SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) {
+sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) {
SkPictInfo info;
if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) {
return nullptr;
fPictureCount = 0;
fPictureRefs = new const SkPicture* [size];
for (uint32_t i = 0; i < size; i++) {
- fPictureRefs[i] = SkPicture::CreateFromStream(stream, proc, topLevelTFPlayback);
+ fPictureRefs[i] = SkPicture::MakeFromStream(stream, proc, topLevelTFPlayback).release();
if (!fPictureRefs[i]) {
return false;
}
// Need a shallow wrapper to return const SkPicture* to match the other factories,
// as SkPicture::CreateFromBuffer() returns SkPicture*
static const SkPicture* create_picture_from_buffer(SkReadBuffer& buffer) {
- return SkPicture::CreateFromBuffer(buffer);
+ return SkPicture::MakeFromBuffer(buffer).release();
}
template <typename T>
return fActivelyRecording ? fRecorder.get() : nullptr;
}
-SkPicture* SkPictureRecorder::endRecordingAsPicture() {
+sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture() {
fActivelyRecording = false;
fRecorder->restoreToCount(1); // If we were missing any restores, add them now.
for (int i = 0; pictList && i < pictList->count(); i++) {
subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin()[i]);
}
- return new SkBigPicture(fCullRect, fRecord.release(), pictList, fBBH.release(),
+ return sk_make_sp<SkBigPicture>(fCullRect, fRecord.release(), pictList, fBBH.release(),
saveLayerData.release(), subPictureBytes);
}
-SkPicture* SkPictureRecorder::endRecordingAsPicture(const SkRect& cullRect) {
+sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPictureWithCull(const SkRect& cullRect) {
fCullRect = cullRect;
- return this->endRecordingAsPicture();
+ return this->finishRecordingAsPicture();
}
}
};
-SkDrawable* SkPictureRecorder::endRecordingAsDrawable() {
+sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable() {
fActivelyRecording = false;
fRecorder->flushMiniRecorder();
fRecorder->restoreToCount(1); // If we were missing any restores, add them now.
fBBH->insert(bounds, fRecord->count());
}
- SkDrawable* drawable =
- new SkRecordedDrawable(fRecord, fBBH, fRecorder->detachDrawableList(), fCullRect,
+ sk_sp<SkDrawable> drawable =
+ sk_make_sp<SkRecordedDrawable>(fRecord, fBBH, fRecorder->detachDrawableList(), fCullRect,
SkToBool(fFlags & kComputeSaveLayerInfo_RecordFlag));
// release our refs now, so only the drawable will be the owner.
// Old code always serialized the picture. New code writes a 'true' first if it did.
if (buffer.isVersionLT(SkReadBuffer::kPictureShaderHasPictureBool_Version) ||
buffer.readBool()) {
- picture.reset(SkPicture::CreateFromBuffer(buffer));
+ picture = SkPicture::MakeFromBuffer(buffer);
}
}
return SkPictureShader::Make(picture, mx, my, &lm, &tile).release();
}
SkFlattenable* SkPictureImageFilter::CreateProc(SkReadBuffer& buffer) {
- SkAutoTUnref<SkPicture> picture;
+ sk_sp<SkPicture> picture;
SkRect cropRect;
if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnabled()) {
buffer.validate(!buffer.readBool());
} else {
if (buffer.readBool()) {
- picture.reset(SkPicture::CreateFromBuffer(buffer));
+ picture = SkPicture::MakeFromBuffer(buffer);
}
}
buffer.readRect(&cropRect);
} else {
filterQuality = (SkFilterQuality)buffer.readInt();
}
- return CreateForLocalSpace(picture, cropRect, filterQuality);
+ return CreateForLocalSpace(picture.get(), cropRect, filterQuality);
}
- return Create(picture, cropRect);
+ return Create(picture.get(), cropRect);
}
void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
}
static int lpicturerecorder_endRecording(lua_State* L) {
- SkPicture* pic = get_obj<SkPictureRecorder>(L, 1)->endRecording();
- if (nullptr == pic) {
+ sk_sp<SkPicture> pic = get_obj<SkPictureRecorder>(L, 1)->finishRecordingAsPicture();
+ if (!pic) {
lua_pushnil(L);
return 1;
}
- push_ref(L, pic)->unref();
+ push_ref(L, std::move(pic));
return 1;
}
testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
testCanvas->clipRect(d.fRect);
testCanvas->drawRect(d.fRect, d.fPaint);
- SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
- canvas->drawPicture(testPicture);
+ canvas->drawPicture(recorder.finishRecordingAsPicture());
}
TEST_STEP(DrawPicture, DrawPictureTestStep);
GrResourceCache::Stats stats;
#endif
- SkAutoTUnref<const SkPicture> picture;
+ sk_sp<SkPicture> picture;
{
SkPictureRecorder recorder;
// Draw something, anything, to prevent an empty-picture optimization,
// which is a singleton and never purged.
c->drawRect(SkRect::MakeWH(1,1), SkPaint());
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
}
GrResourceCache* resourceCache = context->getResourceCache();
SkPaint greenPaint;
greenPaint.setColor(SK_ColorGREEN);
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)), greenPaint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkAutoTUnref<SkImageFilter> pictureFilter(SkPictureImageFilter::Create(picture.get()));
SkAutoTUnref<SkShader> shader(SkPerlinNoiseShader::CreateTurbulence(SK_Scalar1, SK_Scalar1, 1, 0));
SkPaint noisePaint;
recordingCanvas->translate(-55, 0);
recordingCanvas->saveLayer(&bounds, &paint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture1(recorder.endRecording());
+ sk_sp<SkPicture> picture1(recorder.finishRecordingAsPicture());
result->allocN32Pixels(width, height);
SkCanvas canvas(*result);
&factory, 0);
draw_blurred_rect(recordingCanvas1);
draw_blurred_rect(recordingCanvas2);
- SkAutoTUnref<SkPicture> picture1(recorder1.endRecording());
- SkAutoTUnref<SkPicture> picture2(recorder2.endRecording());
+ sk_sp<SkPicture> picture1(recorder1.finishRecordingAsPicture());
+ sk_sp<SkPicture> picture2(recorder2.finishRecordingAsPicture());
for (int y = 0; y < height; y += tileSize) {
for (int x = 0; x < width; x += tileSize) {
SkRect tileRect = SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, tileSize));
- draw_picture_clipped(&canvas1, tileRect, picture1);
- draw_picture_clipped(&canvas2, tileRect, picture2);
+ draw_picture_clipped(&canvas1, tileRect, picture1.get());
+ draw_picture_clipped(&canvas2, tileRect, picture2.get());
}
}
for (int y = 0; y < height; y++) {
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPaint);
recordingCanvas->restore(); // scale
recordingCanvas->restore(); // saveLayer
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- canvas.drawPicture(picture);
+ canvas.drawPicture(recorder.finishRecordingAsPicture());
}
DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
SkPaint greenPaint;
greenPaint.setColor(SK_ColorGREEN);
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Wrap that SkPicture in an SkPictureImageFilter.
SkAutoTUnref<SkImageFilter> imageFilter(
redPaintWithFilter.setColor(SK_ColorRED);
redPaintWithFilter.setImageFilter(imageFilter.get());
outerCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWithFilter);
- SkAutoTUnref<SkPicture> outerPicture(outerRecorder.endRecording());
+ sk_sp<SkPicture> outerPicture(outerRecorder.finishRecordingAsPicture());
SkBitmap bitmap;
bitmap.allocN32Pixels(1, 1);
SkPictureRecorder crossProcessRecorder;
SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &factory, 0);
crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWithFilter);
- SkAutoTUnref<SkPicture> crossProcessPicture(crossProcessRecorder.endRecording());
+ sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsPicture());
canvas.clear(0x0);
canvas.drawPicture(crossProcessPicture);
static void test_clipped_picture_imagefilter(SkImageFilter::Proxy* proxy,
skiatest::Reporter* reporter,
GrContext* context) {
- SkAutoTUnref<SkPicture> picture;
+ sk_sp<SkPicture> picture;
{
SkRTreeFactory factory;
SkPaint greenPaint;
greenPaint.setColor(SK_ColorGREEN);
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint);
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
}
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 2));
SkCanvas* recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
recordingCanvas->saveLayer(&bounds, &imageFilterPaint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
canvas.clear(0);
canvas.drawPicture(picture);
recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
recordingCanvas->saveLayer(nullptr, &imageFilterPaint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture2(recorder.endRecording());
+ sk_sp<SkPicture> picture2(recorder.finishRecordingAsPicture());
canvas.clear(0);
canvas.drawPicture(picture2);
recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
recordingCanvas->saveLayer(&bounds, &colorFilterPaint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture3(recorder.endRecording());
+ sk_sp<SkPicture> picture3(recorder.finishRecordingAsPicture());
canvas.clear(0);
canvas.drawPicture(picture3);
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->clear(SK_ColorCYAN);
- sk_sp<SkPicture> picture(recorder.endRecording());
- return SkImage::MakeFromPicture(picture, SkISize::Make(10, 10), nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), SkISize::Make(10, 10),
+ nullptr, nullptr);
};
#endif
// Want to ensure that our Release is called when the owning image is destroyed
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(100, 100);
canvas->drawImage(image, 0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture);
REPORTER_ASSERT(reporter, picture->approximateOpCount() > 0);
REPORTER_ASSERT(reporter, serializers[i]->didEncode());
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
- SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rstream));
+ sk_sp<SkPicture> deserialized(SkPicture::MakeFromStream(rstream));
REPORTER_ASSERT(reporter, deserialized);
REPORTER_ASSERT(reporter, deserialized->approximateOpCount() > 0);
}
}
void TestResult::testOne() {
- SkPicture* pic = nullptr;
+ sk_sp<SkPicture> pic;
{
#if DEBUG_SHOW_TEST_NAME
if (fTestStep == kCompareBits) {
SkFILEStream stream(path.c_str());
if (!stream.isValid()) {
SkDebugf("invalid stream %s\n", path.c_str());
- goto finish;
+ return;
}
- pic = SkPicture::CreateFromStream(&stream);
+ pic = SkPicture::MakeFromStream(&stream);
if (!pic) {
SkDebugf("unable to decode %s\n", fFilename);
- goto finish;
+ return;
}
SkScalar width = pic->cullRect().width();
SkScalar height = pic->cullRect().height();
if (fScale >= 256) {
SkDebugf("unable to allocate bitmap for %s (w=%f h=%f)\n", fFilename,
width, height);
- goto finish;
+ return;
}
oldBitmap.eraseColor(SK_ColorWHITE);
SkCanvas oldCanvas(oldBitmap);
opBitmap.eraseColor(SK_ColorWHITE);
SkCanvas opCanvas(opBitmap);
opCanvas.setAllowSimplifyClip(true);
- drawPict(pic, &oldCanvas, fScale);
- drawPict(pic, &opCanvas, fScale);
+ drawPict(pic.get(), &oldCanvas, fScale);
+ drawPict(pic.get(), &opCanvas, fScale);
if (fTestStep == kCompareBits) {
fPixelError = similarBits(oldBitmap, opBitmap);
- int oldTime = timePict(pic, &oldCanvas);
- int opTime = timePict(pic, &opCanvas);
+ int oldTime = timePict(pic.get(), &oldCanvas);
+ int opTime = timePict(pic.get(), &opCanvas);
fTime = SkTMax(0, oldTime - opTime);
} else if (fTestStep == kEncodeFiles) {
SkString pngStr = make_png_name(fFilename);
writePict(opBitmap, outOpDir, pngName);
}
}
-finish:
- if (pic) {
- pic->unref();
- }
}
DEFINE_string2(match, m, "PathOpsSkpClipThreaded",
SkIntToScalar(fPictureHeight),
factory);
this->doTest(playbackCanvas, *recordCanvas);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
playbackCanvas.drawPicture(picture);
REPORTER_ASSERT(reporter, SK_ColorGREEN == fResultBitmap.getColor(0, 0));
}
SkPictureRecorder factory;
factory.beginRecording(0, 0, nullptr, 0);
- sk_sp<SkPicture> picture(factory.endRecording());
- paint.setShader(SkShader::MakePictureShader(std::move(picture), SkShader::kClamp_TileMode,
+ paint.setShader(SkShader::MakePictureShader(factory.finishRecordingAsPicture(),
+ SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, nullptr, nullptr));
canvas.drawRect(SkRect::MakeWH(1,1), paint);
SkPictureRecorder recorder;
recorder.beginRecording(100,100)->drawImage(image, 0,0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps());
}
{
canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ());
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps());
canvas = recorder.beginRecording(100, 100);
canvas->drawRect(SkRect::MakeWH(10, 10), paint);
}
- picture.reset(recorder.endRecording());
- REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps());
+ REPORTER_ASSERT(reporter, recorder.finishRecordingAsPicture()->willPlayBackBitmaps());
}
// Creates an SkPictureRecord
recorder.beginRecording(0, 0);
// Turns that into an SkPicture
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Ceates a new SkPictureRecord
recorder.beginRecording(0, 0);
}
static void test_serializing_empty_picture() {
SkPictureRecorder recorder;
recorder.beginRecording(0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream stream;
picture->serialize(&stream);
}
canvas->drawPath(path, paint);
}
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// path effects currently render an SkPicture undesireable for GPU rendering
const char *reason = nullptr;
canvas->drawPath(path, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// A lot of small AA concave paths should be fine for GPU rendering
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
canvas->drawPath(path, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// A lot of large AA concave paths currently render an SkPicture undesireable for GPU rendering
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
canvas->drawPath(path, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// hairline stroked AA concave paths are fine for GPU rendering
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// fast-path dashed effects are fine for GPU rendering ...
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
canvas->drawRect(SkRect::MakeWH(10, 10), paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// ... but only when applied to drawPoint() calls
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
{
canvas->drawPicture(picture.get());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
}
SkPaint complexPaint;
complexPaint.setImageFilter(filter);
- SkAutoTUnref<SkPicture> pict, child;
+ sk_sp<SkPicture> pict, child;
SkRTreeFactory bbhFactory;
{
c->saveLayer(nullptr, &complexPaint);
c->restore();
- child.reset(recorder.endRecording());
+ child = recorder.finishRecordingAsPicture();
}
// create a picture with the structure:
c->restore();
}
- pict.reset(recorder.endRecording());
+ pict = recorder.finishRecordingAsPicture();
}
// Now test out the SaveLayer extraction
REPORTER_ASSERT(reporter, !info4.fIsNested &&
info4.fHasNestedLayers); // has a nested SL
- REPORTER_ASSERT(reporter, child == info5.fPicture); // in a child picture
+ REPORTER_ASSERT(reporter, child.get() == info5.fPicture); // in a child picture
REPORTER_ASSERT(reporter, kWidth == info5.fBounds.width() &&
kHeight == info5.fBounds.height());
REPORTER_ASSERT(reporter, 0 == info5.fBounds.fLeft && 0 == info5.fBounds.fTop);
REPORTER_ASSERT(reporter, !info6.fIsNested &&
info6.fHasNestedLayers); // has a nested SL
- REPORTER_ASSERT(reporter, child == info7.fPicture); // in a child picture
+ REPORTER_ASSERT(reporter, child.get() == info7.fPicture); // in a child picture
REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() &&
kHeight == info7.fBounds.height());
REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBounds.fTop);
{
canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint());
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !picture->hasText());
SkPoint point = SkPoint::Make(10, 10);
{
canvas->drawText("Q", 1, point.fX, point.fY, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
{
canvas->drawPosText("Q", 1, &point, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
{
canvas->drawPosTextH("Q", 1, &point.fX, point.fY, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
canvas->drawTextOnPathHV("Q", 1, path, point.fX, point.fY, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
canvas->drawTextOnPath("Q", 1, path, nullptr, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
// Nest the previous picture inside a new one.
{
canvas->drawPicture(picture.get());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
}
// the 'partialReplay' method.
class SkPictureRecorderReplayTester {
public:
- static SkPicture* Copy(SkPictureRecorder* recorder) {
+ static sk_sp<SkPicture> Copy(SkPictureRecorder* recorder) {
SkPictureRecorder recorder2;
SkCanvas* canvas = recorder2.beginRecording(10, 10);
recorder->partialReplay(canvas);
- return recorder2.endRecording();
+ return recorder2.finishRecordingAsPicture();
}
};
canvas->saveLayer(nullptr, nullptr);
- SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
+ sk_sp<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
// The extra save and restore comes from the Copy process.
- check_save_state(reporter, copy, 2, 1, 3);
+ check_save_state(reporter, copy.get(), 2, 1, 3);
canvas->saveLayer(nullptr, nullptr);
- SkAutoTUnref<SkPicture> final(recorder.endRecording());
+ sk_sp<SkPicture> final(recorder.finishRecordingAsPicture());
- check_save_state(reporter, final, 1, 2, 3);
+ check_save_state(reporter, final.get(), 1, 2, 3);
// The copy shouldn't pick up any operations added after it was made
- check_save_state(reporter, copy, 2, 1, 3);
+ check_save_state(reporter, copy.get(), 2, 1, 3);
}
// (partially) check leakage of draw ops
canvas->drawRect(r, p);
- SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
+ sk_sp<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps());
r.offset(5.0f, 5.0f);
canvas->drawBitmapRect(bm, r, nullptr);
- SkAutoTUnref<SkPicture> final(recorder.endRecording());
+ sk_sp<SkPicture> final(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, final->willPlayBackBitmaps());
REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID());
int expectedSaveCount = canvas->getSaveCount();
- SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
- check_balance(reporter, copy);
+ sk_sp<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
+ check_balance(reporter, copy.get());
REPORTER_ASSERT(reporter, expectedSaveCount = canvas->getSaveCount());
// End the recording of source to test the picture finalization
// process isn't complicated by the partialReplay step
- SkAutoTUnref<SkPicture> final(recorder.endRecording());
+ sk_sp<SkPicture> final(recorder.finishRecordingAsPicture());
}
}
canvas->save();
canvas->translate(10, 10);
canvas->drawRect(rect, paint);
- SkAutoTUnref<SkPicture> extraSavePicture(recorder.endRecording());
+ sk_sp<SkPicture> extraSavePicture(recorder.finishRecordingAsPicture());
testCanvas.drawPicture(extraSavePicture);
REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
canvas->restore();
canvas->restore();
canvas->restore();
- SkAutoTUnref<SkPicture> extraRestorePicture(recorder.endRecording());
+ sk_sp<SkPicture> extraRestorePicture(recorder.finishRecordingAsPicture());
testCanvas.drawPicture(extraRestorePicture);
REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
SkCanvas* canvas = recorder.beginRecording(100, 100);
canvas->translate(10, 10);
canvas->drawRect(rect, paint);
- SkAutoTUnref<SkPicture> noSavePicture(recorder.endRecording());
+ sk_sp<SkPicture> noSavePicture(recorder.finishRecordingAsPicture());
testCanvas.drawPicture(noSavePicture);
REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
for (int i = 0; i < 1000; ++i) {
rand_op(canvas, rand);
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
rand = rand2;
}
canvas->clipRect(rect);
canvas->restore();
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
}
}
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(100, 100);
recordingCanvas->drawBitmap(bm, 0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkCanvas canvas;
canvas.drawPicture(picture);
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()),
SkIntToScalar(bitmap.height()));
canvas->drawBitmap(bitmap, 0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream wStream;
SkAutoTUnref<SkPixelSerializer> serializer(
SkSetErrorCallback(assert_one_parse_error_cb, &context);
SkMemoryStream pictureStream(picture1);
SkClearLastError();
- SkAutoTUnref<SkPicture> pictureFromStream(SkPicture::CreateFromStream(&pictureStream, nullptr));
+ sk_sp<SkPicture> pictureFromStream(SkPicture::MakeFromStream(&pictureStream, nullptr));
REPORTER_ASSERT(reporter, pictureFromStream.get() != nullptr);
SkClearLastError();
SkSetErrorCallback(nullptr, nullptr);
SkCanvas canvas(dst);
pictureStream.rewind();
- pictureFromStream.reset(SkPicture::CreateFromStream(&pictureStream));
+ pictureFromStream = SkPicture::MakeFromStream(&pictureStream);
canvas.drawPicture(pictureFromStream.get());
SkMD5::Digest digest2;
SkPaint paint;
canvas->drawRect(bounds, paint);
canvas->drawRect(bounds, paint);
- SkAutoTUnref<const SkPicture> p(recorder.endRecordingAsPicture(bounds));
+ sk_sp<SkPicture> p(recorder.finishRecordingAsPictureWithCull(bounds));
const SkBigPicture* picture = p->asSkBigPicture();
REPORTER_ASSERT(reporter, picture);
SkPaint p;
p.setColor(SK_ColorBLUE);
canvas->drawPaint(p);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
ClipCountingCanvas testCanvas(10, 10);
picture->playback(&testCanvas);
SkPictureRecorder recorder;
recorder.beginRecording(10, 10);
- SkAutoTUnref<SkPicture> childPlain(recorder.endRecording());
+ sk_sp<SkPicture> childPlain(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !childPlain->willPlayBackBitmaps()); // 0
recorder.beginRecording(10, 10)->drawBitmap(bm, 0, 0);
- SkAutoTUnref<SkPicture> childWithBitmap(recorder.endRecording());
+ sk_sp<SkPicture> childWithBitmap(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, childWithBitmap->willPlayBackBitmaps()); // 1
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawPicture(childPlain);
- SkAutoTUnref<SkPicture> parentPP(recorder.endRecording());
+ sk_sp<SkPicture> parentPP(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !parentPP->willPlayBackBitmaps()); // 0
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawPicture(childWithBitmap);
- SkAutoTUnref<SkPicture> parentPWB(recorder.endRecording());
+ sk_sp<SkPicture> parentPWB(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, parentPWB->willPlayBackBitmaps()); // 1
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawBitmap(bm, 0, 0);
canvas->drawPicture(childPlain);
- SkAutoTUnref<SkPicture> parentWBP(recorder.endRecording());
+ sk_sp<SkPicture> parentWBP(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, parentWBP->willPlayBackBitmaps()); // 1
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawBitmap(bm, 0, 0);
canvas->drawPicture(childWithBitmap);
- SkAutoTUnref<SkPicture> parentWBWB(recorder.endRecording());
+ sk_sp<SkPicture> parentWBWB(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, parentWBWB->willPlayBackBitmaps()); // 2
}
}
SkPictureRecorder recorder;
recorder.beginRecording(0, 0);
- SkAutoTUnref<SkPicture> empty(recorder.endRecording());
+ sk_sp<SkPicture> empty(recorder.finishRecordingAsPicture());
// Empty pictures should still have a valid ID
REPORTER_ASSERT(reporter, empty->uniqueID() != SK_InvalidGenID);
SkCanvas* canvas = recorder.beginRecording(1, 1);
canvas->drawARGB(255, 255, 255, 255);
- SkAutoTUnref<SkPicture> hasData(recorder.endRecording());
+ sk_sp<SkPicture> hasData(recorder.finishRecordingAsPicture());
// picture should have a non-zero id after recording
REPORTER_ASSERT(reporter, hasData->uniqueID() != SK_InvalidGenID);
SkPaint paint;
paint.setTypeface(SkTypeface::CreateFromName("Arial", SkTypeface::kItalic));
canvas->drawText("Q", 1, 0, 10, paint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture->hasText());
SkDynamicMemoryWStream stream;
picture->serialize(&stream);
DEF_TEST(Picture_EmptyBitmap, r) {
SkPictureRecorder recorder;
test_draw_bitmaps(recorder.beginRecording(10, 10));
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
}
DEF_TEST(Canvas_EmptyBitmap, r) {
canvas->drawBitmap(redBM, 50, 50);
canvas->restore();
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Now replay the picture back on another canvas
// and check a couple of its pixels.
// Record a few ops so we don't hit a small- or empty- picture optimization.
c->drawRect(bound, SkPaint());
c->drawRect(bound, SkPaint());
- SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkCanvas big(640, 480), small(300, 200);
REPORTER_ASSERT(r, mut.pixelRef()->unique());
REPORTER_ASSERT(r, immut.pixelRef()->unique());
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
// we want the recorder to go out of scope before our subsequent checks, so we
// place it inside local braces.
SkCanvas* canvas = rec.beginRecording(1920, 1200);
canvas->drawBitmap(mut, 0, 0);
canvas->drawBitmap(immut, 800, 600);
- pic.reset(rec.endRecording());
+ pic = rec.finishRecordingAsPicture();
}
// The picture shares the immutable pixels but copies the mutable ones.
REPORTER_ASSERT(r, !immut.pixelRef()->unique());
// When the picture goes away, it's just our bitmaps holding the refs.
- pic.reset(nullptr);
+ pic = nullptr;
REPORTER_ASSERT(r, mut.pixelRef()->unique());
REPORTER_ASSERT(r, immut.pixelRef()->unique());
}
for (int i = 0; i < 3; i++) {
rec.beginRecording(100, 100);
REPORTER_ASSERT(r, rec.getRecordingCanvas());
- rec.endRecording()->unref();
+ rec.finishRecordingAsPicture();
REPORTER_ASSERT(r, !rec.getRecordingCanvas());
}
}
SkCanvas* c = recorder.beginRecording(SkRect::MakeLTRB(1, 2, 3, 4));
c->clear(SK_ColorCYAN);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream wstream;
picture->serialize(&wstream);
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
- SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstream));
+ sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream));
REPORTER_ASSERT(r, deserializedPicture != nullptr);
REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
opaqueFilterLayerPaint.setColor(0xFF020202); // Opaque.
SkPaint translucentFilterLayerPaint;
translucentFilterLayerPaint.setColor(0x0F020202); // Not opaque.
- SkAutoTUnref<SkPicture> shape;
+ sk_sp<SkPicture> shape;
{
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(100), SkIntToScalar(100));
SkPaint shapePaint;
shapePaint.setColor(SK_ColorWHITE);
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(50), SkIntToScalar(50)), shapePaint);
- shape.reset(recorder.endRecordingAsPicture());
+ shape = recorder.finishRecordingAsPicture();
}
- translucentFilterLayerPaint.setImageFilter(SkPictureImageFilter::Create(shape))->unref();
+ translucentFilterLayerPaint.setImageFilter(SkPictureImageFilter::Create(shape.get()))->unref();
int index = 0;
// Make sure the abort callback works
DEF_TEST(RecordReplaceDraw_Abort, r) {
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
// Record two commands.
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)), SkPaint());
canvas->clipRect(SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)));
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
}
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
JustOneDraw callback;
- GrRecordReplaceDraw(pic, &canvas, nullptr, SkMatrix::I(), &callback);
+ GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), &callback);
switch (rerecord.count()) {
case 3:
// Make sure GrRecordReplaceDraw balances unbalanced saves
DEF_TEST(RecordReplaceDraw_Unbalanced, r) {
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
SkPictureRecorder recorder;
// We won't balance this, but GrRecordReplaceDraw will for us.
canvas->save();
canvas->scale(2, 2);
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
}
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
- GrRecordReplaceDraw(pic, &canvas, nullptr, SkMatrix::I(), nullptr/*callback*/);
+ GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), nullptr/*callback*/);
// ensure rerecord is balanced (in this case by checking that the count is odd)
REPORTER_ASSERT(r, (rerecord.count() & 1) == 1);
// Test out the layer replacement functionality with and w/o a BBH
void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace) {
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
SkPictureRecorder recorder;
canvas->restore();
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth / 2), SkIntToScalar(kHeight / 2)),
SkPaint());
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
}
SkAutoTUnref<GrTexture> texture;
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
- GrRecordReplaceDraw(pic, &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
+ GrRecordReplaceDraw(pic.get(), &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
int numLayers = count_instances_of_type<SkRecords::SaveLayer>(rerecord);
if (doReplace) {
SkIntToScalar(fHeight),
&factory);
drawer.draw(canvas, canvasRect, mode);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkCanvas replayCanvas(fBitmap);
replayCanvas.clear(0xffffffff);
nullptr, 0);
canvas->drawColor(SK_ColorWHITE);
canvas->drawText(text, 2, 24, 32, paint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Serlialize picture and create its clone from stream.
SkDynamicMemoryWStream stream;
picture->serialize(&stream);
SkAutoTDelete<SkStream> inputStream(stream.detachAsStream());
- SkAutoTUnref<SkPicture> loadedPicture(SkPicture::CreateFromStream(inputStream.get()));
+ sk_sp<SkPicture> loadedPicture(SkPicture::MakeFromStream(inputStream.get()));
// Draw both original and clone picture and compare bitmaps -- they should be identical.
SkBitmap origBitmap = draw_picture(*picture);
draw_something(recorder.beginRecording(SkIntToScalar(kBitmapSize),
SkIntToScalar(kBitmapSize),
nullptr, 0));
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
// Serialize picture
SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag);
// Deserialize picture
SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size);
- SkAutoTUnref<SkPicture> readPict(
- SkPicture::CreateFromBuffer(reader));
+ sk_sp<SkPicture> readPict(SkPicture::MakeFromBuffer(reader));
REPORTER_ASSERT(reporter, readPict.get());
}
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "SkAnnotation.h"
-static SkPicture* copy_picture_via_serialization(SkPicture* src) {
+static sk_sp<SkPicture> copy_picture_via_serialization(SkPicture* src) {
SkDynamicMemoryWStream wstream;
src->serialize(&wstream);
SkAutoTDelete<SkStreamAsset> rstream(wstream.detachAsStream());
- return SkPicture::CreateFromStream(rstream);
+ return SkPicture::MakeFromStream(rstream);
}
struct AnnotationRec {
{ r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 },
};
- SkAutoTUnref<SkPicture> pict0(recorder.endRecording());
- SkAutoTUnref<SkPicture> pict1(copy_picture_via_serialization(pict0));
+ sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture());
+ sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get()));
TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs));
canvas.drawPicture(pict1);
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->clear(SK_ColorCYAN);
- sk_sp<SkPicture> picture(recorder.endRecording());
- return SkImage::MakeFromPicture(picture, SkISize::Make(10, 10), nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
+ SkISize::Make(10, 10), nullptr, nullptr);
});
}
}
}
void TestResult::testOne() {
- SkPicture* pic = nullptr;
+ sk_sp<SkPicture> pic;
{
SkString d;
d.printf(" {%d, \"%s\"},", fDirNo, fFilename);
wStream.write(&bytes[0], length);
wStream.flush();
}
- pic = SkPicture::CreateFromStream(&stream);
+ pic = SkPicture::MakeFromStream(&stream);
if (!pic) {
SkDebugf("unable to decode %s\n", fFilename);
goto finish;
if (scale >= 256) {
SkDebugf("unable to allocate bitmap for %s (w=%d h=%d) (sw=%d sh=%d)\n",
fFilename, pWidth, pHeight, dim.fX, dim.fY);
- goto finish;
+ return;
}
SkCanvas skCanvas(bitmap);
drawPict(pic, &skCanvas, fScaleOversized ? scale : 1);
if (!texture) {
SkDebugf("unable to allocate texture for %s (w=%d h=%d)\n", fFilename,
dim.fX, dim.fY);
- goto finish;
+ return;
}
SkGpuDevice grDevice(context, texture.get());
SkCanvas grCanvas(&grDevice);
- drawPict(pic, &grCanvas, fScaleOversized ? scale : 1);
+ drawPict(pic.get(), &grCanvas, fScaleOversized ? scale : 1);
SkBitmap grBitmap;
grBitmap.allocPixels(grCanvas.imageInfo());
writePict(bitmap, outSkDir, pngName);
}
}
-finish:
- delete pic;
}
static SkString makeStatusString(int dirNo) {
this->next();
}
-bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
+sk_sp<SkPicture> VisualBenchmarkStream::ReadPicture(const char path[]) {
// Not strictly necessary, as it will be checked again later,
// but helps to avoid a lot of pointless work if we're going to skip it.
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
- return false;
+ return nullptr;
}
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
if (stream.get() == nullptr) {
SkDebugf("Could not read %s.\n", path);
- return false;
+ return nullptr;
}
- pic->reset(SkPicture::CreateFromStream(stream.get()));
- if (pic->get() == nullptr) {
+ auto pic = SkPicture::MakeFromStream(stream.get());
+ if (!pic) {
SkDebugf("Could not read %s as an SkPicture.\n", path);
- return false;
}
- return true;
+ return pic;
}
Benchmark* VisualBenchmarkStream::next() {
// Render skps
while (fCurrentSKP < fSKPs.count()) {
const SkString& path = fSKPs[fCurrentSKP++];
- SkAutoTUnref<SkPicture> pic;
- if (!ReadPicture(path.c_str(), &pic)) {
+ sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+ if (!pic) {
continue;
}
public:
VisualBenchmarkStream(const SkSurfaceProps&, bool justSKP = false);
- static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic);
+ static sk_sp<SkPicture> ReadPicture(const char* path);
Benchmark* next();
Benchmark* current() { return fBenchmark.get(); }
SkDebugf("Could not read %s.\n", FLAGS_skps[i]);
return 1;
}
- SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
+ sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream));
if (!src) {
SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]);
return 1;
0,
nullptr,
nullptr);
- SkAutoTUnref<SkPicture> dst(r.endRecording());
+ sk_sp<SkPicture> dst(r.finishRecordingAsPicture());
SkFILEWStream ostream(FLAGS_write[0]);
dst->serialize(&ostream);
}
for (SkString file; iter.next(&file); ) {
SkAutoTDelete<SkStream> stream =
SkStream::NewFromFile(SkOSPath::Join(inputs, file.c_str()).c_str());
- SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(stream));
+ sk_sp<SkPicture> picture(SkPicture::MakeFromStream(stream));
SkDynamicMemoryWStream scratch;
Sniffer sniff;
return kError;
}
- SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream));
- if (nullptr == picture.get()) {
+ sk_sp<SkPicture> picture(SkPicture::MakeFromStream(&inputStream));
+ if (nullptr == picture) {
if (!FLAGS_quiet) {
SkDebugf("Could not read the SkPicture\n");
}
picture->playback(recorder.beginRecording(picture->cullRect().width(),
picture->cullRect().height(),
nullptr, 0));
- SkAutoTUnref<SkPicture> recorded(recorder.endRecording());
+ sk_sp<SkPicture> recorded(recorder.finishRecordingAsPicture());
if (recorded->suitableForGpuRasterization(nullptr)) {
SkDebugf("suitable\n");
}
private:
- static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
+ static sk_sp<SkPicture> ReadPicture(const char path[]) {
// Not strictly necessary, as it will be checked again later,
// but helps to avoid a lot of pointless work if we're going to skip it.
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
- return false;
+ return nullptr;
}
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
if (stream.get() == nullptr) {
SkDebugf("Could not read %s.\n", path);
- return false;
+ return nullptr;
}
- pic->reset(SkPicture::CreateFromStream(stream.get()));
- if (pic->get() == nullptr) {
- SkDebugf("Could not read %s as an SkPicture.\n", path);
- return false;
- }
- return true;
+ return SkPicture::MakeFromStream(stream.get());
}
Benchmark* innerNext() {
// Render skps
while (fCurrentSKP < fSKPs.count()) {
const SkString& path = fSKPs[fCurrentSKP++];
- SkAutoTUnref<SkPicture> pic;
- if (!ReadPicture(path.c_str(), &pic)) {
+ auto pic = ReadPicture(path.c_str());
+ if (!pic) {
continue;
}
DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end");
DEFINE_bool2(quiet, q, false, "Silence all non-error related output");
-static SkPicture* load_picture(const char path[]) {
+static sk_sp<SkPicture> load_picture(const char path[]) {
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
- SkPicture* pic = nullptr;
if (stream.get()) {
- pic = SkPicture::CreateFromStream(stream.get());
+ return SkPicture::MakeFromStream(stream.get());
}
- return pic;
+ return nullptr;
}
static void call_canvas(lua_State* L, SkLuaCanvas* canvas,
SkDebugf("scraping %s %s\n", path, moduloStr.c_str());
}
- SkAutoTUnref<SkPicture> pic(load_picture(path));
+ auto pic(load_picture(path));
if (pic.get()) {
SkAutoTUnref<SkLuaCanvas> canvas(
new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()),
#include "SkString.h"
#include "SkDumpCanvas.h"
-static SkPicture* inspect(const char path[]) {
+static sk_sp<SkPicture> inspect(const char path[]) {
SkFILEStream stream(path);
if (!stream.isValid()) {
printf("-- Can't open '%s'\n", path);
}
stream.rewind();
- SkPicture* pic = SkPicture::CreateFromStream(&stream);
+ auto pic = SkPicture::MakeFromStream(&stream);
if (nullptr == pic) {
SkDebugf("Could not create SkPicture: %s\n", path);
return nullptr;
}
for (; index < argc; ++index) {
- SkAutoTUnref<SkPicture> pic(inspect(argv[index]));
+ auto pic(inspect(argv[index]));
if (doDumpOps) {
- dumpOps(pic);
+ dumpOps(pic.get());
}
if (index < argc - 1) {
printf("\n");
fDebugCanvas->draw(canvas);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream outStream;
bool Request::initPictureFromStream(SkStream* stream) {
// parse picture from stream
- fPicture.reset(SkPicture::CreateFromStream(stream));
- if (!fPicture.get()) {
+ fPicture = SkPicture::MakeFromStream(stream);
+ if (!fPicture) {
fprintf(stderr, "Could not create picture from stream.\n");
return false;
}
SkIRect getBounds();
GrContext* getContext();
- SkAutoTUnref<SkPicture> fPicture;
+ sk_sp<SkPicture> fPicture;
GrContextFactory* fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
bool fGPUEnabled;
paint.setColor(color);
r.inset(border, border);
canvas->drawRect(r, paint);
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
SkFILEWStream stream(writePath);
- pict->serialize(&stream);
+ recorder.finishRecordingAsPicture()->serialize(&stream);
}
int tool_main(int argc, char** argv);