diff options
author | Greg Daniel <egdaniel@google.com> | 2017-09-25 12:26:58 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-26 15:17:07 +0000 |
commit | 90f28ec3da530d1720a0a74283a44cfd9c207126 (patch) | |
tree | d5fe69551fcc9e9047d896f73adeeb6c7be09d3f /tests/GrSurfaceTest.cpp | |
parent | 4c9842ec4b2df1b937147c14288e88f0ae13a556 (diff) |
Add some asserts and explict setting of fIsMipMapped
Part 2 of 3 for relanding of https://skia-review.googlesource.com/c/skia/+/42083
Bug: skia:
Change-Id: Iddc2571d88486531c76ab47432c2a51f2ac79043
Reviewed-on: https://skia-review.googlesource.com/44463
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests/GrSurfaceTest.cpp')
-rw-r--r-- | tests/GrSurfaceTest.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 54b87bf10d..7ead7cd971 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -125,6 +125,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { texels[i].fPixels = pixelData.get(); texels[i].fRowBytes = rowBytes >> i; } + desc.fIsMipMapped = true; sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferredMipMap(resourceProvider, desc, SkBudgeted::kNo, texels.get(), @@ -134,6 +135,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { caps->mipMapSupport() && !GrPixelConfigIsSint(desc.fConfig))); + desc.fIsMipMapped = false; desc.fFlags = kRenderTarget_GrSurfaceFlag; tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, false)); @@ -166,78 +168,76 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info) continue; } desc.fFlags |= rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags; - for (bool mipped : {false, true}) { - desc.fIsMipMapped = mipped; - for (GrSurfaceOrigin origin : - {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) { - desc.fOrigin = origin; - for (bool approx : {false, true}) { - auto resourceProvider = context->resourceProvider(); - // Try directly creating the texture. - // Do this twice in an attempt to hit the cache on the second time through. - for (int i = 0; i < 2; ++i) { - sk_sp<GrTexture> tex; - if (approx) { - tex = sk_sp<GrTexture>( - resourceProvider->createApproxTexture(desc, 0)); - } else { - tex = resourceProvider->createTexture(desc, SkBudgeted::kYes); - } - if (!tex) { - continue; - } - auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); - auto texCtx = context->contextPriv().makeWrappedSurfaceContext( - std::move(proxy), nullptr); - SkImageInfo info = SkImageInfo::Make( - kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType); - memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t)); - if (texCtx->readPixels(info, data.get(), 0, 0, 0)) { - uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0; - for (int i = 0; i < kSize * kSize; ++i) { - if (cmp != data.get()[i]) { - ERRORF(reporter, "Failed on config %d", desc.fConfig); - break; - } + desc.fIsMipMapped = false; + for (GrSurfaceOrigin origin : + {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) { + desc.fOrigin = origin; + for (bool approx : {false, true}) { + auto resourceProvider = context->resourceProvider(); + // Try directly creating the texture. + // Do this twice in an attempt to hit the cache on the second time through. + for (int i = 0; i < 2; ++i) { + sk_sp<GrTexture> tex; + if (approx) { + tex = sk_sp<GrTexture>( + resourceProvider->createApproxTexture(desc, 0)); + } else { + tex = resourceProvider->createTexture(desc, SkBudgeted::kYes); + } + if (!tex) { + continue; + } + auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); + auto texCtx = context->contextPriv().makeWrappedSurfaceContext( + std::move(proxy), nullptr); + SkImageInfo info = SkImageInfo::Make( + kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType); + memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t)); + if (texCtx->readPixels(info, data.get(), 0, 0, 0)) { + uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0; + for (int i = 0; i < kSize * kSize; ++i) { + if (cmp != data.get()[i]) { + ERRORF(reporter, "Failed on config %d", desc.fConfig); + break; } } - memset(data.get(), 0xBC, kSize * kSize * sizeof(uint32_t)); - // Here we overwrite the texture so that the second time through we - // test against recycling without reclearing. - if (0 == i) { - texCtx->writePixels(info, data.get(), 0, 0, 0); - } } - context->purgeAllUnlockedResources(); - - // Try creating the texture as a deferred proxy. - for (int i = 0; i < 2; ++i) { - auto surfCtx = context->contextPriv().makeDeferredSurfaceContext( - desc, approx ? SkBackingFit::kApprox : SkBackingFit::kExact, - SkBudgeted::kYes); - if (!surfCtx) { - continue; - } - SkImageInfo info = SkImageInfo::Make( - kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType); - memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t)); - if (surfCtx->readPixels(info, data.get(), 0, 0, 0)) { - uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0; - for (int i = 0; i < kSize * kSize; ++i) { - if (cmp != data.get()[i]) { - ERRORF(reporter, "Failed on config %d", desc.fConfig); - break; - } + memset(data.get(), 0xBC, kSize * kSize * sizeof(uint32_t)); + // Here we overwrite the texture so that the second time through we + // test against recycling without reclearing. + if (0 == i) { + texCtx->writePixels(info, data.get(), 0, 0, 0); + } + } + context->purgeAllUnlockedResources(); + + // Try creating the texture as a deferred proxy. + for (int i = 0; i < 2; ++i) { + auto surfCtx = context->contextPriv().makeDeferredSurfaceContext( + desc, approx ? SkBackingFit::kApprox : SkBackingFit::kExact, + SkBudgeted::kYes); + if (!surfCtx) { + continue; + } + SkImageInfo info = SkImageInfo::Make( + kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType); + memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t)); + if (surfCtx->readPixels(info, data.get(), 0, 0, 0)) { + uint32_t cmp = GrPixelConfigIsOpaque(desc.fConfig) ? 0xFF000000 : 0; + for (int i = 0; i < kSize * kSize; ++i) { + if (cmp != data.get()[i]) { + ERRORF(reporter, "Failed on config %d", desc.fConfig); + break; } } - // Here we overwrite the texture so that the second time through we - // test against recycling without reclearing. - if (0 == i) { - surfCtx->writePixels(info, data.get(), 0, 0, 0); - } } - context->purgeAllUnlockedResources(); + // Here we overwrite the texture so that the second time through we + // test against recycling without reclearing. + if (0 == i) { + surfCtx->writePixels(info, data.get(), 0, 0, 0); + } } + context->purgeAllUnlockedResources(); } } } |