aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-11-11 12:38:40 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-11 18:24:56 +0000
commit294870ff119b89fc902773643b054f14e5d1f554 (patch)
tree8666a14ff9bd50c9138dcbc6f3331e51b8113268 /tests
parent498d403f7703cb2157bf3c877b84906db5a06cd4 (diff)
Add explicit UniqueID classes for GrGpuResource & GrSurfaceProxy
This sets the stage for using the Proxy's/RenderTargetContext's ID above the flush and the RenderTarget's/GrGpuResource's below the flush. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4650 Change-Id: I9f1e6b00c02a0691d90b58c49e1d8c60684884c1 Reviewed-on: https://skia-review.googlesource.com/4650 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ClearTest.cpp9
-rw-r--r--tests/ProxyTest.cpp54
-rw-r--r--tests/SurfaceTest.cpp4
3 files changed, 50 insertions, 17 deletions
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index d83fb92b53..d43e65ff0f 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -37,8 +37,15 @@ static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t
return true;
}
+// TODO: this test does this thorough purging of the rendertargets b.c. right now
+// the clear optimizations rely on the rendertarget's uniqueID. It can be
+// relaxed when we switch that over to using rendertargetcontext ids (although
+// we probably will want to have more clear values then too)
static bool reset_rtc(sk_sp<GrRenderTargetContext>* rtc, GrContext* context, int w, int h) {
- SkDEBUGCODE(uint32_t oldID = 0;)
+#ifdef SK_DEBUG
+ GrGpuResource::UniqueID oldID = GrGpuResource::UniqueID::InvalidID();
+#endif
+
if (*rtc) {
SkDEBUGCODE(oldID = (*rtc)->accessRenderTarget()->uniqueID();)
rtc->reset(nullptr);
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 618941e0be..8d59cae2bf 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -21,14 +21,16 @@ static void check_surface(skiatest::Reporter* reporter,
GrSurfaceOrigin origin,
int width, int height,
GrPixelConfig config,
- uint32_t uniqueID,
+ const GrGpuResource::UniqueID& uniqueID,
SkBudgeted budgeted) {
REPORTER_ASSERT(reporter, proxy->origin() == origin);
REPORTER_ASSERT(reporter, proxy->width() == width);
REPORTER_ASSERT(reporter, proxy->height() == height);
REPORTER_ASSERT(reporter, proxy->config() == config);
- if (SK_InvalidUniqueID != uniqueID) {
- REPORTER_ASSERT(reporter, proxy->uniqueID() == uniqueID);
+ if (!uniqueID.isInvalid()) {
+ REPORTER_ASSERT(reporter, proxy->uniqueID().asUInt() == uniqueID.asUInt());
+ } else {
+ REPORTER_ASSERT(reporter, !proxy->uniqueID().isInvalid());
}
REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
}
@@ -39,20 +41,31 @@ static void check_rendertarget(skiatest::Reporter* reporter,
GrRenderTargetProxy* rtProxy,
int numSamples,
SkBackingFit fit,
- int expectedMaxWindowRects) {
+ int expectedMaxWindowRects,
+ bool wasWrapped) {
REPORTER_ASSERT(reporter, rtProxy->maxWindowRectangles(caps) == expectedMaxWindowRects);
REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples);
+ GrSurfaceProxy::UniqueID idBefore = rtProxy->uniqueID();
GrRenderTarget* rt = rtProxy->instantiate(provider);
REPORTER_ASSERT(reporter, rt);
+ REPORTER_ASSERT(reporter, rtProxy->uniqueID() == idBefore);
+ if (wasWrapped) {
+ // Wrapped resources share their uniqueID with the wrapping RenderTargetProxy
+ REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() == rt->uniqueID().asUInt());
+ } else {
+ // Deferred resources should always have a different ID from their instantiated rendertarget
+ REPORTER_ASSERT(reporter, rtProxy->uniqueID().asUInt() != rt->uniqueID().asUInt());
+ }
+
REPORTER_ASSERT(reporter, rt->origin() == rtProxy->origin());
if (SkBackingFit::kExact == fit) {
REPORTER_ASSERT(reporter, rt->width() == rtProxy->width());
REPORTER_ASSERT(reporter, rt->height() == rtProxy->height());
} else {
REPORTER_ASSERT(reporter, rt->width() >= rtProxy->width());
- REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
+ REPORTER_ASSERT(reporter, rt->height() >= rtProxy->height());
}
REPORTER_ASSERT(reporter, rt->config() == rtProxy->config());
@@ -68,10 +81,21 @@ static void check_rendertarget(skiatest::Reporter* reporter,
static void check_texture(skiatest::Reporter* reporter,
GrTextureProvider* provider,
GrTextureProxy* texProxy,
- SkBackingFit fit) {
+ SkBackingFit fit,
+ bool wasWrapped) {
+ GrSurfaceProxy::UniqueID idBefore = texProxy->uniqueID();
GrTexture* tex = texProxy->instantiate(provider);
REPORTER_ASSERT(reporter, tex);
+ REPORTER_ASSERT(reporter, texProxy->uniqueID() == idBefore);
+ if (wasWrapped) {
+ // Wrapped resources share their uniqueID with the wrapping TextureProxy
+ REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() == tex->uniqueID().asUInt());
+ } else {
+ // Deferred resources should always have a different ID from their instantiated texture
+ REPORTER_ASSERT(reporter, texProxy->uniqueID().asUInt() != tex->uniqueID().asUInt());
+ }
+
REPORTER_ASSERT(reporter, tex->origin() == texProxy->origin());
if (SkBackingFit::kExact == fit) {
REPORTER_ASSERT(reporter, tex->width() == texProxy->width());
@@ -88,6 +112,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
GrTextureProvider* provider = ctxInfo.grContext()->textureProvider();
const GrCaps& caps = *ctxInfo.grContext()->caps();
+ const GrGpuResource::UniqueID kInvalidResourceID = GrGpuResource::UniqueID::InvalidID();
+
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
for (auto widthHeight : { 100, 128 }) {
for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
@@ -112,10 +138,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
fit, budgeted));
check_surface(reporter, sProxy.get(), origin,
widthHeight, widthHeight, config,
- SK_InvalidUniqueID, budgeted);
+ kInvalidResourceID, budgeted);
check_rendertarget(reporter, caps, provider,
- sProxy->asRenderTargetProxy(),
- numSamples, fit, caps.maxWindowRectangles());
+ sProxy->asRenderTargetProxy(), numSamples,
+ fit, caps.maxWindowRectangles(), false);
}
desc.fFlags = kNone_GrSurfaceFlags;
@@ -127,8 +153,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
budgeted));
check_surface(reporter, sProxy.get(), origin,
widthHeight, widthHeight, config,
- SK_InvalidUniqueID, budgeted);
- check_texture(reporter, provider, sProxy->asTextureProxy(), fit);
+ kInvalidResourceID, budgeted);
+ check_texture(reporter, provider, sProxy->asTextureProxy(), fit, false);
}
}
}
@@ -175,7 +201,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
kWidthHeight, kWidthHeight, config,
defaultFBO->uniqueID(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(),
- numSamples, SkBackingFit::kExact, 0);
+ numSamples, SkBackingFit::kExact, 0, true);
}
sk_sp<GrTexture> tex;
@@ -192,7 +218,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
rt->uniqueID(), budgeted);
check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(),
numSamples, SkBackingFit::kExact,
- caps.maxWindowRectangles());
+ caps.maxWindowRectangles(), true);
}
if (!tex) {
@@ -205,7 +231,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight, config, tex->uniqueID(), budgeted);
check_texture(reporter, provider, sProxy->asTextureProxy(),
- SkBackingFit::kExact);
+ SkBackingFit::kExact, true);
}
}
}
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index b755a7ed77..2ac8d29b3c 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -310,7 +310,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) {
ERRORF(reporter, "Not texture backed.");
return static_cast<intptr_t>(0);
}
- return static_cast<intptr_t>(texture->uniqueID());
+ return static_cast<intptr_t>(texture->uniqueID().asUInt());
};
auto surfaceBackingStore = [reporter](SkSurface* surface) {
@@ -321,7 +321,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) {
ERRORF(reporter, "Not render target backed.");
return static_cast<intptr_t>(0);
}
- return static_cast<intptr_t>(rt->uniqueID());
+ return static_cast<intptr_t>(rt->uniqueID().asUInt());
};
test_unique_image_snap(reporter, surface.get(), false, imageBackingStore,