diff options
author | Eric Karl <ericrk@chromium.org> | 2017-05-08 12:02:07 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-09 17:41:25 +0000 |
commit | 5c77975e4c00e18e644c72b56f369858acd11b15 (patch) | |
tree | 187dff83863784225a9f2aa4d8c5abacefc12ec0 /tools | |
parent | fda4600e41ded0b8f0a54222e2dc8a85d53b4121 (diff) |
Add flag to avoid stencil buffers in Skia
Certain systems experience a leak in the GL driver associated with
stencil buffers. Attempts to avoid the leak (while still using stencil
buffers) dind't succeed. This patch adds a GrContextOption
fAvoidStencilBuffers. This disables certain path rendering modes, as
well as stencil based masking/clipping.
Bug: 713854
Change-Id: Ifa6c0f2bd5ee395547bda9165d6c79d197ae8b8b
Reviewed-on: https://skia-review.googlesource.com/15253
Commit-Queue: Eric Karl <ericrk@chromium.org>
Reviewed-by: Eric Karl <ericrk@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/flags/SkCommonFlagsConfig.cpp | 15 | ||||
-rw-r--r-- | tools/flags/SkCommonFlagsConfig.h | 3 | ||||
-rw-r--r-- | tools/gpu/GrContextFactory.cpp | 3 | ||||
-rw-r--r-- | tools/gpu/GrContextFactory.h | 5 |
4 files changed, 21 insertions, 5 deletions
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp index 1e980d20e9..458962e007 100644 --- a/tools/flags/SkCommonFlagsConfig.cpp +++ b/tools/flags/SkCommonFlagsConfig.cpp @@ -64,6 +64,7 @@ static const struct { { "glsrgb", "gpu", "api=gl,color=srgb" }, { "glwide", "gpu", "api=gl,color=f16_wide" }, { "glnarrow", "gpu", "api=gl,color=f16_narrow" }, + { "glnostencils", "gpu", "api=gl,stencils=false" }, { "glessrgb", "gpu", "api=gles,color=srgb" }, { "gleswide", "gpu", "api=gles,color=f16_wide" }, { "glesnarrow", "gpu", "api=gles,color=f16_narrow" }, @@ -151,6 +152,8 @@ static const char configExtendedHelp[] = "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n" "\tsamples\ttype: int\tdefault: 0.\n" "\t Use multisampling with N samples.\n" + "\tstencils\ttype: bool\tdefault: true.\n" + "\t Allow the use of stencil buffers.\n" "\n" "Predefined configs:\n\n" // Help text for pre-defined configs is auto-generated from gPredefinedConfigs @@ -181,7 +184,7 @@ SkCommandLineConfig::~SkCommandLineConfig() { SkCommandLineConfigGpu::SkCommandLineConfigGpu( const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR, bool useInstanced, bool useDIText, int samples, SkColorType colorType, - sk_sp<SkColorSpace> colorSpace) + sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers) : SkCommandLineConfig(tag, SkString("gpu"), viaParts) , fContextType(contextType) , fContextOverrides(ContextOverrides::kNone) @@ -210,6 +213,9 @@ SkCommandLineConfigGpu::SkCommandLineConfigGpu( fContextOverrides |= ContextOverrides::kRequireSRGBSupport; fContextOverrides |= ContextOverrides::kAllowSRGBWithoutDecodeControl; } + if (!useStencilBuffers) { + fContextOverrides |= ContextOverrides::kAvoidStencilBuffers; + } } static bool parse_option_int(const SkString& value, int* outInt) { if (value.isEmpty()) { @@ -370,6 +376,8 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, bool seenColor = false; SkColorType colorType = kRGBA_8888_SkColorType; sk_sp<SkColorSpace> colorSpace = nullptr; + bool seenUseStencils = false; + bool useStencils = true; SkTArray<SkString> optionParts; SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts); @@ -400,6 +408,9 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, } else if (key.equals("color") && !seenColor) { valueOk = parse_option_gpu_color(value, &colorType, &colorSpace); seenColor = true; + } else if (key.equals("stencils") && !seenUseStencils) { + valueOk = parse_option_bool(value, &useStencils); + seenUseStencils = true; } if (!valueOk) { return nullptr; @@ -409,7 +420,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, return nullptr; } return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstanced, useDIText, - samples, colorType, colorSpace); + samples, colorType, colorSpace, useStencils); } #endif diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h index e6ebefd864..a3c3b38cd4 100644 --- a/tools/flags/SkCommonFlagsConfig.h +++ b/tools/flags/SkCommonFlagsConfig.h @@ -55,7 +55,8 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig { 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); + int samples, SkColorType colorType, sk_sp<SkColorSpace> colorSpace, + bool useStencilBuffers); const SkCommandLineConfigGpu* asConfigGpu() const override { return this; } ContextType getContextType() const { return fContextType; } ContextOverrides getContextOverrides() const { return fContextOverrides; } diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index 6ed89542c9..e02bc1b371 100644 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -230,6 +230,9 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv if (ContextOverrides::kAllowSRGBWithoutDecodeControl & overrides) { grOptions.fRequireDecodeDisableForSRGB = false; } + if (ContextOverrides::kAvoidStencilBuffers & overrides) { + grOptions.fAvoidStencilBuffers = true; + } sk_sp<GrContext> grCtx(GrContext::Create(backend, backendContext, grOptions)); if (!grCtx.get()) { return ContextInfo(); diff --git a/tools/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h index 0067e52144..eb54b50bbb 100644 --- a/tools/gpu/GrContextFactory.h +++ b/tools/gpu/GrContextFactory.h @@ -94,9 +94,10 @@ public: kDisableNVPR = 0x1, kUseInstanced = 0x2, kAllowSRGBWithoutDecodeControl = 0x4, + kAvoidStencilBuffers = 0x8, - kRequireNVPRSupport = 0x8, - kRequireSRGBSupport = 0x10 + kRequireNVPRSupport = 0x10, + kRequireSRGBSupport = 0x20, }; static bool IsRenderingContext(ContextType type) { |