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 | |
| 14 | struct GrContextOptions { |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 15 | GrContextOptions() {} |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 16 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 17 | // Suppress prints for the GrContext. |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 18 | bool fSuppressPrints = false; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 19 | |
| 20 | /** Overrides: These options override feature detection using backend API queries. These |
| 21 | overrides can only reduce the feature set or limits, never increase them beyond the |
| 22 | detected values. */ |
| 23 | |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 24 | int fMaxTextureSizeOverride = SK_MaxS32; |
| 25 | |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 26 | /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered |
| 27 | by SkGpuDevice. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 28 | int fMaxTileSizeOverride = 0; |
| 29 | bool fSuppressDualSourceBlending = false; |
joshualitt | 7224c86 | 2015-05-29 06:46:47 -0700 | [diff] [blame] | 30 | |
joshualitt | e5b74c6 | 2015-06-01 14:17:47 -0700 | [diff] [blame] | 31 | /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index |
| 32 | buffers to CPU memory in order to update them. A value of -1 means the GrContext should |
| 33 | deduce the optimal value for this platform. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 34 | int fBufferMapThreshold = -1; |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 35 | |
| 36 | /** some gpus have problems with partial writes of the rendertarget */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 37 | bool fUseDrawInsteadOfPartialRenderTargetWrite = false; |
bsalomon | 648c696 | 2015-10-23 09:06:59 -0700 | [diff] [blame] | 38 | |
bsalomon | 69cfe95 | 2015-11-30 13:27:47 -0800 | [diff] [blame] | 39 | /** The GrContext operates in immediate mode. It will issue all draws to the backend API |
bsalomon | 648c696 | 2015-10-23 09:06:59 -0700 | [diff] [blame] | 40 | immediately. Intended to ease debugging. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 41 | bool fImmediateMode = false; |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 42 | |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 43 | /** For debugging purposes turn each GrDrawOp's bounds into a clip rect. This is used to |
bsalomon | 69cfe95 | 2015-11-30 13:27:47 -0800 | [diff] [blame] | 44 | verify that the clip bounds are conservative. */ |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 45 | bool fClipDrawOpsToBounds = false; |
bsalomon | 69cfe95 | 2015-11-30 13:27:47 -0800 | [diff] [blame] | 46 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 47 | /** For debugging, override the default maximum look-back or look-ahead window for GrOp |
bsalomon | aecc018 | 2016-03-07 11:50:44 -0800 | [diff] [blame] | 48 | combining. */ |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 49 | int fMaxOpCombineLookback = -1; |
| 50 | int fMaxOpCombineLookahead = -1; |
bsalomon | 489147c | 2015-12-14 12:13:09 -0800 | [diff] [blame] | 51 | |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 52 | /** Force us to do all swizzling manually in the shader and don't rely on extensions to do |
| 53 | swizzling. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 54 | bool fUseShaderSwizzling = false; |
brianosman | 9a3fbf7 | 2016-06-09 13:11:08 -0700 | [diff] [blame] | 55 | |
| 56 | /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when |
| 57 | the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap |
| 58 | level and LOD control (ie desktop or ES3). */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 59 | bool fDoManualMipmapping = false; |
csmartdalton | e0d3629 | 2016-07-29 08:14:20 -0700 | [diff] [blame] | 60 | |
| 61 | /** Enable instanced rendering as long as all required functionality is supported by the HW. |
| 62 | Instanced rendering is still experimental at this point and disabled by default. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 63 | bool fEnableInstancedRendering = false; |
| 64 | |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 65 | /** |
| 66 | * If true this allows path mask textures to be cached. This is only really useful if paths |
| 67 | * are commonly rendered at the same scale and fractional translation. |
| 68 | */ |
| 69 | bool fAllowPathMaskCaching = false; |
| 70 | |
| 71 | /** |
brianosman | 2047189 | 2016-12-02 06:43:32 -0800 | [diff] [blame] | 72 | * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an |
| 73 | * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this |
| 74 | * can be set to false, which will significantly expand the number of devices that qualify for |
| 75 | * sRGB support. |
| 76 | */ |
| 77 | bool fRequireDecodeDisableForSRGB = true; |
Brian Osman | 46da1cc | 2017-02-14 14:15:48 -0500 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * If true, the GPU will not be used to perform YUV -> RGB conversion when generating |
| 81 | * textures from codec-backed images. |
| 82 | */ |
| 83 | bool fDisableGpuYUVConversion = false; |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * If true, the caps will never report driver support for path rendering. |
| 87 | */ |
| 88 | bool fSuppressPathRendering = false; |
| 89 | |
| 90 | /** |
| 91 | * Allows the client to include or exclude specific GPU path renderers. |
| 92 | */ |
| 93 | enum class GpuPathRenderers { |
| 94 | kNone = 0, // Always use sofware masks. |
| 95 | kDashLine = 1 << 0, |
| 96 | kStencilAndCover = 1 << 1, |
| 97 | kMSAA = 1 << 2, |
| 98 | kAAHairline = 1 << 3, |
| 99 | kAAConvex = 1 << 4, |
| 100 | kAALinearizing = 1 << 5, |
| 101 | kPLS = 1 << 6, |
| 102 | kDistanceField = 1 << 7, |
| 103 | kTesselating = 1 << 8, |
| 104 | kDefault = 1 << 9, |
| 105 | |
| 106 | kAll = kDefault | (kDefault - 1) |
| 107 | }; |
| 108 | |
| 109 | GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 112 | GR_MAKE_BITFIELD_CLASS_OPS(GrContextOptions::GpuPathRenderers) |
| 113 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 114 | #endif |