aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ProxyRefTest.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-04-11 12:54:57 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-11 19:38:18 +0000
commit1119dc366e15ef737d05d3a087410ea40c508101 (patch)
tree0b1363476a28c6df8baf79a46dbee8a74eac48af /tests/ProxyRefTest.cpp
parentfafe135349bd34961a12bfd8185733709cd0e45e (diff)
Remove discard from GrRenderTarget & force it to always go through a RenderTargetContext
This is a bit sloppy in that it ignores some instances where discards were being issued before. The creation of the temp RTContext in the RenderTarget's discard method was causing an extra split in the opLists. This is split out of: https://skia-review.googlesource.com/c/10284/ (Omnibus: Remove GrSurface-derived classes from ops) Change-Id: Ic366d303280635763b0fae238c4df37c04fb8503 Reviewed-on: https://skia-review.googlesource.com/11125 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/ProxyRefTest.cpp')
-rw-r--r--tests/ProxyRefTest.cpp64
1 files changed, 22 insertions, 42 deletions
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index f5fe6a4047..dc48ef0cf6 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -86,20 +86,12 @@ static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) {
sk_sp<GrTexture> tex(context->resourceProvider()->createTexture(desc, SkBudgeted::kNo));
- sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex));
-
- // Flush the IOWrite from the initial discard or it will confuse the later ref count checks
- context->contextPriv().flushSurfaceWrites(proxy.get());
-
- return proxy;
+ return GrSurfaceProxy::MakeWrapped(std::move(tex));
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider();
- const GrCaps& caps = *ctxInfo.grContext()->caps();
- // Currently the op itself takes a pending write and the render target op list does as well.
- static const int kWritesForDiscard = 2;
for (auto make : { make_deferred, make_wrapped }) {
// A single write
{
@@ -107,18 +99,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get());
- check_refs(reporter, proxy.get(), 1, 1, 0, 1);
+ static const int kExpectedReads = 0;
+ static const int kExpectedWrites = 1;
- // In the deferred case, the discard op created on instantiation adds an
- // extra ref and write
- bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() &&
- caps.discardRenderTargetSupport();
- int expectedWrites = 1 + (proxyGetsDiscardRef ? kWritesForDiscard : 0);
+ check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
proxy->instantiate(provider);
// In the deferred case, this checks that the refs transfered to the GrSurface
- check_refs(reporter, proxy.get(), 1, 1, 0, expectedWrites);
+ check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
}
// A single read
@@ -127,18 +116,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get());
- check_refs(reporter, proxy.get(), 1, 1, 1, 0);
+ static const int kExpectedReads = 1;
+ static const int kExpectedWrites = 0;
- // In the deferred case, the discard op created on instantiation adds an
- // extra ref and write
- bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() &&
- caps.discardRenderTargetSupport();
- int expectedWrites = proxyGetsDiscardRef ? kWritesForDiscard : 0;
+ check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
proxy->instantiate(provider);
// In the deferred case, this checks that the refs transfered to the GrSurface
- check_refs(reporter, proxy.get(), 1, 1, 1, expectedWrites);
+ check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
}
// A single read/write pair
@@ -147,18 +133,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
GrPendingIOResource<GrSurfaceProxy, kRW_GrIOType> fRW(proxy.get());
- check_refs(reporter, proxy.get(), 1, 1, 1, 1);
+ static const int kExpectedReads = 1;
+ static const int kExpectedWrites = 1;
- // In the deferred case, the discard op created on instantiation adds an
- // extra ref and write
- bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() &&
- caps.discardRenderTargetSupport();
- int expectedWrites = 1 + (proxyGetsDiscardRef ? kWritesForDiscard : 0);
+ check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
proxy->instantiate(provider);
// In the deferred case, this checks that the refs transferred to the GrSurface
- check_refs(reporter, proxy.get(), 1, 1, 1, expectedWrites);
+ check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites);
}
// Multiple normal refs
@@ -167,16 +150,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
proxy->ref();
proxy->ref();
- check_refs(reporter, proxy.get(), 3, 3, 0, 0);
+ static const int kExpectedReads = 0;
+ static const int kExpectedWrites = 0;
- bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() &&
- caps.discardRenderTargetSupport();
- int expectedWrites = proxyGetsDiscardRef ? kWritesForDiscard : 0;
+ check_refs(reporter, proxy.get(), 3, 3,kExpectedReads, kExpectedWrites);
proxy->instantiate(provider);
// In the deferred case, this checks that the refs transferred to the GrSurface
- check_refs(reporter, proxy.get(), 3, 3, 0, expectedWrites);
+ check_refs(reporter, proxy.get(), 3, 3, kExpectedReads, kExpectedWrites);
proxy->unref();
proxy->unref();
@@ -189,22 +171,20 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
GrPendingIOResource<GrSurfaceProxy, kWrite_GrIOType> fWrite(proxy.get());
- check_refs(reporter, proxy.get(), 2, 2, 0, 1);
+ static const int kExpectedWrites = 1;
- bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() &&
- caps.discardRenderTargetSupport();
- int expectedWrites = 1 + (proxyGetsDiscardRef ? kWritesForDiscard : 0);
+ check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites);
proxy->instantiate(provider);
// In the deferred case, this checks that the refs transfered to the GrSurface
- check_refs(reporter, proxy.get(), 2, 2, 0, expectedWrites);
+ check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites);
proxy->unref();
- check_refs(reporter, proxy.get(), 1, 1, 0, expectedWrites);
+ check_refs(reporter, proxy.get(), 1, 1, 0, kExpectedWrites);
GrPendingIOResource<GrSurfaceProxy, kRead_GrIOType> fRead(proxy.get());
- check_refs(reporter, proxy.get(), 1, 1, 1, expectedWrites);
+ check_refs(reporter, proxy.get(), 1, 1, 1, kExpectedWrites);
}
}
}