aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/nanobench.cpp17
-rw-r--r--dm/DM.cpp18
-rw-r--r--tests/GrContextFactoryTest.cpp4
-rw-r--r--tools/flags/SkCommonFlagsConfig.cpp13
-rw-r--r--tools/flags/SkCommonFlagsConfig.h9
-rw-r--r--tools/gpu/GrContextFactory.cpp16
-rw-r--r--tools/gpu/GrContextFactory.h17
-rw-r--r--tools/skiaserve/Request.cpp8
8 files changed, 44 insertions, 58 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index ae415fa06b..238e8f6029 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -390,7 +390,7 @@ 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 kBogusContextOptions GrContextFactory::ContextOptions::kNone
#else
#define kBogusContextType 0
#define kBogusContextOptions 0
@@ -403,21 +403,8 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
if (!FLAGS_gpu)
return;
- auto ctxOptions = GrContextFactory::kNone_ContextOptions;
- if (gpuConfig->getUseNVPR()) {
- ctxOptions = static_cast<GrContextFactory::ContextOptions>(
- ctxOptions | GrContextFactory::kEnableNVPR_ContextOptions);
- }
- if (gpuConfig->getUseInstanced()) {
- ctxOptions = static_cast<GrContextFactory::ContextOptions>(
- ctxOptions | GrContextFactory::kUseInstanced_ContextOptions);
- }
- if (SkColorAndColorSpaceAreGammaCorrect(gpuConfig->getColorType(),
- gpuConfig->getColorSpace())) {
- ctxOptions = static_cast<GrContextFactory::ContextOptions>(
- ctxOptions | GrContextFactory::kRequireSRGBSupport_ContextOptions);
- }
const auto ctxType = gpuConfig->getContextType();
+ const auto ctxOptions = gpuConfig->getContextOptions();
const auto sampleCount = gpuConfig->getSamples();
if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) {
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 1598bcddea..fc332a2ade 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -825,21 +825,7 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
if (gpu_supported()) {
if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
GrContextFactory::ContextType contextType = gpuConfig->getContextType();
- GrContextFactory::ContextOptions contextOptions =
- GrContextFactory::kNone_ContextOptions;
- if (gpuConfig->getUseNVPR()) {
- contextOptions = static_cast<GrContextFactory::ContextOptions>(
- contextOptions | GrContextFactory::kEnableNVPR_ContextOptions);
- }
- if (gpuConfig->getUseInstanced()) {
- contextOptions = static_cast<GrContextFactory::ContextOptions>(
- contextOptions | GrContextFactory::kUseInstanced_ContextOptions);
- }
- if (SkColorAndColorSpaceAreGammaCorrect(gpuConfig->getColorType(),
- gpuConfig->getColorSpace())) {
- contextOptions = static_cast<GrContextFactory::ContextOptions>(
- contextOptions | GrContextFactory::kRequireSRGBSupport_ContextOptions);
- }
+ GrContextFactory::ContextOptions contextOptions = gpuConfig->getContextOptions();
GrContextFactory testFactory;
if (!testFactory.get(contextType, contextOptions)) {
info("WARNING: can not create GPU context for config '%s'. "
@@ -1429,7 +1415,7 @@ void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contex
(*test)(reporter, ctxInfo);
}
ctxInfo = factory->getContextInfo(contextType,
- GrContextFactory::kEnableNVPR_ContextOptions);
+ GrContextFactory::ContextOptions::kEnableNVPR);
if (ctxInfo.grContext()) {
(*test)(reporter, ctxInfo);
}
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 3b12b832da..9b600fa8a4 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -23,7 +23,7 @@ DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context = testFactory.get(ctxType,
- GrContextFactory::kEnableNVPR_ContextOptions);
+ GrContextFactory::ContextOptions::kEnableNVPR);
if (!context) {
continue;
}
@@ -57,7 +57,7 @@ DEF_GPUTEST(GrContextFactory_RequiredSRGBSupport, reporter, /*factory*/) {
for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
GrContext* context =
- testFactory.get(ctxType, GrContextFactory::kRequireSRGBSupport_ContextOptions);
+ testFactory.get(ctxType, GrContextFactory::ContextOptions::kRequireSRGBSupport);
if (context) {
REPORTER_ASSERT(reporter, context->caps()->srgbSupport());
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 447c56d511..1d38b562a9 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -6,6 +6,7 @@
*/
#include "SkCommonFlagsConfig.h"
+#include "SkImageInfo.h"
#include <stdlib.h>
@@ -208,12 +209,20 @@ SkCommandLineConfigGpu::SkCommandLineConfigGpu(
sk_sp<SkColorSpace> colorSpace)
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
, fContextType(contextType)
- , fUseNVPR(useNVPR)
- , fUseInstanced(useInstanced)
+ , fContextOptions(ContextOptions::kNone)
, fUseDIText(useDIText)
, fSamples(samples)
, fColorType(colorType)
, fColorSpace(std::move(colorSpace)) {
+ if (useNVPR) {
+ fContextOptions |= ContextOptions::kEnableNVPR;
+ }
+ if (useInstanced) {
+ fContextOptions |= ContextOptions::kUseInstanced;
+ }
+ if (SkColorAndColorSpaceAreGammaCorrect(colorType, colorSpace.get())) {
+ fContextOptions |= ContextOptions::kRequireSRGBSupport;
+ }
}
static bool parse_option_int(const SkString& value, int* outInt) {
if (value.isEmpty()) {
diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h
index 641c68b3ee..e817339c6e 100644
--- a/tools/flags/SkCommonFlagsConfig.h
+++ b/tools/flags/SkCommonFlagsConfig.h
@@ -51,13 +51,15 @@ class SkCommandLineConfig {
class SkCommandLineConfigGpu : public SkCommandLineConfig {
public:
typedef sk_gpu_test::GrContextFactory::ContextType ContextType;
+ typedef sk_gpu_test::GrContextFactory::ContextOptions ContextOptions;
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useInstanced, bool useDIText,
int samples, SkColorType colorType, sk_sp<SkColorSpace> colorSpace);
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
ContextType getContextType() const { return fContextType; }
- bool getUseNVPR() const { return fUseNVPR; }
- bool getUseInstanced() const { return fUseInstanced; }
+ ContextOptions getContextOptions() const { return fContextOptions; }
+ bool getUseNVPR() const { return fContextOptions & ContextOptions::kEnableNVPR; }
+ bool getUseInstanced() const { return fContextOptions & ContextOptions::kUseInstanced; }
bool getUseDIText() const { return fUseDIText; }
int getSamples() const { return fSamples; }
SkColorType getColorType() const { return fColorType; }
@@ -65,8 +67,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
private:
ContextType fContextType;
- bool fUseNVPR;
- bool fUseInstanced;
+ ContextOptions fContextOptions;
bool fUseDIText;
int fSamples;
SkColorType fColorType;
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp
index 2407da930a..c40764b109 100644
--- a/tools/gpu/GrContextFactory.cpp
+++ b/tools/gpu/GrContextFactory.cpp
@@ -31,7 +31,7 @@ GrContextFactory::GrContextFactory() { }
GrContextFactory::GrContextFactory(const GrContextOptions& opts)
: fGlobalOptions(opts) {
- // In this factory, instanced rendering is specified with kUseInstanced_ContextOptions.
+ // In this factory, instanced rendering is specified with ContextOptions::kUseInstanced.
SkASSERT(!fGlobalOptions.fEnableInstancedRendering);
}
@@ -139,7 +139,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
break;
#endif
case kNullGL_ContextType:
- glCtx = CreateNullGLTestContext(kEnableNVPR_ContextOptions & options);
+ glCtx = CreateNullGLTestContext(ContextOptions::kEnableNVPR & options);
break;
case kDebugGL_ContextType:
glCtx = CreateDebugGLTestContext();
@@ -154,7 +154,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
glInterface.reset(SkRef(glCtx->gl()));
// Block NVPR from non-NVPR types. We don't block NVPR from contexts that will use
// instanced rendering because that would prevent us from testing mixed samples.
- if (!((kEnableNVPR_ContextOptions | kUseInstanced_ContextOptions) & options)) {
+ if (!((ContextOptions::kEnableNVPR | ContextOptions::kUseInstanced) & options)) {
glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get()));
if (!glInterface) {
return ContextInfo();
@@ -166,7 +166,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
#ifdef SK_VULKAN
case kVulkan_GrBackend:
SkASSERT(kVulkan_ContextType == type);
- if (kEnableNVPR_ContextOptions & options) {
+ if (ContextOptions::kEnableNVPR & options) {
return ContextInfo();
}
testCtx.reset(CreatePlatformVkTestContext());
@@ -192,24 +192,24 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
testCtx->makeCurrent();
SkASSERT(testCtx && testCtx->backend() == backend);
GrContextOptions grOptions = fGlobalOptions;
- if (kUseInstanced_ContextOptions & options) {
+ if (ContextOptions::kUseInstanced & options) {
grOptions.fEnableInstancedRendering = true;
}
grCtx.reset(GrContext::Create(backend, backendContext, grOptions));
if (!grCtx.get()) {
return ContextInfo();
}
- if (kEnableNVPR_ContextOptions & options) {
+ if (ContextOptions::kEnableNVPR & options) {
if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
return ContextInfo();
}
}
- if (kUseInstanced_ContextOptions & options) {
+ if (ContextOptions::kUseInstanced & options) {
if (GrCaps::InstancedSupport::kNone == grCtx->caps()->instancedSupport()) {
return ContextInfo();
}
}
- if (kRequireSRGBSupport_ContextOptions & options) {
+ if (ContextOptions::kRequireSRGBSupport & options) {
if (!grCtx->caps()->srgbSupport()) {
return ContextInfo();
}
diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h
index f70ebea9ad..d5e87a42f4 100644
--- a/tools/gpu/GrContextFactory.h
+++ b/tools/gpu/GrContextFactory.h
@@ -89,11 +89,11 @@ public:
* 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,
- kUseInstanced_ContextOptions = 0x2,
- kRequireSRGBSupport_ContextOptions = 0x4,
+ enum class ContextOptions {
+ kNone = 0x0,
+ kEnableNVPR = 0x1,
+ kUseInstanced = 0x2,
+ kRequireSRGBSupport = 0x4,
};
static ContextType NativeContextTypeForBackend(GrBackend backend) {
@@ -163,11 +163,11 @@ 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);
+ ContextOptions options = ContextOptions::kNone);
/**
* 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(ContextType type, ContextOptions options = ContextOptions::kNone) {
return this->getContextInfo(type, options).grContext();
}
const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
@@ -186,4 +186,7 @@ private:
const GrContextOptions fGlobalOptions;
};
} // namespace sk_gpu_test
+
+GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOptions);
+
#endif
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index ea2d17afb9..ef1f757595 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -72,10 +72,10 @@ SkCanvas* Request::getCanvas() {
#if SK_SUPPORT_GPU
GrContextFactory* factory = fContextFactory;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNativeGL_ContextType,
- GrContextFactory::kNone_ContextOptions).glContext();
+ GrContextFactory::ContextOptions::kNone).glContext();
if (!gl) {
gl = factory->getContextInfo(GrContextFactory::kMESA_ContextType,
- GrContextFactory::kNone_ContextOptions).glContext();
+ GrContextFactory::ContextOptions::kNone).glContext();
}
if (gl) {
gl->makeCurrent();
@@ -123,10 +123,10 @@ sk_sp<SkData> Request::writeOutSkp() {
GrContext* Request::getContext() {
#if SK_SUPPORT_GPU
GrContext* result = fContextFactory->get(GrContextFactory::kNativeGL_ContextType,
- GrContextFactory::kNone_ContextOptions);
+ GrContextFactory::ContextOptions::kNone);
if (!result) {
result = fContextFactory->get(GrContextFactory::kMESA_ContextType,
- GrContextFactory::kNone_ContextOptions);
+ GrContextFactory::ContextOptions::kNone);
}
return result;
#else