Home | History | Annotate | Download | only in gpu
      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 #include "GrTypes.h"
     13 
     14 struct GrContextOptions {
     15     GrContextOptions() {}
     16 
     17     // Suppress prints for the GrContext.
     18     bool fSuppressPrints = false;
     19 
     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 
     24     int  fMaxTextureSizeOverride = SK_MaxS32;
     25 
     26     /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered
     27         by SkGpuDevice. */
     28     int  fMaxTileSizeOverride = 0;
     29     bool fSuppressDualSourceBlending = false;
     30 
     31     /** 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. */
     34     int  fBufferMapThreshold = -1;
     35 
     36     /** some gpus have problems with partial writes of the rendertarget */
     37     bool fUseDrawInsteadOfPartialRenderTargetWrite = false;
     38 
     39     /** The GrContext operates in immediate mode. It will issue all draws to the backend API
     40         immediately. Intended to ease debugging. */
     41     bool fImmediateMode = false;
     42 
     43     /** For debugging, override the default maximum look-back or look-ahead window for GrOp
     44         combining. */
     45     int fMaxOpCombineLookback = -1;
     46     int fMaxOpCombineLookahead = -1;
     47 
     48     /** Force us to do all swizzling manually in the shader and don't rely on extensions to do
     49         swizzling. */
     50     bool fUseShaderSwizzling = false;
     51 
     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). */
     55     bool fDoManualMipmapping = false;
     56 
     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. */
     59     bool fEnableInstancedRendering = false;
     60 
     61     /**
     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     /**
     68      * 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;
     74 
     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;
     80 
     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,
     97         kSmall             = 1 << 6,
     98         kTessellating      = 1 << 7,
     99         kDefault           = 1 << 8,
    100 
    101         kAll               = kDefault | (kDefault - 1),
    102 
    103         // For legacy. To be removed when updated in Android.
    104         kDistanceField     = kSmall
    105     };
    106 
    107     GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll;
    108 };
    109 
    110 GR_MAKE_BITFIELD_CLASS_OPS(GrContextOptions::GpuPathRenderers)
    111 
    112 #endif
    113