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
This commit is contained in:
parent
2139303e4c
commit
677da9d4af
@ -69,9 +69,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
|
||||
}
|
||||
|
||||
GrSurfaceDesc desc;
|
||||
// use RT flag bit because in GL it makes the texture be bottom-up
|
||||
desc.fFlags = i ? kRenderTarget_GrSurfaceFlag :
|
||||
kNone_GrSurfaceFlags;
|
||||
desc.fOrigin = i ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
|
||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||
desc.fWidth = 2 * S;
|
||||
desc.fHeight = 2 * S;
|
||||
|
@ -291,11 +291,11 @@ GrTexture* SkImageCacherator::lockTexture(GrContext* ctx, const GrUniqueKey& key
|
||||
{
|
||||
ScopedGenerator generator(this);
|
||||
Generator_GrYUVProvider provider(generator);
|
||||
GrTexture* tex = provider.refAsTexture(ctx, desc, true);
|
||||
sk_sp<GrTexture> tex = provider.refAsTexture(ctx, desc, true);
|
||||
if (tex) {
|
||||
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
|
||||
kLockTexturePathCount);
|
||||
return set_key_and_return(tex, key);
|
||||
return set_key_and_return(tex.release(), key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user