switch surface to sk_sp
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1817383002
CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot
Review URL: https://codereview.chromium.org/1817383002
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index b5844d1..8c9c154 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -23,8 +23,8 @@
SkSurface_Raster(SkPixelRef*, const SkSurfaceProps*);
SkCanvas* onNewCanvas() override;
- SkSurface* onNewSurface(const SkImageInfo&) override;
- SkImage* onNewImageSnapshot(SkBudgeted, ForceCopyMode) override;
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
+ sk_sp<SkImage> onNewImageSnapshot(SkBudgeted, ForceCopyMode) override;
void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override;
void onCopyOnWrite(ContentChangeMode) override;
void onRestoreBackingMutability() override;
@@ -109,8 +109,8 @@
SkCanvas* SkSurface_Raster::onNewCanvas() { return new SkCanvas(fBitmap, this->props()); }
-SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
- return SkSurface::NewRaster(info, &this->props());
+sk_sp<SkSurface> SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
+ return SkSurface::MakeRaster(info, &this->props());
}
void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
@@ -118,7 +118,7 @@
canvas->drawBitmap(fBitmap, x, y, paint);
}
-SkImage* SkSurface_Raster::onNewImageSnapshot(SkBudgeted, ForceCopyMode forceCopyMode) {
+sk_sp<SkImage> SkSurface_Raster::onNewImageSnapshot(SkBudgeted, ForceCopyMode forceCopyMode) {
if (fWeOwnThePixels) {
// SkImage_raster requires these pixels are immutable for its full lifetime.
// We'll undo this via onRestoreBackingMutability() if we can avoid the COW.
@@ -131,7 +131,7 @@
// Our pixels are in memory, so read access on the snapshot SkImage could be cheap.
// Lock the shared pixel ref to ensure peekPixels() is usable.
- return SkMakeImageFromRasterBitmap(fBitmap, forceCopyMode).release();
+ return SkMakeImageFromRasterBitmap(fBitmap, forceCopyMode);
}
void SkSurface_Raster::onRestoreBackingMutability() {
@@ -169,9 +169,9 @@
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkSurface::NewRasterDirectReleaseProc(const SkImageInfo& info, void* pixels, size_t rb,
- void (*releaseProc)(void* pixels, void* context),
- void* context, const SkSurfaceProps* props) {
+sk_sp<SkSurface> SkSurface::MakeRasterDirectReleaseProc(const SkImageInfo& info, void* pixels,
+ size_t rb, void (*releaseProc)(void* pixels, void* context), void* context,
+ const SkSurfaceProps* props) {
if (nullptr == releaseProc) {
context = nullptr;
}
@@ -182,16 +182,16 @@
return nullptr;
}
- return new SkSurface_Raster(info, pixels, rb, releaseProc, context, props);
+ return sk_make_sp<SkSurface_Raster>(info, pixels, rb, releaseProc, context, props);
}
-SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes,
- const SkSurfaceProps* props) {
- return NewRasterDirectReleaseProc(info, pixels, rowBytes, nullptr, nullptr, props);
+sk_sp<SkSurface> SkSurface::MakeRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ const SkSurfaceProps* props) {
+ return MakeRasterDirectReleaseProc(info, pixels, rowBytes, nullptr, nullptr, props);
}
-SkSurface* SkSurface::NewRaster(const SkImageInfo& info, size_t rowBytes,
- const SkSurfaceProps* props) {
+sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& info, size_t rowBytes,
+ const SkSurfaceProps* props) {
if (!SkSurface_Raster::Valid(info)) {
return nullptr;
}
@@ -203,9 +203,9 @@
if (rowBytes) {
SkASSERT(pr->rowBytes() == rowBytes);
}
- return new SkSurface_Raster(pr, props);
+ return sk_make_sp<SkSurface_Raster>(pr, props);
}
-SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* props) {
- return NewRaster(info, 0, props);
+sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& info, const SkSurfaceProps* props) {
+ return MakeRaster(info, 0, props);
}