Rename enums in GrContextFactory to remove "GL"
authorbsalomon <bsalomon@google.com>
Tue, 5 Apr 2016 18:06:27 +0000 (11:06 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 5 Apr 2016 18:06:27 +0000 (11:06 -0700)
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

21 files changed:
bench/nanobench.cpp
bench/nanobench.h
dm/DM.cpp
dm/DMGpuSupport.h
dm/DMSrcSink.cpp
dm/DMSrcSink.h
tests/GrContextAbandonTest.cpp
tests/GrContextFactoryTest.cpp
tests/GrPorterDuffTest.cpp
tests/ImageTest.cpp
tests/SkpSkGrTest.cpp
tests/TestConfigParsing.cpp
tests/VkClearTests.cpp
tests/VkUploadPixelsTests.cpp
tests/VkWrapTests.cpp
tools/flags/SkCommonFlagsConfig.cpp
tools/flags/SkCommonFlagsConfig.h
tools/gpu/GrContextFactory.cpp
tools/gpu/GrContextFactory.h
tools/kilobench/kilobench.cpp
tools/skiaserve/Request.cpp

index 521824e97b23e6792a69bd728cf8c10a7b7e3ca4..5e26b483951db10fc45ef47623907faeb34b1ccc 100644 (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
index 844811e26d2dfc86e7b9ab64b5b2941fd2564901..ceab0f6c4fe717d0dfdbb49ef337cc91f0c9b053 100644 (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;
index 97b6eb8f6ab8d3d9f9a69cf75d9f5c3e0211ede6..00cb279e8116d6567365b81c48696f85daa0634e 100644 (file)
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -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);
         }
index 490737f41ee283fceaac2d9ff858be13e81d8edd..2352f83ae4c326fef9e0a709898d7c8df22ed1c6 100644 (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;
-
-    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() {}
 
@@ -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) {
index 5f8727f60e304043441ce44199371f95a97265af..08629675540a84a75c37790014de39327b1cf703 100644 (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,
index c4df845853f8e105421325ead0d9e214b11a0791..743bd1e46766f63d593c53c9678bb274bbb3a042 100644 (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;
index c62973f4da27215ab10da8dc1f309cc1f28ce7db..e1ad8f7de72640d2c8c30469fce40881f89bba02 100644 (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:
index bd1888380a13c96348782796d9c990e3890900bf..6e51b2fda34bdaa1a5022120a4391314f26f90ff 100644 (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);
index 566ec12f5d409947d924f567fd834ca6f056e09b..b0377715b4d13848777315ef1e238d47e5a24784 100644 (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;
index 96bc48e7118a38632268e4c1fea811badb3bdf08..a1c522b7b77e6663e7b47f228e7ff44896012b5d 100644 (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);
index 4469d4fb57c9b3b7acebf1069a2cee1bde315f81..e5553a9a75171f37d649e7f4b07bf75fa633bab6 100644 (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) {
index 301f6a2d9afd9a3ed43f12c27287a7d6f025a5f4..ac7037f9d26192861ff9f68b74d07d1c50c5564d 100644 (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);
index ab13ffd1c921fc0ad6cad9130222a74bec164a49..5b8a30bc1be62ce4dc506ada9c89d1be86b1fe06 100644 (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);
index a509978eda9024c81ec0ca6ebe3c0ec0198c9b9e..e5f72dd635d3c1a1d95a8d82134477040c1f0e02 100644 (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);
index 382bdbe64e6d1877368147858fc2b8ddce89691b..a4fec0876d2ccf4477de710ca9b1047d7f2d140b 100755 (executable)
@@ -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);
index 973f14eaa17d9db82d7a5ecf168ed42623a41d8f..0847ae5b79ea268947ef0bf3c8633c0db754b37d 100644 (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;
index abf5946847466a28e5ac67e77060dbfa2cd167af..5d95ef186ad912e8f591d3ac160f5a01b6d739fd 100644 (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);
index c2321213326aed4bcd902532afd2e138dcc155e0..18fbef811309517178c30ad144216e270eba6283 100755 (executable)
@@ -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();
         }
index 16f6fb23ff9e132cd76f2f72bcba3e09404fc1eb..7c49faaf87a97f013bfe06ef595e789f577e4b4d 100644 (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;
index f4c2999b9111d725971d0ef8b8293c9090fd179b..dc7f938a5d97729cec13a144b01efc2467d0049e 100644 (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();
index 225ca398df1528a385280a22815dd6b9440e7ec0..7534b1df98e985b0ba4b0fedd806d96c9c96c816 100644 (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