aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-08-30 15:14:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-30 19:35:27 +0000
commit195c05b6d5afbd65f803816938e24eebd51292c8 (patch)
tree09464cb77b796259a4ca0d75a32f8ed4d0dcf85a
parentad8a43f7698071f00ce024a935b0bc04a4b19a41 (diff)
Move several GrContextOptions fields behind GR_TEST_UTILS
Bug: skia: Change-Id: I35bc08ad72fb94d8e47fe342d314c4496b954226 Reviewed-on: https://skia-review.googlesource.com/40881 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
-rw-r--r--dm/DMSrcSink.cpp2
-rw-r--r--gm/pathmaskcache.cpp2
-rw-r--r--include/gpu/GrContextOptions.h65
-rw-r--r--include/private/GrTypesPriv.h22
-rw-r--r--src/gpu/GrCaps.cpp11
-rw-r--r--src/gpu/GrContext.cpp4
-rw-r--r--src/gpu/GrPathRendererChain.cpp1
-rw-r--r--src/gpu/GrPathRendererChain.h3
-rw-r--r--src/gpu/GrShaderCaps.cpp2
-rw-r--r--src/gpu/gl/GrGLCaps.cpp14
-rw-r--r--tools/flags/SkCommonFlagsPathRenderer.h8
-rw-r--r--tools/viewer/Viewer.cpp1
12 files changed, 79 insertions, 56 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index dc8a913fa1..384ad10568 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1530,7 +1530,7 @@ Error GPUThreadTestingSink::draw(const Src& src, SkBitmap* dst, SkWStream* wStre
// Also, force us to only use the software path renderer, so we really stress-test the threaded
// version of that code.
GrContextOptions contextOptions = this->baseContextOptions();
- contextOptions.fGpuPathRenderers = GrContextOptions::GpuPathRenderers::kNone;
+ contextOptions.fGpuPathRenderers = GpuPathRenderers::kNone;
contextOptions.fExecutor = fExecutor.get();
Error err = this->onDraw(src, dst, wStream, log, contextOptions);
diff --git a/gm/pathmaskcache.cpp b/gm/pathmaskcache.cpp
index 5e3232b6bd..400c5df9d1 100644
--- a/gm/pathmaskcache.cpp
+++ b/gm/pathmaskcache.cpp
@@ -104,7 +104,7 @@ protected:
}
void modifyGrContextOptions(GrContextOptions* options) override {
- options->fGpuPathRenderers = GrContextOptions::GpuPathRenderers::kNone;
+ options->fGpuPathRenderers = GpuPathRenderers::kNone;
options->fAllowPathMaskCaching = true;
}
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
index 8c577842a0..a4298755b7 100644
--- a/include/gpu/GrContextOptions.h
+++ b/include/gpu/GrContextOptions.h
@@ -10,6 +10,7 @@
#include "SkTypes.h"
#include "GrTypes.h"
+#include "../private/GrTypesPriv.h"
class SkExecutor;
@@ -25,11 +26,6 @@ struct GrContextOptions {
int fMaxTextureSizeOverride = SK_MaxS32;
- /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
- by SkGpuDevice. */
- int fMaxTileSizeOverride = 0;
- bool fSuppressDualSourceBlending = false;
-
/** the threshold in bytes above which we will use a buffer mapping API to map vertex and index
buffers to CPU memory in order to update them. A value of -1 means the GrContext should
deduce the optimal value for this platform. */
@@ -82,52 +78,47 @@ struct GrContextOptions {
bool fDisableGpuYUVConversion = false;
/**
- * If true, the caps will never report driver support for path rendering.
+ * The maximum size of cache textures used for Skia's Glyph cache.
*/
- bool fSuppressPathRendering = false;
+ float fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4;
/**
- * Render everything in wireframe
+ * Bugs on certain drivers cause stencil buffers to leak. This flag causes Skia to avoid
+ * allocating stencil buffers and use alternate rasterization paths, avoiding the leak.
*/
- bool fWireframeMode = false;
+ bool fAvoidStencilBuffers = false;
+#if GR_TEST_UTILS
/**
- * Allows the client to include or exclude specific GPU path renderers.
+ * Private options that are only meant for testing within Skia's tools.
*/
- enum class GpuPathRenderers {
- kNone = 0, // Always use sofware masks and/or GrDefaultPathRenderer.
- kDashLine = 1 << 0,
- kStencilAndCover = 1 << 1,
- kMSAA = 1 << 2,
- kAAConvex = 1 << 3,
- kAALinearizing = 1 << 4,
- kSmall = 1 << 5,
- kCoverageCounting = 1 << 6,
- kTessellating = 1 << 7,
-
- kAll = (kTessellating | (kTessellating - 1)),
-
- // Temporarily disabling CCPR by default until it has had a time to soak.
- kDefault = kAll & ~kCoverageCounting,
-
- // For legacy. To be removed when updated in Android.
- kDistanceField = kSmall
- };
- GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault;
+ /**
+ * If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
+ * by SkGpuDevice.
+ */
+ int fMaxTileSizeOverride = 0;
/**
- * The maximum size of cache textures used for Skia's Glyph cache.
+ * Prevents use of dual source blending, to test that all xfer modes work correctly without it.
*/
- float fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4;
+ bool fSuppressDualSourceBlending = false;
/**
- * Bugs on certain drivers cause stencil buffers to leak. This flag causes Skia to avoid
- * allocating stencil buffers and use alternate rasterization paths, avoiding the leak.
+ * If true, the caps will never report driver support for path rendering.
*/
- bool fAvoidStencilBuffers = false;
-};
+ bool fSuppressPathRendering = false;
-GR_MAKE_BITFIELD_CLASS_OPS(GrContextOptions::GpuPathRenderers)
+ /**
+ * Render everything in wireframe
+ */
+ bool fWireframeMode = false;
+
+ /**
+ * Include or exclude specific GPU path renderers.
+ */
+ GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault;
+#endif
+};
#endif
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index 41a2deaecf..9c5d3c0eb0 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -608,4 +608,26 @@ T* const* unique_ptr_address_as_pointer_address(std::unique_ptr<T> const* up) {
*/
typedef uint64_t GrFence;
+/**
+ * Used to include or exclude specific GPU path renderers for testing purposes.
+ */
+enum class GpuPathRenderers {
+ kNone = 0, // Always use sofware masks and/or GrDefaultPathRenderer.
+ kDashLine = 1 << 0,
+ kStencilAndCover = 1 << 1,
+ kMSAA = 1 << 2,
+ kAAConvex = 1 << 3,
+ kAALinearizing = 1 << 4,
+ kSmall = 1 << 5,
+ kCoverageCounting = 1 << 6,
+ kTessellating = 1 << 7,
+
+ kAll = (kTessellating | (kTessellating - 1)),
+
+ // Temporarily disabling CCPR by default until it has had a time to soak.
+ kDefault = kAll & ~kCoverageCounting,
+};
+
+GR_MAKE_BITFIELD_CLASS_OPS(GpuPathRenderers)
+
#endif
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 3d1987a22a..3566b4ebf4 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -72,7 +72,11 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fMaxWindowRectangles = 0;
fSuppressPrints = options.fSuppressPrints;
+#if GR_TEST_UTILS
fWireframeMode = options.fWireframeMode;
+#else
+ fWireframeMode = false;
+#endif
fBufferMapThreshold = options.fBufferMapThreshold;
fAvoidInstancedDrawsToFPTargets = false;
fAvoidStencilBuffers = false;
@@ -83,12 +87,13 @@ GrCaps::GrCaps(const GrContextOptions& options) {
void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
this->onApplyOptionsOverrides(options);
fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride);
+ fMaxTileSize = fMaxTextureSize;
+#if GR_TEST_UTILS
// If the max tile override is zero, it means we should use the max texture size.
- if (!options.fMaxTileSizeOverride || options.fMaxTileSizeOverride > fMaxTextureSize) {
- fMaxTileSize = fMaxTextureSize;
- } else {
+ if (options.fMaxTileSizeOverride && options.fMaxTileSizeOverride < fMaxTextureSize) {
fMaxTileSize = options.fMaxTileSizeOverride;
}
+#endif
if (fMaxWindowRectangles > GrWindowRectangles::kMaxWindows) {
SkDebugf("WARNING: capping window rectangles at %i. HW advertises support for %i.\n",
GrWindowRectangles::kMaxWindows, fMaxWindowRectangles);
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index decb0edd6f..d05f1976f1 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -196,9 +196,11 @@ bool GrContext::init(const GrContextOptions& options) {
GrPathRendererChain::Options prcOptions;
prcOptions.fAllowPathMaskCaching = options.fAllowPathMaskCaching;
+#if GR_TEST_UTILS
prcOptions.fGpuPathRenderers = options.fGpuPathRenderers;
+#endif
if (options.fDisableDistanceFieldPaths) {
- prcOptions.fGpuPathRenderers &= ~GrContextOptions::GpuPathRenderers::kDistanceField;
+ prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kSmall;
}
fDrawingManager.reset(new GrDrawingManager(this, prcOptions, &fSingleOwner));
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index b379a48720..354d086a22 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -28,7 +28,6 @@
#include "ops/GrTessellatingPathRenderer.h"
GrPathRendererChain::GrPathRendererChain(GrContext* context, const Options& options) {
- using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
const GrCaps& caps = *context->caps();
if (options.fGpuPathRenderers & GpuPathRenderers::kDashLine) {
fChain.push_back(sk_make_sp<GrDashLinePathRenderer>());
diff --git a/src/gpu/GrPathRendererChain.h b/src/gpu/GrPathRendererChain.h
index 41f26de88d..7d2c56ea8c 100644
--- a/src/gpu/GrPathRendererChain.h
+++ b/src/gpu/GrPathRendererChain.h
@@ -10,7 +10,7 @@
#include "GrPathRenderer.h"
-#include "GrContextOptions.h"
+#include "GrTypesPriv.h"
#include "SkTypes.h"
#include "SkTArray.h"
@@ -25,7 +25,6 @@ class GrContext;
class GrPathRendererChain : public SkNoncopyable {
public:
struct Options {
- using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
bool fAllowPathMaskCaching = false;
GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault;
};
diff --git a/src/gpu/GrShaderCaps.cpp b/src/gpu/GrShaderCaps.cpp
index 06fe03a5aa..dd436401a6 100644
--- a/src/gpu/GrShaderCaps.cpp
+++ b/src/gpu/GrShaderCaps.cpp
@@ -231,5 +231,7 @@ void GrShaderCaps::initSamplerPrecisionTable() {
}
void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) {
+#if GR_TEST_UTILS
fDualSourceBlendingSupport = fDualSourceBlendingSupport && !options.fSuppressDualSourceBlending;
+#endif
}
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 377ff48f5a..8715f59216 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -291,9 +291,12 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
this->initGLSL(ctxInfo);
GrShaderCaps* shaderCaps = fShaderCaps.get();
- if (!contextOptions.fSuppressPathRendering) {
- shaderCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli);
+ shaderCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli);
+#if GR_TEST_UTILS
+ if (contextOptions.fSuppressPathRendering) {
+ shaderCaps->fPathRenderingSupport = false;
}
+#endif
// For now these two are equivalent but we could have dst read in shader via some other method.
// Before setting this, initGLSL() must have been called.
@@ -1070,8 +1073,11 @@ void GrGLCaps::initFSAASupport(const GrContextOptions& contextOptions, const GrG
// renderer is available and enabled; no other path renderers support this feature.
if (fMultisampleDisableSupport &&
this->shaderCaps()->dualSourceBlendingSupport() &&
- this->shaderCaps()->pathRenderingSupport() &&
- (contextOptions.fGpuPathRenderers & GrContextOptions::GpuPathRenderers::kStencilAndCover)) {
+ this->shaderCaps()->pathRenderingSupport()
+#if GR_TEST_UTILS
+ && (contextOptions.fGpuPathRenderers & GpuPathRenderers::kStencilAndCover)
+#endif
+ ) {
fUsesMixedSamples = ctxInfo.hasExtension("GL_NV_framebuffer_mixed_samples") ||
ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_mixed_samples");
// Workaround NVIDIA bug related to glInvalidateFramebuffer and mixed samples.
diff --git a/tools/flags/SkCommonFlagsPathRenderer.h b/tools/flags/SkCommonFlagsPathRenderer.h
index 8ed74aa8fb..02b5d1798c 100644
--- a/tools/flags/SkCommonFlagsPathRenderer.h
+++ b/tools/flags/SkCommonFlagsPathRenderer.h
@@ -10,7 +10,7 @@
#if SK_SUPPORT_GPU
-#include "GrContextOptions.h"
+#include "GrTypesPriv.h"
#include "SkCommandLineFlags.h"
#include "SkTypes.h"
@@ -22,8 +22,7 @@ DECLARE_string(pr);
"[[~]all [~]default [~]dashline [~]nvpr [~]msaa [~]aaconvex " \
"[~]aalinearizing [~]small [~]tess]")
-inline GrContextOptions::GpuPathRenderers get_named_pathrenderers_flags(const char* name) {
- using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
+inline GpuPathRenderers get_named_pathrenderers_flags(const char* name) {
if (!strcmp(name, "all")) {
return GpuPathRenderers::kAll;
} else if (!strcmp(name, "default")) {
@@ -51,8 +50,7 @@ inline GrContextOptions::GpuPathRenderers get_named_pathrenderers_flags(const ch
return GpuPathRenderers::kNone;
}
-inline GrContextOptions::GpuPathRenderers CollectGpuPathRenderersFromFlags() {
- using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
+inline GpuPathRenderers CollectGpuPathRenderersFromFlags() {
if (FLAGS_pr.isEmpty()) {
return GpuPathRenderers::kDefault;
}
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 4e6684310f..e1f72d7575 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -47,7 +47,6 @@
using namespace sk_app;
-using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
static std::map<GpuPathRenderers, std::string> gPathRendererNames;
Application* Application::Create(int argc, char** argv, void* platformData) {