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 { GrContextOptionsGrContextOptions15 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 /** Force us to do all swizzling manually in the shader and don't rely on extensions to do 40 swizzling. */ 41 bool fUseShaderSwizzling = false; 42 43 /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when 44 the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap 45 level and LOD control (ie desktop or ES3). */ 46 bool fDoManualMipmapping = false; 47 48 /** Enable instanced rendering as long as all required functionality is supported by the HW. 49 Instanced rendering is still experimental at this point and disabled by default. */ 50 bool fEnableInstancedRendering = false; 51 52 /** 53 * If true this allows path mask textures to be cached. This is only really useful if paths 54 * are commonly rendered at the same scale and fractional translation. 55 */ 56 bool fAllowPathMaskCaching = false; 57 58 /** 59 * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an 60 * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this 61 * can be set to false, which will significantly expand the number of devices that qualify for 62 * sRGB support. 63 */ 64 bool fRequireDecodeDisableForSRGB = true; 65 66 /** 67 * If true, the GPU will not be used to perform YUV -> RGB conversion when generating 68 * textures from codec-backed images. 69 */ 70 bool fDisableGpuYUVConversion = false; 71 72 /** 73 * If true, the caps will never report driver support for path rendering. 74 */ 75 bool fSuppressPathRendering = false; 76 77 /** 78 * Render everything in wireframe 79 */ 80 bool fWireframeMode = false; 81 82 /** 83 * Allows the client to include or exclude specific GPU path renderers. 84 */ 85 enum class GpuPathRenderers { 86 kNone = 0, // Always use sofware masks. 87 kDashLine = 1 << 0, 88 kStencilAndCover = 1 << 1, 89 kMSAA = 1 << 2, 90 kAAHairline = 1 << 3, 91 kAAConvex = 1 << 4, 92 kAALinearizing = 1 << 5, 93 kSmall = 1 << 6, 94 kCoverageCounting = 1 << 7, 95 kTessellating = 1 << 8, 96 kDefault = 1 << 9, 97 98 // Temporarily disabling CCPR by default until it has had a time to soak. 99 kAll = (kDefault | (kDefault - 1)) & ~kCoverageCounting, 100 101 // For legacy. To be removed when updated in Android. 102 kDistanceField = kSmall 103 }; 104 105 GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll; 106 107 /** 108 * The maximum size of cache textures used for Skia's Glyph cache. 109 */ 110 float fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4; 111 112 /** 113 * Bugs on certain drivers cause stencil buffers to leak. This flag causes Skia to avoid 114 * allocating stencil buffers and use alternate rasterization paths, avoiding the leak. 115 */ 116 bool fAvoidStencilBuffers = false; 117 }; 118 119 GR_MAKE_BITFIELD_CLASS_OPS(GrContextOptions::GpuPathRenderers) 120 121 #endif 122