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" |
| 12 | |
| 13 | struct GrContextOptions { |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 14 | GrContextOptions() {} |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 15 | |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 16 | // Suppress prints for the GrContext. |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 17 | bool fSuppressPrints = false; |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 18 | |
| 19 | /** Overrides: These options override feature detection using backend API queries. These |
| 20 | overrides can only reduce the feature set or limits, never increase them beyond the |
| 21 | detected values. */ |
| 22 | |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 23 | int fMaxTextureSizeOverride = SK_MaxS32; |
| 24 | |
bsalomon | 8c07b7a | 2015-11-02 11:36:52 -0800 | [diff] [blame] | 25 | /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered |
| 26 | by SkGpuDevice. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 27 | int fMaxTileSizeOverride = 0; |
| 28 | bool fSuppressDualSourceBlending = false; |
joshualitt | 7224c86 | 2015-05-29 06:46:47 -0700 | [diff] [blame] | 29 | |
joshualitt | e5b74c6 | 2015-06-01 14:17:47 -0700 | [diff] [blame] | 30 | /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index |
| 31 | buffers to CPU memory in order to update them. A value of -1 means the GrContext should |
| 32 | deduce the optimal value for this platform. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 33 | int fBufferMapThreshold = -1; |
joshualitt | 83bc229 | 2015-06-18 14:18:02 -0700 | [diff] [blame] | 34 | |
| 35 | /** some gpus have problems with partial writes of the rendertarget */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 36 | bool fUseDrawInsteadOfPartialRenderTargetWrite = false; |
bsalomon | 648c696 | 2015-10-23 09:06:59 -0700 | [diff] [blame] | 37 | |
bsalomon | 69cfe95 | 2015-11-30 13:27:47 -0800 | [diff] [blame] | 38 | /** 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] | 39 | immediately. Intended to ease debugging. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 40 | bool fImmediateMode = false; |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 41 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame^] | 42 | /** For debugging purposes turn each GrOp's bounds into a clip rect. This is used to |
bsalomon | 69cfe95 | 2015-11-30 13:27:47 -0800 | [diff] [blame] | 43 | verify that the clip bounds are conservative. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 44 | bool fClipBatchToBounds = false; |
bsalomon | 69cfe95 | 2015-11-30 13:27:47 -0800 | [diff] [blame] | 45 | |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame^] | 46 | /** 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] | 47 | combining. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 48 | int fMaxBatchLookback = -1; |
| 49 | int fMaxBatchLookahead = -1; |
bsalomon | 489147c | 2015-12-14 12:13:09 -0800 | [diff] [blame] | 50 | |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 51 | /** Force us to do all swizzling manually in the shader and don't rely on extensions to do |
| 52 | swizzling. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 53 | bool fUseShaderSwizzling = false; |
brianosman | 9a3fbf7 | 2016-06-09 13:11:08 -0700 | [diff] [blame] | 54 | |
| 55 | /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when |
| 56 | the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap |
| 57 | level and LOD control (ie desktop or ES3). */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 58 | bool fDoManualMipmapping = false; |
csmartdalton | e0d3629 | 2016-07-29 08:14:20 -0700 | [diff] [blame] | 59 | |
| 60 | /** Enable instanced rendering as long as all required functionality is supported by the HW. |
| 61 | Instanced rendering is still experimental at this point and disabled by default. */ |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 62 | bool fEnableInstancedRendering = false; |
| 63 | |
| 64 | /** Disables distance field rendering for paths. Distance field computation can be expensive |
| 65 | and yields no benefit if a path is not rendered multiple times with different transforms */ |
| 66 | bool fDisableDistanceFieldPaths = false; |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * If true this allows path mask textures to be cached. This is only really useful if paths |
| 70 | * are commonly rendered at the same scale and fractional translation. |
| 71 | */ |
| 72 | bool fAllowPathMaskCaching = false; |
| 73 | |
| 74 | /** |
| 75 | * Force all path draws to go through through the sw-rasterize-to-texture code path (assuming |
| 76 | * the path is not recognized as a simpler shape (e.g. a rrect). This is intended for testing |
| 77 | * purposes. |
| 78 | */ |
| 79 | bool fForceSWPathMasks = false; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | #endif |