}
#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) {
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();
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; \
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
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;
#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)) {
// 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) {
call_test(test, reporter, context);
}
context = factory->getContextInfo(contextType,
- GrContextFactory::kEnableNVPR_GLContextOptions);
+ GrContextFactory::kEnableNVPR_ContextOptions);
if (context.fGrContext) {
call_test(test, reporter, context);
}
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) {
GrContextFactory() {};
explicit GrContextFactory(const GrContextOptions&) {}
- typedef int GLContextType;
-
- 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,
+ typedef int ContextType;
+
+ 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() {}
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) {
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,
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);
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;
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:
// 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;
}
// 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,
// 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());
}
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;
}
// 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);
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;
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[] = {
GrContextFactory otherFactory;
GrContextFactory::ContextInfo otherContextInfo =
- otherFactory.getContextInfo(GrContextFactory::kNative_GLContextType);
+ otherFactory.getContextInfo(GrContextFactory::kNativeGL_ContextType);
glContext->makeCurrent();
REPORTER_ASSERT(reporter, proxy);
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) {
#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);
}
#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);
}
}
-
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);
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);
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);
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);
}
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
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;
// * 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);
}
}
-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) {
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;
}
// 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();
glCtx->makeCurrent();
#ifdef SK_VULKAN
- if (kEnableNVPR_GLContextOptions & options) {
+ if (kEnableNVPR_ContextOptions & options) {
return ContextInfo();
} else {
GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(GrVkBackendContext::Create());
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();
}
*/
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.");
/**
* 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;
}
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),
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();
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);
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