bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 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 "SkTypes.h" |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 12 | #include "GrTypes.h" |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame^] | 13 | #include "../private/GrTypesPriv.h" |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 14 | |
Brian Osman | 5127998 | 2017-08-23 10:12:00 -0400 | [diff] [blame] | 15 | class SkExecutor; |
| 16 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 17 | struct GrContextOptions { |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 18 | GrContextOptions() {} |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 19 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 20 | // Suppress prints for the GrContext. |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 21 | bool fSuppressPrints = false; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 22 | |
| 23 | /** Overrides: These options override feature detection using backend API queries. These |
| 24 | overrides can only reduce the feature set or limits, never increase them beyond the |
| 25 | detected values. */ |
| 26 | |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 27 | int fMaxTextureSizeOverride = SK_MaxS32; |
| 28 | |
joshualitt | e5b74c6 | 2015-06-01 14:17:47 -0700 | [diff] [blame] | 29 | /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index |
| 30 | buffers to CPU memory in order to update them. A value of -1 means the GrContext should |
| 31 | deduce the optimal value for this platform. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 32 | int fBufferMapThreshold = -1; |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 33 | |
Brian Osman | 5127998 | 2017-08-23 10:12:00 -0400 | [diff] [blame] | 34 | /** |
| 35 | * Executor to handle threaded work within Ganesh. If this is nullptr, then all work will be |
| 36 | * done serially on the main thread. To have worker threads assist with various tasks, set this |
| 37 | * to a valid SkExecutor instance. Currently, used for software path rendering, but may be used |
| 38 | * for other tasks. |
| 39 | */ |
| 40 | SkExecutor* fExecutor = nullptr; |
| 41 | |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 42 | /** some gpus have problems with partial writes of the rendertarget */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 43 | bool fUseDrawInsteadOfPartialRenderTargetWrite = false; |
bsalomon | 648c696 | 2015-10-23 09:06:59 -0700 | [diff] [blame] | 44 | |
brianosman | 9a3fbf7 | 2016-06-09 13:11:08 -0700 | [diff] [blame] | 45 | /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when |
| 46 | the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap |
| 47 | level and LOD control (ie desktop or ES3). */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 48 | bool fDoManualMipmapping = false; |
csmartdalton | e0d3629 | 2016-07-29 08:14:20 -0700 | [diff] [blame] | 49 | |
| 50 | /** Enable instanced rendering as long as all required functionality is supported by the HW. |
| 51 | Instanced rendering is still experimental at this point and disabled by default. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 52 | bool fEnableInstancedRendering = false; |
| 53 | |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 54 | /** |
Brian Osman | b350ae2 | 2017-08-29 16:15:39 -0400 | [diff] [blame] | 55 | * Disables distance field rendering for paths. Distance field computation can be expensive, |
| 56 | * and yields no benefit if a path is not rendered multiple times with different transforms. |
| 57 | */ |
| 58 | bool fDisableDistanceFieldPaths = false; |
| 59 | |
| 60 | /** |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 61 | * If true this allows path mask textures to be cached. This is only really useful if paths |
| 62 | * are commonly rendered at the same scale and fractional translation. |
| 63 | */ |
| 64 | bool fAllowPathMaskCaching = false; |
| 65 | |
| 66 | /** |
brianosman | 2047189 | 2016-12-02 06:43:32 -0800 | [diff] [blame] | 67 | * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an |
| 68 | * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this |
| 69 | * can be set to false, which will significantly expand the number of devices that qualify for |
| 70 | * sRGB support. |
| 71 | */ |
| 72 | bool fRequireDecodeDisableForSRGB = true; |
Brian Osman | 46da1cc | 2017-02-14 14:15:48 -0500 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * If true, the GPU will not be used to perform YUV -> RGB conversion when generating |
| 76 | * textures from codec-backed images. |
| 77 | */ |
| 78 | bool fDisableGpuYUVConversion = false; |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame^] | 81 | * The maximum size of cache textures used for Skia's Glyph cache. |
| 82 | */ |
| 83 | float fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4; |
| 84 | |
| 85 | /** |
| 86 | * Bugs on certain drivers cause stencil buffers to leak. This flag causes Skia to avoid |
| 87 | * allocating stencil buffers and use alternate rasterization paths, avoiding the leak. |
| 88 | */ |
| 89 | bool fAvoidStencilBuffers = false; |
| 90 | |
| 91 | #if GR_TEST_UTILS |
| 92 | /** |
| 93 | * Private options that are only meant for testing within Skia's tools. |
| 94 | */ |
| 95 | |
| 96 | /** |
| 97 | * If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered |
| 98 | * by SkGpuDevice. |
| 99 | */ |
| 100 | int fMaxTileSizeOverride = 0; |
| 101 | |
| 102 | /** |
| 103 | * Prevents use of dual source blending, to test that all xfer modes work correctly without it. |
| 104 | */ |
| 105 | bool fSuppressDualSourceBlending = false; |
| 106 | |
| 107 | /** |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 108 | * If true, the caps will never report driver support for path rendering. |
| 109 | */ |
| 110 | bool fSuppressPathRendering = false; |
| 111 | |
| 112 | /** |
Jim Van Verth | fbdc080 | 2017-05-02 16:15:53 -0400 | [diff] [blame] | 113 | * Render everything in wireframe |
| 114 | */ |
| 115 | bool fWireframeMode = false; |
| 116 | |
| 117 | /** |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame^] | 118 | * Include or exclude specific GPU path renderers. |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 119 | */ |
Brian Osman | 8b0f265 | 2017-08-29 15:18:34 -0400 | [diff] [blame] | 120 | GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault; |
Brian Osman | 195c05b | 2017-08-30 15:14:04 -0400 | [diff] [blame^] | 121 | #endif |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 122 | }; |
| 123 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 124 | #endif |