diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 4 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 12 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 3 | ||||
-rw-r--r-- | src/core/SkPictureImageGenerator.cpp | 5 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 2 | ||||
-rw-r--r-- | src/core/SkPictureRecord.h | 2 | ||||
-rw-r--r-- | src/core/SkPixmap.cpp | 3 | ||||
-rw-r--r-- | src/core/SkRecorder.cpp | 4 | ||||
-rw-r--r-- | src/core/SkRecorder.h | 2 | ||||
-rw-r--r-- | src/core/SkSpecialImage.cpp | 19 |
10 files changed, 33 insertions, 23 deletions
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: |