• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
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 skgpu_graphite_ContextOptions_DEFINED
9 #define skgpu_graphite_ContextOptions_DEFINED
10 
11 namespace skgpu { class ShaderErrorHandler; }
12 
13 namespace skgpu::graphite {
14 
15 struct SK_API ContextOptions {
ContextOptionsContextOptions16     ContextOptions() {}
17 
18     /**
19      * Disables correctness workarounds that are enabled for particular GPUs, OSes, or drivers.
20      * This does not affect code path choices that are made for perfomance reasons nor does it
21      * override other ContextOption settings.
22      */
23     bool fDisableDriverCorrectnessWorkarounds = false;
24 
25     /**
26      * If present, use this object to report shader compilation failures. If not, report failures
27      * via SkDebugf and assert.
28      */
29     skgpu::ShaderErrorHandler* fShaderErrorHandler = nullptr;
30 
31     /**
32      * Will the client make sure to only ever be executing one thread that uses the Context and all
33      * derived classes (e.g. Recorders, Recordings, etc.) at a time. If so we can possibly make some
34      * objects (e.g. VulkanMemoryAllocator) not thread safe to improve single thread performance.
35      */
36     bool fClientWillExternallySynchronizeAllThreads = false;
37 
38     /**
39      * The maximum size of cache textures used for Skia's Glyph cache.
40      */
41     size_t fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4;
42 
43     /**
44      * Below this threshold size in device space distance field fonts won't be used. Distance field
45      * fonts don't support hinting which is more important at smaller sizes.
46      */
47     float fMinDistanceFieldFontSize = 18;
48 
49     /**
50      * Above this threshold size in device space glyphs are drawn as individual paths.
51      */
52 #if defined(SK_BUILD_FOR_ANDROID)
53     float fGlyphsAsPathsFontSize = 384;
54 #elif defined(SK_BUILD_FOR_MAC)
55     float fGlyphsAsPathsFontSize = 256;
56 #else
57     float fGlyphsAsPathsFontSize = 324;
58 #endif
59 
60     /**
61      * Can the glyph atlas use multiple textures. If allowed, the each texture's size is bound by
62      * fGlypheCacheTextureMaximumBytes.
63      */
64     bool fAllowMultipleGlyphCacheTextures = true;
65 
66     /**
67      * If true, then add 1 pixel padding to all glyph masks in the atlas to support bi-lerp
68      * rendering of all glyphs. This must be set to true to use Slugs.
69      */
70     #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG) || \
71         defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE) || \
72         defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_STRIKE_SERIALIZE)
73     bool fSupportBilerpFromGlyphAtlas = true;
74     #else
75     bool fSupportBilerpFromGlyphAtlas = false;
76     #endif
77 
78 #if GRAPHITE_TEST_UTILS
79     /**
80      * Private options that are only meant for testing within Skia's tools.
81      */
82 
83     /**
84      * Maximum width and height of internal texture atlases.
85      */
86     int  fMaxTextureAtlasSize = 2048;
87 
88     /**
89      * If true, will store a pointer in Recorder that points back to the Context
90      * that created it. Used by readPixels() and other methods that normally require a Context.
91      */
92     bool fStoreContextRefInRecorder = false;
93 #endif
94 };
95 
96 }  // namespace skgpu::graphite
97 
98 #endif  // skgpu_graphite_ContextOptions
99