blob: 4c922f3d2ffbe07ea64b1cbbe90aba2f9c61c6d2 [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
14struct GrContextOptions {
Mike Kleinfc6c37b2016-09-27 09:34:10 -040015 GrContextOptions() {}
bsalomon682c2692015-05-22 14:01:46 -070016
bsalomon682c2692015-05-22 14:01:46 -070017 // Suppress prints for the GrContext.
bsalomon6b2552f2016-09-15 13:50:26 -070018 bool fSuppressPrints = false;
bsalomon4ee6bd82015-05-27 13:23:23 -070019
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
bsalomon6b2552f2016-09-15 13:50:26 -070024 int fMaxTextureSizeOverride = SK_MaxS32;
25
bsalomon8c07b7a2015-11-02 11:36:52 -080026 /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
27 by SkGpuDevice. */
bsalomon6b2552f2016-09-15 13:50:26 -070028 int fMaxTileSizeOverride = 0;
29 bool fSuppressDualSourceBlending = false;
joshualitt7224c862015-05-29 06:46:47 -070030
joshualitte5b74c62015-06-01 14:17:47 -070031 /** 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. */
bsalomon6b2552f2016-09-15 13:50:26 -070034 int fBufferMapThreshold = -1;
joshualitt83bc2292015-06-18 14:18:02 -070035
36 /** some gpus have problems with partial writes of the rendertarget */
bsalomon6b2552f2016-09-15 13:50:26 -070037 bool fUseDrawInsteadOfPartialRenderTargetWrite = false;
bsalomon648c6962015-10-23 09:06:59 -070038
bsalomon69cfe952015-11-30 13:27:47 -080039 /** The GrContext operates in immediate mode. It will issue all draws to the backend API
bsalomon648c6962015-10-23 09:06:59 -070040 immediately. Intended to ease debugging. */
bsalomon6b2552f2016-09-15 13:50:26 -070041 bool fImmediateMode = false;
egdanielb7e7d572015-11-04 04:23:53 -080042
Brian Salomon25a88092016-12-01 09:36:50 -050043 /** For debugging, override the default maximum look-back or look-ahead window for GrOp
bsalomonaecc0182016-03-07 11:50:44 -080044 combining. */
Brian Salomon09d994e2016-12-21 11:14:46 -050045 int fMaxOpCombineLookback = -1;
46 int fMaxOpCombineLookahead = -1;
bsalomon489147c2015-12-14 12:13:09 -080047
egdanielb7e7d572015-11-04 04:23:53 -080048 /** Force us to do all swizzling manually in the shader and don't rely on extensions to do
49 swizzling. */
bsalomon6b2552f2016-09-15 13:50:26 -070050 bool fUseShaderSwizzling = false;
brianosman9a3fbf72016-06-09 13:11:08 -070051
52 /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when
53 the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap
54 level and LOD control (ie desktop or ES3). */
bsalomon6b2552f2016-09-15 13:50:26 -070055 bool fDoManualMipmapping = false;
csmartdaltone0d36292016-07-29 08:14:20 -070056
57 /** Enable instanced rendering as long as all required functionality is supported by the HW.
58 Instanced rendering is still experimental at this point and disabled by default. */
bsalomon6b2552f2016-09-15 13:50:26 -070059 bool fEnableInstancedRendering = false;
60
bsalomon39ef7fb2016-09-21 11:16:05 -070061 /**
62 * If true this allows path mask textures to be cached. This is only really useful if paths
63 * are commonly rendered at the same scale and fractional translation.
64 */
65 bool fAllowPathMaskCaching = false;
66
67 /**
brianosman20471892016-12-02 06:43:32 -080068 * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an
69 * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this
70 * can be set to false, which will significantly expand the number of devices that qualify for
71 * sRGB support.
72 */
73 bool fRequireDecodeDisableForSRGB = true;
Brian Osman46da1cc2017-02-14 14:15:48 -050074
75 /**
76 * If true, the GPU will not be used to perform YUV -> RGB conversion when generating
77 * textures from codec-backed images.
78 */
79 bool fDisableGpuYUVConversion = false;
csmartdalton008b9d82017-02-22 12:00:42 -070080
81 /**
82 * If true, the caps will never report driver support for path rendering.
83 */
84 bool fSuppressPathRendering = false;
85
86 /**
87 * Allows the client to include or exclude specific GPU path renderers.
88 */
89 enum class GpuPathRenderers {
90 kNone = 0, // Always use sofware masks.
91 kDashLine = 1 << 0,
92 kStencilAndCover = 1 << 1,
93 kMSAA = 1 << 2,
94 kAAHairline = 1 << 3,
95 kAAConvex = 1 << 4,
96 kAALinearizing = 1 << 5,
Brian Salomon42c456f2017-03-06 11:29:48 -050097 kDistanceField = 1 << 6,
98 kTessellating = 1 << 7,
99 kDefault = 1 << 8,
csmartdalton008b9d82017-02-22 12:00:42 -0700100
101 kAll = kDefault | (kDefault - 1)
102 };
103
104 GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll;
bsalomon682c2692015-05-22 14:01:46 -0700105};
106
csmartdalton008b9d82017-02-22 12:00:42 -0700107GR_MAKE_BITFIELD_CLASS_OPS(GrContextOptions::GpuPathRenderers)
108
bsalomon682c2692015-05-22 14:01:46 -0700109#endif