GrContextOptions.h revision 6d342285a4546b54cb17570aae7eeb8a123c81ae
1682c269a1511200322916af83053e26004c0ec40bsalomon/* 2682c269a1511200322916af83053e26004c0ec40bsalomon * Copyright 2015 Google Inc. 3682c269a1511200322916af83053e26004c0ec40bsalomon * 4682c269a1511200322916af83053e26004c0ec40bsalomon * Use of this source code is governed by a BSD-style license that can be 5682c269a1511200322916af83053e26004c0ec40bsalomon * found in the LICENSE file. 6682c269a1511200322916af83053e26004c0ec40bsalomon */ 7682c269a1511200322916af83053e26004c0ec40bsalomon 8682c269a1511200322916af83053e26004c0ec40bsalomon#ifndef GrContextOptions_DEFINED 9682c269a1511200322916af83053e26004c0ec40bsalomon#define GrContextOptions_DEFINED 10682c269a1511200322916af83053e26004c0ec40bsalomon 11682c269a1511200322916af83053e26004c0ec40bsalomon#include "SkTypes.h" 12008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton#include "GrTypes.h" 13682c269a1511200322916af83053e26004c0ec40bsalomon 14682c269a1511200322916af83053e26004c0ec40bsalomonstruct GrContextOptions { 15fc6c37b981daeece7474ce61070c707c37eefa62Mike Klein GrContextOptions() {} 16682c269a1511200322916af83053e26004c0ec40bsalomon 17682c269a1511200322916af83053e26004c0ec40bsalomon // Suppress prints for the GrContext. 186b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon bool fSuppressPrints = false; 194ee6bd86c500d9b464e2f8cb3565544b8c97c0a9bsalomon 204ee6bd86c500d9b464e2f8cb3565544b8c97c0a9bsalomon /** Overrides: These options override feature detection using backend API queries. These 214ee6bd86c500d9b464e2f8cb3565544b8c97c0a9bsalomon overrides can only reduce the feature set or limits, never increase them beyond the 224ee6bd86c500d9b464e2f8cb3565544b8c97c0a9bsalomon detected values. */ 234ee6bd86c500d9b464e2f8cb3565544b8c97c0a9bsalomon 246b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon int fMaxTextureSizeOverride = SK_MaxS32; 256b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon 268c07b7ab53b93b39015a409a4e0a9174feb6a4c3bsalomon /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered 278c07b7ab53b93b39015a409a4e0a9174feb6a4c3bsalomon by SkGpuDevice. */ 286b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon int fMaxTileSizeOverride = 0; 296b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon bool fSuppressDualSourceBlending = false; 307224c866321e4222ef452fc0c73ae05283a2227cjoshualitt 31e5b74c68564baab3639b21a95ce5b4b92949ca27joshualitt /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index 32e5b74c68564baab3639b21a95ce5b4b92949ca27joshualitt buffers to CPU memory in order to update them. A value of -1 means the GrContext should 33e5b74c68564baab3639b21a95ce5b4b92949ca27joshualitt deduce the optimal value for this platform. */ 346b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon int fBufferMapThreshold = -1; 3583bc22970364f1ff94751b99c4b4048b3c66e1a2joshualitt 3683bc22970364f1ff94751b99c4b4048b3c66e1a2joshualitt /** some gpus have problems with partial writes of the rendertarget */ 376b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon bool fUseDrawInsteadOfPartialRenderTargetWrite = false; 38648c696438410fe0f0f5db9bb7935006fecf9cadbsalomon 3969cfe95b7be386cf7d349b61388e93ea7c3cd386bsalomon /** The GrContext operates in immediate mode. It will issue all draws to the backend API 40648c696438410fe0f0f5db9bb7935006fecf9cadbsalomon immediately. Intended to ease debugging. */ 416b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon bool fImmediateMode = false; 42b7e7d5748d74c7482436b33733d7770484bb62e3egdaniel 43b7e7d5748d74c7482436b33733d7770484bb62e3egdaniel /** Force us to do all swizzling manually in the shader and don't rely on extensions to do 44b7e7d5748d74c7482436b33733d7770484bb62e3egdaniel swizzling. */ 456b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon bool fUseShaderSwizzling = false; 469a3fbf7e559ca59a7b67a62be743496da1e31724brianosman 479a3fbf7e559ca59a7b67a62be743496da1e31724brianosman /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when 489a3fbf7e559ca59a7b67a62be743496da1e31724brianosman the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap 499a3fbf7e559ca59a7b67a62be743496da1e31724brianosman level and LOD control (ie desktop or ES3). */ 506b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon bool fDoManualMipmapping = false; 51e0d362929d6569e8737d80dead791c640390e819csmartdalton 52e0d362929d6569e8737d80dead791c640390e819csmartdalton /** Enable instanced rendering as long as all required functionality is supported by the HW. 53e0d362929d6569e8737d80dead791c640390e819csmartdalton Instanced rendering is still experimental at this point and disabled by default. */ 546b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon bool fEnableInstancedRendering = false; 556b2552f10983d1b6d33303e3e9965ae71944c1d5bsalomon 5639ef7fb885d7be648b9f0ecd027bc400d1213cecbsalomon /** 5739ef7fb885d7be648b9f0ecd027bc400d1213cecbsalomon * If true this allows path mask textures to be cached. This is only really useful if paths 5839ef7fb885d7be648b9f0ecd027bc400d1213cecbsalomon * are commonly rendered at the same scale and fractional translation. 5939ef7fb885d7be648b9f0ecd027bc400d1213cecbsalomon */ 6039ef7fb885d7be648b9f0ecd027bc400d1213cecbsalomon bool fAllowPathMaskCaching = false; 6139ef7fb885d7be648b9f0ecd027bc400d1213cecbsalomon 6239ef7fb885d7be648b9f0ecd027bc400d1213cecbsalomon /** 6320471894eaa441193d5ae8f2395e8244c91c55afbrianosman * If true, sRGB support will not be enabled unless sRGB decoding can be disabled (via an 6420471894eaa441193d5ae8f2395e8244c91c55afbrianosman * extension). If mixed use of "legacy" mode and sRGB/color-correct mode is not required, this 6520471894eaa441193d5ae8f2395e8244c91c55afbrianosman * can be set to false, which will significantly expand the number of devices that qualify for 6620471894eaa441193d5ae8f2395e8244c91c55afbrianosman * sRGB support. 6720471894eaa441193d5ae8f2395e8244c91c55afbrianosman */ 6820471894eaa441193d5ae8f2395e8244c91c55afbrianosman bool fRequireDecodeDisableForSRGB = true; 6946da1cc9f20c277f7789355038d426931195aa65Brian Osman 7046da1cc9f20c277f7789355038d426931195aa65Brian Osman /** 7146da1cc9f20c277f7789355038d426931195aa65Brian Osman * If true, the GPU will not be used to perform YUV -> RGB conversion when generating 7246da1cc9f20c277f7789355038d426931195aa65Brian Osman * textures from codec-backed images. 7346da1cc9f20c277f7789355038d426931195aa65Brian Osman */ 7446da1cc9f20c277f7789355038d426931195aa65Brian Osman bool fDisableGpuYUVConversion = false; 75008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton 76008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton /** 77008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton * If true, the caps will never report driver support for path rendering. 78008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton */ 79008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton bool fSuppressPathRendering = false; 80008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton 81008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton /** 82fbdc080d3cae3695544ffbc05c6ff6f5b4514c02Jim Van Verth * Render everything in wireframe 83fbdc080d3cae3695544ffbc05c6ff6f5b4514c02Jim Van Verth */ 84fbdc080d3cae3695544ffbc05c6ff6f5b4514c02Jim Van Verth bool fWireframeMode = false; 85fbdc080d3cae3695544ffbc05c6ff6f5b4514c02Jim Van Verth 86fbdc080d3cae3695544ffbc05c6ff6f5b4514c02Jim Van Verth /** 87008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton * Allows the client to include or exclude specific GPU path renderers. 88008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton */ 89008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton enum class GpuPathRenderers { 90008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton kNone = 0, // Always use sofware masks. 91008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton kDashLine = 1 << 0, 92008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton kStencilAndCover = 1 << 1, 93008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton kMSAA = 1 << 2, 94008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton kAAHairline = 1 << 3, 95008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton kAAConvex = 1 << 4, 96008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton kAALinearizing = 1 << 5, 97830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth kSmall = 1 << 6, 9842c456fd20bd45dd02f6d5eb0af7acf04341b1eeBrian Salomon kTessellating = 1 << 7, 9942c456fd20bd45dd02f6d5eb0af7acf04341b1eeBrian Salomon kDefault = 1 << 8, 100008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton 101830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth kAll = kDefault | (kDefault - 1), 102830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth 103830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth // For legacy. To be removed when updated in Android. 104830104632fd79eb5ac5bf8755a1c0271d13acb22Jim Van Verth kDistanceField = kSmall 105008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton }; 106008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton 107008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll; 1086d342285a4546b54cb17570aae7eeb8a123c81aeEric Karl 1096d342285a4546b54cb17570aae7eeb8a123c81aeEric Karl /** 1106d342285a4546b54cb17570aae7eeb8a123c81aeEric Karl * The maximum size of cache textures used for Skia's Glyph cache. 1116d342285a4546b54cb17570aae7eeb8a123c81aeEric Karl */ 1126d342285a4546b54cb17570aae7eeb8a123c81aeEric Karl float fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4; 113682c269a1511200322916af83053e26004c0ec40bsalomon}; 114682c269a1511200322916af83053e26004c0ec40bsalomon 115008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdaltonGR_MAKE_BITFIELD_CLASS_OPS(GrContextOptions::GpuPathRenderers) 116008b9d80ab9adbf2656eceaf54d11cd15e4dda05csmartdalton 117682c269a1511200322916af83053e26004c0ec40bsalomon#endif 118