blob: b94b5cee5f2c050895ff7cca1e8b7f241a41e36a [file] [log] [blame]
bsalomon682c2692015-05-22 14:01:46 -07001/*
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"
csmartdalton008b9d82017-02-22 12:00:42 -070012#include "GrTypes.h"
bsalomon682c2692015-05-22 14:01:46 -070013
Brian Osman51279982017-08-23 10:12:00 -040014class SkExecutor;
15
bsalomon682c2692015-05-22 14:01:46 -070016struct GrContextOptions {
Mike Kleinfc6c37b2016-09-27 09:34:10 -040017 GrContextOptions() {}
bsalomon682c2692015-05-22 14:01:46 -070018
bsalomon682c2692015-05-22 14:01:46 -070019 // Suppress prints for the GrContext.
bsalomon6b2552f2016-09-15 13:50:26 -070020 bool fSuppressPrints = false;
bsalomon4ee6bd82015-05-27 13:23:23 -070021
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
bsalomon6b2552f2016-09-15 13:50:26 -070026 int fMaxTextureSizeOverride = SK_MaxS32;
27
bsalomon8c07b7a2015-11-02 11:36:52 -080028 /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
29 by SkGpuDevice. */
bsalomon6b2552f2016-09-15 13:50:26 -070030 int fMaxTileSizeOverride = 0;
31 bool fSuppressDualSourceBlending = false;
joshualitt7224c862015-05-29 06:46:47 -070032
joshualitte5b74c62015-06-01 14:17:47 -070033 /** 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. */
bsalomon6b2552f2016-09-15 13:50:26 -070036 int fBufferMapThreshold = -1;
joshualitt83bc2292015-06-18 14:18:02 -070037
Brian Osman51279982017-08-23 10:12:00 -040038 /**
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
joshualitt83bc2292015-06-18 14:18:02 -070046 /** some gpus have problems with partial writes of the rendertarget */
bsalomon6b2552f2016-09-15 13:50:26 -070047 bool fUseDrawInsteadOfPartialRenderTargetWrite = false;
bsalomon648c6962015-10-23 09:06:59 -070048
brianosman9a3fbf72016-06-09 13:11:08 -070049 /** 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). */
bsalomon6b2552f2016-09-15 13:50:26 -070052 bool fDoManualMipmapping = false;
csmartdaltone0d36292016-07-29 08:14:20 -070053
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. */
bsalomon6b2552f2016-09-15 13:50:26 -070056 bool fEnableInstancedRendering = false;
57
bsalomon39ef7fb2016-09-21 11:16:05 -070058 /**
59 * If true this allows path mask textures to be cached. This is only really useful if paths
60 * are commonly rendered at the same scale and fractional translation.
61 */
62 bool fAllowPathMaskCaching = false;
63
64 /**
brianosman20471892016-12-02 06:43:32 -080065 * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an
66 * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this
67 * can be set to false, which will significantly expand the number of devices that qualify for
68 * sRGB support.
69 */
70 bool fRequireDecodeDisableForSRGB = true;
Brian Osman46da1cc2017-02-14 14:15:48 -050071
72 /**
73 * If true, the GPU will not be used to perform YUV -> RGB conversion when generating
74 * textures from codec-backed images.
75 */
76 bool fDisableGpuYUVConversion = false;
csmartdalton008b9d82017-02-22 12:00:42 -070077
78 /**
79 * If true, the caps will never report driver support for path rendering.
80 */
81 bool fSuppressPathRendering = false;
82
83 /**
Jim Van Verthfbdc0802017-05-02 16:15:53 -040084 * Render everything in wireframe
85 */
86 bool fWireframeMode = false;
87
88 /**
csmartdalton008b9d82017-02-22 12:00:42 -070089 * Allows the client to include or exclude specific GPU path renderers.
90 */
91 enum class GpuPathRenderers {
Brian Osman8b0f2652017-08-29 15:18:34 -040092 kNone = 0, // Always use sofware masks and/or GrDefaultPathRenderer.
csmartdalton008b9d82017-02-22 12:00:42 -070093 kDashLine = 1 << 0,
94 kStencilAndCover = 1 << 1,
95 kMSAA = 1 << 2,
96 kAAHairline = 1 << 3,
97 kAAConvex = 1 << 4,
98 kAALinearizing = 1 << 5,
Jim Van Verth83010462017-03-16 08:45:39 -040099 kSmall = 1 << 6,
Chris Dalton1a325d22017-07-14 15:17:41 -0600100 kCoverageCounting = 1 << 7,
101 kTessellating = 1 << 8,
Brian Osman8b0f2652017-08-29 15:18:34 -0400102
103 kAll = (kTessellating | (kTessellating - 1)),
csmartdalton008b9d82017-02-22 12:00:42 -0700104
Chris Dalton1a325d22017-07-14 15:17:41 -0600105 // Temporarily disabling CCPR by default until it has had a time to soak.
Brian Osman8b0f2652017-08-29 15:18:34 -0400106 kDefault = kAll & ~kCoverageCounting,
Jim Van Verth83010462017-03-16 08:45:39 -0400107
108 // For legacy. To be removed when updated in Android.
109 kDistanceField = kSmall
csmartdalton008b9d82017-02-22 12:00:42 -0700110 };
111
Brian Osman8b0f2652017-08-29 15:18:34 -0400112 GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault;
Eric Karl6d342282017-05-03 17:08:42 -0700113
114 /**
115 * The maximum size of cache textures used for Skia's Glyph cache.
116 */
117 float fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4;
Eric Karl5c779752017-05-08 12:02:07 -0700118
119 /**
120 * Bugs on certain drivers cause stencil buffers to leak. This flag causes Skia to avoid
121 * allocating stencil buffers and use alternate rasterization paths, avoiding the leak.
122 */
123 bool fAvoidStencilBuffers = false;
bsalomon682c2692015-05-22 14:01:46 -0700124};
125
csmartdalton008b9d82017-02-22 12:00:42 -0700126GR_MAKE_BITFIELD_CLASS_OPS(GrContextOptions::GpuPathRenderers)
127
bsalomon682c2692015-05-22 14:01:46 -0700128#endif