diff options
author | 2016-05-11 05:15:55 -0700 | |
---|---|---|
committer | 2016-05-11 05:15:56 -0700 | |
commit | 677da9d4af2558ddd50a900e90a093d1b522bd5f (patch) | |
tree | 4a6252fd10a9fa9e66562f602e18455e4179af22 /src/gpu | |
parent | 2139303e4c0a9cbcfac695977a80eb026a9296ab (diff) |
Minor GrRenderTarget retraction
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1967743003
Review-Url: https://codereview.chromium.org/1967743003
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrYUVProvider.cpp | 24 | ||||
-rw-r--r-- | src/gpu/GrYUVProvider.h | 2 | ||||
-rw-r--r-- | src/gpu/SkGr.cpp | 13 |
3 files changed, 16 insertions, 23 deletions
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp index 6cd7c959b0..b4320d0b02 100644 --- a/src/gpu/GrYUVProvider.cpp +++ b/src/gpu/GrYUVProvider.cpp @@ -80,7 +80,9 @@ bool YUVScoper::init(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo, v return true; } -GrTexture* GrYUVProvider::refAsTexture(GrContext* ctx, const GrSurfaceDesc& desc, bool useCache) { +sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx, + const GrSurfaceDesc& desc, + bool useCache) { SkYUVPlanesCache::Info yuvInfo; void* planes[3]; YUVScoper scoper; @@ -110,18 +112,13 @@ GrTexture* GrYUVProvider::refAsTexture(GrContext* ctx, const GrSurfaceDesc& desc } } - GrSurfaceDesc rtDesc = desc; - rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; - - SkAutoTUnref<GrTexture> result(ctx->textureProvider()->createTexture(rtDesc, SkBudgeted::kYes, - nullptr, 0)); - if (!result) { + sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact, + desc.fWidth, desc.fHeight, + desc.fConfig, desc.fSampleCnt)); + if (!drawContext) { return nullptr; } - GrRenderTarget* renderTarget = result->asRenderTarget(); - SkASSERT(renderTarget); - GrPaint paint; // We may be decoding an sRGB image, but the result of our linear math on the YUV planes // is already in sRGB in that case. Don't convert (which will make the image too bright). @@ -137,12 +134,7 @@ GrTexture* GrYUVProvider::refAsTexture(GrContext* ctx, const GrSurfaceDesc& desc const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth, yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); - sk_sp<GrDrawContext> drawContext(ctx->drawContext(sk_ref_sp(renderTarget))); - if (!drawContext) { - return nullptr; - } - drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), r); - return result.release(); + return drawContext->asTexture(); } diff --git a/src/gpu/GrYUVProvider.h b/src/gpu/GrYUVProvider.h index 85b238d098..c32af15df0 100644 --- a/src/gpu/GrYUVProvider.h +++ b/src/gpu/GrYUVProvider.h @@ -35,7 +35,7 @@ public: * * On failure (e.g. the provider had no data), this returns NULL. */ - GrTexture* refAsTexture(GrContext*, const GrSurfaceDesc&, bool useCache); + sk_sp<GrTexture> refAsTexture(GrContext*, const GrSurfaceDesc&, bool useCache); virtual uint32_t onGetID() = 0; diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index f1f48bc960..120db1348c 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -181,8 +181,8 @@ public: } }; -static GrTexture* create_texture_from_yuv(GrContext* ctx, const SkBitmap& bm, - const GrSurfaceDesc& desc) { +static sk_sp<GrTexture> create_texture_from_yuv(GrContext* ctx, const SkBitmap& bm, + const GrSurfaceDesc& desc) { // Subsets are not supported, the whole pixelRef is loaded when using YUV decoding SkPixelRef* pixelRef = bm.pixelRef(); if ((nullptr == pixelRef) || @@ -218,8 +218,9 @@ GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bitmap) { return texture; } - if (GrTexture* texture = create_texture_from_yuv(ctx, bitmap, desc)) { - return texture; + sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc)); + if (texture) { + return texture.release(); } SkAutoLockPixels alp(bitmap); @@ -339,9 +340,9 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b } } - GrTexture* texture = create_texture_from_yuv(ctx, bitmap, desc); + sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc)); if (texture) { - return texture; + return texture.release(); } // SkMipMap::Build doesn't handle sRGB data correctly (yet). |