Revert of Rename enums in GrContextFactory to remove "GL" (patchset #4 id:60001 of https://codereview.chromium.org/1845923004/ )

Reason for revert:
Many GM images unexpectedly changed with this CL.

Original issue's description:
> 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

TBR=egdaniel@google.com,jvanverth@google.com
# Not skipping CQ checks because original CL landed more than 1 days ago.

Review URL: https://codereview.chromium.org/1856703002
This commit is contained in:
bsalomon 2016-04-04 05:56:59 -07:00 committed by Commit bot
parent aee62f5639
commit b4b4cf36c6
21 changed files with 184 additions and 181 deletions

View File

@ -385,11 +385,11 @@ static int setup_gpu_bench(Target* target, Benchmark* bench, int maxGpuFrameLag)
}
#if SK_SUPPORT_GPU
#define kBogusContextType GrContextFactory::kNativeGL_ContextType
#define kBogusContextOptions GrContextFactory::kNone_ContextOptions
#define kBogusGLContextType GrContextFactory::kNative_GLContextType
#define kBogusGLContextOptions GrContextFactory::kNone_GLContextOptions
#else
#define kBogusContextType 0
#define kBogusContextOptions 0
#define kBogusGLContextType 0
#define kBogusGLContextOptions 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_ContextOptions
: GrContextFactory::kNone_ContextOptions;
const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEnableNVPR_GLContextOptions
: GrContextFactory::kNone_GLContextOptions;
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, kBogusContextType, kBogusContextOptions, false \
0, kBogusGLContextType, kBogusGLContextOptions, 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, kBogusContextType, kBogusContextOptions, false };
0, kBogusGLContextType, kBogusGLContextOptions, 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::ContextType ctxType;
sk_gpu_test::GrContextFactory::ContextOptions ctxOptions;
sk_gpu_test::GrContextFactory::GLContextType ctxType;
sk_gpu_test::GrContextFactory::GLContextOptions 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::ContextType contextType = gpuConfig->getContextType();
GrContextFactory::ContextOptions contextOptions =
GrContextFactory::kNone_ContextOptions;
GrContextFactory::GLContextType contextType = gpuConfig->getContextType();
GrContextFactory::GLContextOptions contextOptions =
GrContextFactory::kNone_GLContextOptions;
if (gpuConfig->getUseNVPR()) {
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kEnableNVPR_ContextOptions);
contextOptions = static_cast<GrContextFactory::GLContextOptions>(
contextOptions | GrContextFactory::kEnableNVPR_GLContextOptions);
}
if (kSRGB_SkColorProfileType == gpuConfig->getProfileType() ||
kRGBA_F16_SkColorType == gpuConfig->getColorType()) {
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kRequireSRGBSupport_ContextOptions);
contextOptions = static_cast<GrContextFactory::GLContextOptions>(
contextOptions | GrContextFactory::kRequireSRGBSupport_GLContextOptions);
}
GrContextFactory testFactory;
if (!testFactory.get(contextType, contextOptions)) {
@ -1442,36 +1442,35 @@ 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::ContextType contextTypes[] = {
GrContextFactory::kNativeGL_ContextType,
GrContextFactory::GLContextType contextTypes[] = {
GrContextFactory::kNative_GLContextType,
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
GrContextFactory::kANGLE_ContextType,
GrContextFactory::kANGLE_GLContextType,
#endif
GrContextFactory::kANGLE_GL_ContextType,
GrContextFactory::kANGLE_GL_GLContextType,
#endif
#if SK_COMMAND_BUFFER
GrContextFactory::kCommandBuffer_ContextType,
GrContextFactory::kCommandBuffer_GLContextType,
#endif
#if SK_MESA
GrContextFactory::kMESA_ContextType,
GrContextFactory::kMESA_GLContextType,
#endif
GrContextFactory::kNullGL_ContextType,
GrContextFactory::kDebugGL_ContextType,
GrContextFactory::kNull_GLContextType,
GrContextFactory::kDebug_GLContextType,
};
// 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");
static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kGLContextTypeCnt - 2,
"Skipping unexpected GLContextType for GPU tests");
for (auto& contextType : contextTypes) {
int contextSelector = kNone_GPUTestContexts;
if (GrContextFactory::IsRenderingContext(contextType)) {
if (GrContextFactory::IsRenderingGLContext(contextType)) {
contextSelector |= kAllRendering_GPUTestContexts;
} else if (contextType == GrContextFactory::kNativeGL_ContextType) {
} else if (contextType == GrContextFactory::kNative_GLContextType) {
contextSelector |= kNative_GPUTestContexts;
} else if (contextType == GrContextFactory::kNullGL_ContextType) {
} else if (contextType == GrContextFactory::kNull_GLContextType) {
contextSelector |= kNull_GPUTestContexts;
} else if (contextType == GrContextFactory::kDebugGL_ContextType) {
} else if (contextType == GrContextFactory::kDebug_GLContextType) {
contextSelector |= kDebug_GPUTestContexts;
}
if ((testContexts & contextSelector) == 0) {
@ -1482,7 +1481,7 @@ void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
call_test(test, reporter, context);
}
context = factory->getContextInfo(contextType,
GrContextFactory::kEnableNVPR_ContextOptions);
GrContextFactory::kEnableNVPR_GLContextOptions);
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::ContextType type,
sk_gpu_test::GrContextFactory::ContextOptions options,
sk_gpu_test::GrContextFactory::GLContextType type,
sk_gpu_test::GrContextFactory::GLContextOptions options,
SkImageInfo info,
int samples,
bool useDIText) {
@ -66,22 +66,20 @@ public:
GrContextFactory() {};
explicit GrContextFactory(const GrContextOptions&) {}
typedef int ContextType;
typedef int GLContextType;
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,
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,
};
void destroyContexts() {}
@ -96,8 +94,8 @@ namespace DM {
static const bool kGPUDisabled = true;
static inline SkSurface* NewGpuSurface(sk_gpu_test::GrContextFactory*,
sk_gpu_test::GrContextFactory::ContextType,
sk_gpu_test::GrContextFactory::ContextOptions,
sk_gpu_test::GrContextFactory::GLContextType,
sk_gpu_test::GrContextFactory::GLContextOptions,
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::ContextType ct,
GrContextFactory::ContextOptions options,
GPUSink::GPUSink(GrContextFactory::GLContextType ct,
GrContextFactory::GLContextOptions options,
int samples,
bool diText,
SkColorType colorType,

View File

@ -232,8 +232,8 @@ public:
class GPUSink : public Sink {
public:
GPUSink(sk_gpu_test::GrContextFactory::ContextType,
sk_gpu_test::GrContextFactory::ContextOptions,
GPUSink(sk_gpu_test::GrContextFactory::GLContextType,
sk_gpu_test::GrContextFactory::GLContextOptions,
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::ContextType fContextType;
sk_gpu_test::GrContextFactory::ContextOptions fContextOptions;
sk_gpu_test::GrContextFactory::GLContextType fContextType;
sk_gpu_test::GrContextFactory::GLContextOptions 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::kContextTypeCnt; ++i) {
GrContextFactory testFactory;
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
GrContextFactory::ContextInfo info = testFactory.getContextInfo(ctxType);
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory testFactory;
GrContextFactory::GLContextType ctxType = (GrContextFactory::GLContextType) 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::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context = testFactory.get(ctxType,
GrContextFactory::kEnableNVPR_ContextOptions);
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory::GLContextType>(i);
GrContext* context = testFactory.get(glCtxType,
GrContextFactory::kEnableNVPR_GLContextOptions);
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::kLastContextType; ++i) {
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType)i;
GrContext* context = testFactory.get(ctxType);
for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) {
GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
GrContext* context = testFactory.get(glCtxType);
if (context) {
REPORTER_ASSERT(
reporter,
@ -54,15 +54,16 @@ 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::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory::GLContextType>(i);
GrContext* context =
testFactory.get(ctxType, GrContextFactory::kRequireSRGBSupport_ContextOptions);
testFactory.get(glCtxType,
GrContextFactory::kRequireSRGBSupport_GLContextOptions);
if (context) {
REPORTER_ASSERT(reporter, context->caps()->srgbSupport());
} else {
context = testFactory.get(ctxType);
context = testFactory.get(glCtxType);
if (context) {
REPORTER_ASSERT(reporter, !context->caps()->srgbSupport());
}
@ -72,9 +73,10 @@ DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
GrContextFactory testFactory;
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
GrContextFactory::ContextInfo info1 = testFactory.getContextInfo(ctxType);
for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
GrContextFactory::ContextInfo info1 =
testFactory.getContextInfo(glCtxType);
if (!info1.fGrContext) {
continue;
}
@ -85,7 +87,7 @@ DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
// Test that we get different context after abandon.
GrContextFactory::ContextInfo info2 =
testFactory.getContextInfo(ctxType);
testFactory.getContextInfo(glCtxType);
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::kNullGL_ContextType);
GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNull_GLContextType);
if (!ctx) {
SkFAIL("Failed to create null context without ARB_blend_func_extended.");
return;

View File

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

View File

@ -253,11 +253,11 @@ static SkString make_png_name(const char* filename) {
return pngName;
}
typedef GrContextFactory::ContextType ContextType;
typedef GrContextFactory::GLContextType GLContextType;
#ifdef SK_BUILD_FOR_WIN
static const ContextType kAngle = GrContextFactory::kANGLE_ContextType;
static const GLContextType kAngle = GrContextFactory::kANGLE_GLContextType;
#else
static const ContextType kNative = GrContextFactory::kNativeGL_ContextType;
static const GLContextType kNative = GrContextFactory::kNative_GLContextType;
#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::kNativeGL_ContextType);
== GrContextFactory::kNative_GLContextType);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
@ -164,46 +164,47 @@ DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) {
}
#if SK_SUPPORT_GPU
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() ==
GrContextFactory::kNativeGL_ContextType);
GrContextFactory::kNative_GLContextType);
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_ContextType);
GrContextFactory::kANGLE_GLContextType);
#else
REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
#endif
REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()->getContextType() ==
GrContextFactory::kANGLE_GL_ContextType);
GrContextFactory::kANGLE_GL_GLContextType);
#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_ContextType);
GrContextFactory::kMESA_GLContextType);
#else
REPORTER_ASSERT(reporter, !configs[3]->asConfigGpu());
#endif
#if SK_COMMAND_BUFFER
REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()->getContextType() ==
GrContextFactory::kCommandBuffer_ContextType);
GrContextFactory::kCommandBuffer_GLContextType);
#else
REPORTER_ASSERT(reporter, !configs[4]->asConfigGpu());
#endif
REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() ==
GrContextFactory::kNativeGL_ContextType);
GrContextFactory::kNative_GLContextType);
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_ContextType);
GrContextFactory::kGLES_GLContextType);
REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR());
REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0);
#endif
}
@ -235,13 +236,16 @@ 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)",
"gpu(api=debug)", "gpu(api=gl)", "gpu(api=gles)", ""
"gpu", "gpu()", "gpu(samples=0)", "gpu(api=gles,samples=0)"
// 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)"
});
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::kContextTypeCnt; ++type) {
if (static_cast<GrContextFactory::ContextType>(type) !=
GrContextFactory::kNativeGL_ContextType) {
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
if (static_cast<GrContextFactory::GLContextType>(type) !=
GrContextFactory::kNative_GLContextType) {
continue;
}
GrContext* context = debugFactory.get(static_cast<GrContextFactory::ContextType>(type));
GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(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::kContextTypeCnt; ++type) {
if (static_cast<GrContextFactory::ContextType>(type) !=
GrContextFactory::kNativeGL_ContextType) {
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
if (static_cast<GrContextFactory::GLContextType>(type) !=
GrContextFactory::kNative_GLContextType) {
continue;
}
GrContext* context = debugFactory.get(static_cast<GrContextFactory::ContextType>(type));
GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(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::kLastContextType; ++type) {
if (static_cast<GrContextFactory::ContextType>(type) !=
GrContextFactory::kNativeGL_ContextType) {
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
if (static_cast<GrContextFactory::GLContextType>(type) !=
GrContextFactory::kNative_GLContextType) {
continue;
}
GrContext* context = debugFactory.get(static_cast<GrContextFactory::ContextType>(type));
GrContext* context = debugFactory.get(static_cast<GrContextFactory::GLContextType>(type));
if (context) {
wrap_tex_test(reporter, context);
wrap_rt_test(reporter, context);

View File

@ -201,43 +201,47 @@ 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_ContextType;
*outContextType = GrContextFactory::kGL_GLContextType;
return true;
}
if (value.equals("gles")) {
*outContextType = GrContextFactory::kGLES_ContextType;
*outContextType = GrContextFactory::kGLES_GLContextType;
return true;
}
if (value.equals("debug")) {
*outContextType = GrContextFactory::kDebugGL_ContextType;
*outContextType = GrContextFactory::kDebug_GLContextType;
return true;
}
if (value.equals("null")) {
*outContextType = GrContextFactory::kNullGL_ContextType;
*outContextType = GrContextFactory::kNull_GLContextType;
return true;
}
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
if (value.equals("angle")) {
*outContextType = GrContextFactory::kANGLE_ContextType;
*outContextType = GrContextFactory::kANGLE_GLContextType;
return true;
}
#endif
if (value.equals("angle-gl")) {
*outContextType = GrContextFactory::kANGLE_GL_ContextType;
*outContextType = GrContextFactory::kANGLE_GL_GLContextType;
return true;
}
#endif
#if SK_COMMAND_BUFFER
if (value.equals("commandbuffer")) {
*outContextType = GrContextFactory::kCommandBuffer_ContextType;
*outContextType = GrContextFactory::kCommandBuffer_GLContextType;
return true;
}
#endif
#if SK_MESA
if (value.equals("mesa")) {
*outContextType = GrContextFactory::kMESA_ContextType;
*outContextType = GrContextFactory::kMESA_GLContextType;
return true;
}
#endif
@ -269,7 +273,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
const SkString& options) {
// Defaults for GPU backend.
bool seenAPI = false;
SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeGL_ContextType;
SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNative_GLContextType;
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::ContextType ContextType;
typedef sk_gpu_test::GrContextFactory::GLContextType ContextType;
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useDIText, int samples,
SkColorType colorType, SkColorProfileType profileType);

View File

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

View File

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

View File

@ -175,8 +175,8 @@ struct GPUTarget {
}
bool init(Benchmark* bench, GrContextFactory* factory, bool useDfText,
GrContextFactory::ContextType ctxType,
GrContextFactory::ContextOptions ctxOptions, int numSamples) {
GrContextFactory::GLContextType ctxType,
GrContextFactory::GLContextOptions 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::kNativeGL_ContextType,
GrContextFactory::kNone_ContextOptions, 0));
GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions, 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::kNativeGL_ContextType,
GrContextFactory::kNone_ContextOptions).fGLContext;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions).fGLContext;
gl->makeCurrent();
#endif
SkASSERT(fDebugCanvas);
@ -109,8 +109,8 @@ SkData* Request::writeOutSkp() {
GrContext* Request::getContext() {
#if SK_SUPPORT_GPU
return fContextFactory->get(GrContextFactory::kNativeGL_ContextType,
GrContextFactory::kNone_ContextOptions);
return fContextFactory->get(GrContextFactory::kNative_GLContextType,
GrContextFactory::kNone_GLContextOptions);
#else
return nullptr;
#endif