diff options
author | kkinnunen <kkinnunen@nvidia.com> | 2015-12-01 04:35:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-01 04:35:26 -0800 |
commit | 1530283c483cb88aa725bce50a6d193dd00ee570 (patch) | |
tree | c34d73ac28d83690a4cbf1196854176677e07366 /tests/GrTextureMipMapInvalidationTest.cpp | |
parent | 362c900625dc2ece854678455776b711c1e44c04 (diff) |
Generate list of GPU contexts outside tests
Use DEF_GPUTEST_FOR_*_CONTEXT macros to obtain the
test GPU context.
Makes changing the context -related classes easier,
since not all tests need to be changed.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1448873002
Diffstat (limited to 'tests/GrTextureMipMapInvalidationTest.cpp')
-rw-r--r-- | tests/GrTextureMipMapInvalidationTest.cpp | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/tests/GrTextureMipMapInvalidationTest.cpp b/tests/GrTextureMipMapInvalidationTest.cpp index f046f8ff6b..e0a12829cc 100644 --- a/tests/GrTextureMipMapInvalidationTest.cpp +++ b/tests/GrTextureMipMapInvalidationTest.cpp @@ -10,7 +10,6 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrContextFactory.h" #include "GrTexture.h" #include "GrTexturePriv.h" #include "SkCanvas.h" @@ -20,47 +19,44 @@ // Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static upcasting of texture // and render targets to GrSurface all work as expected. -DEF_GPUTEST(GrTextureMipMapInvalidationTest, reporter, factory) { - GrContext* context = factory->get(GrContextFactory::kNull_GLContextType); - if (context) { - GrSurfaceDesc desc; - desc.fConfig = kSkia8888_GrPixelConfig; - desc.fFlags = kRenderTarget_GrSurfaceFlag; - desc.fWidth = 256; - desc.fHeight = 256; - desc.fSampleCnt = 0; - GrSurface* texRT1 = context->textureProvider()->createTexture(desc, false, nullptr, 0); - GrSurface* texRT2 = context->textureProvider()->createTexture(desc, false, nullptr, 0); - REPORTER_ASSERT(reporter, nullptr != texRT1); - REPORTER_ASSERT(reporter, nullptr != texRT2); - GrTexture* tex = texRT1->asTexture(); - REPORTER_ASSERT(reporter, nullptr != tex); - SkBitmap bitmap; - GrWrapTextureInBitmap(tex, 256, 256, false, &bitmap); - - // No mipmaps initially - REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps()); - - // Painting with downscale and medium filter quality should result in mipmap creation - SkSurface* surface = SkSurface::NewRenderTargetDirect(texRT2->asRenderTarget()); - SkPaint paint; - paint.setFilterQuality(kMedium_SkFilterQuality); - surface->getCanvas()->scale(0.2f, 0.2f); - surface->getCanvas()->drawBitmap(bitmap, 0, 0, &paint); - context->flush(); - - REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); - REPORTER_ASSERT(reporter, false == tex->texturePriv().mipMapsAreDirty()); - - // Invalidating the contents of the bitmap should invalidate the mipmap, but not de-allocate - bitmap.notifyPixelsChanged(); - REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); - REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty()); - - surface->unref(); - texRT1->unref(); - texRT2->unref(); - } +DEF_GPUTEST_FOR_NULL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, context) { + GrSurfaceDesc desc; + desc.fConfig = kSkia8888_GrPixelConfig; + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fWidth = 256; + desc.fHeight = 256; + desc.fSampleCnt = 0; + GrSurface* texRT1 = context->textureProvider()->createTexture(desc, false, nullptr, 0); + GrSurface* texRT2 = context->textureProvider()->createTexture(desc, false, nullptr, 0); + REPORTER_ASSERT(reporter, nullptr != texRT1); + REPORTER_ASSERT(reporter, nullptr != texRT2); + GrTexture* tex = texRT1->asTexture(); + REPORTER_ASSERT(reporter, nullptr != tex); + SkBitmap bitmap; + GrWrapTextureInBitmap(tex, 256, 256, false, &bitmap); + + // No mipmaps initially + REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps()); + + // Painting with downscale and medium filter quality should result in mipmap creation + SkSurface* surface = SkSurface::NewRenderTargetDirect(texRT2->asRenderTarget()); + SkPaint paint; + paint.setFilterQuality(kMedium_SkFilterQuality); + surface->getCanvas()->scale(0.2f, 0.2f); + surface->getCanvas()->drawBitmap(bitmap, 0, 0, &paint); + context->flush(); + + REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); + REPORTER_ASSERT(reporter, false == tex->texturePriv().mipMapsAreDirty()); + + // Invalidating the contents of the bitmap should invalidate the mipmap, but not de-allocate + bitmap.notifyPixelsChanged(); + REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps()); + REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty()); + + surface->unref(); + texRT1->unref(); + texRT2->unref(); } #endif |