Skia
2D Graphics Library
GrContextOptions.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef GrContextOptions_DEFINED
9 #define GrContextOptions_DEFINED
10 
11 #include "include/core/SkData.h"
12 #include "include/core/SkString.h"
13 #include "include/core/SkTypes.h"
15 #include "include/gpu/GrTypes.h"
17 #include "include/private/gpu/ganesh/GrTypesPriv.h"
18 
19 #include <vector>
20 
21 class SkExecutor;
22 
23 #if defined(SK_GANESH)
24 struct SK_API GrContextOptions {
25  enum class Enable {
27  kNo,
29  kYes,
33  kDefault
34  };
35 
36  enum class ShaderCacheStrategy {
37  kSkSL,
38  kBackendSource,
39  kBackendBinary,
40  };
41 
47  class SK_API PersistentCache {
48  public:
49  virtual ~PersistentCache() = default;
50 
54  virtual sk_sp<SkData> load(const SkData& key) = 0;
55 
56  // Placeholder until all clients override the 3-parameter store(), then remove this, and
57  // make that version pure virtual.
58  virtual void store(const SkData& /*key*/, const SkData& /*data*/) { SkASSERT(false); }
59 
64  virtual void store(const SkData& key, const SkData& data, const SkString& /*description*/) {
65  this->store(key, data);
66  }
67 
68  protected:
69  PersistentCache() = default;
70  PersistentCache(const PersistentCache&) = delete;
71  PersistentCache& operator=(const PersistentCache&) = delete;
72  };
73 
74  using ShaderErrorHandler = skgpu::ShaderErrorHandler;
75 
76  GrContextOptions() {}
77 
78  // Suppress prints for the GrContext.
79  bool fSuppressPrints = false;
80 
87  Enable fSkipGLErrorChecks = Enable::kDefault;
88 
93  int fMaxTextureSizeOverride = SK_MaxS32;
94 
98  int fBufferMapThreshold = -1;
99 
104  size_t fMinimumStagingBufferSize = 64 * 1024;
105 
112  SkExecutor* fExecutor = nullptr;
113 
117  bool fDoManualMipmapping = false;
118 
124  // FIXME: Once this is removed from Chrome and Android, rename to fEnable"".
125  bool fDisableCoverageCountingPaths = true;
126 
131  bool fDisableDistanceFieldPaths = false;
132 
137  bool fAllowPathMaskCaching = true;
138 
143  bool fDisableGpuYUVConversion = false;
144 
148  size_t fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4;
149 
154  float fMinDistanceFieldFontSize = 18;
155 
159 #if defined(SK_BUILD_FOR_ANDROID)
160  float fGlyphsAsPathsFontSize = 384;
161 #elif defined(SK_BUILD_FOR_MAC)
162  float fGlyphsAsPathsFontSize = 256;
163 #else
164  float fGlyphsAsPathsFontSize = 324;
165 #endif
166 
171  Enable fAllowMultipleGlyphCacheTextures = Enable::kDefault;
172 
177  bool fAvoidStencilBuffers = false;
178 
182  Enable fUseDrawInsteadOfClear = Enable::kDefault;
183 
190  Enable fReduceOpsTaskSplitting = Enable::kDefault;
191 
197  bool fPreferExternalImagesOverES3 = false;
198 
204  bool fDisableDriverCorrectnessWorkarounds = false;
205 
209  int fRuntimeProgramCacheSize = 256;
210 
214  PersistentCache* fPersistentCache = nullptr;
215 
222  ShaderCacheStrategy fShaderCacheStrategy = ShaderCacheStrategy::kBackendBinary;
223 
228  ShaderErrorHandler* fShaderErrorHandler = nullptr;
229 
236  int fInternalMultisampleCount = 4;
237 
247  int fMaxCachedVulkanSecondaryCommandBuffers = -1;
248 
252  bool fSuppressMipmapSupport = false;
253 
258  bool fDisableTessellationPathRenderer = false;
259 
264  bool fEnableExperimentalHardwareTessellation = false;
265 
270  bool fSupportBilerpFromGlyphAtlas = false;
271 
276  bool fReducedShaderVariations = false;
277 
281  bool fAllowMSAAOnNewIntel = false;
282 
290  bool fAlwaysUseTexStorageWhenAvailable = false;
291 
298  GrDirectContextDestroyedContext fContextDeleteContext = nullptr;
299  GrDirectContextDestroyedProc fContextDeleteProc = nullptr;
300 
301 #if defined(GR_TEST_UTILS)
310  bool fFailFlushTimeCallbacks = false;
311 
315  bool fSuppressDualSourceBlending = false;
316 
321  bool fSuppressAdvancedBlendEquations = false;
322 
326  bool fSuppressFramebufferFetch = false;
327 
331  bool fAllPathsVolatile = false;
332 
336  bool fWireframeMode = false;
337 
341  bool fClearAllTextures = false;
342 
346  bool fRandomGLOOM = false;
347 
351  bool fDisallowWriteAndTransferPixelRowBytes = false;
352 
356  GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault;
357 
364  int fResourceCacheLimitOverride = -1;
365 
369  int fMaxTextureAtlasSize = 2048;
370 #endif
371 
372  GrDriverBugWorkarounds fDriverBugWorkarounds;
373 };
374 #else
376  struct PersistentCache {};
377 };
378 #endif
379 
380 #endif
void * GrDirectContextDestroyedContext
Definition: GrTypes.h:193
void(* GrDirectContextDestroyedProc)(GrDirectContextDestroyedContext destroyedContext)
Definition: GrTypes.h:194
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
Definition: GrDriverBugWorkarounds.h:35
SkData holds an immutable data buffer.
Definition: SkData.h:25
Definition: SkExecutor.h:15
Light weight class for managing strings.
Definition: SkString.h:118
Abstract class to report errors when compiling shaders.
Definition: ShaderErrorHandler.h:17
Definition: GrContextOptions.h:376
Definition: GrContextOptions.h:375