Switch SkImage_Base asTextureProxyRef to return view instead.
Bug: skia:9556 Change-Id: Ibcdf187021c22290013d99d8684f891576046052 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268937 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
45f94f8344
commit
febdedfa44
@ -189,7 +189,7 @@ protected:
|
||||
SkASSERT(ctx);
|
||||
SkASSERT(ctx == fCtx.get());
|
||||
|
||||
if (!fView.proxy()) {
|
||||
if (!fView) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -273,9 +273,9 @@ protected:
|
||||
}
|
||||
|
||||
static void draw_as_tex(SkCanvas* canvas, SkImage* image, SkScalar x, SkScalar y) {
|
||||
sk_sp<GrTextureProxy> proxy(as_IB(image)->asTextureProxyRef(
|
||||
canvas->getGrContext(), GrSamplerState::Filter::kBilerp, nullptr));
|
||||
if (!proxy) {
|
||||
GrSurfaceProxyView view = as_IB(image)->refView(canvas->getGrContext(),
|
||||
GrSamplerState::Filter::kBilerp, nullptr);
|
||||
if (!view) {
|
||||
// show placeholder if we have no texture
|
||||
SkPaint paint;
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
@ -287,12 +287,6 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: The asTextureProxyRef which takes a sampler and adjust needs to return a
|
||||
// GrSurfaceProxyView instead. For now we just grab the info off the proxy.
|
||||
GrSurfaceOrigin origin = proxy->origin();
|
||||
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||
|
||||
// No API to draw a GrTexture directly, so we cheat and create a private image subclass
|
||||
sk_sp<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()),
|
||||
image->uniqueID(), std::move(view),
|
||||
|
@ -1006,7 +1006,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
|
||||
|
||||
SkASSERT(result->isTextureBacked());
|
||||
GrSurfaceProxyView view = result->view(this->context());
|
||||
if (!view.proxy()) {
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1050,21 +1050,17 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
|
||||
auto filter = paint.getFilterQuality() > kNone_SkFilterQuality
|
||||
? GrSamplerState::Filter::kBilerp
|
||||
: GrSamplerState::Filter::kNearest;
|
||||
sk_sp<GrTextureProxy> clipProxy =
|
||||
as_IB(clipImage)->asTextureProxyRef(this->context(), filter, nullptr);
|
||||
GrSurfaceProxyView clipView = as_IB(clipImage)->refView(this->context(), filter, nullptr);
|
||||
// Fold clip matrix into ctm
|
||||
ctm.preConcat(clipMatrix);
|
||||
SkMatrix inverseClipMatrix;
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> cfp;
|
||||
if (clipProxy && ctm.invert(&inverseClipMatrix)) {
|
||||
if (clipView && ctm.invert(&inverseClipMatrix)) {
|
||||
GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
|
||||
|
||||
GrSurfaceOrigin origin = clipProxy->origin();
|
||||
GrSwizzle swizzle = clipProxy->textureSwizzle();
|
||||
GrSurfaceProxyView view(std::move(clipProxy), origin, swizzle);
|
||||
cfp = GrTextureEffect::Make(std::move(view), clipImage->alphaType(), inverseClipMatrix,
|
||||
filter);
|
||||
cfp = GrTextureEffect::Make(std::move(clipView), clipImage->alphaType(),
|
||||
inverseClipMatrix, filter);
|
||||
if (srcColorType != GrColorType::kAlpha_8) {
|
||||
cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
|
||||
}
|
||||
@ -1180,7 +1176,7 @@ sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) {
|
||||
// TODO: this makes a tight copy of 'bitmap' but it doesn't have to be (given SkSpecialImage's
|
||||
// semantics). Since this is cached we would have to bake the fit into the cache key though.
|
||||
auto view = GrMakeCachedBitmapProxyView(fContext.get(), bitmap);
|
||||
if (!view.proxy()) {
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1246,7 +1242,7 @@ sk_sp<SkSpecialImage> SkGpuDevice::snapSpecial(const SkIRect& subset, bool force
|
||||
subset,
|
||||
SkBackingFit::kApprox,
|
||||
SkBudgeted::kYes); // Always budgeted
|
||||
if (!view.proxy()) {
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1348,7 +1344,7 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
|
||||
auto dstColorSpace = fRenderTargetContext->colorInfo().colorSpace();
|
||||
const GrSamplerState::Filter filter = compute_lattice_filter_mode(*paint);
|
||||
auto view = producer->viewForParams(&filter, nullptr);
|
||||
if (!view.proxy()) {
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
auto csxf = GrColorSpaceXform::Make(producer->colorSpace(), producer->alphaType(),
|
||||
|
@ -540,13 +540,7 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
|
||||
uint32_t uniqueID;
|
||||
view = image->refPinnedView(this->context(), &uniqueID);
|
||||
if (!view) {
|
||||
auto proxy = image->asTextureProxyRef(
|
||||
this->context(), GrSamplerState::Filter::kBilerp, nullptr);
|
||||
if (proxy) {
|
||||
GrSurfaceOrigin origin = proxy->origin();
|
||||
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
||||
view = GrSurfaceProxyView(std::move(proxy), origin, swizzle);
|
||||
}
|
||||
view = image->refView(this->context(), GrSamplerState::Filter::kBilerp, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2166,17 +2166,17 @@ bool GrVkGpu::onFinishFlush(GrSurfaceProxy* proxies[], int n,
|
||||
continue;
|
||||
}
|
||||
SkImage_GpuBase* gpuImage = static_cast<SkImage_GpuBase*>(as_IB(image));
|
||||
sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef(this->getContext());
|
||||
SkASSERT(proxy);
|
||||
const GrSurfaceProxyView* view = gpuImage->view(this->getContext());
|
||||
SkASSERT(view && *view);
|
||||
|
||||
if (!proxy->isInstantiated()) {
|
||||
if (!view->proxy()->isInstantiated()) {
|
||||
auto resourceProvider = this->getContext()->priv().resourceProvider();
|
||||
if (!proxy->instantiate(resourceProvider)) {
|
||||
if (!view->proxy()->instantiate(resourceProvider)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
GrTexture* tex = proxy->peekTexture();
|
||||
GrTexture* tex = view->proxy()->peekTexture();
|
||||
if (!tex) {
|
||||
continue;
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ 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(GrRecordingContext*) const { return nullptr; }
|
||||
|
||||
// If it exists, this returns a pointer to the GrSurfaceProxyView of image. The caller does not
|
||||
// own the returned view and must copy it if they want to gain a ref to the internal proxy.
|
||||
@ -65,8 +64,8 @@ public:
|
||||
// this call will flatten a SkImage_GpuYUV to a single texture.
|
||||
virtual const GrSurfaceProxyView* view(GrRecordingContext*) const { return nullptr; }
|
||||
|
||||
virtual sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const = 0;
|
||||
virtual GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const = 0;
|
||||
virtual GrSurfaceProxyView refPinnedView(GrRecordingContext*, uint32_t* uniqueID) const {
|
||||
return {};
|
||||
}
|
||||
|
@ -32,9 +32,6 @@ public:
|
||||
GrTextureProxy* peekProxy() const override {
|
||||
return fView.asTextureProxy();
|
||||
}
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*) const override {
|
||||
return fView.asTextureProxyRef();
|
||||
}
|
||||
|
||||
const GrSurfaceProxyView* view(GrRecordingContext* context) const override {
|
||||
if (!fView.proxy()) {
|
||||
|
@ -189,17 +189,16 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels,
|
||||
return sContext->readPixels(dstInfo, dstPixels, dstRB, {srcX, srcY});
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> SkImage_GpuBase::asTextureProxyRef(GrRecordingContext* context,
|
||||
GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
GrSurfaceProxyView SkImage_GpuBase::refView(GrRecordingContext* context, GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
if (!context || !fContext->priv().matches(context)) {
|
||||
SkASSERT(0);
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
GrTextureAdjuster adjuster(fContext.get(), *this->view(context), this->imageInfo().colorInfo(),
|
||||
this->uniqueID());
|
||||
return adjuster.viewForParams(params, scaleAdjust).asTextureProxyRef();
|
||||
return adjuster.viewForParams(params, scaleAdjust);
|
||||
}
|
||||
|
||||
GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContextIO,
|
||||
@ -210,8 +209,9 @@ GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContext
|
||||
return GrBackendTexture(); // invalid
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef(direct);
|
||||
SkASSERT(proxy);
|
||||
const GrSurfaceProxyView* view = this->view(direct);
|
||||
SkASSERT(view && *view);
|
||||
GrSurfaceProxy* proxy = view->proxy();
|
||||
|
||||
if (!proxy->isInstantiated()) {
|
||||
auto resourceProvider = direct->priv().resourceProvider();
|
||||
@ -224,7 +224,7 @@ GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContext
|
||||
GrTexture* texture = proxy->peekTexture();
|
||||
if (texture) {
|
||||
if (flushPendingGrContextIO) {
|
||||
direct->priv().flushSurface(proxy.get());
|
||||
direct->priv().flushSurface(proxy);
|
||||
}
|
||||
if (origin) {
|
||||
*origin = proxy->origin();
|
||||
@ -246,14 +246,14 @@ GrTexture* SkImage_GpuBase::onGetTexture() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> refProxy = this->asTextureProxyRef(direct);
|
||||
SkASSERT(refProxy && !refProxy->isInstantiated());
|
||||
const GrSurfaceProxyView* view = this->view(direct);
|
||||
SkASSERT(view && *view && !view->proxy()->isInstantiated());
|
||||
|
||||
if (!refProxy->instantiate(direct->priv().resourceProvider())) {
|
||||
if (!view->proxy()->instantiate(direct->priv().resourceProvider())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return refProxy->peekTexture();
|
||||
return view->proxy()->peekTexture();
|
||||
}
|
||||
|
||||
bool SkImage_GpuBase::onIsValid(GrContext* context) const {
|
||||
|
@ -28,14 +28,8 @@ public:
|
||||
bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
|
||||
int srcX, int srcY, CachingHint) const override;
|
||||
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext* context) const override {
|
||||
// we shouldn't end up calling this
|
||||
SkASSERT(false);
|
||||
return this->INHERITED::asTextureProxyRef(context);
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const final;
|
||||
GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const final;
|
||||
|
||||
GrSurfaceProxyView refPinnedView(GrRecordingContext* context, uint32_t* uniqueID) const final {
|
||||
*uniqueID = this->uniqueID();
|
||||
|
@ -169,11 +169,6 @@ void SkImage_GpuYUVA::flattenToRGB(GrRecordingContext* context) const {
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef(GrRecordingContext* context) const {
|
||||
this->flattenToRGB(context);
|
||||
return fRGBView.asTextureProxyRef();
|
||||
}
|
||||
|
||||
GrSurfaceProxyView SkImage_GpuYUVA::refMippedView(GrRecordingContext* context) const {
|
||||
// if invalid or already has miplevels
|
||||
this->flattenToRGB(context);
|
||||
|
@ -33,7 +33,6 @@ 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(GrRecordingContext*) const override;
|
||||
|
||||
const GrSurfaceProxyView* view(GrRecordingContext* context) const override;
|
||||
|
||||
|
@ -238,15 +238,14 @@ bool SkImage_Lazy::onIsValid(GrContext* context) const {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> SkImage_Lazy::asTextureProxyRef(GrRecordingContext* context,
|
||||
GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
GrSurfaceProxyView SkImage_Lazy::refView(GrRecordingContext* context, GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
GrImageTextureMaker textureMaker(context, this, kAllow_CachingHint);
|
||||
return textureMaker.viewForParams(params, scaleAdjust).asTextureProxyRef();
|
||||
return textureMaker.viewForParams(params, scaleAdjust);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -42,9 +42,8 @@ public:
|
||||
bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY,
|
||||
CachingHint) const override;
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*,
|
||||
GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const override;
|
||||
GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const override;
|
||||
sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4],
|
||||
SkYUVColorSpace*, const void* planes[4]) override;
|
||||
#endif
|
||||
|
@ -73,13 +73,14 @@ public:
|
||||
uint32_t id = kNeedNewImageUniqueID);
|
||||
~SkImage_Raster() override;
|
||||
|
||||
bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, CachingHint) const override;
|
||||
bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY,
|
||||
CachingHint) const override;
|
||||
bool onPeekPixels(SkPixmap*) const override;
|
||||
const SkBitmap* onPeekBitmap() const override { return &fBitmap; }
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> asTextureProxyRef(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const override;
|
||||
GrSurfaceProxyView refView(GrRecordingContext*, GrSamplerState,
|
||||
SkScalar scaleAdjust[2]) const override;
|
||||
#endif
|
||||
|
||||
bool getROPixels(SkBitmap*, CachingHint) const override;
|
||||
@ -167,21 +168,20 @@ bool SkImage_Raster::getROPixels(SkBitmap* dst, CachingHint) const {
|
||||
}
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_sp<GrTextureProxy> SkImage_Raster::asTextureProxyRef(GrRecordingContext* context,
|
||||
GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
GrSurfaceProxyView SkImage_Raster::refView(GrRecordingContext* context, GrSamplerState params,
|
||||
SkScalar scaleAdjust[2]) const {
|
||||
if (!context) {
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t uniqueID;
|
||||
if (GrSurfaceProxyView view = this->refPinnedView(context, &uniqueID)) {
|
||||
GrTextureAdjuster adjuster(context, std::move(view), fBitmap.info().colorInfo(),
|
||||
fPinnedUniqueID);
|
||||
return adjuster.viewForParams(params, scaleAdjust).asTextureProxyRef();
|
||||
return adjuster.viewForParams(params, scaleAdjust);
|
||||
}
|
||||
|
||||
return GrRefCachedBitmapView(context, fBitmap, params, scaleAdjust).asTextureProxyRef();
|
||||
return GrRefCachedBitmapView(context, fBitmap, params, scaleAdjust);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -214,16 +214,11 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
|
||||
args.fContext->priv().options().fSharpenMipmappedTextures, &doBicubic);
|
||||
GrSamplerState samplerState(wrapModes, textureFilterMode);
|
||||
SkScalar scaleAdjust[2] = { 1.0f, 1.0f };
|
||||
sk_sp<GrTextureProxy> proxy(as_IB(fImage)->asTextureProxyRef(args.fContext, samplerState,
|
||||
scaleAdjust));
|
||||
if (!proxy) {
|
||||
GrSurfaceProxyView view = as_IB(fImage)->refView(args.fContext, samplerState, scaleAdjust);
|
||||
if (!view) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrSurfaceOrigin origin = proxy->origin();
|
||||
GrSwizzle swizzle = proxy->textureSwizzle();
|
||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||
|
||||
SkAlphaType srcAlphaType = fImage->alphaType();
|
||||
|
||||
lmInverse.postScale(scaleAdjust[0], scaleAdjust[1]);
|
||||
|
@ -63,10 +63,10 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLTextureParameters, reporter, ctxInfo) {
|
||||
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
|
||||
REPORTER_ASSERT(reporter, wrappedImage);
|
||||
|
||||
sk_sp<GrTextureProxy> texProxy = as_IB(wrappedImage)->asTextureProxyRef(context);
|
||||
REPORTER_ASSERT(reporter, texProxy.get());
|
||||
REPORTER_ASSERT(reporter, texProxy->isInstantiated());
|
||||
auto texture = static_cast<GrGLTexture*>(texProxy->peekTexture());
|
||||
const GrSurfaceProxyView* view = as_IB(wrappedImage)->view(context);
|
||||
REPORTER_ASSERT(reporter, view);
|
||||
REPORTER_ASSERT(reporter, view->proxy()->isInstantiated());
|
||||
auto texture = static_cast<GrGLTexture*>(view->proxy()->peekTexture());
|
||||
REPORTER_ASSERT(reporter, texture);
|
||||
auto parameters = texture->parameters();
|
||||
REPORTER_ASSERT(reporter, parameters);
|
||||
|
@ -66,7 +66,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
|
||||
kRGBA_8888_SkColorType,
|
||||
kPremul_SkAlphaType, nullptr,
|
||||
nullptr, nullptr);
|
||||
proxy = as_IB(image)->asTextureProxyRef(context);
|
||||
const GrSurfaceProxyView* view = as_IB(image)->view(context);
|
||||
REPORTER_ASSERT(reporter, view);
|
||||
if (!view) {
|
||||
context->deleteBackendTexture(backendTex);
|
||||
return;
|
||||
}
|
||||
proxy = view->asTextureProxyRef();
|
||||
}
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
if (!proxy) {
|
||||
|
@ -966,44 +966,42 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
|
||||
sk_sp<SkImage> refImg(imageMaker(ctx));
|
||||
|
||||
// Any context should be able to borrow the texture at this point
|
||||
sk_sp<GrTextureProxy> proxy = as_IB(refImg)->asTextureProxyRef(
|
||||
ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
GrSurfaceProxyView view =
|
||||
as_IB(refImg)->refView(ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, view);
|
||||
|
||||
// But once it's borrowed, no other context should be able to borrow
|
||||
otherTestContext->makeCurrent();
|
||||
sk_sp<GrTextureProxy> otherProxy = as_IB(refImg)->asTextureProxyRef(
|
||||
otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, !otherProxy);
|
||||
GrSurfaceProxyView otherView =
|
||||
as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, !otherView);
|
||||
|
||||
// Original context (that's already borrowing) should be okay
|
||||
testContext->makeCurrent();
|
||||
sk_sp<GrTextureProxy> proxySecondRef = as_IB(refImg)->asTextureProxyRef(
|
||||
ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, proxySecondRef);
|
||||
GrSurfaceProxyView viewSecondRef =
|
||||
as_IB(refImg)->refView(ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, viewSecondRef);
|
||||
|
||||
// Release first ref from the original context
|
||||
proxy.reset(nullptr);
|
||||
view.reset();
|
||||
|
||||
// We released one proxy but not the other from the current borrowing context. Make sure
|
||||
// a new context is still not able to borrow the texture.
|
||||
otherTestContext->makeCurrent();
|
||||
otherProxy = as_IB(refImg)->asTextureProxyRef(
|
||||
otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, !otherProxy);
|
||||
otherView = as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, !otherView);
|
||||
|
||||
// Release second ref from the original context
|
||||
testContext->makeCurrent();
|
||||
proxySecondRef.reset(nullptr);
|
||||
viewSecondRef.reset();
|
||||
|
||||
// Now we should be able to borrow the texture from the other context
|
||||
otherTestContext->makeCurrent();
|
||||
otherProxy = as_IB(refImg)->asTextureProxyRef(
|
||||
otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, otherProxy);
|
||||
otherView = as_IB(refImg)->refView(otherCtx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, otherView);
|
||||
|
||||
// Release everything
|
||||
otherProxy.reset(nullptr);
|
||||
otherView.reset();
|
||||
refImg.reset(nullptr);
|
||||
}
|
||||
}
|
||||
@ -1040,9 +1038,9 @@ DEF_GPUTEST(SkImage_CrossContextGrayAlphaConfigs, reporter, options) {
|
||||
sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false);
|
||||
REPORTER_ASSERT(reporter, image);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy =
|
||||
as_IB(image)->asTextureProxyRef(ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
GrSurfaceProxyView view =
|
||||
as_IB(image)->refView(ctx, GrSamplerState::Filter::kNearest, nullptr);
|
||||
REPORTER_ASSERT(reporter, view);
|
||||
|
||||
bool expectAlpha = kAlpha_8_SkColorType == ct;
|
||||
GrColorType grCT = SkColorTypeToGrColorType(image->colorType());
|
||||
@ -1432,7 +1430,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
|
||||
REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
|
||||
|
||||
// Flatten it and repeat.
|
||||
as_IB(i2.get())->asTextureProxyRef(c);
|
||||
as_IB(i2.get())->view(c);
|
||||
REPORTER_ASSERT(reporter,
|
||||
static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->testingOnly_IsFlattened());
|
||||
REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
|
||||
@ -1454,7 +1452,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
|
||||
// make the YUVA planes from backend textures rather than pixmaps that GrContext must upload.
|
||||
// Calling numFlushes rebases the flush count from here.
|
||||
numFlushes();
|
||||
as_IB(i2.get())->asTextureProxyRef(c);
|
||||
as_IB(i2.get())->view(c);
|
||||
REPORTER_ASSERT(reporter,
|
||||
static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->testingOnly_IsFlattened());
|
||||
REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
|
||||
|
@ -67,10 +67,10 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
|
||||
kPremul_SkAlphaType, nullptr);
|
||||
REPORTER_ASSERT(reporter, wrappedImage.get());
|
||||
|
||||
sk_sp<GrTextureProxy> texProxy = as_IB(wrappedImage)->asTextureProxyRef(context);
|
||||
REPORTER_ASSERT(reporter, texProxy.get());
|
||||
REPORTER_ASSERT(reporter, texProxy->isInstantiated());
|
||||
GrTexture* texture = texProxy->peekTexture();
|
||||
const GrSurfaceProxyView* view = as_IB(wrappedImage)->view(context);
|
||||
REPORTER_ASSERT(reporter, view);
|
||||
REPORTER_ASSERT(reporter, view->proxy()->isInstantiated());
|
||||
GrTexture* texture = view->proxy()->peekTexture();
|
||||
REPORTER_ASSERT(reporter, texture);
|
||||
|
||||
// Verify that modifying the layout via the GrVkTexture is reflected in the GrBackendTexture
|
||||
|
Loading…
Reference in New Issue
Block a user