Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 1789443002: Revert "Revert of add Make variations to return SkImage by sk_sp (patchset #5 id:80001 of https://c… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use get, not release, when calling legacy function that wants ptr Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Gpu.cpp
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index b87e50ba0ae932960422a39ce6f91a7b49c5322f..6494fd1a17a4abade008b5f9b71eda7dddc74ffa 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -134,7 +134,7 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t row
return true;
}
-SkImage* SkImage_Gpu::onNewSubset(const SkIRect& subset) const {
+sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const {
GrContext* ctx = fTexture->getContext();
GrSurfaceDesc desc = fTexture->desc();
desc.fWidth = subset.width();
@@ -145,16 +145,16 @@ SkImage* SkImage_Gpu::onNewSubset(const SkIRect& subset) const {
return nullptr;
}
ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0));
- return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, fAlphaType, subTx,
- fBudgeted);
+ return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
+ fAlphaType, subTx, fBudgeted);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
-static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc,
- SkAlphaType at, GrWrapOwnership ownership,
- SkImage::TextureReleaseProc releaseProc,
- SkImage::ReleaseContext releaseCtx) {
+static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc,
+ SkAlphaType at, GrWrapOwnership ownership,
+ SkImage::TextureReleaseProc releaseProc,
+ SkImage::ReleaseContext releaseCtx) {
if (desc.fWidth <= 0 || desc.fHeight <= 0) {
return nullptr;
}
@@ -167,21 +167,23 @@ static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextur
}
const SkBudgeted budgeted = SkBudgeted::kNo;
- return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex, budgeted);
+ return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
+ at, tex, budgeted);
}
-SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, SkAlphaType at,
- TextureReleaseProc releaseP, ReleaseContext releaseC) {
+sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
+ SkAlphaType at, TextureReleaseProc releaseP,
+ ReleaseContext releaseC) {
return new_wrapped_texture_common(ctx, desc, at, kBorrow_GrWrapOwnership, releaseP, releaseC);
}
-SkImage* SkImage::NewFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
- SkAlphaType at) {
+sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
+ SkAlphaType at) {
return new_wrapped_texture_common(ctx, desc, at, kAdopt_GrWrapOwnership, nullptr, nullptr);
}
-SkImage* SkImage::NewFromTextureCopy(GrContext* ctx, const GrBackendTextureDesc& desc,
- SkAlphaType at) {
+sk_sp<SkImage> SkImage::MakeFromTextureCopy(GrContext* ctx, const GrBackendTextureDesc& desc,
+ SkAlphaType at) {
if (desc.fWidth <= 0 || desc.fHeight <= 0) {
return nullptr;
}
@@ -197,14 +199,14 @@ SkImage* SkImage::NewFromTextureCopy(GrContext* ctx, const GrBackendTextureDesc&
return nullptr;
}
- return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst,
- SkBudgeted::kYes);
+ return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst,
+ SkBudgeted::kYes);
}
-SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorSpace,
- const GrBackendObject yuvTextureHandles[3],
- const SkISize yuvSizes[3],
- GrSurfaceOrigin origin) {
+sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorSpace,
+ const GrBackendObject yuvTextureHandles[3],
+ const SkISize yuvSizes[3],
+ GrSurfaceOrigin origin) {
const SkBudgeted budgeted = SkBudgeted::kYes;
if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 ||
@@ -275,25 +277,25 @@ SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorS
drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect);
ctx->flushSurfaceWrites(dst);
- return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
- kOpaque_SkAlphaType, dst, budgeted);
+ return sk_make_sp<SkImage_Gpu>(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
+ kOpaque_SkAlphaType, dst, budgeted);
}
-static SkImage* create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
+static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
SkAutoTUnref<GrTexture> texture(maker->refTextureForParams(GrTextureParams::ClampNoFilter()));
if (!texture) {
return nullptr;
}
- return new SkImage_Gpu(texture->width(), texture->height(), id, at, texture,
- SkBudgeted::kNo);
+ return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), id, at, texture,
+ SkBudgeted::kNo);
}
-SkImage* SkImage::newTextureImage(GrContext *context) const {
+sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const {
if (!context) {
return nullptr;
}
if (GrTexture* peek = as_IB(this)->peekTexture()) {
- return peek->getContext() == context ? SkRef(const_cast<SkImage*>(this)) : nullptr;
+ return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(this)) : nullptr;
}
// No way to check whether a image is premul or not?
SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
@@ -310,8 +312,8 @@ SkImage* SkImage::newTextureImage(GrContext *context) const {
return create_image_from_maker(&maker, at, this->uniqueID());
}
-SkImage* SkImage::NewTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap,
- SkBudgeted budgeted) {
+sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap,
+ SkBudgeted budgeted) {
if (!ctx) {
return nullptr;
}
@@ -319,8 +321,8 @@ SkImage* SkImage::NewTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap,
if (!texture) {
return nullptr;
}
- return new SkImage_Gpu(texture->width(), texture->height(), kNeedNewImageUniqueID,
- pixmap.alphaType(), texture, budgeted);
+ return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
+ pixmap.alphaType(), texture, budgeted);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698