diff options
author | 2015-05-22 12:25:41 -0700 | |
---|---|---|
committer | 2015-05-22 12:25:41 -0700 | |
commit | f28cff71db2cbb1ff18a8fbf1e80ca761d1f69bc (patch) | |
tree | b91e0e301f518cd417afb870824e84aa16297a7d /include | |
parent | a624d12b2d10cff79ba4b31744d81cc2e0a8db5f (diff) |
Store context options on caps.
Review URL: https://codereview.chromium.org/1158433006
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrCaps.h | 12 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 26 | ||||
-rw-r--r-- | include/gpu/GrContextOptions.h | 24 | ||||
-rw-r--r-- | include/gpu/GrTypesPriv.h | 10 |
4 files changed, 45 insertions, 27 deletions
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h index 580017a9fe..be62d8a851 100644 --- a/include/gpu/GrCaps.h +++ b/include/gpu/GrCaps.h @@ -14,6 +14,8 @@ #include "SkRefCnt.h" #include "SkString.h" +struct GrContextOptions; + class GrShaderCaps : public SkRefCnt { public: SK_DECLARE_INST_COUNT(GrShaderCaps) @@ -103,7 +105,7 @@ class GrCaps : public SkRefCnt { public: SK_DECLARE_INST_COUNT(GrCaps) - GrCaps(); + GrCaps(const GrContextOptions&); virtual SkString dump() const; @@ -186,6 +188,11 @@ public: return fConfigTextureSupport[config]; } + bool suppressPrints() const { return fSupressPrints; } + + bool drawPathMasksToCompressedTexturesSupport() const { + return fDrawPathMasksToCompressedTextureSupport; } + protected: SkAutoTUnref<GrShaderCaps> fShaderCaps; @@ -214,6 +221,9 @@ protected: bool fConfigTextureSupport[kGrPixelConfigCnt]; private: + bool fSupressPrints : 1; + bool fDrawPathMasksToCompressedTextureSupport : 1; + typedef SkRefCnt INHERITED; }; diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index a6fdf75d89..b6fef3d80c 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -20,6 +20,7 @@ class GrAARectRenderer; class GrBatchFontCache; +struct GrContextOptions; class GrDrawTarget; class GrFragmentProcessor; class GrGpu; @@ -46,20 +47,11 @@ class SK_API GrContext : public SkRefCnt { public: SK_DECLARE_INST_COUNT(GrContext) - struct Options { - Options() : fDrawPathToCompressedTexture(false), fSuppressPrints(false) { } - - // EXPERIMENTAL - // May be removed in the future, or may become standard depending - // on the outcomes of a variety of internal tests. - bool fDrawPathToCompressedTexture; - bool fSuppressPrints; - }; - /** * Creates a GrContext for a backend context. */ - static GrContext* Create(GrBackend, GrBackendContext, const Options* opts = NULL); + static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions& options); + static GrContext* Create(GrBackend, GrBackendContext); /** * Only defined in test apps. @@ -530,7 +522,6 @@ public: GrResourceProvider* resourceProvider() { return fResourceProvider; } const GrResourceProvider* resourceProvider() const { return fResourceProvider; } GrResourceCache* getResourceCache() { return fResourceCache; } - bool suppressPrints() const { return fOptions.fSuppressPrints; } // Called by tests that draw directly to the context via GrDrawTarget void getTestTarget(GrTestTarget*); @@ -548,12 +539,6 @@ public: GrPathRendererChain::DrawType drawType = GrPathRendererChain::kColor_DrawType, GrPathRendererChain::StencilSupport* stencilSupport = NULL); - /** - * This returns a copy of the the GrContext::Options that was passed to the - * constructor of this class. - */ - const Options& getOptions() const { return fOptions; } - /** Prints cache stats to the string if GR_CACHE_STATS == 1. */ void dumpCacheStats(SkString*) const; void printCacheStats() const; @@ -599,11 +584,10 @@ private: int fMaxTextureSizeOverride; - const Options fOptions; const uint32_t fUniqueID; - GrContext(const Options&); // init must be called after the constructor. - bool init(GrBackend, GrBackendContext); + GrContext(); // init must be called after the constructor. + bool init(GrBackend, GrBackendContext, const GrContextOptions& options); void initMockContext(); void initCommon(); diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h new file mode 100644 index 0000000000..a2b2d2d9d7 --- /dev/null +++ b/include/gpu/GrContextOptions.h @@ -0,0 +1,24 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrContextOptions_DEFINED +#define GrContextOptions_DEFINED + +#include "GrTypes.h" + +struct GrContextOptions { + GrContextOptions() : fDrawPathToCompressedTexture(false), fSuppressPrints(false) {} + + // EXPERIMENTAL + // May be removed in the future, or may become standard depending + // on the outcomes of a variety of internal tests. + bool fDrawPathToCompressedTexture; + // Suppress prints for the GrContext. + bool fSuppressPrints; +}; + +#endif diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h index eaf1aa4050..9202742df9 100644 --- a/include/gpu/GrTypesPriv.h +++ b/include/gpu/GrTypesPriv.h @@ -265,13 +265,13 @@ private: }; #ifdef SK_DEBUG -// Takes a pointer to a GrContext, and will suppress prints if required -#define GrContextDebugf(context, ...) \ - if (!context->suppressPrints()) { \ - SkDebugf(__VA_ARGS__); \ +// Takes a pointer to a GrCaps, and will suppress prints if required +#define GrCapsDebugf(caps, ...) \ + if (!caps->suppressPrints()) { \ + SkDebugf(__VA_ARGS__); \ } #else -#define GrContextDebugf(context, ...) +#define GrCapsDebugf(caps, ...) #endif #endif |