blob: a4298755b7a2ecbf3358bf14f88e399e473ae3ab [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"
Brian Osman195c05b2017-08-30 15:14:04 -040013#include "../private/GrTypesPriv.h"
bsalomon682c2692015-05-22 14:01:46 -070014
Brian Osman51279982017-08-23 10:12:00 -040015class SkExecutor;
16
bsalomon682c2692015-05-22 14:01:46 -070017struct GrContextOptions {
Mike Kleinfc6c37b2016-09-27 09:34:10 -040018 GrContextOptions() {}
bsalomon682c2692015-05-22 14:01:46 -070019
bsalomon682c2692015-05-22 14:01:46 -070020 // Suppress prints for the GrContext.
bsalomon6b2552f2016-09-15 13:50:26 -070021 bool fSuppressPrints = false;
bsalomon4ee6bd82015-05-27 13:23:23 -070022
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
bsalomon6b2552f2016-09-15 13:50:26 -070027 int fMaxTextureSizeOverride = SK_MaxS32;
28
joshualitte5b74c62015-06-01 14:17:47 -070029 /** 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. */
bsalomon6b2552f2016-09-15 13:50:26 -070032 int fBufferMapThreshold = -1;
joshualitt83bc2292015-06-18 14:18:02 -070033
Brian Osman51279982017-08-23 10:12:00 -040034 /**
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
joshualitt83bc2292015-06-18 14:18:02 -070042 /** some gpus have problems with partial writes of the rendertarget */
bsalomon6b2552f2016-09-15 13:50:26 -070043 bool fUseDrawInsteadOfPartialRenderTargetWrite = false;
bsalomon648c6962015-10-23 09:06:59 -070044
brianosman9a3fbf72016-06-09 13:11:08 -070045 /** 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). */
bsalomon6b2552f2016-09-15 13:50:26 -070048 bool fDoManualMipmapping = false;
csmartdaltone0d36292016-07-29 08:14:20 -070049
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. */
bsalomon6b2552f2016-09-15 13:50:26 -070052 bool fEnableInstancedRendering = false;
53
bsalomon39ef7fb2016-09-21 11:16:05 -070054 /**
Brian Osmanb350ae22017-08-29 16:15:39 -040055 * 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 /**
bsalomon39ef7fb2016-09-21 11:16:05 -070061 * 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 /**
brianosman20471892016-12-02 06:43:32 -080067 * 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 Osman46da1cc2017-02-14 14:15:48 -050073
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;
csmartdalton008b9d82017-02-22 12:00:42 -070079
80 /**
Brian Osman195c05b2017-08-30 15:14:04 -040081 * 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 /**
csmartdalton008b9d82017-02-22 12:00:42 -0700108 * If true, the caps will never report driver support for path rendering.
109 */
110 bool fSuppressPathRendering = false;
111
112 /**
Jim Van Verthfbdc0802017-05-02 16:15:53 -0400113 * Render everything in wireframe
114 */
115 bool fWireframeMode = false;
116
117 /**
Brian Osman195c05b2017-08-30 15:14:04 -0400118 * Include or exclude specific GPU path renderers.
csmartdalton008b9d82017-02-22 12:00:42 -0700119 */
Brian Osman8b0f2652017-08-29 15:18:34 -0400120 GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kDefault;
Brian Osman195c05b2017-08-30 15:14:04 -0400121#endif
bsalomon682c2692015-05-22 14:01:46 -0700122};
123
bsalomon682c2692015-05-22 14:01:46 -0700124#endif