From 1530283c483cb88aa725bce50a6d193dd00ee570 Mon Sep 17 00:00:00 2001 From: kkinnunen Date: Tue, 1 Dec 2015 04:35:26 -0800 Subject: 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 --- tests/FloatingPointTextureTest.cpp | 59 ++++++++++++++------------------------ 1 file changed, 22 insertions(+), 37 deletions(-) (limited to 'tests/FloatingPointTextureTest.cpp') diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp index c5103c813f..04f73c7cd9 100644 --- a/tests/FloatingPointTextureTest.cpp +++ b/tests/FloatingPointTextureTest.cpp @@ -14,19 +14,17 @@ #include #include "Test.h" + #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrTexture.h" -#include "GrContextFactory.h" - -#include "SkGpuDevice.h" #include "SkHalf.h" static const int DEV_W = 100, DEV_H = 100; static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H); template -void runFPTest(skiatest::Reporter* reporter, GrContextFactory* factory, +void runFPTest(skiatest::Reporter* reporter, GrContext* context, T min, T max, T epsilon, T maxInt, int arraySize, GrPixelConfig config) { SkTDArray controlPixelData, readBuffer; controlPixelData.setCount(arraySize); @@ -40,43 +38,30 @@ void runFPTest(skiatest::Reporter* reporter, GrContextFactory* factory, } for (int origin = 0; origin < 2; ++origin) { - for (int glCtxType = 0; glCtxType < GrContextFactory::kGLContextTypeCnt; ++glCtxType) { - GrSurfaceDesc desc; - desc.fFlags = kRenderTarget_GrSurfaceFlag; - desc.fWidth = DEV_W; - desc.fHeight = DEV_H; - desc.fConfig = config; - desc.fOrigin = 0 == origin ? + GrSurfaceDesc desc; + desc.fFlags = kRenderTarget_GrSurfaceFlag; + desc.fWidth = DEV_W; + desc.fHeight = DEV_H; + desc.fConfig = config; + desc.fOrigin = 0 == origin ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin; - - GrContextFactory::GLContextType type = - static_cast(glCtxType); - if (!GrContextFactory::IsRenderingGLContext(type)) { - continue; - } - GrContext* context = factory->get(type); - if (nullptr == context) { - continue; - } - - SkAutoTUnref fpTexture(context->textureProvider()->createTexture( - desc, false, controlPixelData.begin(), 0)); - // Floating point textures are NOT supported everywhere - if (nullptr == fpTexture) { - continue; - } - fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.begin(), 0); - REPORTER_ASSERT(reporter, - 0 == memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes())); + SkAutoTUnref fpTexture(context->textureProvider()->createTexture( + desc, false, controlPixelData.begin(), 0)); + // Floating point textures are NOT supported everywhere + if (nullptr == fpTexture) { + continue; } + fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.begin(), 0); + REPORTER_ASSERT(reporter, + 0 == memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes())); } } static const int FP_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 4/*RGBA*/; static const float kMaxIntegerRepresentableInSPFloatingPoint = 16777216; // 2 ^ 24 -DEF_GPUTEST(FloatingPointTextureTest, reporter, factory) { - runFPTest(reporter, factory, FLT_MIN, FLT_MAX, FLT_EPSILON, +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FloatingPointTextureTest, reporter, context) { + runFPTest(reporter, context, FLT_MIN, FLT_MAX, FLT_EPSILON, kMaxIntegerRepresentableInSPFloatingPoint, FP_CONTROL_ARRAY_SIZE, kRGBA_float_GrPixelConfig); } @@ -84,16 +69,16 @@ DEF_GPUTEST(FloatingPointTextureTest, reporter, factory) { static const int HALF_ALPHA_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 1 /*alpha-only*/; static const SkHalf kMaxIntegerRepresentableInHalfFloatingPoint = 0x6800; // 2 ^ 11 -DEF_GPUTEST(HalfFloatAlphaTextureTest, reporter, factory) { - runFPTest(reporter, factory, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon, +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(HalfFloatAlphaTextureTest, reporter, context) { + runFPTest(reporter, context, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon, kMaxIntegerRepresentableInHalfFloatingPoint, HALF_ALPHA_CONTROL_ARRAY_SIZE, kAlpha_half_GrPixelConfig); } static const int HALF_RGBA_CONTROL_ARRAY_SIZE = DEV_W * DEV_H * 4 /*RGBA*/; -DEF_GPUTEST(HalfFloatRGBATextureTest, reporter, factory) { - runFPTest(reporter, factory, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon, +DEF_GPUTEST_FOR_RENDERING_CONTEXTS(HalfFloatRGBATextureTest, reporter, context) { + runFPTest(reporter, context, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon, kMaxIntegerRepresentableInHalfFloatingPoint, HALF_RGBA_CONTROL_ARRAY_SIZE, kRGBA_half_GrPixelConfig); } -- cgit v1.2.3