diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp index 74996296d7..6614c9944c 100644 --- a/gm/image_pict.cpp +++ b/gm/image_pict.cpp @@ -156,7 +156,7 @@ public: surface->getCanvas()->translate(-100, -100); surface->getCanvas()->drawPicture(pic); sk_sp image(surface->makeImageSnapshot()); - fProxy = as_IB(image)->asTextureProxyRef(); + fProxy = as_IB(image)->asTextureProxyRef(fCtx.get()); } } protected: diff --git a/src/core/SkPictureImageGenerator.cpp b/src/core/SkPictureImageGenerator.cpp index ed3cbfa52f..ac34a3eb7d 100644 --- a/src/core/SkPictureImageGenerator.cpp +++ b/src/core/SkPictureImageGenerator.cpp @@ -119,7 +119,7 @@ sk_sp SkPictureImageGenerator::onGenerateTexture( if (!image) { return nullptr; } - sk_sp proxy = as_IB(image)->asTextureProxyRef(); + sk_sp proxy = as_IB(image)->asTextureProxyRef(ctx); SkASSERT(!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped()); return proxy; } diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp index 92bb57af36..008181542d 100644 --- a/src/core/SkSpecialImage.cpp +++ b/src/core/SkSpecialImage.cpp @@ -193,7 +193,7 @@ sk_sp SkSpecialImage::MakeFromImage(GrRecordingContext* context, SkASSERT(rect_fits(subset, image->width(), image->height())); #if SK_SUPPORT_GPU - if (sk_sp proxy = as_IB(image)->asTextureProxyRef()) { + if (sk_sp proxy = as_IB(image)->asTextureProxyRef(context)) { if (!as_IB(image)->context()->priv().matches(context)) { return nullptr; } diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp index b412cf016e..c1f7a20c7c 100644 --- a/src/gpu/GrImageTextureMaker.cpp +++ b/src/gpu/GrImageTextureMaker.cpp @@ -61,9 +61,9 @@ sk_sp GrYUVAImageTextureMaker::refOriginalTextureProxy(bool will } if (willBeMipped) { - return fImage->asMippedTextureProxyRef(); + return fImage->asMippedTextureProxyRef(this->context()); } else { - return fImage->asTextureProxyRef(); + return fImage->asTextureProxyRef(this->context()); } } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 16c5cf820d..1dc594ba39 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1192,7 +1192,7 @@ sk_sp SkGpuDevice::makeSpecial(const SkBitmap& bitmap) { sk_sp SkGpuDevice::makeSpecial(const SkImage* image) { SkPixmap pm; if (image->isTextureBacked()) { - sk_sp proxy = as_IB(image)->asTextureProxyRef(); + sk_sp proxy = as_IB(image)->asTextureProxyRef(this->context()); return SkSpecialImage::MakeDeferredFromGpu(fContext.get(), SkIRect::MakeWH(image->width(), image->height()), @@ -1316,7 +1316,8 @@ void SkGpuDevice::drawImageNine(const SkImage* image, ASSERT_SINGLE_OWNER uint32_t pinnedUniqueID; auto iter = skstd::make_unique(image->width(), image->height(), center, dst); - if (sk_sp proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) { + if (sk_sp proxy = as_IB(image)->refPinnedTextureProxy(this->context(), + &pinnedUniqueID)) { GrTextureAdjuster adjuster(this->context(), std::move(proxy), image->alphaType(), pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace()); @@ -1376,7 +1377,8 @@ void SkGpuDevice::drawImageLattice(const SkImage* image, ASSERT_SINGLE_OWNER uint32_t pinnedUniqueID; auto iter = skstd::make_unique(lattice, dst); - if (sk_sp proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) { + if (sk_sp proxy = as_IB(image)->refPinnedTextureProxy(this->context(), + &pinnedUniqueID)) { GrTextureAdjuster adjuster(this->context(), std::move(proxy), image->alphaType(), pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace()); diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp index da2c887818..5b505060ea 100644 --- a/src/gpu/SkGpuDevice_drawTexture.cpp +++ b/src/gpu/SkGpuDevice_drawTexture.cpp @@ -389,7 +389,8 @@ void SkGpuDevice::drawImageQuad(const SkImage* image, const SkRect* srcRect, con // Pinned texture proxies can be rendered directly as textures, or with relatively simple // adjustments applied to the image content (scaling, mipmaps, color space, etc.) uint32_t pinnedUniqueID; - if (sk_sp proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) { + if (sk_sp proxy = as_IB(image)->refPinnedTextureProxy(this->context(), + &pinnedUniqueID)) { SK_HISTOGRAM_BOOLEAN("DrawTiled", false); LogDrawScaleFactor(this->ctm(), srcToDst, paint.getFilterQuality()); @@ -509,7 +510,8 @@ void SkGpuDevice::tmp_drawImageSetV2(const SkCanvas::ImageSetEntry set[], int ds } uint32_t uniqueID; - textures[i].fProxy = as_IB(set[i].fImage.get())->refPinnedTextureProxy(&uniqueID); + textures[i].fProxy = as_IB(set[i].fImage.get())->refPinnedTextureProxy(this->context(), + &uniqueID); if (!textures[i].fProxy) { // FIXME(michaelludwig) - If asTextureProxyRef fails, does going through drawImageQuad // make sense? Does that catch the lazy-image cases then? diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp index c9064831fc..509b6f8cb7 100644 --- a/src/image/SkImage.cpp +++ b/src/image/SkImage.cpp @@ -141,7 +141,13 @@ sk_sp SkImage::makeSubset(const SkIRect& subset) const { if (bounds == subset) { return sk_ref_sp(const_cast(this)); } - return as_IB(this)->onMakeSubset(subset); + + // CONTEXT TODO: propagate the context parameter to the top-level API +#if SK_SUPPORT_GPU + return as_IB(this)->onMakeSubset(as_IB(this)->context(), subset); +#else + return as_IB(this)->onMakeSubset(nullptr, subset); +#endif } #if SK_SUPPORT_GPU @@ -321,7 +327,13 @@ sk_sp SkImage::makeColorSpace(sk_sp target) const { return sk_ref_sp(const_cast(this)); } - return as_IB(this)->onMakeColorTypeAndColorSpace(this->colorType(), std::move(target)); + // CONTEXT TODO: propagate the context parameter to the top-level API +#if SK_SUPPORT_GPU + return as_IB(this)->onMakeColorTypeAndColorSpace(as_IB(this)->context(), +#else + return as_IB(this)->onMakeColorTypeAndColorSpace(nullptr, +#endif + this->colorType(), std::move(target)); } sk_sp SkImage::makeColorTypeAndColorSpace(SkColorType targetColorType, @@ -340,7 +352,13 @@ sk_sp SkImage::makeColorTypeAndColorSpace(SkColorType targetColorType, return sk_ref_sp(const_cast(this)); } - return as_IB(this)->onMakeColorTypeAndColorSpace(targetColorType, std::move(targetColorSpace)); + // CONTEXT TODO: propagate the context parameter to the top-level API +#if SK_SUPPORT_GPU + return as_IB(this)->onMakeColorTypeAndColorSpace(as_IB(this)->context(), +#else + return as_IB(this)->onMakeColorTypeAndColorSpace(nullptr, +#endif + targetColorType, std::move(targetColorSpace)); } sk_sp SkImage::makeNonTextureImage() const { diff --git a/src/image/SkImage_Base.h b/src/image/SkImage_Base.h index 170a0b1065..bb1a981ac9 100644 --- a/src/image/SkImage_Base.h +++ b/src/image/SkImage_Base.h @@ -57,10 +57,11 @@ public: // will return nullptr unless the YUVA planes have been converted to RGBA in which case // that single backing proxy will be returned. virtual GrTextureProxy* peekProxy() const { return nullptr; } - virtual sk_sp asTextureProxyRef() const { return nullptr; } + virtual sk_sp asTextureProxyRef(GrRecordingContext*) const { return nullptr; } virtual sk_sp asTextureProxyRef(GrRecordingContext*, const GrSamplerState&, SkScalar scaleAdjust[2]) const = 0; - virtual sk_sp refPinnedTextureProxy(uint32_t* uniqueID) const { + virtual sk_sp refPinnedTextureProxy(GrRecordingContext*, + uint32_t* uniqueID) const { return nullptr; } virtual bool isYUVA() const { return false; } @@ -75,7 +76,7 @@ public: // but only inspect them (or encode them). virtual bool getROPixels(SkBitmap*, CachingHint = kAllow_CachingHint) const = 0; - virtual sk_sp onMakeSubset(const SkIRect&) const = 0; + virtual sk_sp onMakeSubset(GrRecordingContext*, const SkIRect&) const = 0; virtual sk_sp getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4], SkYUVColorSpace*, const void* planes[4]); @@ -100,7 +101,8 @@ public: virtual bool onPinAsTexture(GrContext*) const { return false; } virtual void onUnpinAsTexture(GrContext*) const {} - virtual sk_sp onMakeColorTypeAndColorSpace(SkColorType, sk_sp) const = 0; + virtual sk_sp onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType, sk_sp) const = 0; protected: SkImage_Base(int width, int height, uint32_t uniqueID); diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index cbe83dd85f..33f77cfe59 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -23,6 +23,8 @@ #include "GrGpu.h" #include "GrImageTextureMaker.h" #include "GrProxyProvider.h" +#include "GrRecordingContext.h" +#include "GrRecordingContextPriv.h" #include "GrRenderTargetContext.h" #include "GrResourceProvider.h" #include "GrResourceProviderPriv.h" @@ -63,13 +65,18 @@ SkImageInfo SkImage_Gpu::onImageInfo() const { return SkImageInfo::Make(fProxy->width(), fProxy->height(), colorType, fAlphaType, fColorSpace); } -sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT, +sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* context, + SkColorType targetCT, sk_sp targetCS) const { + if (!context || !fContext->priv().matches(context)) { + return nullptr; + } + auto xform = GrColorSpaceXformEffect::Make(fColorSpace.get(), fAlphaType, targetCS.get(), fAlphaType); SkASSERT(xform || targetCT != this->colorType()); - sk_sp proxy = this->asTextureProxyRef(); + sk_sp proxy = this->asTextureProxyRef(context); GrBackendFormat format = proxy->backendFormat().makeTexture2D(); if (!format.isValid()) { @@ -77,7 +84,7 @@ sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT, } sk_sp renderTargetContext( - fContext->priv().makeDeferredRenderTargetContextWithFallback( + context->priv().makeDeferredRenderTargetContextWithFallback( format, SkBackingFit::kExact, this->width(), this->height(), SkColorType2GrPixelConfig(targetCT), nullptr)); if (!renderTargetContext) { @@ -359,7 +366,7 @@ sk_sp SkImage::makeTextureImage(GrContext* context, SkColorSpace* dstCo return nullptr; } - sk_sp proxy = as_IB(this)->asTextureProxyRef(); + sk_sp proxy = as_IB(this)->asTextureProxyRef(context); SkASSERT(proxy); if (GrMipMapped::kNo == mipMapped || proxy->mipMapped() == mipMapped) { return sk_ref_sp(const_cast(this)); @@ -706,7 +713,7 @@ bool SkImage::MakeBackendTextureFromSkImage(GrContext* ctx, if (!image->unique() || !texture->surfacePriv().hasUniqueRef() || texture->resourcePriv().refsWrappedObjects()) { // onMakeSubset will always copy the image. - image = as_IB(image)->onMakeSubset(image->bounds()); + image = as_IB(image)->onMakeSubset(ctx, image->bounds()); if (!image) { return false; } diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h index 5a6116273f..e05ec6c67b 100644 --- a/src/image/SkImage_Gpu.h +++ b/src/image/SkImage_Gpu.h @@ -31,13 +31,14 @@ public: GrTextureProxy* peekProxy() const override { return fProxy.get(); } - sk_sp asTextureProxyRef() const override { + sk_sp asTextureProxyRef(GrRecordingContext*) const override { return fProxy; } bool onIsTextureBacked() const override { return SkToBool(fProxy.get()); } - sk_sp onMakeColorTypeAndColorSpace(SkColorType, sk_sp) const final; + sk_sp onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType, sk_sp) const final; /** * This is the implementation of SkDeferredDisplayListRecorder::makePromiseImage. diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp index 0c42f8fd37..2618dd4276 100644 --- a/src/image/SkImage_GpuBase.cpp +++ b/src/image/SkImage_GpuBase.cpp @@ -10,6 +10,8 @@ #include "GrClip.h" #include "GrContext.h" #include "GrContextPriv.h" +#include "GrRecordingContext.h" +#include "GrRecordingContextPriv.h" #include "GrRenderTargetContext.h" #include "GrTexture.h" #include "GrTextureAdjuster.h" @@ -88,8 +90,7 @@ bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const { } sk_sp sContext = direct->priv().makeWrappedSurfaceContext( - this->asTextureProxyRef(), - fColorSpace); + this->asTextureProxyRef(direct), fColorSpace); if (!sContext) { return false; } @@ -105,8 +106,13 @@ bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const { return true; } -sk_sp SkImage_GpuBase::onMakeSubset(const SkIRect& subset) const { - sk_sp proxy = this->asTextureProxyRef(); +sk_sp SkImage_GpuBase::onMakeSubset(GrRecordingContext* context, + const SkIRect& subset) const { + if (!context || !fContext->priv().matches(context)) { + return nullptr; + } + + sk_sp proxy = this->asTextureProxyRef(context); GrSurfaceDesc desc; desc.fWidth = subset.width(); @@ -119,7 +125,7 @@ sk_sp SkImage_GpuBase::onMakeSubset(const SkIRect& subset) const { } // TODO: Should this inherit our proxy's budgeted status? - sk_sp sContext(fContext->priv().makeDeferredSurfaceContext( + sk_sp sContext(context->priv().makeDeferredSurfaceContext( format, desc, proxy->origin(), GrMipMapped::kNo, SkBackingFit::kExact, proxy->isBudgeted())); if (!sContext) { @@ -183,7 +189,7 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, } sk_sp sContext = direct->priv().makeWrappedSurfaceContext( - this->asTextureProxyRef(), this->refColorSpace()); + this->asTextureProxyRef(direct), this->refColorSpace()); if (!sContext) { return false; } @@ -209,12 +215,12 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, sk_sp SkImage_GpuBase::asTextureProxyRef(GrRecordingContext* context, const GrSamplerState& params, SkScalar scaleAdjust[2]) const { - if (!fContext->priv().matches(context)) { + if (!context || !fContext->priv().matches(context)) { SkASSERT(0); return nullptr; } - GrTextureAdjuster adjuster(fContext.get(), this->asTextureProxyRef(), fAlphaType, + GrTextureAdjuster adjuster(fContext.get(), this->asTextureProxyRef(context), fAlphaType, this->uniqueID(), fColorSpace.get()); return adjuster.refTextureProxyForParams(params, scaleAdjust); } @@ -224,10 +230,10 @@ GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContext auto direct = fContext->priv().asDirectContext(); if (!direct) { // This image was created with a DDL context and cannot be instantiated. - return GrBackendTexture(); + return GrBackendTexture(); // invalid } - sk_sp proxy = this->asTextureProxyRef(); + sk_sp proxy = this->asTextureProxyRef(direct); SkASSERT(proxy); if (!proxy->isInstantiated()) { @@ -239,7 +245,6 @@ GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContext } GrTexture* texture = proxy->peekTexture(); - if (texture) { if (flushPendingGrContextIO) { direct->priv().prepareSurfaceForExternalIO(proxy.get()); @@ -264,7 +269,7 @@ GrTexture* SkImage_GpuBase::onGetTexture() const { return nullptr; } - sk_sp proxyRef = this->asTextureProxyRef(); + sk_sp proxyRef = this->asTextureProxyRef(direct); SkASSERT(proxyRef && !proxyRef->isInstantiated()); if (!proxyRef->instantiate(direct->priv().resourceProvider())) { diff --git a/src/image/SkImage_GpuBase.h b/src/image/SkImage_GpuBase.h index 86b4b2e719..0058711ddf 100644 --- a/src/image/SkImage_GpuBase.h +++ b/src/image/SkImage_GpuBase.h @@ -27,22 +27,23 @@ public: GrContext* context() const final { return fContext.get(); } bool getROPixels(SkBitmap*, CachingHint) const final; - sk_sp onMakeSubset(const SkIRect& subset) const final; + sk_sp onMakeSubset(GrRecordingContext*, const SkIRect& subset) const final; bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB, int srcX, int srcY, CachingHint) const override; - sk_sp asTextureProxyRef() const override { + sk_sp asTextureProxyRef(GrRecordingContext* context) const override { // we shouldn't end up calling this SkASSERT(false); - return this->INHERITED::asTextureProxyRef(); + return this->INHERITED::asTextureProxyRef(context); } sk_sp asTextureProxyRef(GrRecordingContext*, const GrSamplerState&, SkScalar scaleAdjust[2]) const final; - sk_sp refPinnedTextureProxy(uint32_t* uniqueID) const final { + sk_sp refPinnedTextureProxy(GrRecordingContext* context, + uint32_t* uniqueID) const final { *uniqueID = this->uniqueID(); - return this->asTextureProxyRef(); + return this->asTextureProxyRef(context); } GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO, diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp index 528373b369..a0b29eb4ff 100644 --- a/src/image/SkImage_GpuYUVA.cpp +++ b/src/image/SkImage_GpuYUVA.cpp @@ -13,6 +13,8 @@ #include "GrContext.h" #include "GrContextPriv.h" #include "GrGpu.h" +#include "GrRecordingContext.h" +#include "GrRecordingContextPriv.h" #include "GrRenderTargetContext.h" #include "GrTexture.h" #include "GrTextureProducer.h" @@ -102,37 +104,46 @@ GrTextureProxy* SkImage_GpuYUVA::peekProxy() const { return fRGBProxy.get(); } -sk_sp SkImage_GpuYUVA::asTextureProxyRef() const { - if (!fRGBProxy) { - const GrBackendFormat format = - fContext->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); - - // Needs to create a render target in order to draw to it for the yuv->rgb conversion. - sk_sp renderTargetContext( - fContext->priv().makeDeferredRenderTargetContext( - format, SkBackingFit::kExact, this->width(), this->height(), - kRGBA_8888_GrPixelConfig, fColorSpace, 1, GrMipMapped::kNo, fOrigin)); - if (!renderTargetContext) { - return nullptr; - } - - auto colorSpaceXform = GrColorSpaceXform::Make(fColorSpace.get(), fAlphaType, - fTargetColorSpace.get(), fAlphaType); - const SkRect rect = SkRect::MakeIWH(this->width(), this->height()); - if (!RenderYUVAToRGBA(fContext.get(), renderTargetContext.get(), rect, fYUVColorSpace, - std::move(colorSpaceXform), fProxies, fYUVAIndices)) { - return nullptr; - } - - fRGBProxy = renderTargetContext->asTextureProxyRef(); +sk_sp SkImage_GpuYUVA::asTextureProxyRef(GrRecordingContext* context) const { + if (fRGBProxy) { + return fRGBProxy; } + if (!context || !fContext->priv().matches(context)) { + return nullptr; + } + + const GrBackendFormat format = + fContext->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); + + // Needs to create a render target in order to draw to it for the yuv->rgb conversion. + sk_sp renderTargetContext( + context->priv().makeDeferredRenderTargetContext( + format, SkBackingFit::kExact, this->width(), this->height(), + kRGBA_8888_GrPixelConfig, fColorSpace, 1, GrMipMapped::kNo, fOrigin)); + if (!renderTargetContext) { + return nullptr; + } + + auto colorSpaceXform = GrColorSpaceXform::Make(fColorSpace.get(), fAlphaType, + fTargetColorSpace.get(), fAlphaType); + const SkRect rect = SkRect::MakeIWH(this->width(), this->height()); + if (!RenderYUVAToRGBA(fContext.get(), renderTargetContext.get(), rect, fYUVColorSpace, + std::move(colorSpaceXform), fProxies, fYUVAIndices)) { + return nullptr; + } + + fRGBProxy = renderTargetContext->asTextureProxyRef(); return fRGBProxy; } -sk_sp SkImage_GpuYUVA::asMippedTextureProxyRef() const { +sk_sp SkImage_GpuYUVA::asMippedTextureProxyRef(GrRecordingContext* context) const { + if (!context || !fContext->priv().matches(context)) { + return nullptr; + } + // if invalid or already has miplevels - auto proxy = this->asTextureProxyRef(); + auto proxy = this->asTextureProxyRef(context); if (!proxy || GrMipMapped::kYes == fRGBProxy->mipMapped()) { return proxy; } @@ -149,7 +160,8 @@ sk_sp SkImage_GpuYUVA::asMippedTextureProxyRef() const { ////////////////////////////////////////////////////////////////////////////////////////////////// -sk_sp SkImage_GpuYUVA::onMakeColorTypeAndColorSpace(SkColorType, +sk_sp SkImage_GpuYUVA::onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType, sk_sp targetCS) const { // We explicitly ignore color type changes, for now. diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h index 8a9aac40f9..ef09c902d7 100644 --- a/src/image/SkImage_GpuYUVA.h +++ b/src/image/SkImage_GpuYUVA.h @@ -34,11 +34,12 @@ public: // This returns the single backing proxy if the YUV channels have already been flattened but // nullptr if they have not. GrTextureProxy* peekProxy() const override; - sk_sp asTextureProxyRef() const override; + sk_sp asTextureProxyRef(GrRecordingContext*) const override; virtual bool onIsTextureBacked() const override { return SkToBool(fProxies[0].get()); } - sk_sp onMakeColorTypeAndColorSpace(SkColorType, sk_sp) const final; + sk_sp onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType, sk_sp) const final; virtual bool isYUVA() const override { return true; } virtual bool asYUVATextureProxiesRef(sk_sp proxies[4], @@ -55,7 +56,7 @@ public: bool setupMipmapsForPlanes() const; // Returns a ref-ed texture proxy with miplevels - sk_sp asMippedTextureProxyRef() const; + sk_sp asMippedTextureProxyRef(GrRecordingContext*) const; /** * This is the implementation of SkDeferredDisplayListRecorder::makeYUVAPromiseTexture. diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index db85e951a1..ad69750541 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -250,7 +250,8 @@ sk_sp SkImage_Lazy::asTextureProxyRef(GrRecordingContext* contex } #endif -sk_sp SkImage_Lazy::onMakeSubset(const SkIRect& subset) const { +sk_sp SkImage_Lazy::onMakeSubset(GrRecordingContext* context, + const SkIRect& subset) const { SkASSERT(fInfo.bounds().contains(subset)); SkASSERT(fInfo.bounds() != subset); @@ -260,7 +261,8 @@ sk_sp SkImage_Lazy::onMakeSubset(const SkIRect& subset) const { return validator ? sk_sp(new SkImage_Lazy(&validator)) : nullptr; } -sk_sp SkImage_Lazy::onMakeColorTypeAndColorSpace(SkColorType targetCT, +sk_sp SkImage_Lazy::onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType targetCT, sk_sp targetCS) const { SkAutoExclusive autoAquire(fOnMakeColorTypeAndSpaceMutex); if (fOnMakeColorTypeAndSpaceResult && diff --git a/src/image/SkImage_Lazy.h b/src/image/SkImage_Lazy.h index e1407e9da5..8578558cd6 100644 --- a/src/image/SkImage_Lazy.h +++ b/src/image/SkImage_Lazy.h @@ -53,10 +53,11 @@ public: SkYUVColorSpace*, const void* planes[4]) override; #endif sk_sp onRefEncoded() const override; - sk_sp onMakeSubset(const SkIRect&) const override; + sk_sp onMakeSubset(GrRecordingContext*, const SkIRect&) const override; bool getROPixels(SkBitmap*, CachingHint) const override; bool onIsLazyGenerated() const override { return true; } - sk_sp onMakeColorTypeAndColorSpace(SkColorType, sk_sp) const override; + sk_sp onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType, sk_sp) const override; bool onIsValid(GrContext*) const override; diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp index b1e5e08c40..296f34aa08 100644 --- a/src/image/SkImage_Raster.cpp +++ b/src/image/SkImage_Raster.cpp @@ -86,7 +86,7 @@ public: #endif bool getROPixels(SkBitmap*, CachingHint) const override; - sk_sp onMakeSubset(const SkIRect&) const override; + sk_sp onMakeSubset(GrRecordingContext*, const SkIRect&) const override; SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } @@ -101,7 +101,8 @@ public: SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable()); } - sk_sp onMakeColorTypeAndColorSpace(SkColorType, sk_sp) const override; + sk_sp onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType, sk_sp) const override; bool onIsValid(GrContext* context) const override { return true; } void notifyAddedToRasterCache() const override { @@ -113,7 +114,8 @@ public: } #if SK_SUPPORT_GPU - sk_sp refPinnedTextureProxy(uint32_t* uniqueID) const override; + sk_sp refPinnedTextureProxy(GrRecordingContext*, + uint32_t* uniqueID) const override; bool onPinAsTexture(GrContext*) const override; void onUnpinAsTexture(GrContext*) const override; #endif @@ -177,7 +179,7 @@ sk_sp SkImage_Raster::asTextureProxyRef(GrRecordingContext* cont } uint32_t uniqueID; - sk_sp tex = this->refPinnedTextureProxy(&uniqueID); + sk_sp tex = this->refPinnedTextureProxy(context, &uniqueID); if (tex) { GrTextureAdjuster adjuster(context, fPinnedProxy, fBitmap.alphaType(), fPinnedUniqueID, fBitmap.colorSpace()); @@ -190,7 +192,8 @@ sk_sp SkImage_Raster::asTextureProxyRef(GrRecordingContext* cont #if SK_SUPPORT_GPU -sk_sp SkImage_Raster::refPinnedTextureProxy(uint32_t* uniqueID) const { +sk_sp SkImage_Raster::refPinnedTextureProxy(GrRecordingContext*, + uint32_t* uniqueID) const { if (fPinnedProxy) { SkASSERT(fPinnedCount > 0); SkASSERT(fPinnedUniqueID != 0); @@ -231,7 +234,7 @@ void SkImage_Raster::onUnpinAsTexture(GrContext* ctx) const { } #endif -sk_sp SkImage_Raster::onMakeSubset(const SkIRect& subset) const { +sk_sp SkImage_Raster::onMakeSubset(GrRecordingContext*, const SkIRect& subset) const { SkImageInfo info = fBitmap.info().makeWH(subset.width(), subset.height()); SkBitmap bitmap; if (!bitmap.tryAllocPixels(info)) { @@ -337,7 +340,8 @@ bool SkImage_Raster::onAsLegacyBitmap(SkBitmap* bitmap) const { /////////////////////////////////////////////////////////////////////////////// -sk_sp SkImage_Raster::onMakeColorTypeAndColorSpace(SkColorType targetCT, +sk_sp SkImage_Raster::onMakeColorTypeAndColorSpace(GrRecordingContext*, + SkColorType targetCT, sk_sp targetCS) const { SkPixmap src; SkAssertResult(fBitmap.peekPixels(&src)); diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp index fc29d82802..d26aec186f 100644 --- a/tests/GrMipMappedTest.cpp +++ b/tests/GrMipMappedTest.cpp @@ -64,7 +64,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) { kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr, nullptr, nullptr); - proxy = as_IB(image)->asTextureProxyRef(); + proxy = as_IB(image)->asTextureProxyRef(context); } REPORTER_ASSERT(reporter, proxy); if (!proxy) { diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 78e068ae98..640b341d40 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -776,11 +776,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { [] (SkSurface* s){ return sk_ref_sp(s->getCanvas()->internal_private_accessTopLayerRenderTargetContext()); }, - [] (SkSurface* s){ + [context] (SkSurface* s){ sk_sp i(s->makeImageSnapshot()); SkImage_Gpu* gpuImage = (SkImage_Gpu *) as_IB(i); - sk_sp proxy = gpuImage->asTextureProxyRef(); - GrContext* context = gpuImage->context(); + sk_sp proxy = gpuImage->asTextureProxyRef(context); return context->priv().makeWrappedSurfaceContext(std::move(proxy), gpuImage->refColorSpace()); } diff --git a/tests/VkBackendSurfaceTest.cpp b/tests/VkBackendSurfaceTest.cpp index 0075872211..c89c3edd56 100644 --- a/tests/VkBackendSurfaceTest.cpp +++ b/tests/VkBackendSurfaceTest.cpp @@ -63,7 +63,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) { kPremul_SkAlphaType, nullptr); REPORTER_ASSERT(reporter, wrappedImage.get()); - sk_sp texProxy = as_IB(wrappedImage)->asTextureProxyRef(); + sk_sp texProxy = as_IB(wrappedImage)->asTextureProxyRef(context); REPORTER_ASSERT(reporter, texProxy.get()); REPORTER_ASSERT(reporter, texProxy->isInstantiated()); GrTexture* texture = texProxy->peekTexture();