blob: 65daf72eadd4d6284629fbe139835b84d9e071b4 [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"
12
13struct GrContextOptions {
Mike Kleinfc6c37b2016-09-27 09:34:10 -040014 GrContextOptions() {}
bsalomon682c2692015-05-22 14:01:46 -070015
bsalomon682c2692015-05-22 14:01:46 -070016 // Suppress prints for the GrContext.
bsalomon6b2552f2016-09-15 13:50:26 -070017 bool fSuppressPrints = false;
bsalomon4ee6bd82015-05-27 13:23:23 -070018
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
bsalomon6b2552f2016-09-15 13:50:26 -070023 int fMaxTextureSizeOverride = SK_MaxS32;
24
bsalomon8c07b7a2015-11-02 11:36:52 -080025 /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
26 by SkGpuDevice. */
bsalomon6b2552f2016-09-15 13:50:26 -070027 int fMaxTileSizeOverride = 0;
28 bool fSuppressDualSourceBlending = false;
joshualitt7224c862015-05-29 06:46:47 -070029
joshualitte5b74c62015-06-01 14:17:47 -070030 /** 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. */
bsalomon6b2552f2016-09-15 13:50:26 -070033 int fBufferMapThreshold = -1;
joshualitt83bc2292015-06-18 14:18:02 -070034
35 /** some gpus have problems with partial writes of the rendertarget */
bsalomon6b2552f2016-09-15 13:50:26 -070036 bool fUseDrawInsteadOfPartialRenderTargetWrite = false;
bsalomon648c6962015-10-23 09:06:59 -070037
bsalomon69cfe952015-11-30 13:27:47 -080038 /** The GrContext operates in immediate mode. It will issue all draws to the backend API
bsalomon648c6962015-10-23 09:06:59 -070039 immediately. Intended to ease debugging. */
bsalomon6b2552f2016-09-15 13:50:26 -070040 bool fImmediateMode = false;
egdanielb7e7d572015-11-04 04:23:53 -080041
Brian Salomon25a88092016-12-01 09:36:50 -050042 /** For debugging purposes turn each GrOp's bounds into a clip rect. This is used to
bsalomon69cfe952015-11-30 13:27:47 -080043 verify that the clip bounds are conservative. */
bsalomon6b2552f2016-09-15 13:50:26 -070044 bool fClipBatchToBounds = false;
bsalomon69cfe952015-11-30 13:27:47 -080045
Brian Salomon25a88092016-12-01 09:36:50 -050046 /** For debugging, override the default maximum look-back or look-ahead window for GrOp
bsalomonaecc0182016-03-07 11:50:44 -080047 combining. */
bsalomon6b2552f2016-09-15 13:50:26 -070048 int fMaxBatchLookback = -1;
49 int fMaxBatchLookahead = -1;
bsalomon489147c2015-12-14 12:13:09 -080050
egdanielb7e7d572015-11-04 04:23:53 -080051 /** Force us to do all swizzling manually in the shader and don't rely on extensions to do
52 swizzling. */
bsalomon6b2552f2016-09-15 13:50:26 -070053 bool fUseShaderSwizzling = false;
brianosman9a3fbf72016-06-09 13:11:08 -070054
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). */
bsalomon6b2552f2016-09-15 13:50:26 -070058 bool fDoManualMipmapping = false;
csmartdaltone0d36292016-07-29 08:14:20 -070059
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. */
bsalomon6b2552f2016-09-15 13:50:26 -070062 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;
bsalomon39ef7fb2016-09-21 11:16:05 -070067
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;
brianosman20471892016-12-02 06:43:32 -080080
81 /**
82 * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an
83 * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this
84 * can be set to false, which will significantly expand the number of devices that qualify for
85 * sRGB support.
86 */
87 bool fRequireDecodeDisableForSRGB = true;
bsalomon682c2692015-05-22 14:01:46 -070088};
89
90#endif