GrContextOptions.h revision 97e398d98928f9497063594ebe633efe2d0f4968
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
13struct GrContextOptions {
14    GrContextOptions()
15        : fSuppressPrints(false)
16        , fMaxTextureSizeOverride(SK_MaxS32)
17        , fMaxTileSizeOverride(0)
18        , fSuppressDualSourceBlending(false)
19        , fBufferMapThreshold(-1)
20        , fUseDrawInsteadOfPartialRenderTargetWrite(false)
21        , fImmediateMode(false)
22        , fClipBatchToBounds(false)
23        , fDrawBatchBounds(false)
24        , fMaxBatchLookback(-1)
25        , fMaxBatchLookahead(-1)
26        , fUseShaderSwizzling(false) {}
27
28    // Suppress prints for the GrContext.
29    bool fSuppressPrints;
30
31    /** Overrides: These options override feature detection using backend API queries. These
32        overrides can only reduce the feature set or limits, never increase them beyond the
33        detected values. */
34
35    int  fMaxTextureSizeOverride;
36    /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
37        by SkGpuDevice. */
38    int  fMaxTileSizeOverride;
39    bool fSuppressDualSourceBlending;
40
41    /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index
42        buffers to CPU memory in order to update them.  A value of -1 means the GrContext should
43        deduce the optimal value for this platform. */
44    int  fBufferMapThreshold;
45
46    /** some gpus have problems with partial writes of the rendertarget */
47    bool fUseDrawInsteadOfPartialRenderTargetWrite;
48
49    /** The GrContext operates in immediate mode. It will issue all draws to the backend API
50        immediately. Intended to ease debugging. */
51    bool fImmediateMode;
52
53    /** For debugging purposes turn each GrBatch's bounds into a clip rect. This is used to
54        verify that the clip bounds are conservative. */
55    bool fClipBatchToBounds;
56
57    /** For debugging purposes draw a wireframe device bounds rect for each GrBatch. The wire
58        frame rect is draw before the GrBatch in order to visualize batches that draw outside
59        of their dev bounds. */
60    bool fDrawBatchBounds;
61
62    /** For debugging, override the default maximum look-back or look-ahead window for GrBatch
63        combining. */
64    int fMaxBatchLookback;
65    int fMaxBatchLookahead;
66
67    /** Force us to do all swizzling manually in the shader and don't rely on extensions to do
68        swizzling. */
69    bool fUseShaderSwizzling;
70
71    /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when
72        the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap
73        level and LOD control (ie desktop or ES3). */
74    bool fDoManualMipmapping;
75};
76
77#endif
78