From f7129fc173b2ff9c9a6915fe62c19758679bc3f4 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Tue, 4 Aug 2020 14:07:40 -0400 Subject: [PATCH] Migrate MakeFromAdoptedTexture to GrRecordingContext This also follows up on the comments Rob left in his zombie review. Bug: skia:104662 Change-Id: I7031f7b2832eb3f47025e5d269248b854cc912e0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307780 Reviewed-by: Robert Phillips Reviewed-by: Mike Reed Commit-Queue: Mike Reed Auto-Submit: Adlai Holler --- gm/rectangletexture.cpp | 2 +- include/core/SkImage.h | 16 +++++----------- src/image/SkImage.cpp | 11 +---------- src/image/SkImage_Gpu.cpp | 15 +++------------ 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/gm/rectangletexture.cpp b/gm/rectangletexture.cpp index 949e9b5c15..e316f6b421 100644 --- a/gm/rectangletexture.cpp +++ b/gm/rectangletexture.cpp @@ -99,7 +99,7 @@ private: SkASSERT(content.colorType() == kRGBA_8888_SkColorType); auto format = GrBackendFormat::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_RECTANGLE); auto bet = dContext->createBackendTexture(content.width(), content.height(), format, - GrMipmapped::kNo, GrRenderable::kNo); + GrMipmapped::kNo, GrRenderable::kNo); if (!bet.isValid()) { return nullptr; } diff --git a/include/core/SkImage.h b/include/core/SkImage.h index f6a2cab4c7..621f11ef75 100644 --- a/include/core/SkImage.h +++ b/include/core/SkImage.h @@ -397,25 +397,19 @@ public: @param context GPU context @param backendTexture texture residing on GPU + @param imageOrigin origin of the resulting image + @param colorType color type of the resulting image + @param alphaType alpha type of the resulting image @param colorSpace range of colors; may be nullptr @return created SkImage, or nullptr */ - static sk_sp MakeFromAdoptedTexture(GrDirectContext* context, + static sk_sp MakeFromAdoptedTexture(GrRecordingContext* context, const GrBackendTexture& backendTexture, - GrSurfaceOrigin surfaceOrigin, + GrSurfaceOrigin imageOrigin, SkColorType colorType, SkAlphaType alphaType = kPremul_SkAlphaType, sk_sp colorSpace = nullptr); -#ifdef SK_IMAGE_MAKE_FROM_ADOPTED_TEXTURE_LEGACY_API - static sk_sp MakeFromAdoptedTexture(GrContext* context, - const GrBackendTexture& backendTexture, - GrSurfaceOrigin surfaceOrigin, - SkColorType colorType, - SkAlphaType alphaType = kPremul_SkAlphaType, - sk_sp colorSpace = nullptr); -#endif - /** Creates an SkImage by flattening the specified YUVA planes into a single, interleaved RGBA image. diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index 41ed4c4740..5abd4aceb3 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -541,22 +541,13 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext*, return false; } -sk_sp SkImage::MakeFromAdoptedTexture(GrDirectContext*, +sk_sp SkImage::MakeFromAdoptedTexture(GrRecordingContext*, const GrBackendTexture&, GrSurfaceOrigin, SkColorType, SkAlphaType, sk_sp) { return nullptr; } -#ifdef SK_IMAGE_MAKE_FROM_ADOPTED_TEXTURE_LEGACY_API -sk_sp SkImage::MakeFromAdoptedTexture(GrContext*, - const GrBackendTexture&, GrSurfaceOrigin, - SkColorType, SkAlphaType, - sk_sp) { - return nullptr; -} -#endif - sk_sp SkImage::MakeFromYUVATexturesCopy(GrRecordingContext*, SkYUVColorSpace, const GrBackendTexture[], diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 3b9415b316..532ffa499c 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -251,11 +251,12 @@ sk_sp SkImage::MakeFromTexture(GrContext* ctx, kBorrow_GrWrapOwnership, std::move(releaseHelper)); } -sk_sp SkImage::MakeFromAdoptedTexture(GrDirectContext* dContext, +sk_sp SkImage::MakeFromAdoptedTexture(GrRecordingContext* rContext, const GrBackendTexture& tex, GrSurfaceOrigin origin, SkColorType ct, SkAlphaType at, sk_sp cs) { - if (!dContext || !dContext->priv().resourceProvider()) { + auto dContext = GrAsDirectContext(rContext); + if (!dContext) { // We have a DDL context and we don't support adopted textures for them. return nullptr; } @@ -275,16 +276,6 @@ sk_sp SkImage::MakeFromAdoptedTexture(GrDirectContext* dContext, kAdopt_GrWrapOwnership, nullptr); } -#ifdef SK_IMAGE_MAKE_FROM_ADOPTED_TEXTURE_LEGACY_API -sk_sp SkImage::MakeFromAdoptedTexture(GrContext* ctx, - const GrBackendTexture& tex, GrSurfaceOrigin origin, - SkColorType ct, SkAlphaType at, - sk_sp cs) { - return SkImage::MakeFromAdoptedTexture(GrAsDirectContext(ctx), tex, origin, ct, - at, std::move(cs)); -} -#endif - sk_sp SkImage::MakeTextureFromCompressed(GrDirectContext* direct, sk_sp data, int width, int height, CompressionType type, GrMipmapped mipMapped,