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