aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrCaps.h10
-rw-r--r--src/core/SkDeferredDisplayListRecorder.cpp2
-rw-r--r--src/gpu/GrProxyProvider.cpp213
-rw-r--r--src/gpu/gl/GrGLCaps.cpp7
-rw-r--r--src/gpu/gl/GrGLCaps.h1
-rw-r--r--src/image/SkSurface_Gpu.cpp7
-rw-r--r--tests/DeferredDisplayListTest.cpp163
-rw-r--r--tests/ProxyTest.cpp14
8 files changed, 103 insertions, 314 deletions
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index 7f1a45ef26..27ad6a164d 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -59,11 +59,6 @@ public:
bool instanceAttribSupport() const { return fInstanceAttribSupport; }
bool usesMixedSamples() const { return fUsesMixedSamples; }
- // Returns whether mixed samples is supported for the given backend render target.
- bool isMixedSamplesSupportedForRT(const GrBackendRenderTarget& rt) const {
- return this->usesMixedSamples() && this->onIsMixedSamplesSupportedForRT(rt);
- }
-
// Primitive restart functionality is core in ES 3.0, but using it will cause slowdowns on some
// systems. This cap is only set if primitive restart will improve performance.
bool usePrimitiveRestart() const { return fUsePrimitiveRestart; }
@@ -312,11 +307,6 @@ private:
virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
virtual void onDumpJSON(SkJSONWriter*) const {}
- // Backends should implement this if they have any extra requirements for use of mixed
- // samples for a specific GrBackendRenderTarget outside of basic support.
- virtual bool onIsMixedSamplesSupportedForRT(const GrBackendRenderTarget&) const {
- return true;
- }
// Backends should implement this if they have any extra requirements for use of window
// rectangles for a specific GrBackendRenderTarget outside of basic support.
virtual bool onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget&) const {
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index 077548062d..96bb575924 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -83,7 +83,7 @@ bool SkDeferredDisplayListRecorder::init() {
// DDL is being replayed into.
sk_sp<GrRenderTargetProxy> proxy = proxyProvider->createLazyRenderTargetProxy(
- [ lazyProxyData ] (GrResourceProvider* resourceProvider) {
+ [lazyProxyData](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
return sk_sp<GrSurface>();
}
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 758a0d1601..dbd49a7ac3 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -408,51 +408,28 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = backendTex.width();
- desc.fHeight = backendTex.height();
- desc.fConfig = backendTex.config();
- GrMipMapped mipMapped = backendTex.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
+ // This is only supported on a direct GrContext.
+ if (!fResourceProvider) {
+ return nullptr;
+ }
+
+ sk_sp<GrTexture> tex = fResourceProvider->wrapBackendTexture(backendTex, ownership);
+ if (!tex) {
+ return nullptr;
+ }
sk_sp<GrReleaseProcHelper> releaseHelper;
if (releaseProc) {
releaseHelper.reset(new GrReleaseProcHelper(releaseProc, releaseCtx));
+ // This gives the texture a ref on the releaseHelper
+ tex->setRelease(releaseHelper);
}
- sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
- [backendTex, ownership, releaseHelper](GrResourceProvider* resourceProvider) {
- if (!resourceProvider) {
- // If this had a releaseHelper it will get unrefed when we delete this lambda
- // and will call the release proc so that the client knows they can free the
- // underlying backend object.
- return sk_sp<GrTexture>();
- }
+ SkASSERT(!tex->asRenderTarget()); // Strictly a GrTexture
+ // Make sure we match how we created the proxy with SkBudgeted::kNo
+ SkASSERT(SkBudgeted::kNo == tex->resourcePriv().isBudgeted());
- sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(backendTex,
- ownership);
- if (!tex) {
- return sk_sp<GrTexture>();
- }
- if (releaseHelper) {
- // This gives the texture a ref on the releaseHelper
- tex->setRelease(releaseHelper);
- }
- SkASSERT(!tex->asRenderTarget()); // Strictly a GrTexture
- // Make sure we match how we created the proxy with SkBudgeted::kNo
- SkASSERT(SkBudgeted::kNo == tex->resourcePriv().isBudgeted());
-
- return tex;
- },
- desc, origin, mipMapped, SkBackingFit::kExact, SkBudgeted::kNo);
-
- if (fResourceProvider) {
- // In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however,
- // we're better off instantiating the proxy immediately here.
- if (!proxy->priv().doLazyInstantiation(fResourceProvider)) {
- return nullptr;
- }
- }
- return proxy;
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin));
}
sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
@@ -462,54 +439,27 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
return nullptr;
}
+ // This is only supported on a direct GrContext.
+ if (!fResourceProvider) {
+ return nullptr;
+ }
+
sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, backendTex.config());
if (!sampleCnt) {
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = backendTex.width();
- desc.fHeight = backendTex.height();
- desc.fConfig = backendTex.config();
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fSampleCnt = sampleCnt;
- GrMipMapped mipMapped = backendTex.hasMipMaps() ? GrMipMapped::kYes : GrMipMapped::kNo;
-
- GrRenderTargetFlags renderTargetFlags = GrRenderTargetFlags::kNone;
- if (fCaps->usesMixedSamples() && sampleCnt > 1) {
- renderTargetFlags |= GrRenderTargetFlags::kMixedSampled;
- }
- if (fCaps->maxWindowRectangles() > 0) {
- renderTargetFlags |= GrRenderTargetFlags::kWindowRectsSupport;
+ sk_sp<GrTexture> tex =
+ fResourceProvider->wrapRenderableBackendTexture(backendTex, sampleCnt, ownership);
+ if (!tex) {
+ return nullptr;
}
- sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
- [backendTex, sampleCnt, ownership](GrResourceProvider* resourceProvider) {
- if (!resourceProvider) {
- return sk_sp<GrTexture>();
- }
-
- sk_sp<GrTexture> tex = resourceProvider->wrapRenderableBackendTexture(
- backendTex, sampleCnt, ownership);
- if (!tex) {
- return sk_sp<GrTexture>();
- }
- SkASSERT(tex->asRenderTarget()); // A GrTextureRenderTarget
- // Make sure we match how we created the proxy with SkBudgeted::kNo
- SkASSERT(SkBudgeted::kNo == tex->resourcePriv().isBudgeted());
+ SkASSERT(tex->asRenderTarget()); // A GrTextureRenderTarget
+ // Make sure we match how we created the proxy with SkBudgeted::kNo
+ SkASSERT(SkBudgeted::kNo == tex->resourcePriv().isBudgeted());
- return tex;
- },
- desc, origin, mipMapped, renderTargetFlags, SkBackingFit::kExact, SkBudgeted::kNo);
-
- if (fResourceProvider) {
- // In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however,
- // we're better off instantiating the proxy immediately here.
- if (!proxy->priv().doLazyInstantiation(fResourceProvider)) {
- return nullptr;
- }
- }
- return proxy;
+ return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin));
}
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
@@ -518,49 +468,21 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = backendRT.width();
- desc.fHeight = backendRT.height();
- desc.fConfig = backendRT.config();
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fSampleCnt = backendRT.sampleCnt();
-
- GrRenderTargetFlags renderTargetFlags = GrRenderTargetFlags::kNone;
- if (fCaps->isMixedSamplesSupportedForRT(backendRT) && backendRT.sampleCnt() > 1) {
- renderTargetFlags |= GrRenderTargetFlags::kMixedSampled;
- }
- if (fCaps->isWindowRectanglesSupportedForRT(backendRT)) {
- renderTargetFlags |= GrRenderTargetFlags::kWindowRectsSupport;
+ // This is only supported on a direct GrContext.
+ if (!fResourceProvider) {
+ return nullptr;
}
- sk_sp<GrRenderTargetProxy> proxy = this->createLazyRenderTargetProxy(
- [backendRT](GrResourceProvider* resourceProvider) {
- if (!resourceProvider) {
- return sk_sp<GrRenderTarget>();
- }
-
- sk_sp<GrRenderTarget> rt = resourceProvider->wrapBackendRenderTarget(backendRT);
- if (!rt) {
- return sk_sp<GrRenderTarget>();
- }
- SkASSERT(!rt->asTexture()); // A GrRenderTarget that's not textureable
- SkASSERT(!rt->getUniqueKey().isValid());
- // Make sure we match how we created the proxy with SkBudgeted::kNo
- SkASSERT(SkBudgeted::kNo == rt->resourcePriv().isBudgeted());
-
- return rt;
- },
- desc, origin, renderTargetFlags, Textureable::kNo, GrMipMapped::kNo,
- SkBackingFit::kExact, SkBudgeted::kNo);
-
- if (fResourceProvider) {
- // In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however,
- // we're better off instantiating the proxy immediately here.
- if (!proxy->priv().doLazyInstantiation(fResourceProvider)) {
- return nullptr;
- }
+ sk_sp<GrRenderTarget> rt = fResourceProvider->wrapBackendRenderTarget(backendRT);
+ if (!rt) {
+ return nullptr;
}
- return proxy;
+ SkASSERT(!rt->asTexture()); // A GrRenderTarget that's not textureable
+ SkASSERT(!rt->getUniqueKey().isValid());
+ // Make sure we match how we created the proxy with SkBudgeted::kNo
+ SkASSERT(SkBudgeted::kNo == rt->resourcePriv().isBudgeted());
+
+ return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(std::move(rt), origin));
}
sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
@@ -569,55 +491,22 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
return nullptr;
}
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, backendTex.config());
- if (!sampleCnt) {
+ // This is only supported on a direct GrContext.
+ if (!fResourceProvider) {
return nullptr;
}
- GrSurfaceDesc desc;
- desc.fWidth = backendTex.width();
- desc.fHeight = backendTex.height();
- desc.fConfig = backendTex.config();
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fSampleCnt = sampleCnt;
-
- GrRenderTargetFlags renderTargetFlags = GrRenderTargetFlags::kNone;
- if (fCaps->usesMixedSamples() && sampleCnt > 1) {
- renderTargetFlags |= GrRenderTargetFlags::kMixedSampled;
- }
- if (fCaps->maxWindowRectangles() > 0) {
- renderTargetFlags |= GrRenderTargetFlags::kWindowRectsSupport;
+ sk_sp<GrRenderTarget> rt =
+ fResourceProvider->wrapBackendTextureAsRenderTarget(backendTex, sampleCnt);
+ if (!rt) {
+ return nullptr;
}
+ SkASSERT(!rt->asTexture()); // A GrRenderTarget that's not textureable
+ SkASSERT(!rt->getUniqueKey().isValid());
+ // Make sure we match how we created the proxy with SkBudgeted::kNo
+ SkASSERT(SkBudgeted::kNo == rt->resourcePriv().isBudgeted());
- sk_sp<GrRenderTargetProxy> proxy = this->createLazyRenderTargetProxy(
- [backendTex, sampleCnt](GrResourceProvider* resourceProvider) {
- if (!resourceProvider) {
- return sk_sp<GrRenderTarget>();
- }
-
- sk_sp<GrRenderTarget> rt = resourceProvider->wrapBackendTextureAsRenderTarget(
- backendTex, sampleCnt);
- if (!rt) {
- return sk_sp<GrRenderTarget>();
- }
- SkASSERT(!rt->asTexture()); // A GrRenderTarget that's not textureable
- SkASSERT(!rt->getUniqueKey().isValid());
- // Make sure we match how we created the proxy with SkBudgeted::kNo
- SkASSERT(SkBudgeted::kNo == rt->resourcePriv().isBudgeted());
-
- return rt;
- },
- desc, origin, renderTargetFlags, Textureable::kNo, GrMipMapped::kNo,
- SkBackingFit::kExact, SkBudgeted::kNo);
-
- if (fResourceProvider) {
- // In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however,
- // we're better off instantiating the proxy immediately here.
- if (!proxy->priv().doLazyInstantiation(fResourceProvider)) {
- return nullptr;
- }
- }
- return proxy;
+ return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(rt), origin));
}
sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 957811e70f..aec7a37e1b 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -2452,13 +2452,6 @@ bool GrGLCaps::surfaceSupportsWritePixels(const GrSurface* surface) const {
return true;
}
-bool GrGLCaps::onIsMixedSamplesSupportedForRT(const GrBackendRenderTarget& backendRT) const {
- const GrGLFramebufferInfo* fbInfo = backendRT.getGLFramebufferInfo();
- SkASSERT(fbInfo);
- // Mixed samples are not supported for FBO 0;
- return fbInfo->fFBOID != 0;
-}
-
bool GrGLCaps::onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget& backendRT) const {
const GrGLFramebufferInfo* fbInfo = backendRT.getGLFramebufferInfo();
SkASSERT(fbInfo);
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index dbcccd5edd..5d3fa6a6f6 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -435,7 +435,6 @@ private:
void onApplyOptionsOverrides(const GrContextOptions& options) override;
- bool onIsMixedSamplesSupportedForRT(const GrBackendRenderTarget&) const override;
bool onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget&) const override;
void initFSAASupport(const GrContextOptions& contextOptions, const GrGLContextInfo&,
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 78dcd59e54..a96131337f 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -307,9 +307,10 @@ sk_sp<SkSurface> SkSurface_Gpu::MakeWrappedRenderTarget(GrContext* context,
return nullptr;
}
- sk_sp<SkGpuDevice> device(SkGpuDevice::Make(context, std::move(rtc),
- rtc->width(), rtc->height(),
- SkGpuDevice::kUninit_InitContents));
+ int w = rtc->width();
+ int h = rtc->height();
+ sk_sp<SkGpuDevice> device(
+ SkGpuDevice::Make(context, std::move(rtc), w, h, SkGpuDevice::kUninit_InitContents));
if (!device) {
return nullptr;
}
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 4b425aed7e..b0c80c32ef 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -358,143 +358,50 @@ enum class DDLStage { kMakeImage, kDrawImage, kDetach, kDrawDDL };
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
GrGpu* gpu = context->contextPriv().getGpu();
- for (auto lastStage : { DDLStage::kMakeImage, DDLStage::kDrawImage,
- DDLStage::kDetach, DDLStage::kDrawDDL } ) {
- for (auto earlyImageReset : { false , true } ) {
- GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
- nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, false, GrMipMapped::kNo);
- if (!backendTex.isValid()) {
- continue;
- }
-
- SurfaceParameters params;
-
- sk_sp<SkSurface> s = params.make(context);
- if (!s) {
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- continue;
- }
-
- SkSurfaceCharacterization c;
- SkAssertResult(s->characterize(&c));
-
- std::unique_ptr<SkDeferredDisplayListRecorder> recorder(
- new SkDeferredDisplayListRecorder(c));
-
- SkCanvas* canvas = recorder->getCanvas();
- if (!canvas) {
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- continue;
- }
-
- GrContext* deferredContext = canvas->getGrContext();
- if (!deferredContext) {
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- continue;
- }
-
- sk_sp<SkImage> image = SkImage::MakeFromAdoptedTexture(deferredContext, backendTex,
- kTopLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- kPremul_SkAlphaType, nullptr);
- // Adopted Textures are not supported in DDL
- REPORTER_ASSERT(reporter, !image);
-
- TextureReleaseChecker releaseChecker;
- image = SkImage::MakeFromTexture(deferredContext, backendTex,
- kTopLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- kPremul_SkAlphaType, nullptr,
- TextureReleaseChecker::Release, &releaseChecker);
-
- REPORTER_ASSERT(reporter, image);
- if (!image) {
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- continue;
- }
+ GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
+ nullptr, kSize, kSize, kRGBA_8888_GrPixelConfig, false, GrMipMapped::kNo);
+ if (!backendTex.isValid()) {
+ return;
+ }
- if (DDLStage::kMakeImage == lastStage) {
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- image.reset();
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- recorder.reset();
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- continue;
- }
+ SurfaceParameters params;
- canvas->drawImage(image.get(), 0, 0);
+ sk_sp<SkSurface> s = params.make(context);
+ if (!s) {
+ gpu->deleteTestingOnlyBackendTexture(&backendTex);
+ return;
+ }
- if (earlyImageReset) {
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- image.reset();
- // Ref should still be held by DDL recorder since we did the draw
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- }
+ SkSurfaceCharacterization c;
+ SkAssertResult(s->characterize(&c));
- if (DDLStage::kDrawImage == lastStage) {
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- recorder.reset();
- if (earlyImageReset) {
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- } else {
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- image.reset();
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- }
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- continue;
- }
+ std::unique_ptr<SkDeferredDisplayListRecorder> recorder(new SkDeferredDisplayListRecorder(c));
- std::unique_ptr<SkDeferredDisplayList> ddl = recorder->detach();
- if (DDLStage::kDetach == lastStage) {
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- recorder.reset();
-#ifndef SK_RASTER_RECORDER_IMPLEMENTATION
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
-#endif
- ddl.reset();
- if (earlyImageReset) {
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- } else {
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- image.reset();
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- }
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- continue;
- }
+ SkCanvas* canvas = recorder->getCanvas();
+ if (!canvas) {
+ gpu->deleteTestingOnlyBackendTexture(&backendTex);
+ return;
+ }
- REPORTER_ASSERT(reporter, s->draw(ddl.get()));
+ GrContext* deferredContext = canvas->getGrContext();
+ if (!deferredContext) {
+ gpu->deleteTestingOnlyBackendTexture(&backendTex);
+ return;
+ }
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- recorder.reset();
-#ifndef SK_RASTER_RECORDER_IMPLEMENTATION
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
-#endif
- ddl.reset();
-#ifndef SK_RASTER_RECORDER_IMPLEMENTATION
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
-#endif
+ // Wrapped Backend Textures are not supported in DDL
+ sk_sp<SkImage> image =
+ SkImage::MakeFromAdoptedTexture(deferredContext, backendTex, kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
+ REPORTER_ASSERT(reporter, !image);
- // Force all draws to flush and sync by calling a read pixels
- SkImageInfo imageInfo = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType,
- kPremul_SkAlphaType);
- SkBitmap bitmap;
- bitmap.allocPixels(imageInfo);
- s->readPixels(imageInfo, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
-
- if (earlyImageReset) {
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- } else {
- REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
- image.reset();
- REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
- }
+ TextureReleaseChecker releaseChecker;
+ image = SkImage::MakeFromTexture(deferredContext, backendTex, kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr,
+ TextureReleaseChecker::Release, &releaseChecker);
+ REPORTER_ASSERT(reporter, !image);
- gpu->deleteTestingOnlyBackendTexture(&backendTex);
- }
- }
+ gpu->deleteTestingOnlyBackendTexture(&backendTex);
}
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 9d52281763..8f5eb13639 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -48,12 +48,17 @@ static void check_rendertarget(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples);
GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID();
+ bool preinstantiated = rtProxy->priv().isInstantiated();
REPORTER_ASSERT(reporter, rtProxy->instantiate(provider));
GrRenderTarget* rt = rtProxy->priv().peekRenderTarget();
REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
// Deferred resources should always have a different ID from their instantiated rendertarget
- REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
+ if (preinstantiated) {
+ REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
+ } else {
+ REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
+ }
if (SkBackingFit::kExact == fit) {
REPORTER_ASSERT(reporter, rt->width() == rtProxy->width());
@@ -76,12 +81,17 @@ static void check_texture(skiatest::Reporter* reporter,
SkBackingFit fit) {
GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
+ bool preinstantiated = texProxy->priv().isInstantiated();
REPORTER_ASSERT(reporter, texProxy->instantiate(provider));
GrTexture* tex = texProxy->priv().peekTexture();
REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
// Deferred resources should always have a different ID from their instantiated texture
- REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
+ if (preinstantiated) {
+ REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
+ } else {
+ REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
+ }
if (SkBackingFit::kExact == fit) {
REPORTER_ASSERT(reporter, tex->width() == texProxy->width());