aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c/sk_surface.cpp4
-rw-r--r--src/core/SkBitmapDevice.cpp4
-rw-r--r--src/core/SkCanvas.cpp12
-rw-r--r--src/core/SkDevice.cpp3
-rw-r--r--src/core/SkPictureImageGenerator.cpp5
-rw-r--r--src/core/SkPictureRecord.cpp2
-rw-r--r--src/core/SkPictureRecord.h2
-rw-r--r--src/core/SkPixmap.cpp3
-rw-r--r--src/core/SkRecorder.cpp4
-rw-r--r--src/core/SkRecorder.h2
-rw-r--r--src/core/SkSpecialImage.cpp19
-rw-r--r--src/gpu/GrLayerHoister.cpp4
-rw-r--r--src/gpu/SkGpuDevice.cpp6
-rw-r--r--src/gpu/SkGpuDevice.h2
-rw-r--r--src/image/SkImage_Base.h4
-rw-r--r--src/image/SkImage_Generator.cpp2
-rw-r--r--src/image/SkImage_Gpu.h4
-rw-r--r--src/image/SkImage_Raster.cpp2
-rw-r--r--src/image/SkSurface.cpp21
-rw-r--r--src/image/SkSurface_Base.h6
-rw-r--r--src/image/SkSurface_Gpu.cpp51
-rw-r--r--src/image/SkSurface_Gpu.h4
-rw-r--r--src/image/SkSurface_Raster.cpp36
-rw-r--r--src/pdf/SkPDFDevice.cpp10
-rw-r--r--src/pdf/SkPDFDevice.h2
-rw-r--r--src/utils/SkLua.cpp12
-rw-r--r--src/utils/SkRGBAToYUV.cpp2
-rw-r--r--src/views/SkWindow.cpp3
28 files changed, 122 insertions, 109 deletions
diff --git a/src/c/sk_surface.cpp b/src/c/sk_surface.cpp
index 75a1643775..fcc22465c6 100644
--- a/src/c/sk_surface.cpp
+++ b/src/c/sk_surface.cpp
@@ -433,7 +433,7 @@ sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t* cinfo,
}
SkSurfaceProps surfProps(0, geo);
- return (sk_surface_t*)SkSurface::NewRaster(info, &surfProps);
+ return (sk_surface_t*)SkSurface::MakeRaster(info, &surfProps).release();
}
sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t* cinfo, void* pixels,
@@ -449,7 +449,7 @@ sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t* cinfo, void* pi
}
SkSurfaceProps surfProps(0, geo);
- return (sk_surface_t*)SkSurface::NewRasterDirect(info, pixels, rowBytes, &surfProps);
+ return (sk_surface_t*)SkSurface::MakeRasterDirect(info, pixels, rowBytes, &surfProps).release();
}
void sk_surface_unref(sk_surface_t* csurf) {
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index fc0e63e9ae..c8ac8d2d44 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -360,8 +360,8 @@ void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
draw.drawSprite(static_cast<SkBitmapDevice*>(device)->fBitmap, x, y, paint);
}
-SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
- return SkSurface::NewRaster(info, &props);
+sk_sp<SkSurface> SkBitmapDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
+ return SkSurface::MakeRaster(info, &props);
}
SkImageFilter::Cache* SkBitmapDevice::getImageFilterCache() {
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index f7f870210d..7c1c07b5f2 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1314,16 +1314,16 @@ void SkCanvas::internalRestore() {
}
}
-SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* props) {
+sk_sp<SkSurface> SkCanvas::makeSurface(const SkImageInfo& info, const SkSurfaceProps* props) {
if (nullptr == props) {
props = &fProps;
}
return this->onNewSurface(info, *props);
}
-SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
+sk_sp<SkSurface> SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
SkBaseDevice* dev = this->getDevice();
- return dev ? dev->newSurface(info, props) : nullptr;
+ return dev ? dev->makeSurface(info, props) : nullptr;
}
SkImageInfo SkCanvas::imageInfo() const {
@@ -3043,3 +3043,9 @@ SkAutoCanvasMatrixPaint::SkAutoCanvasMatrixPaint(SkCanvas* canvas, const SkMatri
SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
fCanvas->restoreToCount(fSaveCount);
}
+
+#ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
+SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* props) {
+ return this->makeSurface(info, props).release();
+}
+#endif
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index fb4b48fdbd..d854520a97 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -452,3 +452,6 @@ uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const {
return flags;
}
+sk_sp<SkSurface> SkBaseDevice::makeSurface(SkImageInfo const&, SkSurfaceProps const&) {
+ return nullptr;
+}
diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp
index f90ac0f1ee..6f4ffa1f5b 100644
--- a/src/core/SkPictureImageGenerator.cpp
+++ b/src/core/SkPictureImageGenerator.cpp
@@ -139,9 +139,8 @@ GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIR
//
// TODO: respect the usage, by possibly creating a different (pow2) surface
//
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kYes,
- surfaceInfo));
- if (!surface.get()) {
+ sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes, surfaceInfo));
+ if (!surface) {
return nullptr;
}
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 2718ee999d..459402b115 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -791,7 +791,7 @@ void SkPictureRecord::onDrawAnnotation(const SkRect& rect, const char key[], SkD
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfaceProps&) {
+sk_sp<SkSurface> SkPictureRecord::onNewSurface(const SkImageInfo& info, const SkSurfaceProps&) {
return nullptr;
}
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 089bc81ee5..129f94f9b3 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -149,7 +149,7 @@ protected:
SkASSERT(fWriter.bytesWritten() == initialOffset + size);
}
- SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
bool onPeekPixels(SkPixmap*) override { return false; }
void willSave() override;
diff --git a/src/core/SkPixmap.cpp b/src/core/SkPixmap.cpp
index 787c92252e..e73440ed2a 100644
--- a/src/core/SkPixmap.cpp
+++ b/src/core/SkPixmap.cpp
@@ -259,8 +259,7 @@ bool SkPixmap::scalePixels(const SkPixmap& dst, SkFilterQuality quality) const {
}
bitmap.setIsVolatile(true); // so we don't try to cache it
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirect(dst.info(), dst.writable_addr(),
- dst.rowBytes()));
+ auto surface(SkSurface::MakeRasterDirect(dst.info(), dst.writable_addr(), dst.rowBytes()));
if (!surface) {
return false;
}
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 4e23da20cc..ff5c27d7e5 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -11,6 +11,7 @@
#include "SkPicture.h"
#include "SkPictureUtils.h"
#include "SkRecorder.h"
+#include "SkSurface.h"
//#define WRAP_BITMAP_AS_IMAGE
@@ -381,3 +382,6 @@ void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
APPEND(ClipRegion, this->devBounds(), deviceRgn, op);
}
+sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfaceProps&) {
+ return nullptr;
+}
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index 44fb839d59..1299efbdd6 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -122,7 +122,7 @@ public:
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
- SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override { return nullptr; }
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
void flushMiniRecorder();
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index ecdd910c19..dfbde75dc7 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -41,7 +41,7 @@ public:
virtual sk_sp<SkImage> onMakeTightSubset(const SkIRect& subset) const = 0;
- virtual SkSurface* onMakeTightSurface(const SkImageInfo& info) const = 0;
+ virtual sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const = 0;
private:
typedef SkSpecialImage INHERITED;
@@ -105,8 +105,7 @@ sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageInfo& info) con
}
sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageInfo& info) const {
- sk_sp<SkSurface> tmp(as_SIB(this)->onMakeTightSurface(info));
- return tmp;
+ return as_SIB(this)->onMakeTightSurface(info);
}
sk_sp<SkSpecialImage> SkSpecialImage::makeSubset(const SkIRect& subset) const {
@@ -244,14 +243,14 @@ public:
return fImage->makeSubset(subset);
}
- SkSurface* onMakeTightSurface(const SkImageInfo& info) const override {
+ sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
#if SK_SUPPORT_GPU
GrTexture* texture = as_IB(fImage.get())->peekTexture();
if (texture) {
- return SkSurface::NewRenderTarget(texture->getContext(), SkBudgeted::kYes, info, 0);
+ return SkSurface::MakeRenderTarget(texture->getContext(), SkBudgeted::kYes, info);
}
#endif
- return SkSurface::NewRaster(info, nullptr);
+ return SkSurface::MakeRaster(info, nullptr);
}
private:
@@ -369,8 +368,8 @@ public:
return SkImage::MakeFromBitmap(subsetBM);
}
- SkSurface* onMakeTightSurface(const SkImageInfo& info) const override {
- return SkSurface::NewRaster(info);
+ sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
+ return SkSurface::MakeRaster(info);
}
private:
@@ -512,8 +511,8 @@ public:
fAlphaType, subTx, SkBudgeted::kYes);
}
- SkSurface* onMakeTightSurface(const SkImageInfo& info) const override {
- return SkSurface::NewRenderTarget(fTexture->getContext(), SkBudgeted::kYes, info);
+ sk_sp<SkSurface> onMakeTightSurface(const SkImageInfo& info) const override {
+ return SkSurface::MakeRenderTarget(fTexture->getContext(), SkBudgeted::kYes, info);
}
private:
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index 5638d8a6b2..f1a51a8fee 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -232,7 +232,7 @@ void GrLayerHoister::DrawLayersToAtlas(GrContext* context,
if (atlased.count() > 0) {
// All the atlased layers are rendered into the same GrTexture
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
+ auto surface(SkSurface::MakeRenderTargetDirect(
atlased[0].fLayer->texture()->asRenderTarget(), &props));
SkCanvas* atlasCanvas = surface->getCanvas();
@@ -334,7 +334,7 @@ void GrLayerHoister::DrawLayers(GrContext* context, const SkTDArray<GrHoistedLay
// Each non-atlased layer has its own GrTexture
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(
+ auto surface(SkSurface::MakeRenderTargetDirect(
layer->texture()->asRenderTarget(), &props));
SkCanvas* layerCanvas = surface->getCanvas();
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 823e9b84ff..f4a1d4ee3e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1799,12 +1799,12 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
}
}
-SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
+sk_sp<SkSurface> SkGpuDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
ASSERT_SINGLE_OWNER
// TODO: Change the signature of newSurface to take a budgeted parameter.
static const SkBudgeted kBudgeted = SkBudgeted::kNo;
- return SkSurface::NewRenderTarget(fContext, kBudgeted, info, fRenderTarget->desc().fSampleCnt,
- &props);
+ return SkSurface::MakeRenderTarget(fContext, kBudgeted, info, fRenderTarget->desc().fSampleCnt,
+ &props);
}
bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture* mainPicture,
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index e57da44c69..8d69e4ce8e 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -180,7 +180,7 @@ private:
SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
- SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override;
+ sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&) override;
SkImageFilter::Cache* getImageFilterCache() override;
diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h
index 8dc2cb6eae..ec5556a50d 100644
--- a/src/image/SkImage_Base.h
+++ b/src/image/SkImage_Base.h
@@ -39,8 +39,8 @@ public:
// but only inspect them (or encode them).
virtual bool getROPixels(SkBitmap*, CachingHint = kAllow_CachingHint) const = 0;
- virtual SkSurface* onNewSurface(const SkImageInfo& info) const {
- return SkSurface::NewRaster(info);
+ virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) const {
+ return SkSurface::MakeRaster(info);
}
// Caller must call unref when they are done.
diff --git a/src/image/SkImage_Generator.cpp b/src/image/SkImage_Generator.cpp
index f8af12a612..44dd7b11f8 100644
--- a/src/image/SkImage_Generator.cpp
+++ b/src/image/SkImage_Generator.cpp
@@ -79,7 +79,7 @@ sk_sp<SkImage> SkImage_Generator::onMakeSubset(const SkIRect& subset) const {
const SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(),
this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
if (!surface) {
return nullptr;
}
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 8f59af14a4..333a96386e 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -42,8 +42,8 @@ public:
bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY, CachingHint) const override;
- SkSurface* onNewSurface(const SkImageInfo& info) const override {
- return SkSurface::NewRenderTarget(fTexture->getContext(), SkBudgeted::kNo, info);
+ sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) const override {
+ return SkSurface::MakeRenderTarget(fTexture->getContext(), SkBudgeted::kNo, info);
}
bool asBitmapForImageFilters(SkBitmap* bitmap) const override;
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 764d5eb290..83daab7c44 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -176,7 +176,7 @@ sk_sp<SkImage> SkImage_Raster::onMakeSubset(const SkIRect& subset) const {
// TODO : could consider heurist of sharing pixels, if subset is pretty close to complete
SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBitmap.alphaType());
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
if (!surface) {
return nullptr;
}
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index bb807ba7a5..b3a65fa7b4 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -172,7 +172,7 @@ sk_sp<SkImage> SkSurface::makeImageSnapshot(SkBudgeted budgeted, ForceUnique uni
return asSB(this)->refCachedImage(budgeted, unique);
}
-SkSurface* SkSurface::newSurface(const SkImageInfo& info) {
+sk_sp<SkSurface> SkSurface::makeSurface(const SkImageInfo& info) {
return asSB(this)->onNewSurface(info);
}
@@ -222,27 +222,28 @@ void SkSurface::prepareForExternalIO() {
#if !SK_SUPPORT_GPU
-SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget*, const SkSurfaceProps*) {
+sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget*, const SkSurfaceProps*) {
return nullptr;
}
-SkSurface* SkSurface::NewRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int,
- const SkSurfaceProps*, GrTextureStorageAllocator) {
+sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int,
+ const SkSurfaceProps*, GrTextureStorageAllocator) {
return nullptr;
}
-SkSurface* SkSurface::NewFromBackendTexture(GrContext*, const GrBackendTextureDesc&,
- const SkSurfaceProps*) {
+sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTextureDesc&,
+ const SkSurfaceProps*) {
return nullptr;
}
-SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext*, const GrBackendRenderTargetDesc&,
- const SkSurfaceProps*) {
+sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext*,
+ const GrBackendRenderTargetDesc&,
+ const SkSurfaceProps*) {
return nullptr;
}
-SkSurface* NewFromBackendTextureAsRenderTarget(GrContext*, const GrBackendTextureDesc&,
- const SkSurfaceProps*) {
+sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext*, const GrBackendTextureDesc&,
+ const SkSurfaceProps*) {
return nullptr;
}
diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h
index 96dd305960..7164c884e0 100644
--- a/src/image/SkSurface_Base.h
+++ b/src/image/SkSurface_Base.h
@@ -35,7 +35,7 @@ public:
*/
virtual SkCanvas* onNewCanvas() = 0;
- virtual SkSurface* onNewSurface(const SkImageInfo&) = 0;
+ virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo&) = 0;
/**
* Allocate an SkImage that represents the current contents of the surface.
@@ -43,7 +43,7 @@ public:
* must faithfully represent the current contents, even if the surface
* is changed after this called (e.g. it is drawn to via its canvas).
*/
- virtual SkImage* onNewImageSnapshot(SkBudgeted, ForceCopyMode) = 0;
+ virtual sk_sp<SkImage> onNewImageSnapshot(SkBudgeted, ForceCopyMode) = 0;
/**
* Default implementation:
@@ -124,7 +124,7 @@ sk_sp<SkImage> SkSurface_Base::refCachedImage(SkBudgeted budgeted, ForceUnique u
}
ForceCopyMode fcm = (kYes_ForceUnique == unique) ? kYes_ForceCopyMode :
kNo_ForceCopyMode;
- snap = this->onNewImageSnapshot(budgeted, fcm);
+ snap = this->onNewImageSnapshot(budgeted, fcm).release();
if (kNo_ForceUnique == unique) {
SkASSERT(!fCachedImage);
fCachedImage = SkSafeRef(snap);
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 649db129c3..a023acd9a2 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -68,16 +68,16 @@ SkCanvas* SkSurface_Gpu::onNewCanvas() {
return new SkCanvas(fDevice, flags);
}
-SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
+sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
GrRenderTarget* rt = fDevice->accessRenderTarget();
int sampleCount = rt->numColorSamples();
// TODO: Make caller specify this (change virtual signature of onNewSurface).
static const SkBudgeted kBudgeted = SkBudgeted::kNo;
- return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampleCount,
- &this->props());
+ return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, sampleCount,
+ &this->props());
}
-SkImage* SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode forceCopyMode) {
+sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode forceCopyMode) {
GrRenderTarget* rt = fDevice->accessRenderTarget();
SkASSERT(rt);
GrTexture* tex = rt->asTexture();
@@ -99,10 +99,10 @@ SkImage* SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode fo
tex = copy;
}
const SkImageInfo info = fDevice->imageInfo();
- SkImage* image = nullptr;
+ sk_sp<SkImage> image;
if (tex) {
- image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUniqueID,
- info.alphaType(), tex, budgeted);
+ image = sk_make_sp<SkImage_Gpu>(info.width(), info.height(), kNeedNewImageUniqueID,
+ info.alphaType(), tex, budgeted);
}
return image;
}
@@ -134,29 +134,32 @@ void SkSurface_Gpu::onPrepareForExternalIO() {
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurfaceProps* props) {
+sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target,
+ const SkSurfaceProps* props) {
SkAutoTUnref<SkGpuDevice> device(
SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents));
if (!device) {
return nullptr;
}
- return new SkSurface_Gpu(device);
+ return sk_make_sp<SkSurface_Gpu>(device);
}
-SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, SkBudgeted budgeted, const SkImageInfo& info,
- int sampleCount, const SkSurfaceProps* props,
- GrTextureStorageAllocator customAllocator) {
+sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted,
+ const SkImageInfo& info, int sampleCount,
+ const SkSurfaceProps* props,
+ GrTextureStorageAllocator customAllocator) {
SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(
ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitContents,
customAllocator));
if (!device) {
return nullptr;
}
- return new SkSurface_Gpu(device);
+ return sk_make_sp<SkSurface_Gpu>(device);
}
-SkSurface* SkSurface::NewFromBackendTexture(GrContext* context, const GrBackendTextureDesc& desc,
- const SkSurfaceProps* props) {
+sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
+ const GrBackendTextureDesc& desc,
+ const SkSurfaceProps* props) {
if (nullptr == context) {
return nullptr;
}
@@ -173,12 +176,12 @@ SkSurface* SkSurface::NewFromBackendTexture(GrContext* context, const GrBackendT
if (!device) {
return nullptr;
}
- return new SkSurface_Gpu(device);
+ return sk_make_sp<SkSurface_Gpu>(device);
}
-SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext* context,
- const GrBackendRenderTargetDesc& desc,
- const SkSurfaceProps* props) {
+sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
+ const GrBackendRenderTargetDesc& desc,
+ const SkSurfaceProps* props) {
if (nullptr == context) {
return nullptr;
}
@@ -191,12 +194,12 @@ SkSurface* SkSurface::NewFromBackendRenderTarget(GrContext* context,
if (!device) {
return nullptr;
}
- return new SkSurface_Gpu(device);
+ return sk_make_sp<SkSurface_Gpu>(device);
}
-SkSurface* SkSurface::NewFromBackendTextureAsRenderTarget(GrContext* context,
- const GrBackendTextureDesc& desc,
- const SkSurfaceProps* props) {
+sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* context,
+ const GrBackendTextureDesc& desc,
+ const SkSurfaceProps* props) {
if (nullptr == context) {
return nullptr;
}
@@ -210,7 +213,7 @@ SkSurface* SkSurface::NewFromBackendTextureAsRenderTarget(GrContext* context,
if (!device) {
return nullptr;
}
- return new SkSurface_Gpu(device);
+ return sk_make_sp<SkSurface_Gpu>(device);
}
#endif
diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h
index 72e9caf462..1e76f26c2a 100644
--- a/src/image/SkSurface_Gpu.h
+++ b/src/image/SkSurface_Gpu.h
@@ -22,8 +22,8 @@ public:
GrBackendObject onGetTextureHandle(BackendHandleAccess) override;
bool onGetRenderTargetHandle(GrBackendObject*, BackendHandleAccess) override;
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 onCopyOnWrite(ContentChangeMode) override;
void onDiscard() override;
void onPrepareForExternalIO() override;
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index b5844d1f5b..8c9c154a9c 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -23,8 +23,8 @@ public:
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 @@ SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr, const SkSurfaceProps* props)
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 @@ void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
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 @@ SkImage* SkSurface_Raster::onNewImageSnapshot(SkBudgeted, ForceCopyMode forceCop
// 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 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
///////////////////////////////////////////////////////////////////////////////
-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 @@ SkSurface* SkSurface::NewRasterDirectReleaseProc(const SkImageInfo& info, void*
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 @@ SkSurface* SkSurface::NewRaster(const SkImageInfo& info, size_t rowBytes,
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);
}
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 66048ff751..9ab3b0d7e0 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1412,8 +1412,8 @@ void SkPDFDevice::onDetachFromCanvas() {
fClipStack = nullptr;
}
-SkSurface* SkPDFDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
- return SkSurface::NewRaster(info, &props);
+sk_sp<SkSurface> SkPDFDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
+ return SkSurface::MakeRaster(info, &props);
}
ContentEntry* SkPDFDevice::getLastContentEntry() {
@@ -2115,8 +2115,7 @@ static SkSize rect_to_size(const SkRect& r) {
}
static const SkImage* color_filter(const SkImage* image, SkColorFilter* colorFilter) {
- sk_sp<SkSurface> surface(SkSurface::NewRaster(
- SkImageInfo::MakeN32Premul(image->dimensions())));
+ auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(image->dimensions())));
if (!surface) {
return image;
}
@@ -2194,8 +2193,7 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix,
SkISize wh = rect_to_size(physicalPerspectiveBounds).toCeil();
- sk_sp<SkSurface> surface(
- SkSurface::NewRaster(SkImageInfo::MakeN32Premul(wh)));
+ auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(wh)));
if (!surface) {
return;
}
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index 138ec19b59..cfc2b546e8 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -195,7 +195,7 @@ protected:
return fLegacyBitmap;
}
- SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override;
+ sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&) override;
void drawAnnotation(const SkDraw&, const SkRect&, const char key[], SkData* value) override;
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index d0b6a4b1ac..c25bbf4409 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -716,11 +716,11 @@ static int lcanvas_newSurface(lua_State* L) {
int width = lua2int_def(L, 2, 0);
int height = lua2int_def(L, 3, 0);
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- SkSurface* surface = get_ref<SkCanvas>(L, 1)->newSurface(info);
+ auto surface = get_ref<SkCanvas>(L, 1)->makeSurface(info);
if (nullptr == surface) {
lua_pushnil(L);
} else {
- push_ref(L, surface)->unref();
+ push_ref(L, surface);
}
return 1;
}
@@ -1769,11 +1769,11 @@ static int lsurface_newSurface(lua_State* L) {
int width = lua2int_def(L, 2, 0);
int height = lua2int_def(L, 3, 0);
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- SkSurface* surface = get_ref<SkSurface>(L, 1)->newSurface(info);
+ auto surface = get_ref<SkSurface>(L, 1)->makeSurface(info);
if (nullptr == surface) {
lua_pushnil(L);
} else {
- push_ref(L, surface)->unref();
+ push_ref(L, surface);
}
return 1;
}
@@ -2063,11 +2063,11 @@ static int lsk_newRasterSurface(lua_State* L) {
int height = lua2int_def(L, 2, 0);
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- SkSurface* surface = SkSurface::NewRaster(info, &props);
+ auto surface = SkSurface::MakeRaster(info, &props);
if (nullptr == surface) {
lua_pushnil(L);
} else {
- push_ref(L, surface)->unref();
+ push_ref(L, surface);
}
return 1;
}
diff --git a/src/utils/SkRGBAToYUV.cpp b/src/utils/SkRGBAToYUV.cpp
index eebbda4869..63d9152362 100644
--- a/src/utils/SkRGBAToYUV.cpp
+++ b/src/utils/SkRGBAToYUV.cpp
@@ -38,7 +38,7 @@ bool SkRGBAToYUV(const SkImage* image, const SkISize sizes[3], void* const plane
for (int i = 0; i < 3; ++i) {
size_t rb = rowBytes[i] ? rowBytes[i] : sizes[i].fWidth;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirect(
+ auto surface(SkSurface::MakeRasterDirect(
SkImageInfo::MakeA8(sizes[i].fWidth, sizes[i].fHeight), planes[i], rb));
if (!surface) {
return false;
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index 056b3eab50..481a1f9eb2 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -32,7 +32,8 @@ SkWindow::~SkWindow() {
SkSurface* SkWindow::createSurface() {
const SkBitmap& bm = this->getBitmap();
- return SkSurface::NewRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(), &fSurfaceProps);
+ return SkSurface::MakeRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(),
+ &fSurfaceProps).release();
}
void SkWindow::setMatrix(const SkMatrix& matrix) {