aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FloatingPointTextureTest.cpp
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-12-01 04:35:26 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-01 04:35:26 -0800
commit1530283c483cb88aa725bce50a6d193dd00ee570 (patch)
treec34d73ac28d83690a4cbf1196854176677e07366 /tests/FloatingPointTextureTest.cpp
parent362c900625dc2ece854678455776b711c1e44c04 (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/FloatingPointTextureTest.cpp')
-rw-r--r--tests/FloatingPointTextureTest.cpp59
1 files changed, 22 insertions, 37 deletions
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 <float.h>
#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 <typename T>
-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<T> 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<GrContextFactory::GLContextType>(glCtxType);
- if (!GrContextFactory::IsRenderingGLContext(type)) {
- continue;
- }
- GrContext* context = factory->get(type);
- if (nullptr == context) {
- continue;
- }
-
- SkAutoTUnref<GrTexture> 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<GrTexture> 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<float>(reporter, factory, FLT_MIN, FLT_MAX, FLT_EPSILON,
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FloatingPointTextureTest, reporter, context) {
+ runFPTest<float>(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<SkHalf>(reporter, factory, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon,
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(HalfFloatAlphaTextureTest, reporter, context) {
+ runFPTest<SkHalf>(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<SkHalf>(reporter, factory, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon,
+DEF_GPUTEST_FOR_RENDERING_CONTEXTS(HalfFloatRGBATextureTest, reporter, context) {
+ runFPTest<SkHalf>(reporter, context, SK_HalfMin, SK_HalfMax, SK_HalfEpsilon,
kMaxIntegerRepresentableInHalfFloatingPoint,
HALF_RGBA_CONTROL_ARRAY_SIZE, kRGBA_half_GrPixelConfig);
}