Make SkImage_Base::asTextureProxyRef take a GrRecordingContext parameter

In future Ganesh the SkImage's will only have GrImageContexts. asTextureProxyRef, however, may need to perform some rendering thus requires an external GrRecordingContext.

Change-Id: I893573e9f3462b4c4cf5e29a7f8ee74027a2ce6e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/197134
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-03-05 12:35:44 -05:00 committed by Skia Commit-Bot
parent 9ac0407006
commit 6603a1743e
20 changed files with 143 additions and 86 deletions

View File

@ -156,7 +156,7 @@ public:
surface->getCanvas()->translate(-100, -100);
surface->getCanvas()->drawPicture(pic);
sk_sp<SkImage> image(surface->makeImageSnapshot());
fProxy = as_IB(image)->asTextureProxyRef();
fProxy = as_IB(image)->asTextureProxyRef(fCtx.get());
}
}
protected:

View File

@ -119,7 +119,7 @@ sk_sp<GrTextureProxy> SkPictureImageGenerator::onGenerateTexture(
if (!image) {
return nullptr;
}
sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef();
sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef(ctx);
SkASSERT(!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped());
return proxy;
}

View File

@ -193,7 +193,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(GrRecordingContext* context,
SkASSERT(rect_fits(subset, image->width(), image->height()));
#if SK_SUPPORT_GPU
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef()) {
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef(context)) {
if (!as_IB(image)->context()->priv().matches(context)) {
return nullptr;
}

View File

@ -61,9 +61,9 @@ sk_sp<GrTextureProxy> GrYUVAImageTextureMaker::refOriginalTextureProxy(bool will
}
if (willBeMipped) {
return fImage->asMippedTextureProxyRef();
return fImage->asMippedTextureProxyRef(this->context());
} else {
return fImage->asTextureProxyRef();
return fImage->asTextureProxyRef(this->context());
}
}

View File

@ -1192,7 +1192,7 @@ sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkImage* image) {
SkPixmap pm;
if (image->isTextureBacked()) {
sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef();
sk_sp<GrTextureProxy> 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<SkLatticeIter>(image->width(), image->height(), center, dst);
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) {
if (sk_sp<GrTextureProxy> 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<SkLatticeIter>(lattice, dst);
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) {
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(this->context(),
&pinnedUniqueID)) {
GrTextureAdjuster adjuster(this->context(), std::move(proxy),
image->alphaType(), pinnedUniqueID,
as_IB(image)->onImageInfo().colorSpace());

View File

@ -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<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) {
if (sk_sp<GrTextureProxy> 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?

View File

@ -141,7 +141,13 @@ sk_sp<SkImage> SkImage::makeSubset(const SkIRect& subset) const {
if (bounds == subset) {
return sk_ref_sp(const_cast<SkImage*>(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> SkImage::makeColorSpace(sk_sp<SkColorSpace> target) const {
return sk_ref_sp(const_cast<SkImage*>(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> SkImage::makeColorTypeAndColorSpace(SkColorType targetColorType,
@ -340,7 +352,13 @@ sk_sp<SkImage> SkImage::makeColorTypeAndColorSpace(SkColorType targetColorType,
return sk_ref_sp(const_cast<SkImage*>(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> SkImage::makeNonTextureImage() const {

View File

@ -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<GrTextureProxy> asTextureProxyRef() const { return nullptr; }
virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const { return nullptr; }
virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, const GrSamplerState&,
SkScalar scaleAdjust[2]) const = 0;
virtual sk_sp<GrTextureProxy> refPinnedTextureProxy(uint32_t* uniqueID) const {
virtual sk_sp<GrTextureProxy> 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<SkImage> onMakeSubset(const SkIRect&) const = 0;
virtual sk_sp<SkImage> onMakeSubset(GrRecordingContext*, const SkIRect&) const = 0;
virtual sk_sp<SkCachedData> 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<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>) const = 0;
virtual sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType, sk_sp<SkColorSpace>) const = 0;
protected:
SkImage_Base(int width, int height, uint32_t uniqueID);

View File

@ -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> SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT,
sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* context,
SkColorType targetCT,
sk_sp<SkColorSpace> 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<GrTextureProxy> proxy = this->asTextureProxyRef();
sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef(context);
GrBackendFormat format = proxy->backendFormat().makeTexture2D();
if (!format.isValid()) {
@ -77,7 +84,7 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(SkColorType targetCT,
}
sk_sp<GrRenderTargetContext> 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> SkImage::makeTextureImage(GrContext* context, SkColorSpace* dstCo
return nullptr;
}
sk_sp<GrTextureProxy> proxy = as_IB(this)->asTextureProxyRef();
sk_sp<GrTextureProxy> proxy = as_IB(this)->asTextureProxyRef(context);
SkASSERT(proxy);
if (GrMipMapped::kNo == mipMapped || proxy->mipMapped() == mipMapped) {
return sk_ref_sp(const_cast<SkImage*>(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;
}

View File

@ -31,13 +31,14 @@ public:
GrTextureProxy* peekProxy() const override {
return fProxy.get();
}
sk_sp<GrTextureProxy> asTextureProxyRef() const override {
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override {
return fProxy;
}
bool onIsTextureBacked() const override { return SkToBool(fProxy.get()); }
sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>) const final;
sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType, sk_sp<SkColorSpace>) const final;
/**
* This is the implementation of SkDeferredDisplayListRecorder::makePromiseImage.

View File

@ -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<GrSurfaceContext> 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> SkImage_GpuBase::onMakeSubset(const SkIRect& subset) const {
sk_sp<GrSurfaceProxy> proxy = this->asTextureProxyRef();
sk_sp<SkImage> SkImage_GpuBase::onMakeSubset(GrRecordingContext* context,
const SkIRect& subset) const {
if (!context || !fContext->priv().matches(context)) {
return nullptr;
}
sk_sp<GrSurfaceProxy> proxy = this->asTextureProxyRef(context);
GrSurfaceDesc desc;
desc.fWidth = subset.width();
@ -119,7 +125,7 @@ sk_sp<SkImage> SkImage_GpuBase::onMakeSubset(const SkIRect& subset) const {
}
// TODO: Should this inherit our proxy's budgeted status?
sk_sp<GrSurfaceContext> sContext(fContext->priv().makeDeferredSurfaceContext(
sk_sp<GrSurfaceContext> 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<GrSurfaceContext> 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<GrTextureProxy> 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<GrTextureProxy> proxy = this->asTextureProxyRef();
sk_sp<GrTextureProxy> 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<GrTextureProxy> proxyRef = this->asTextureProxyRef();
sk_sp<GrTextureProxy> proxyRef = this->asTextureProxyRef(direct);
SkASSERT(proxyRef && !proxyRef->isInstantiated());
if (!proxyRef->instantiate(direct->priv().resourceProvider())) {

View File

@ -27,22 +27,23 @@ public:
GrContext* context() const final { return fContext.get(); }
bool getROPixels(SkBitmap*, CachingHint) const final;
sk_sp<SkImage> onMakeSubset(const SkIRect& subset) const final;
sk_sp<SkImage> 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<GrTextureProxy> asTextureProxyRef() const override {
sk_sp<GrTextureProxy> 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<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, const GrSamplerState&,
SkScalar scaleAdjust[2]) const final;
sk_sp<GrTextureProxy> refPinnedTextureProxy(uint32_t* uniqueID) const final {
sk_sp<GrTextureProxy> refPinnedTextureProxy(GrRecordingContext* context,
uint32_t* uniqueID) const final {
*uniqueID = this->uniqueID();
return this->asTextureProxyRef();
return this->asTextureProxyRef(context);
}
GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,

View File

@ -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<GrTextureProxy> 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<GrRenderTargetContext> 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<GrTextureProxy> 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<GrRenderTargetContext> 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<GrTextureProxy> SkImage_GpuYUVA::asMippedTextureProxyRef() const {
sk_sp<GrTextureProxy> 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<GrTextureProxy> SkImage_GpuYUVA::asMippedTextureProxyRef() const {
//////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkImage> SkImage_GpuYUVA::onMakeColorTypeAndColorSpace(SkColorType,
sk_sp<SkImage> SkImage_GpuYUVA::onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType,
sk_sp<SkColorSpace> targetCS) const {
// We explicitly ignore color type changes, for now.

View File

@ -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<GrTextureProxy> asTextureProxyRef() const override;
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override;
virtual bool onIsTextureBacked() const override { return SkToBool(fProxies[0].get()); }
sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>) const final;
sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType, sk_sp<SkColorSpace>) const final;
virtual bool isYUVA() const override { return true; }
virtual bool asYUVATextureProxiesRef(sk_sp<GrTextureProxy> proxies[4],
@ -55,7 +56,7 @@ public:
bool setupMipmapsForPlanes() const;
// Returns a ref-ed texture proxy with miplevels
sk_sp<GrTextureProxy> asMippedTextureProxyRef() const;
sk_sp<GrTextureProxy> asMippedTextureProxyRef(GrRecordingContext*) const;
/**
* This is the implementation of SkDeferredDisplayListRecorder::makeYUVAPromiseTexture.

View File

@ -250,7 +250,8 @@ sk_sp<GrTextureProxy> SkImage_Lazy::asTextureProxyRef(GrRecordingContext* contex
}
#endif
sk_sp<SkImage> SkImage_Lazy::onMakeSubset(const SkIRect& subset) const {
sk_sp<SkImage> 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> SkImage_Lazy::onMakeSubset(const SkIRect& subset) const {
return validator ? sk_sp<SkImage>(new SkImage_Lazy(&validator)) : nullptr;
}
sk_sp<SkImage> SkImage_Lazy::onMakeColorTypeAndColorSpace(SkColorType targetCT,
sk_sp<SkImage> SkImage_Lazy::onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType targetCT,
sk_sp<SkColorSpace> targetCS) const {
SkAutoExclusive autoAquire(fOnMakeColorTypeAndSpaceMutex);
if (fOnMakeColorTypeAndSpaceResult &&

View File

@ -53,10 +53,11 @@ public:
SkYUVColorSpace*, const void* planes[4]) override;
#endif
sk_sp<SkData> onRefEncoded() const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
sk_sp<SkImage> onMakeSubset(GrRecordingContext*, const SkIRect&) const override;
bool getROPixels(SkBitmap*, CachingHint) const override;
bool onIsLazyGenerated() const override { return true; }
sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>) const override;
sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType, sk_sp<SkColorSpace>) const override;
bool onIsValid(GrContext*) const override;

View File

@ -86,7 +86,7 @@ public:
#endif
bool getROPixels(SkBitmap*, CachingHint) const override;
sk_sp<SkImage> onMakeSubset(const SkIRect&) const override;
sk_sp<SkImage> onMakeSubset(GrRecordingContext*, const SkIRect&) const override;
SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
@ -101,7 +101,8 @@ public:
SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable());
}
sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>) const override;
sk_sp<SkImage> onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType, sk_sp<SkColorSpace>) 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<GrTextureProxy> refPinnedTextureProxy(uint32_t* uniqueID) const override;
sk_sp<GrTextureProxy> refPinnedTextureProxy(GrRecordingContext*,
uint32_t* uniqueID) const override;
bool onPinAsTexture(GrContext*) const override;
void onUnpinAsTexture(GrContext*) const override;
#endif
@ -177,7 +179,7 @@ sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrRecordingContext* cont
}
uint32_t uniqueID;
sk_sp<GrTextureProxy> tex = this->refPinnedTextureProxy(&uniqueID);
sk_sp<GrTextureProxy> tex = this->refPinnedTextureProxy(context, &uniqueID);
if (tex) {
GrTextureAdjuster adjuster(context, fPinnedProxy, fBitmap.alphaType(), fPinnedUniqueID,
fBitmap.colorSpace());
@ -190,7 +192,8 @@ sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrRecordingContext* cont
#if SK_SUPPORT_GPU
sk_sp<GrTextureProxy> SkImage_Raster::refPinnedTextureProxy(uint32_t* uniqueID) const {
sk_sp<GrTextureProxy> 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> SkImage_Raster::onMakeSubset(const SkIRect& subset) const {
sk_sp<SkImage> 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> SkImage_Raster::onMakeColorTypeAndColorSpace(SkColorType targetCT,
sk_sp<SkImage> SkImage_Raster::onMakeColorTypeAndColorSpace(GrRecordingContext*,
SkColorType targetCT,
sk_sp<SkColorSpace> targetCS) const {
SkPixmap src;
SkAssertResult(fBitmap.peekPixels(&src));

View File

@ -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) {

View File

@ -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<SkImage> i(s->makeImageSnapshot());
SkImage_Gpu* gpuImage = (SkImage_Gpu *) as_IB(i);
sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef();
GrContext* context = gpuImage->context();
sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef(context);
return context->priv().makeWrappedSurfaceContext(std::move(proxy),
gpuImage->refColorSpace());
}

View File

@ -63,7 +63,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
kPremul_SkAlphaType, nullptr);
REPORTER_ASSERT(reporter, wrappedImage.get());
sk_sp<GrTextureProxy> texProxy = as_IB(wrappedImage)->asTextureProxyRef();
sk_sp<GrTextureProxy> texProxy = as_IB(wrappedImage)->asTextureProxyRef(context);
REPORTER_ASSERT(reporter, texProxy.get());
REPORTER_ASSERT(reporter, texProxy->isInstantiated());
GrTexture* texture = texProxy->peekTexture();