Rename enums in GrContextFactory to remove "GL"

Also, remove kNative as a separate context type and instead make it an alias for kGL or kGLES based on OS.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1845923004

Committed: https://skia.googlesource.com/skia/+/2d9c6f81353597aebf5934547e5cba7a872196fb

Review URL: https://codereview.chromium.org/1845923004
This commit is contained in:
bsalomon 2016-04-05 11:06:27 -07:00 committed by Commit bot
parent 3a15fd4a9a
commit 85b4b53e78
21 changed files with 182 additions and 184 deletions

View File

@ -385,11 +385,11 @@ static int setup_gpu_bench(Target* target, Benchmark* bench, int maxGpuFrameLag)
}
#if SK_SUPPORT_GPU
#define kBogusGLContextType GrContextFactory::kNative_GLContextType
#define kBogusGLContextOptions GrContextFactory::kNone_GLContextOptions
#define kBogusContextType GrContextFactory::kNativeGL_ContextType
#define kBogusContextOptions GrContextFactory::kNone_ContextOptions
#else
#define kBogusGLContextType 0
#define kBogusGLContextOptions 0
#define kBogusContextType 0
#define kBogusContextOptions 0
#endif
static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* configs) {
@ -399,8 +399,8 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
if (!FLAGS_gpu)
return;
const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEnableNVPR_GLContextOptions
: GrContextFactory::kNone_GLContextOptions;
const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEnableNVPR_ContextOptions
: GrContextFactory::kNone_ContextOptions;
const auto ctxType = gpuConfig->getContextType();
const auto sampleCount = gpuConfig->getSamples();
@ -437,7 +437,7 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
if (config->getTag().equals(#name)) { \
Config config = { \
SkString(#name), Benchmark::backend, color, alpha, profile, \
0, kBogusGLContextType, kBogusGLContextOptions, false \
0, kBogusContextType, kBogusContextOptions, false \
}; \
configs->push_back(config); \
return; \
@ -463,7 +463,7 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
if (config->getTag().equals("hwui")) {
Config config = { SkString("hwui"), Benchmark::kHWUI_Backend,
kRGBA_8888_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfileType,
0, kBogusGLContextType, kBogusGLContextOptions, false };
0, kBogusContextType, kBogusContextOptions, false };
configs->push_back(config);
}
#endif

View File

@ -29,8 +29,8 @@ struct Config {
SkColorProfileType profile;
int samples;
#if SK_SUPPORT_GPU
sk_gpu_test::GrContextFactory::GLContextType ctxType;
sk_gpu_test::GrContextFactory::GLContextOptions ctxOptions;
sk_gpu_test::GrContextFactory::ContextType ctxType;
sk_gpu_test::GrContextFactory::ContextOptions ctxOptions;
bool useDFText;
#else
int bogusInt;

View File

@ -814,17 +814,17 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
#if SK_SUPPORT_GPU
if (gpu_supported()) {
if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
GrContextFactory::GLContextType contextType = gpuConfig->getContextType();
GrContextFactory::GLContextOptions contextOptions =
GrContextFactory::kNone_GLContextOptions;
GrContextFactory::ContextType contextType = gpuConfig->getContextType();
GrContextFactory::ContextOptions contextOptions =
GrContextFactory::kNone_ContextOptions;
if (gpuConfig->getUseNVPR()) {
contextOptions = static_cast<GrContextFactory::GLContextOptions>(
contextOptions | GrContextFactory::kEnableNVPR_GLContextOptions);
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kEnableNVPR_ContextOptions);
}
if (kSRGB_SkColorProfileType == gpuConfig->getProfileType() ||
kRGBA_F16_SkColorType == gpuConfig->getColorType()) {
contextOptions = static_cast<GrContextFactory::GLContextOptions>(
contextOptions | GrContextFactory::kRequireSRGBSupport_GLContextOptions);
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kRequireSRGBSupport_ContextOptions);
}
GrContextFactory testFactory;
if (!testFactory.get(contextType, contextOptions)) {
@ -1441,35 +1441,36 @@ void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
// Iterate over context types, except use "native" instead of explicitly trying OpenGL and
// OpenGL ES. Do not use GLES on desktop, since tests do not account for not fixing
// http://skbug.com/2809
GrContextFactory::GLContextType contextTypes[] = {
GrContextFactory::kNative_GLContextType,
GrContextFactory::ContextType contextTypes[] = {
GrContextFactory::kNativeGL_ContextType,
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
GrContextFactory::kANGLE_GLContextType,
GrContextFactory::kANGLE_ContextType,
#endif
GrContextFactory::kANGLE_GL_GLContextType,
GrContextFactory::kANGLE_GL_ContextType,
#endif
#if SK_COMMAND_BUFFER
GrContextFactory::kCommandBuffer_GLContextType,
GrContextFactory::kCommandBuffer_ContextType,
#endif
#if SK_MESA
GrContextFactory::kMESA_GLContextType,
GrContextFactory::kMESA_ContextType,
#endif
GrContextFactory::kNull_GLContextType,
GrContextFactory::kDebug_GLContextType,
GrContextFactory::kNullGL_ContextType,
GrContextFactory::kDebugGL_ContextType,
};
static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kGLContextTypeCnt - 2,
"Skipping unexpected GLContextType for GPU tests");
// Should have named all the context types except one of GL or GLES.
static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kContextTypeCnt - 1,
"Skipping unexpected ContextType for GPU tests");
for (auto& contextType : contextTypes) {
int contextSelector = kNone_GPUTestContexts;
if (GrContextFactory::IsRenderingGLContext(contextType)) {
if (GrContextFactory::IsRenderingContext(contextType)) {
contextSelector |= kAllRendering_GPUTestContexts;
} else if (contextType == GrContextFactory::kNative_GLContextType) {
} else if (contextType == GrContextFactory::kNativeGL_ContextType) {
contextSelector |= kNative_GPUTestContexts;
} else if (contextType == GrContextFactory::kNull_GLContextType) {
} else if (contextType == GrContextFactory::kNullGL_ContextType) {
contextSelector |= kNull_GPUTestContexts;
} else if (contextType == GrContextFactory::kDebug_GLContextType) {
} else if (contextType == GrContextFactory::kDebugGL_ContextType) {
contextSelector |= kDebug_GPUTestContexts;
}
if ((testContexts & contextSelector) == 0) {
@ -1480,7 +1481,7 @@ void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
call_test(test, reporter, context);
}
context = factory->getContextInfo(contextType,
GrContextFactory::kEnableNVPR_GLContextOptions);
GrContextFactory::kEnableNVPR_ContextOptions);
if (context.fGrContext) {
call_test(test, reporter, context);
}

View File

@ -30,8 +30,8 @@ static const bool kGPUDisabled = false;
static inline sk_sp<SkSurface> NewGpuSurface(
sk_gpu_test::GrContextFactory* grFactory,
sk_gpu_test::GrContextFactory::GLContextType type,
sk_gpu_test::GrContextFactory::GLContextOptions options,
sk_gpu_test::GrContextFactory::ContextType type,
sk_gpu_test::GrContextFactory::ContextOptions options,
SkImageInfo info,
int samples,
bool useDIText) {
@ -66,20 +66,22 @@ public:
GrContextFactory() {};
explicit GrContextFactory(const GrContextOptions&) {}
typedef int GLContextType;
typedef int ContextType;
static const GLContextType kANGLE_GLContextType = 0,
kANGLE_GL_GLContextType = 0,
kCommandBuffer_GLContextType = 0,
kDebug_GLContextType = 0,
kMESA_GLContextType = 0,
kNVPR_GLContextType = 0,
kNative_GLContextType = 0,
kNull_GLContextType = 0;
static const int kGLContextTypeCnt = 1;
enum GLContextOptions {
kNone_GLContextOptions = 0,
kEnableNVPR_GLContextOptions = 0x1,
static const ContextType kANGLE_ContextType = 0,
kANGLE_GL_ContextType = 0,
kCommandBuffer_ContextType = 0,
kDebugGL_ContextType = 0,
kMESA_ContextType = 0,
kNVPR_ContextType = 0,
kNativeGL_ContextType = 0,
kGL_ContextType = 0,
kGLES_ContextType = 0,
kNullGL_ContextType = 0;
static const int kContextTypeCnt = 1;
enum ContextOptions {
kNone_ContextOptions = 0,
kEnableNVPR_ContextOptions = 0x1,
};
void destroyContexts() {}
@ -94,8 +96,8 @@ namespace DM {
static const bool kGPUDisabled = true;
static inline SkSurface* NewGpuSurface(sk_gpu_test::GrContextFactory*,
sk_gpu_test::GrContextFactory::GLContextType,
sk_gpu_test::GrContextFactory::GLContextOptions,
sk_gpu_test::GrContextFactory::ContextType,
sk_gpu_test::GrContextFactory::ContextOptions,
SkImageInfo,
int,
bool) {

View File

@ -941,8 +941,8 @@ Error NullSink::draw(const Src& src, SkBitmap*, SkWStream*, SkString*) const {
DEFINE_bool(gpuStats, false, "Append GPU stats to the log for each GPU task?");
GPUSink::GPUSink(GrContextFactory::GLContextType ct,
GrContextFactory::GLContextOptions options,
GPUSink::GPUSink(GrContextFactory::ContextType ct,
GrContextFactory::ContextOptions options,
int samples,
bool diText,
SkColorType colorType,

View File

@ -232,8 +232,8 @@ public:
class GPUSink : public Sink {
public:
GPUSink(sk_gpu_test::GrContextFactory::GLContextType,
sk_gpu_test::GrContextFactory::GLContextOptions,
GPUSink(sk_gpu_test::GrContextFactory::ContextType,
sk_gpu_test::GrContextFactory::ContextOptions,
int samples, bool diText, SkColorType colorType, SkColorProfileType profileType,
bool threaded);
@ -242,8 +242,8 @@ public:
const char* fileExtension() const override { return "png"; }
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; }
private:
sk_gpu_test::GrContextFactory::GLContextType fContextType;
sk_gpu_test::GrContextFactory::GLContextOptions fContextOptions;
sk_gpu_test::GrContextFactory::ContextType fContextType;
sk_gpu_test::GrContextFactory::ContextOptions fContextOptions;
int fSampleCount;
bool fUseDIText;
SkColorType fColorType;

View File

@ -16,10 +16,10 @@ using sk_gpu_test::GrContextFactory;
DEF_GPUTEST(GrContext_abandonContext, reporter, /*factory*/) {
for (int testType = 0; testType < 6; ++testType) {
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory testFactory;
GrContextFactory::GLContextType ctxType = (GrContextFactory::GLContextType) i;
GrContextFactory::ContextInfo info = testFactory.getContextInfo(ctxType);
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory testFactory;
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
GrContextFactory::ContextInfo info = testFactory.getContextInfo(ctxType);
if (GrContext* context = info.fGrContext) {
switch (testType) {
case 0:

View File

@ -20,10 +20,10 @@ DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
// or the context creation fails.
GrContextFactory testFactory;
// Test that if NVPR is possible, caps are in sync.
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory::GLContextType>(i);
GrContext* context = testFactory.get(glCtxType,
GrContextFactory::kEnableNVPR_GLContextOptions);
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context = testFactory.get(ctxType,
GrContextFactory::kEnableNVPR_ContextOptions);
if (!context) {
continue;
}
@ -37,9 +37,9 @@ DEF_GPUTEST(GrContextFactory_NoPathRenderingUnlessNVPRRequested, reporter, /*fac
// Test that if NVPR is not requested, the context never has path rendering support.
GrContextFactory testFactory;
for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) {
GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
GrContext* context = testFactory.get(glCtxType);
for (int i = 0; i <= GrContextFactory::kLastContextType; ++i) {
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType)i;
GrContext* context = testFactory.get(ctxType);
if (context) {
REPORTER_ASSERT(
reporter,
@ -54,16 +54,15 @@ DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
// created without that flag would not have had sRGB support.
GrContextFactory testFactory;
// Test that if sRGB is requested, caps are in sync.
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory::GLContextType>(i);
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context =
testFactory.get(glCtxType,
GrContextFactory::kRequireSRGBSupport_GLContextOptions);
testFactory.get(ctxType, GrContextFactory::kRequireSRGBSupport_ContextOptions);
if (context) {
REPORTER_ASSERT(reporter, context->caps()->srgbSupport());
} else {
context = testFactory.get(glCtxType);
context = testFactory.get(ctxType);
if (context) {
REPORTER_ASSERT(reporter, !context->caps()->srgbSupport());
}
@ -73,10 +72,9 @@ DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
GrContextFactory testFactory;
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
GrContextFactory::ContextInfo info1 =
testFactory.getContextInfo(glCtxType);
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
GrContextFactory::ContextInfo info1 = testFactory.getContextInfo(ctxType);
if (!info1.fGrContext) {
continue;
}
@ -87,7 +85,7 @@ DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
// Test that we get different context after abandon.
GrContextFactory::ContextInfo info2 =
testFactory.getContextInfo(glCtxType);
testFactory.getContextInfo(ctxType);
REPORTER_ASSERT(reporter, info2.fGrContext);
REPORTER_ASSERT(reporter, info2.fGLContext);
REPORTER_ASSERT(reporter, info1.fGrContext != info2.fGrContext);

View File

@ -1148,7 +1148,7 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
GrContextOptions opts;
opts.fSuppressDualSourceBlending = true;
sk_gpu_test::GrContextFactory mockFactory(opts);
GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNull_GLContextType);
GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNullGL_ContextType);
if (!ctx) {
SkFAIL("Failed to create null context without ARB_blend_func_extended.");
return;

View File

@ -407,7 +407,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_Gpu2Cpu, reporter, context) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_newTextureImage, reporter, context, glContext) {
GrContextFactory otherFactory;
GrContextFactory::ContextInfo otherContextInfo =
otherFactory.getContextInfo(GrContextFactory::kNative_GLContextType);
otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType);
glContext->makeCurrent();
std::function<sk_sp<SkImage>()> imageFactories[] = {
@ -825,7 +825,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredTextureImage, reporter, context, glCo
GrContextFactory otherFactory;
GrContextFactory::ContextInfo otherContextInfo =
otherFactory.getContextInfo(GrContextFactory::kNative_GLContextType);
otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType);
glContext->makeCurrent();
REPORTER_ASSERT(reporter, proxy);

View File

@ -253,11 +253,11 @@ static SkString make_png_name(const char* filename) {
return pngName;
}
typedef GrContextFactory::GLContextType GLContextType;
typedef GrContextFactory::ContextType ContextType;
#ifdef SK_BUILD_FOR_WIN
static const GLContextType kAngle = GrContextFactory::kANGLE_GLContextType;
static const ContextType kAngle = GrContextFactory::kANGLE_ContextType;
#else
static const GLContextType kNative = GrContextFactory::kNative_GLContextType;
static const ContextType kNative = GrContextFactory::kNativeGL_ContextType;
#endif
static int similarBits(const SkBitmap& gr, const SkBitmap& sk) {

View File

@ -41,7 +41,7 @@ DEF_TEST(ParseConfigs_Gpu, reporter) {
#if SK_SUPPORT_GPU
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu());
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType()
== GrContextFactory::kNative_GLContextType);
== GrContextFactory::kNativeGL_ContextType);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
@ -184,48 +184,48 @@ DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) {
}
#if SK_SUPPORT_GPU
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() ==
GrContextFactory::kNative_GLContextType);
GrContextFactory::kNativeGL_ContextType);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR());
REPORTER_ASSERT(reporter, !configs[0]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
REPORTER_ASSERT(reporter, configs[1]->asConfigGpu()->getContextType() ==
GrContextFactory::kANGLE_GLContextType);
GrContextFactory::kANGLE_ContextType);
#else
REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
#endif
REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()->getContextType() ==
GrContextFactory::kANGLE_GL_GLContextType);
GrContextFactory::kANGLE_GL_ContextType);
#else
REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu());
#endif
#if SK_MESA
REPORTER_ASSERT(reporter, configs[3]->asConfigGpu()->getContextType() ==
GrContextFactory::kMESA_GLContextType);
GrContextFactory::kMESA_ContextType);
#else
REPORTER_ASSERT(reporter, !configs[3]->asConfigGpu());
#endif
#if SK_COMMAND_BUFFER
REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()->getContextType() ==
GrContextFactory::kCommandBuffer_GLContextType);
GrContextFactory::kCommandBuffer_ContextType);
#else
REPORTER_ASSERT(reporter, !configs[4]->asConfigGpu());
#endif
REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() ==
GrContextFactory::kNative_GLContextType);
GrContextFactory::kNativeGL_ContextType);
REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR());
REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0);
REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() ==
GrContextFactory::kGLES_GLContextType);
GrContextFactory::kGLES_ContextType);
REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR());
REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0);
REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getContextType() ==
GrContextFactory::kGL_GLContextType);
GrContextFactory::kGL_ContextType);
REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseNVPR());
REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 0);
@ -260,16 +260,13 @@ DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) {
}
}
DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) {
// These just list explicitly some properties of the system.
SkCommandLineFlags::StringArray config1 = make_string_array({
// Options are not canonized -> two same configs have a different tag.
"gpu(nvpr=true,dit=true)", "gpu(dit=true,nvpr=true)",
// API native is alias for gl or gles, but it's not canonized -> different tag.
"gpu(api=native)", "gpu(api=gl)", "gpu(api=gles)", ""
// Default values are not canonized -> different tag.
"gpu", "gpu()", "gpu(samples=0)", "gpu(api=native,samples=0)"
"gpu(api=debug)", "gpu(api=gl)", "gpu(api=gles)", ""
"gpu", "gpu()", "gpu(samples=0)", "gpu(api=gles,samples=0)"
});
SkCommandLineConfigArray configs;
ParseConfigs(config1, &configs);

View File

@ -200,12 +200,12 @@ DEF_GPUTEST(VkClearTests, reporter, factory) {
GrContextOptions opts;
opts.fSuppressPrints = true;
GrContextFactory debugFactory(opts);
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
if (static_cast<GrContextFactory::GLContextType>(type) !=
GrContextFactory::kNative_GLContextType) {
for (int type = 0; type < GrContextFactory::kContextTypeCnt; ++type) {
if (static_cast<GrContextFactory::ContextType>(type) !=
GrContextFactory::kNativeGL_ContextType) {
continue;
}
GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(type));
GrContext* context = debugFactory.get(static_cast<GrContextFactory::ContextType>(type));
if (context) {
basic_clear_test(reporter, context, kRGBA_8888_GrPixelConfig);
basic_clear_test(reporter, context, kBGRA_8888_GrPixelConfig);

View File

@ -137,12 +137,12 @@ DEF_GPUTEST(VkUploadPixelsTests, reporter, factory) {
GrContextOptions opts;
opts.fSuppressPrints = true;
GrContextFactory debugFactory(opts);
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
if (static_cast<GrContextFactory::GLContextType>(type) !=
GrContextFactory::kNative_GLContextType) {
for (int type = 0; type < GrContextFactory::kContextTypeCnt; ++type) {
if (static_cast<GrContextFactory::ContextType>(type) !=
GrContextFactory::kNativeGL_ContextType) {
continue;
}
GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(type));
GrContext* context = debugFactory.get(static_cast<GrContextFactory::ContextType>(type));
if (context) {
basic_texture_test(reporter, context, kRGBA_8888_GrPixelConfig, false, false);
basic_texture_test(reporter, context, kRGBA_8888_GrPixelConfig, true, false);

View File

@ -162,12 +162,12 @@ DEF_GPUTEST(VkWrapTests, reporter, factory) {
GrContextOptions opts;
opts.fSuppressPrints = true;
GrContextFactory debugFactory(opts);
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
if (static_cast<GrContextFactory::GLContextType>(type) !=
GrContextFactory::kNative_GLContextType) {
for (int type = 0; type < GrContextFactory::kLastContextType; ++type) {
if (static_cast<GrContextFactory::ContextType>(type) !=
GrContextFactory::kNativeGL_ContextType) {
continue;
}
GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(type));
GrContext* context = debugFactory.get(static_cast<GrContextFactory::ContextType>(type));
if (context) {
wrap_tex_test(reporter, context);
wrap_rt_test(reporter, context);

View File

@ -211,47 +211,43 @@ static bool parse_option_bool(const SkString& value, bool* outBool) {
}
static bool parse_option_gpu_api(const SkString& value,
SkCommandLineConfigGpu::ContextType* outContextType) {
if (value.equals("native")) {
*outContextType = GrContextFactory::kNative_GLContextType;
return true;
}
if (value.equals("gl")) {
*outContextType = GrContextFactory::kGL_GLContextType;
*outContextType = GrContextFactory::kGL_ContextType;
return true;
}
if (value.equals("gles")) {
*outContextType = GrContextFactory::kGLES_GLContextType;
*outContextType = GrContextFactory::kGLES_ContextType;
return true;
}
if (value.equals("debug")) {
*outContextType = GrContextFactory::kDebug_GLContextType;
*outContextType = GrContextFactory::kDebugGL_ContextType;
return true;
}
if (value.equals("null")) {
*outContextType = GrContextFactory::kNull_GLContextType;
*outContextType = GrContextFactory::kNullGL_ContextType;
return true;
}
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
if (value.equals("angle")) {
*outContextType = GrContextFactory::kANGLE_GLContextType;
*outContextType = GrContextFactory::kANGLE_ContextType;
return true;
}
#endif
if (value.equals("angle-gl")) {
*outContextType = GrContextFactory::kANGLE_GL_GLContextType;
*outContextType = GrContextFactory::kANGLE_GL_ContextType;
return true;
}
#endif
#if SK_COMMAND_BUFFER
if (value.equals("commandbuffer")) {
*outContextType = GrContextFactory::kCommandBuffer_GLContextType;
*outContextType = GrContextFactory::kCommandBuffer_ContextType;
return true;
}
#endif
#if SK_MESA
if (value.equals("mesa")) {
*outContextType = GrContextFactory::kMESA_GLContextType;
*outContextType = GrContextFactory::kMESA_ContextType;
return true;
}
#endif
@ -283,7 +279,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
const SkString& options) {
// Defaults for GPU backend.
bool seenAPI = false;
SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNative_GLContextType;
SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeGL_ContextType;
bool seenUseNVPR = false;
bool useNVPR = false;
bool seenUseDIText =false;

View File

@ -50,7 +50,7 @@ class SkCommandLineConfig {
// * backends that represent a shorthand of above (such as "msaa16" representing "gpu(samples=16)")
class SkCommandLineConfigGpu : public SkCommandLineConfig {
public:
typedef sk_gpu_test::GrContextFactory::GLContextType ContextType;
typedef sk_gpu_test::GrContextFactory::ContextType ContextType;
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useDIText, int samples,
SkColorType colorType, SkColorProfileType profileType);

View File

@ -74,8 +74,16 @@ void GrContextFactory::releaseResourcesAndAbandonContexts() {
}
}
GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType type,
GLContextOptions options) {
#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
const GrContextFactory::ContextType GrContextFactory::kNativeGL_ContextType =
GrContextFactory::kGL_ContextType;
#else
const GrContextFactory::ContextType GrContextFactory::kNativeGL_ContextType =
GrContextFactory::kGLES_ContextType;
#endif
GrContextFactory::ContextInfo GrContextFactory::getContextInfo(ContextType type,
ContextOptions options) {
for (int i = 0; i < fContexts.count(); ++i) {
Context& context = fContexts[i];
if (!context.fGLContext) {
@ -90,39 +98,36 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
SkAutoTDelete<GLTestContext> glCtx;
SkAutoTUnref<GrContext> grCtx;
switch (type) {
case kNative_GLContextType:
glCtx.reset(CreatePlatformGLTestContext(kNone_GrGLStandard));
break;
case kGL_GLContextType:
case kGL_ContextType:
glCtx.reset(CreatePlatformGLTestContext(kGL_GrGLStandard));
break;
case kGLES_GLContextType:
case kGLES_ContextType:
glCtx.reset(CreatePlatformGLTestContext(kGLES_GrGLStandard));
break;
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
case kANGLE_GLContextType:
case kANGLE_ContextType:
glCtx.reset(CreateANGLEDirect3DGLTestContext());
break;
#endif
case kANGLE_GL_GLContextType:
case kANGLE_GL_ContextType:
glCtx.reset(CreateANGLEOpenGLGLTestContext());
break;
#endif
#if SK_COMMAND_BUFFER
case kCommandBuffer_GLContextType:
case kCommandBuffer_ContextType:
glCtx.reset(CommandBufferGLTestContext::Create());
break;
#endif
#if SK_MESA
case kMESA_GLContextType:
case kMESA_ContextType:
glCtx.reset(CreateMesaGLTestContext());
break;
#endif
case kNull_GLContextType:
case kNullGL_ContextType:
glCtx.reset(CreateNullGLTestContext());
break;
case kDebug_GLContextType:
case kDebugGL_ContextType:
glCtx.reset(CreateDebugGLTestContext());
break;
}
@ -134,7 +139,7 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
// Block NVPR from non-NVPR types.
SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
if (!(kEnableNVPR_GLContextOptions & options)) {
if (!(kEnableNVPR_ContextOptions & options)) {
glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface));
if (!glInterface) {
return ContextInfo();
@ -143,7 +148,7 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
glCtx->makeCurrent();
#ifdef SK_VULKAN
if (kEnableNVPR_GLContextOptions & options) {
if (kEnableNVPR_ContextOptions & options) {
return ContextInfo();
} else {
GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(GrVkBackendContext::Create());
@ -156,12 +161,12 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
if (!grCtx.get()) {
return ContextInfo();
}
if (kEnableNVPR_GLContextOptions & options) {
if (kEnableNVPR_ContextOptions & options) {
if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
return ContextInfo();
}
}
if (kRequireSRGBSupport_GLContextOptions & options) {
if (kRequireSRGBSupport_ContextOptions & options) {
if (!grCtx->caps()->srgbSupport()) {
return ContextInfo();
}

View File

@ -24,76 +24,76 @@ namespace sk_gpu_test {
*/
class GrContextFactory : SkNoncopyable {
public:
enum GLContextType {
kNative_GLContextType, //! OpenGL or OpenGL ES context.
kGL_GLContextType, //! OpenGL context.
kGLES_GLContextType, //! OpenGL ES context.
enum ContextType {
kGL_ContextType, //! OpenGL context.
kGLES_ContextType, //! OpenGL ES context.
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
kANGLE_GLContextType, //! ANGLE on DirectX OpenGL ES context.
kANGLE_ContextType, //! ANGLE on DirectX OpenGL ES context.
#endif
kANGLE_GL_GLContextType, //! ANGLE on OpenGL OpenGL ES context.
kANGLE_GL_ContextType, //! ANGLE on OpenGL OpenGL ES context.
#endif
#if SK_COMMAND_BUFFER
kCommandBuffer_GLContextType, //! Chromium command buffer OpenGL ES context.
kCommandBuffer_ContextType, //! Chromium command buffer OpenGL ES context.
#endif
#if SK_MESA
kMESA_GLContextType, //! MESA OpenGL context
kMESA_ContextType, //! MESA OpenGL context
#endif
kNull_GLContextType, //! Non-rendering OpenGL mock context.
kDebug_GLContextType, //! Non-rendering, state verifying OpenGL context.
kLastGLContextType = kDebug_GLContextType
kNullGL_ContextType, //! Non-rendering OpenGL mock context.
kDebugGL_ContextType, //! Non-rendering, state verifying OpenGL context.
kLastContextType = kDebugGL_ContextType
};
static const int kGLContextTypeCnt = kLastGLContextType + 1;
//! OpenGL or OpenGL ES context depending on the platform. To be removed.
static const ContextType kNativeGL_ContextType;
static const int kContextTypeCnt = kLastContextType + 1;
/**
* Options for GL context creation. For historical and testing reasons the options will default
* to not using GL_NV_path_rendering extension even when the driver supports it.
*/
enum GLContextOptions {
kNone_GLContextOptions = 0,
kEnableNVPR_GLContextOptions = 0x1,
kRequireSRGBSupport_GLContextOptions = 0x2,
enum ContextOptions {
kNone_ContextOptions = 0x0,
kEnableNVPR_ContextOptions = 0x1,
kRequireSRGBSupport_ContextOptions = 0x2,
};
static bool IsRenderingGLContext(GLContextType type) {
static bool IsRenderingContext(ContextType type) {
switch (type) {
case kNull_GLContextType:
case kDebug_GLContextType:
case kNullGL_ContextType:
case kDebugGL_ContextType:
return false;
default:
return true;
}
}
static const char* GLContextTypeName(GLContextType type) {
static const char* ContextTypeName(ContextType type) {
switch (type) {
case kNative_GLContextType:
return "native";
case kGL_GLContextType:
case kGL_ContextType:
return "gl";
case kGLES_GLContextType:
case kGLES_ContextType:
return "gles";
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
case kANGLE_GLContextType:
case kANGLE_ContextType:
return "angle";
#endif
case kANGLE_GL_GLContextType:
case kANGLE_GL_ContextType:
return "angle-gl";
#endif
#if SK_COMMAND_BUFFER
case kCommandBuffer_GLContextType:
case kCommandBuffer_ContextType:
return "commandbuffer";
#endif
#if SK_MESA
case kMESA_GLContextType:
case kMESA_ContextType:
return "mesa";
#endif
case kNull_GLContextType:
case kNullGL_ContextType:
return "null";
case kDebug_GLContextType:
case kDebugGL_ContextType:
return "debug";
default:
SkFAIL("Unknown GL Context type.");
@ -122,22 +122,21 @@ public:
/**
* Get a context initialized with a type of GL context. It also makes the GL context current.
*/
ContextInfo getContextInfo(GLContextType type,
GLContextOptions options = kNone_GLContextOptions);
ContextInfo getContextInfo(ContextType type,
ContextOptions options = kNone_ContextOptions);
/**
* Get a GrContext initialized with a type of GL context. It also makes the GL context current.
*/
GrContext* get(GLContextType type,
GLContextOptions options = kNone_GLContextOptions) {
GrContext* get(ContextType type, ContextOptions options = kNone_ContextOptions) {
return this->getContextInfo(type, options).fGrContext;
}
const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
private:
struct Context {
GLContextType fType;
GLContextOptions fOptions;
GLTestContext* fGLContext;
ContextType fType;
ContextOptions fOptions;
GLTestContext* fGLContext; // null if non-GL
GrContext* fGrContext;
};
SkTArray<Context, true> fContexts;

View File

@ -175,8 +175,8 @@ struct GPUTarget {
}
bool init(Benchmark* bench, GrContextFactory* factory, bool useDfText,
GrContextFactory::GLContextType ctxType,
GrContextFactory::GLContextOptions ctxOptions, int numSamples) {
GrContextFactory::ContextType ctxType,
GrContextFactory::ContextOptions ctxOptions, int numSamples) {
GrContext* context = factory->get(ctxType, ctxOptions);
int maxRTSize = context->caps()->maxRenderTargetSize();
SkImageInfo info = SkImageInfo::Make(SkTMin(bench->getSize().fX, maxRTSize),
@ -478,8 +478,8 @@ struct AutoSetupContextBenchAndTarget {
fCtxFactory.reset(new GrContextFactory(grContextOpts));
SkAssertResult(fTarget.init(bench, fCtxFactory, false,
GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions, 0));
GrContextFactory::kNativeGL_ContextType,
GrContextFactory::kNone_ContextOptions, 0));
fCanvas = fTarget.getCanvas();
fTarget.setup();

View File

@ -65,8 +65,8 @@ SkData* Request::writeCanvasToPng(SkCanvas* canvas) {
SkCanvas* Request::getCanvas() {
#if SK_SUPPORT_GPU
GrContextFactory* factory = fContextFactory;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions).fGLContext;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNativeGL_ContextType,
GrContextFactory::kNone_ContextOptions).fGLContext;
gl->makeCurrent();
#endif
SkASSERT(fDebugCanvas);
@ -109,8 +109,8 @@ SkData* Request::writeOutSkp() {
GrContext* Request::getContext() {
#if SK_SUPPORT_GPU
return fContextFactory->get(GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions);
return fContextFactory->get(GrContextFactory::kNativeGL_ContextType,
GrContextFactory::kNone_ContextOptions);
#else
return nullptr;
#endif