aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/nanobench.cpp18
-rw-r--r--bench/nanobench.h2
-rw-r--r--dm/DM.cpp11
-rw-r--r--dm/DMGpuSupport.h13
-rw-r--r--dm/DMSrcSink.cpp8
-rw-r--r--dm/DMSrcSink.h16
-rw-r--r--tests/GrContextFactoryTest.cpp11
-rw-r--r--tools/flags/SkCommonFlagsConfig.cpp21
-rw-r--r--tools/flags/SkCommonFlagsConfig.h14
-rw-r--r--tools/gpu/GrContextFactory.cpp29
-rw-r--r--tools/gpu/GrContextFactory.h38
-rw-r--r--tools/skiaserve/Request.cpp8
-rw-r--r--tools/skpbench/skpbench.cpp2
13 files changed, 97 insertions, 94 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 92475d31f8..e97e9a0bf3 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -189,11 +189,11 @@ struct GPUTarget : public Target {
0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
this->surface = SkSurface::MakeRenderTarget(gGrFactory->get(this->config.ctxType,
- this->config.ctxOptions),
+ this->config.ctxOverrides),
SkBudgeted::kNo, info,
this->config.samples, &props);
this->context = gGrFactory->getContextInfo(this->config.ctxType,
- this->config.ctxOptions).testContext();
+ this->config.ctxOverrides).testContext();
if (!this->surface.get()) {
return false;
}
@@ -392,10 +392,10 @@ static int setup_gpu_bench(Target* target, Benchmark* bench, int maxGpuFrameLag)
#if SK_SUPPORT_GPU
#define kBogusContextType GrContextFactory::kNativeGL_ContextType
-#define kBogusContextOptions GrContextFactory::ContextOptions::kNone
+#define kBogusContextOverrides GrContextFactory::ContextOverrides::kNone
#else
#define kBogusContextType 0
-#define kBogusContextOptions 0
+#define kBogusContextOverrides 0
#endif
static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* configs) {
@@ -406,10 +406,10 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
return;
const auto ctxType = gpuConfig->getContextType();
- const auto ctxOptions = gpuConfig->getContextOptions();
+ const auto ctxOverrides = gpuConfig->getContextOverrides();
const auto sampleCount = gpuConfig->getSamples();
- if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) {
+ if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOverrides)) {
const auto maxSampleCount = ctx->caps()->maxSampleCount();
if (sampleCount > ctx->caps()->maxSampleCount()) {
SkDebugf("Configuration sample count %d exceeds maximum %d.\n",
@@ -429,7 +429,7 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
sk_ref_sp(gpuConfig->getColorSpace()),
sampleCount,
ctxType,
- ctxOptions,
+ ctxOverrides,
gpuConfig->getUseDIText()
};
@@ -442,7 +442,7 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
if (config->getTag().equals(#name)) { \
Config config = { \
SkString(#name), Benchmark::backend, color, alpha, colorSpace, \
- 0, kBogusContextType, kBogusContextOptions, false \
+ 0, kBogusContextType, kBogusContextOverrides, false \
}; \
configs->push_back(config); \
return; \
@@ -1333,7 +1333,7 @@ int main(int argc, char** argv) {
#if SK_SUPPORT_GPU
if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) {
GrContext* context = gGrFactory->get(configs[i].ctxType,
- configs[i].ctxOptions);
+ configs[i].ctxOverrides);
context->printCacheStats();
context->printGpuStats();
}
diff --git a/bench/nanobench.h b/bench/nanobench.h
index ce1e33ec4f..ffd6893c4a 100644
--- a/bench/nanobench.h
+++ b/bench/nanobench.h
@@ -30,7 +30,7 @@ struct Config {
int samples;
#if SK_SUPPORT_GPU
sk_gpu_test::GrContextFactory::ContextType ctxType;
- sk_gpu_test::GrContextFactory::ContextOptions ctxOptions;
+ sk_gpu_test::GrContextFactory::ContextOverrides ctxOverrides;
bool useDFText;
#else
int bogusInt;
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 6bef230ca7..c25076ff06 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -843,14 +843,14 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
if (gpu_supported()) {
if (const SkCommandLineConfigGpu* gpuConfig = config->asConfigGpu()) {
GrContextFactory::ContextType contextType = gpuConfig->getContextType();
- GrContextFactory::ContextOptions contextOptions = gpuConfig->getContextOptions();
+ GrContextFactory::ContextOverrides contextOverrides = gpuConfig->getContextOverrides();
GrContextFactory testFactory;
- if (!testFactory.get(contextType, contextOptions)) {
+ if (!testFactory.get(contextType, contextOverrides)) {
info("WARNING: can not create GPU context for config '%s'. "
"GM tests will be skipped.\n", gpuConfig->getTag().c_str());
return nullptr;
}
- return new GPUSink(contextType, contextOptions, gpuConfig->getSamples(),
+ return new GPUSink(contextType, contextOverrides, gpuConfig->getSamples(),
gpuConfig->getUseDIText(), gpuConfig->getColorType(),
sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading);
}
@@ -1462,7 +1462,8 @@ void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contex
continue;
}
}
- ContextInfo ctxInfo = factory->getContextInfo(contextType);
+ ContextInfo ctxInfo = factory->getContextInfo(contextType,
+ GrContextFactory::ContextOverrides::kDisableNVPR);
if (contextTypeFilter && !(*contextTypeFilter)(contextType)) {
continue;
}
@@ -1471,7 +1472,7 @@ void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contex
(*test)(reporter, ctxInfo);
}
ctxInfo = factory->getContextInfo(contextType,
- GrContextFactory::ContextOptions::kEnableNVPR);
+ GrContextFactory::ContextOverrides::kRequireNVPRSupport);
if (ctxInfo.grContext()) {
(*test)(reporter, ctxInfo);
}
diff --git a/dm/DMGpuSupport.h b/dm/DMGpuSupport.h
index 1ea51d2621..75bfc3b23e 100644
--- a/dm/DMGpuSupport.h
+++ b/dm/DMGpuSupport.h
@@ -31,13 +31,13 @@ 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::ContextOverrides overrides,
SkImageInfo info,
int samples,
bool useDIText) {
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
- return SkSurface::MakeRenderTarget(grFactory->get(type, options), SkBudgeted::kNo,
+ return SkSurface::MakeRenderTarget(grFactory->get(type, overrides), SkBudgeted::kNo,
info, samples, &props);
}
@@ -63,7 +63,7 @@ public:
namespace sk_gpu_test {
class GrContextFactory {
public:
- GrContextFactory() {};
+ GrContextFactory() {}
explicit GrContextFactory(const GrContextOptions&) {}
typedef int ContextType;
@@ -80,10 +80,7 @@ public:
kNullGL_ContextType = 0,
kVulkan_ContextType = 0;
static const int kContextTypeCnt = 1;
- enum ContextOptions {
- kNone_ContextOptions = 0,
- kEnableNVPR_ContextOptions = 0x1,
- };
+ enum class ContextOverrides {};
void destroyContexts() {}
void abandonContexts() {}
@@ -98,7 +95,7 @@ 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::ContextOverrides,
SkImageInfo,
int,
bool) {
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index e70cae31a4..a4991116ca 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1223,14 +1223,14 @@ 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,
+ GrContextFactory::ContextOverrides overrides,
int samples,
bool diText,
SkColorType colorType,
sk_sp<SkColorSpace> colorSpace,
bool threaded)
: fContextType(ct)
- , fContextOptions(options)
+ , fContextOverrides(overrides)
, fSampleCount(samples)
, fUseDIText(diText)
, fColorType(colorType)
@@ -1257,7 +1257,7 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
SkImageInfo::Make(size.width(), size.height(), fColorType,
kPremul_SkAlphaType, fColorSpace);
#if SK_SUPPORT_GPU
- GrContext* context = factory.getContextInfo(fContextType, fContextOptions).grContext();
+ GrContext* context = factory.getContextInfo(fContextType, fContextOverrides).grContext();
const int maxDimension = context->caps()->maxTextureSize();
if (maxDimension < SkTMax(size.width(), size.height())) {
return Error::Nonfatal("Src too large to create a texture.\n");
@@ -1265,7 +1265,7 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
#endif
auto surface(
- NewGpuSurface(&factory, fContextType, fContextOptions, info, fSampleCount, fUseDIText));
+ NewGpuSurface(&factory, fContextType, fContextOverrides, info, fSampleCount, fUseDIText));
if (!surface) {
return "Could not create a surface.";
}
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 9c6808ecd6..92c5773d36 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -303,7 +303,7 @@ public:
class GPUSink : public Sink {
public:
GPUSink(sk_gpu_test::GrContextFactory::ContextType,
- sk_gpu_test::GrContextFactory::ContextOptions,
+ sk_gpu_test::GrContextFactory::ContextOverrides,
int samples, bool diText, SkColorType colorType, sk_sp<SkColorSpace> colorSpace,
bool threaded);
@@ -312,13 +312,13 @@ 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;
- int fSampleCount;
- bool fUseDIText;
- SkColorType fColorType;
- sk_sp<SkColorSpace> fColorSpace;
- bool fThreaded;
+ sk_gpu_test::GrContextFactory::ContextType fContextType;
+ sk_gpu_test::GrContextFactory::ContextOverrides fContextOverrides;
+ int fSampleCount;
+ bool fUseDIText;
+ SkColorType fColorType;
+ sk_sp<SkColorSpace> fColorSpace;
+ bool fThreaded;
};
class PDFSink : public Sink {
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 9b600fa8a4..f7ddf36d91 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::ContextOptions::kEnableNVPR);
+ GrContextFactory::ContextOverrides::kRequireNVPRSupport);
if (!context) {
continue;
}
@@ -33,13 +33,14 @@ DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter,
}
}
-DEF_GPUTEST(GrContextFactory_NoPathRenderingUnlessNVPRRequested, reporter, /*factory*/) {
- // Test that if NVPR is not requested, the context never has path rendering support.
+DEF_GPUTEST(GrContextFactory_NoPathRenderingIfNVPRDisabled, reporter, /*factory*/) {
+ // Test that if NVPR is explicitly disabled, the context has no path rendering support.
GrContextFactory testFactory;
for (int i = 0; i <= GrContextFactory::kLastContextType; ++i) {
GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType)i;
- GrContext* context = testFactory.get(ctxType);
+ GrContext* context =
+ testFactory.get(ctxType, GrContextFactory::ContextOverrides::kDisableNVPR);
if (context) {
REPORTER_ASSERT(
reporter,
@@ -57,7 +58,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::ContextOptions::kRequireSRGBSupport);
+ testFactory.get(ctxType, GrContextFactory::ContextOverrides::kRequireSRGBSupport);
if (context) {
REPORTER_ASSERT(reporter, context->caps()->srgbSupport());
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 65ba372d7c..3e5e9b9fff 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -169,30 +169,31 @@ SkCommandLineConfigGpu::SkCommandLineConfigGpu(
sk_sp<SkColorSpace> colorSpace)
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
, fContextType(contextType)
- , fContextOptions(ContextOptions::kNone)
+ , fContextOverrides(ContextOverrides::kNone)
, fUseDIText(useDIText)
, fSamples(samples)
, fColorType(colorType)
, fColorSpace(std::move(colorSpace)) {
if (useNVPR) {
- fContextOptions |= ContextOptions::kEnableNVPR;
+ fContextOverrides |= ContextOverrides::kRequireNVPRSupport;
+ } else if (!useInstanced) {
+ // We don't disable NVPR for instanced configs. Otherwise the caps wouldn't use mixed
+ // samples and we couldn't test the mixed samples backend for simple shapes.
+ fContextOverrides |= ContextOverrides::kDisableNVPR;
}
if (useInstanced) {
- fContextOptions |= ContextOptions::kUseInstanced;
+ fContextOverrides |= ContextOverrides::kUseInstanced;
}
// Subtle logic: If the config has a color space attached, we're going to be rendering to sRGB,
// so we need that capability. In addition, to get the widest test coverage, we DO NOT require
// that we can disable sRGB decode. (That's for rendering sRGB sources to legacy surfaces).
//
// If the config doesn't have a color space attached, we're going to be rendering in legacy
- // mode. In that case, we can't allow a context to be created that has sRGB support without
- // the ability to disable sRGB decode. Otherwise, all of our sRGB source resources will be
- // treated as sRGB textures, but we will be unable to prevent the decode, causing them to be
- // too dark.
+ // mode. In that case, we don't require sRGB capability and we defer to the client to decide on
+ // sRGB decode control.
if (fColorSpace) {
- fContextOptions |= ContextOptions::kRequireSRGBSupport;
- } else {
- fContextOptions |= ContextOptions::kRequireSRGBDecodeDisableSupport;
+ fContextOverrides |= ContextOverrides::kRequireSRGBSupport;
+ fContextOverrides |= ContextOverrides::kAllowSRGBWithoutDecodeControl;
}
}
static bool parse_option_int(const SkString& value, int* outInt) {
diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h
index 2b80397a2a..7336fa7971 100644
--- a/tools/flags/SkCommonFlagsConfig.h
+++ b/tools/flags/SkCommonFlagsConfig.h
@@ -51,15 +51,19 @@ class SkCommandLineConfig {
class SkCommandLineConfigGpu : public SkCommandLineConfig {
public:
typedef sk_gpu_test::GrContextFactory::ContextType ContextType;
- typedef sk_gpu_test::GrContextFactory::ContextOptions ContextOptions;
+ typedef sk_gpu_test::GrContextFactory::ContextOverrides ContextOverrides;
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; }
- ContextOptions getContextOptions() const { return fContextOptions; }
- bool getUseNVPR() const { return fContextOptions & ContextOptions::kEnableNVPR; }
- bool getUseInstanced() const { return fContextOptions & ContextOptions::kUseInstanced; }
+ ContextOverrides getContextOverrides() const { return fContextOverrides; }
+ bool getUseNVPR() const {
+ SkASSERT(!(fContextOverrides & ContextOverrides::kRequireNVPRSupport) ||
+ !(fContextOverrides & ContextOverrides::kDisableNVPR));
+ return fContextOverrides & ContextOverrides::kRequireNVPRSupport;
+ }
+ bool getUseInstanced() const { return fContextOverrides & ContextOverrides::kUseInstanced; }
bool getUseDIText() const { return fUseDIText; }
int getSamples() const { return fSamples; }
SkColorType getColorType() const { return fColorType; }
@@ -67,7 +71,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
private:
ContextType fContextType;
- ContextOptions fContextOptions;
+ ContextOverrides fContextOverrides;
bool fUseDIText;
int fSamples;
SkColorType fColorType;
diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp
index bd745bcfcd..401189a6a3 100644
--- a/tools/gpu/GrContextFactory.cpp
+++ b/tools/gpu/GrContextFactory.cpp
@@ -43,8 +43,6 @@ GrContextFactory::GrContextFactory() { }
GrContextFactory::GrContextFactory(const GrContextOptions& opts)
: fGlobalOptions(opts) {
- // In this factory, instanced rendering is specified with ContextOptions::kUseInstanced.
- SkASSERT(!fGlobalOptions.fEnableInstancedRendering);
}
GrContextFactory::~GrContextFactory() {
@@ -105,11 +103,11 @@ const GrContextFactory::ContextType GrContextFactory::kNativeGL_ContextType =
GrContextFactory::kGLES_ContextType;
#endif
-ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions options) {
+ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOverrides overrides) {
for (int i = 0; i < fContexts.count(); ++i) {
Context& context = fContexts[i];
if (context.fType == type &&
- context.fOptions == options &&
+ context.fOverrides == overrides &&
!context.fAbandoned) {
context.fTestContext->makeCurrent();
return ContextInfo(context.fBackend, context.fTestContext, context.fGrContext);
@@ -156,7 +154,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
break;
#endif
case kNullGL_ContextType:
- glCtx = CreateNullGLTestContext(ContextOptions::kEnableNVPR & options);
+ glCtx = CreateNullGLTestContext(ContextOverrides::kRequireNVPRSupport & overrides);
break;
case kDebugGL_ContextType:
glCtx = CreateDebugGLTestContext();
@@ -169,9 +167,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
}
testCtx.reset(glCtx);
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 (!((ContextOptions::kEnableNVPR | ContextOptions::kUseInstanced) & options)) {
+ if (ContextOverrides::kDisableNVPR & overrides) {
glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get()));
if (!glInterface) {
return ContextInfo();
@@ -183,7 +179,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
#ifdef SK_VULKAN
case kVulkan_GrBackend:
SkASSERT(kVulkan_ContextType == type);
- if (ContextOptions::kEnableNVPR & options) {
+ if (ContextOverrides::kRequireNVPRSupport & overrides) {
return ContextInfo();
}
testCtx.reset(CreatePlatformVkTestContext());
@@ -209,26 +205,27 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
testCtx->makeCurrent();
SkASSERT(testCtx && testCtx->backend() == backend);
GrContextOptions grOptions = fGlobalOptions;
- if (ContextOptions::kUseInstanced & options) {
+ if (ContextOverrides::kUseInstanced & overrides) {
grOptions.fEnableInstancedRendering = true;
}
- grOptions.fRequireDecodeDisableForSRGB =
- SkToBool(ContextOptions::kRequireSRGBDecodeDisableSupport & options);
+ if (ContextOverrides::kAllowSRGBWithoutDecodeControl & overrides) {
+ grOptions.fRequireDecodeDisableForSRGB = false;
+ }
grCtx.reset(GrContext::Create(backend, backendContext, grOptions));
if (!grCtx.get()) {
return ContextInfo();
}
- if (ContextOptions::kEnableNVPR & options) {
+ if (ContextOverrides::kRequireNVPRSupport & overrides) {
if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
return ContextInfo();
}
}
- if (ContextOptions::kUseInstanced & options) {
+ if (ContextOverrides::kUseInstanced & overrides) {
if (GrCaps::InstancedSupport::kNone == grCtx->caps()->instancedSupport()) {
return ContextInfo();
}
}
- if (ContextOptions::kRequireSRGBSupport & options) {
+ if (ContextOverrides::kRequireSRGBSupport & overrides) {
if (!grCtx->caps()->srgbSupport()) {
return ContextInfo();
}
@@ -239,7 +236,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
context.fTestContext = testCtx.release();
context.fGrContext = SkRef(grCtx.get());
context.fType = type;
- context.fOptions = options;
+ context.fOverrides = overrides;
context.fAbandoned = false;
return ContextInfo(context.fBackend, context.fTestContext, context.fGrContext);
}
diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h
index a232112d75..48b250d0ea 100644
--- a/tools/gpu/GrContextFactory.h
+++ b/tools/gpu/GrContextFactory.h
@@ -89,15 +89,17 @@ public:
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.
+ * Overrides for the initial GrContextOptions provided at construction time, and required
+ * features that will cause context creation to fail if not present.
*/
- enum class ContextOptions {
- kNone = 0x0,
- kEnableNVPR = 0x1,
- kUseInstanced = 0x2,
- kRequireSRGBSupport = 0x4,
- kRequireSRGBDecodeDisableSupport = 0x8,
+ enum class ContextOverrides {
+ kNone = 0x0,
+ kDisableNVPR = 0x1,
+ kUseInstanced = 0x2,
+ kAllowSRGBWithoutDecodeControl = 0x4,
+
+ kRequireNVPRSupport = 0x8,
+ kRequireSRGBSupport = 0x10
};
static ContextType NativeContextTypeForBackend(GrBackend backend) {
@@ -144,23 +146,23 @@ public:
* Get a context initialized with a type of GL context. It also makes the GL context current.
*/
ContextInfo getContextInfo(ContextType type,
- ContextOptions options = ContextOptions::kNone);
+ ContextOverrides overrides = ContextOverrides::kNone);
/**
* Get a GrContext initialized with a type of GL context. It also makes the GL context current.
*/
- GrContext* get(ContextType type, ContextOptions options = ContextOptions::kNone) {
- return this->getContextInfo(type, options).grContext();
+ GrContext* get(ContextType type, ContextOverrides overrides = ContextOverrides::kNone) {
+ return this->getContextInfo(type, overrides).grContext();
}
const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
private:
struct Context {
- ContextType fType;
- ContextOptions fOptions;
- GrBackend fBackend;
- TestContext* fTestContext;
- GrContext* fGrContext;
- bool fAbandoned;
+ ContextType fType;
+ ContextOverrides fOverrides;
+ GrBackend fBackend;
+ TestContext* fTestContext;
+ GrContext* fGrContext;
+ bool fAbandoned;
};
SkTArray<Context, true> fContexts;
std::unique_ptr<GLTestContext> fSentinelGLContext;
@@ -168,6 +170,6 @@ private:
};
} // namespace sk_gpu_test
-GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOptions);
+GR_MAKE_BITFIELD_CLASS_OPS(sk_gpu_test::GrContextFactory::ContextOverrides);
#endif
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index 0fbccc39b3..125302b376 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -74,10 +74,10 @@ SkCanvas* Request::getCanvas() {
#if SK_SUPPORT_GPU
GrContextFactory* factory = fContextFactory;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNativeGL_ContextType,
- GrContextFactory::ContextOptions::kNone).glContext();
+ GrContextFactory::ContextOverrides::kNone).glContext();
if (!gl) {
gl = factory->getContextInfo(GrContextFactory::kMESA_ContextType,
- GrContextFactory::ContextOptions::kNone).glContext();
+ GrContextFactory::ContextOverrides::kNone).glContext();
}
if (gl) {
gl->makeCurrent();
@@ -127,10 +127,10 @@ sk_sp<SkData> Request::writeOutSkp() {
GrContext* Request::getContext() {
#if SK_SUPPORT_GPU
GrContext* result = fContextFactory->get(GrContextFactory::kNativeGL_ContextType,
- GrContextFactory::ContextOptions::kNone);
+ GrContextFactory::ContextOverrides::kNone);
if (!result) {
result = fContextFactory->get(GrContextFactory::kMESA_ContextType,
- GrContextFactory::ContextOptions::kNone);
+ GrContextFactory::ContextOverrides::kNone);
}
return result;
#else
diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp
index 897878e27d..3887c5ea88 100644
--- a/tools/skpbench/skpbench.cpp
+++ b/tools/skpbench/skpbench.cpp
@@ -273,7 +273,7 @@ int main(int argc, char** argv) {
// Create a context.
sk_gpu_test::GrContextFactory factory;
sk_gpu_test::ContextInfo ctxInfo =
- factory.getContextInfo(config->getContextType(), config->getContextOptions());
+ factory.getContextInfo(config->getContextType(), config->getContextOverrides());
GrContext* ctx = ctxInfo.grContext();
if (!ctx) {
exitf(ExitErr::kUnavailable, "failed to create context for config %s",