1*c8dee2aaSAndroid Build Coastguard Worker /* 2*c8dee2aaSAndroid Build Coastguard Worker * Copyright 2020 Google Inc. 3*c8dee2aaSAndroid Build Coastguard Worker * 4*c8dee2aaSAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license that can be 5*c8dee2aaSAndroid Build Coastguard Worker * found in the LICENSE file. 6*c8dee2aaSAndroid Build Coastguard Worker */ 7*c8dee2aaSAndroid Build Coastguard Worker 8*c8dee2aaSAndroid Build Coastguard Worker #ifndef GrDirectContext_DEFINED 9*c8dee2aaSAndroid Build Coastguard Worker #define GrDirectContext_DEFINED 10*c8dee2aaSAndroid Build Coastguard Worker 11*c8dee2aaSAndroid Build Coastguard Worker #include "include/core/SkColor.h" 12*c8dee2aaSAndroid Build Coastguard Worker #include "include/core/SkRefCnt.h" 13*c8dee2aaSAndroid Build Coastguard Worker #include "include/core/SkTypes.h" 14*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/GpuTypes.h" 15*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/ganesh/GrContextOptions.h" 16*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/ganesh/GrRecordingContext.h" 17*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/ganesh/GrTypes.h" 18*c8dee2aaSAndroid Build Coastguard Worker 19*c8dee2aaSAndroid Build Coastguard Worker #include <chrono> 20*c8dee2aaSAndroid Build Coastguard Worker #include <cstddef> 21*c8dee2aaSAndroid Build Coastguard Worker #include <cstdint> 22*c8dee2aaSAndroid Build Coastguard Worker #include <memory> 23*c8dee2aaSAndroid Build Coastguard Worker #include <string_view> 24*c8dee2aaSAndroid Build Coastguard Worker 25*c8dee2aaSAndroid Build Coastguard Worker class GrAtlasManager; 26*c8dee2aaSAndroid Build Coastguard Worker class GrBackendSemaphore; 27*c8dee2aaSAndroid Build Coastguard Worker class GrBackendFormat; 28*c8dee2aaSAndroid Build Coastguard Worker class GrBackendTexture; 29*c8dee2aaSAndroid Build Coastguard Worker class GrBackendRenderTarget; 30*c8dee2aaSAndroid Build Coastguard Worker class GrClientMappedBufferManager; 31*c8dee2aaSAndroid Build Coastguard Worker class GrContextThreadSafeProxy; 32*c8dee2aaSAndroid Build Coastguard Worker class GrDirectContextPriv; 33*c8dee2aaSAndroid Build Coastguard Worker class GrGpu; 34*c8dee2aaSAndroid Build Coastguard Worker class GrResourceCache; 35*c8dee2aaSAndroid Build Coastguard Worker class GrResourceProvider; 36*c8dee2aaSAndroid Build Coastguard Worker class SkData; 37*c8dee2aaSAndroid Build Coastguard Worker class SkImage; 38*c8dee2aaSAndroid Build Coastguard Worker class SkPixmap; 39*c8dee2aaSAndroid Build Coastguard Worker class SkSurface; 40*c8dee2aaSAndroid Build Coastguard Worker class SkTaskGroup; 41*c8dee2aaSAndroid Build Coastguard Worker class SkTraceMemoryDump; 42*c8dee2aaSAndroid Build Coastguard Worker enum SkColorType : int; 43*c8dee2aaSAndroid Build Coastguard Worker enum class SkTextureCompressionType; 44*c8dee2aaSAndroid Build Coastguard Worker struct GrMockOptions; 45*c8dee2aaSAndroid Build Coastguard Worker struct GrD3DBackendContext; // IWYU pragma: keep 46*c8dee2aaSAndroid Build Coastguard Worker 47*c8dee2aaSAndroid Build Coastguard Worker namespace skgpu { 48*c8dee2aaSAndroid Build Coastguard Worker class MutableTextureState; 49*c8dee2aaSAndroid Build Coastguard Worker #if !defined(SK_ENABLE_OPTIMIZE_SIZE) 50*c8dee2aaSAndroid Build Coastguard Worker namespace ganesh { class SmallPathAtlasMgr; } 51*c8dee2aaSAndroid Build Coastguard Worker #endif 52*c8dee2aaSAndroid Build Coastguard Worker } 53*c8dee2aaSAndroid Build Coastguard Worker namespace sktext { namespace gpu { class StrikeCache; } } 54*c8dee2aaSAndroid Build Coastguard Worker namespace wgpu { class Device; } // IWYU pragma: keep 55*c8dee2aaSAndroid Build Coastguard Worker 56*c8dee2aaSAndroid Build Coastguard Worker namespace SkSurfaces { 57*c8dee2aaSAndroid Build Coastguard Worker enum class BackendSurfaceAccess; 58*c8dee2aaSAndroid Build Coastguard Worker } 59*c8dee2aaSAndroid Build Coastguard Worker 60*c8dee2aaSAndroid Build Coastguard Worker class SK_API GrDirectContext : public GrRecordingContext { 61*c8dee2aaSAndroid Build Coastguard Worker public: 62*c8dee2aaSAndroid Build Coastguard Worker #ifdef SK_DIRECT3D 63*c8dee2aaSAndroid Build Coastguard Worker /** 64*c8dee2aaSAndroid Build Coastguard Worker * Makes a GrDirectContext which uses Direct3D as the backend. The Direct3D context 65*c8dee2aaSAndroid Build Coastguard Worker * must be kept alive until the returned GrDirectContext is first destroyed or abandoned. 66*c8dee2aaSAndroid Build Coastguard Worker */ 67*c8dee2aaSAndroid Build Coastguard Worker static sk_sp<GrDirectContext> MakeDirect3D(const GrD3DBackendContext&, const GrContextOptions&); 68*c8dee2aaSAndroid Build Coastguard Worker static sk_sp<GrDirectContext> MakeDirect3D(const GrD3DBackendContext&); 69*c8dee2aaSAndroid Build Coastguard Worker #endif 70*c8dee2aaSAndroid Build Coastguard Worker 71*c8dee2aaSAndroid Build Coastguard Worker static sk_sp<GrDirectContext> MakeMock(const GrMockOptions*, const GrContextOptions&); 72*c8dee2aaSAndroid Build Coastguard Worker static sk_sp<GrDirectContext> MakeMock(const GrMockOptions*); 73*c8dee2aaSAndroid Build Coastguard Worker 74*c8dee2aaSAndroid Build Coastguard Worker ~GrDirectContext() override; 75*c8dee2aaSAndroid Build Coastguard Worker 76*c8dee2aaSAndroid Build Coastguard Worker /** 77*c8dee2aaSAndroid Build Coastguard Worker * The context normally assumes that no outsider is setting state 78*c8dee2aaSAndroid Build Coastguard Worker * within the underlying 3D API's context/device/whatever. This call informs 79*c8dee2aaSAndroid Build Coastguard Worker * the context that the state was modified and it should resend. Shouldn't 80*c8dee2aaSAndroid Build Coastguard Worker * be called frequently for good performance. 81*c8dee2aaSAndroid Build Coastguard Worker * The flag bits, state, is dependent on which backend is used by the 82*c8dee2aaSAndroid Build Coastguard Worker * context, either GL or D3D (possible in future). 83*c8dee2aaSAndroid Build Coastguard Worker */ 84*c8dee2aaSAndroid Build Coastguard Worker void resetContext(uint32_t state = kAll_GrBackendState); 85*c8dee2aaSAndroid Build Coastguard Worker 86*c8dee2aaSAndroid Build Coastguard Worker /** 87*c8dee2aaSAndroid Build Coastguard Worker * If the backend is GrBackendApi::kOpenGL, then all texture unit/target combinations for which 88*c8dee2aaSAndroid Build Coastguard Worker * the context has modified the bound texture will have texture id 0 bound. This does not 89*c8dee2aaSAndroid Build Coastguard Worker * flush the context. Calling resetContext() does not change the set that will be bound 90*c8dee2aaSAndroid Build Coastguard Worker * to texture id 0 on the next call to resetGLTextureBindings(). After this is called 91*c8dee2aaSAndroid Build Coastguard Worker * all unit/target combinations are considered to have unmodified bindings until the context 92*c8dee2aaSAndroid Build Coastguard Worker * subsequently modifies them (meaning if this is called twice in a row with no intervening 93*c8dee2aaSAndroid Build Coastguard Worker * context usage then the second call is a no-op.) 94*c8dee2aaSAndroid Build Coastguard Worker */ 95*c8dee2aaSAndroid Build Coastguard Worker void resetGLTextureBindings(); 96*c8dee2aaSAndroid Build Coastguard Worker 97*c8dee2aaSAndroid Build Coastguard Worker /** 98*c8dee2aaSAndroid Build Coastguard Worker * Abandons all GPU resources and assumes the underlying backend 3D API context is no longer 99*c8dee2aaSAndroid Build Coastguard Worker * usable. Call this if you have lost the associated GPU context, and thus internal texture, 100*c8dee2aaSAndroid Build Coastguard Worker * buffer, etc. references/IDs are now invalid. Calling this ensures that the destructors of the 101*c8dee2aaSAndroid Build Coastguard Worker * context and any of its created resource objects will not make backend 3D API calls. Content 102*c8dee2aaSAndroid Build Coastguard Worker * rendered but not previously flushed may be lost. After this function is called all subsequent 103*c8dee2aaSAndroid Build Coastguard Worker * calls on the context will fail or be no-ops. 104*c8dee2aaSAndroid Build Coastguard Worker * 105*c8dee2aaSAndroid Build Coastguard Worker * The typical use case for this function is that the underlying 3D context was lost and further 106*c8dee2aaSAndroid Build Coastguard Worker * API calls may crash. 107*c8dee2aaSAndroid Build Coastguard Worker * 108*c8dee2aaSAndroid Build Coastguard Worker * This call is not valid to be made inside ReleaseProcs passed into SkSurface or SkImages. The 109*c8dee2aaSAndroid Build Coastguard Worker * call will simply fail (and assert in debug) if it is called while inside a ReleaseProc. 110*c8dee2aaSAndroid Build Coastguard Worker * 111*c8dee2aaSAndroid Build Coastguard Worker * For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or VkInstance used to 112*c8dee2aaSAndroid Build Coastguard Worker * create the context must be kept alive even after abandoning the context. Those objects must 113*c8dee2aaSAndroid Build Coastguard Worker * live for the lifetime of the context object itself. The reason for this is so that 114*c8dee2aaSAndroid Build Coastguard Worker * we can continue to delete any outstanding GrBackendTextures/RenderTargets which must be 115*c8dee2aaSAndroid Build Coastguard Worker * cleaned up even in a device lost state. 116*c8dee2aaSAndroid Build Coastguard Worker */ 117*c8dee2aaSAndroid Build Coastguard Worker void abandonContext() override; 118*c8dee2aaSAndroid Build Coastguard Worker 119*c8dee2aaSAndroid Build Coastguard Worker /** 120*c8dee2aaSAndroid Build Coastguard Worker * Returns true if the context was abandoned or if the backend specific context has gotten into 121*c8dee2aaSAndroid Build Coastguard Worker * an unrecoverarble, lost state (e.g. in Vulkan backend if we've gotten a 122*c8dee2aaSAndroid Build Coastguard Worker * VK_ERROR_DEVICE_LOST). If the backend context is lost, this call will also abandon this 123*c8dee2aaSAndroid Build Coastguard Worker * context. 124*c8dee2aaSAndroid Build Coastguard Worker */ 125*c8dee2aaSAndroid Build Coastguard Worker bool abandoned() override; 126*c8dee2aaSAndroid Build Coastguard Worker 127*c8dee2aaSAndroid Build Coastguard Worker /** 128*c8dee2aaSAndroid Build Coastguard Worker * Returns true if the backend specific context has gotten into an unrecoverarble, lost state 129*c8dee2aaSAndroid Build Coastguard Worker * (e.g. in Vulkan backend if we've gotten a VK_ERROR_DEVICE_LOST). If the backend context is 130*c8dee2aaSAndroid Build Coastguard Worker * lost, this call will also abandon this context. 131*c8dee2aaSAndroid Build Coastguard Worker */ 132*c8dee2aaSAndroid Build Coastguard Worker bool isDeviceLost(); 133*c8dee2aaSAndroid Build Coastguard Worker 134*c8dee2aaSAndroid Build Coastguard Worker // TODO: Remove this from public after migrating Chrome. 135*c8dee2aaSAndroid Build Coastguard Worker sk_sp<GrContextThreadSafeProxy> threadSafeProxy(); 136*c8dee2aaSAndroid Build Coastguard Worker 137*c8dee2aaSAndroid Build Coastguard Worker /** 138*c8dee2aaSAndroid Build Coastguard Worker * Checks if the underlying 3D API reported an out-of-memory error. If this returns true it is 139*c8dee2aaSAndroid Build Coastguard Worker * reset and will return false until another out-of-memory error is reported by the 3D API. If 140*c8dee2aaSAndroid Build Coastguard Worker * the context is abandoned then this will report false. 141*c8dee2aaSAndroid Build Coastguard Worker * 142*c8dee2aaSAndroid Build Coastguard Worker * Currently this is implemented for: 143*c8dee2aaSAndroid Build Coastguard Worker * 144*c8dee2aaSAndroid Build Coastguard Worker * OpenGL [ES] - Note that client calls to glGetError() may swallow GL_OUT_OF_MEMORY errors and 145*c8dee2aaSAndroid Build Coastguard Worker * therefore hide the error from Skia. Also, it is not advised to use this in combination with 146*c8dee2aaSAndroid Build Coastguard Worker * enabling GrContextOptions::fSkipGLErrorChecks. That option may prevent the context from ever 147*c8dee2aaSAndroid Build Coastguard Worker * checking the GL context for OOM. 148*c8dee2aaSAndroid Build Coastguard Worker * 149*c8dee2aaSAndroid Build Coastguard Worker * Vulkan - Reports true if VK_ERROR_OUT_OF_HOST_MEMORY or VK_ERROR_OUT_OF_DEVICE_MEMORY has 150*c8dee2aaSAndroid Build Coastguard Worker * occurred. 151*c8dee2aaSAndroid Build Coastguard Worker */ 152*c8dee2aaSAndroid Build Coastguard Worker bool oomed(); 153*c8dee2aaSAndroid Build Coastguard Worker 154*c8dee2aaSAndroid Build Coastguard Worker /** 155*c8dee2aaSAndroid Build Coastguard Worker * This is similar to abandonContext() however the underlying 3D context is not yet lost and 156*c8dee2aaSAndroid Build Coastguard Worker * the context will cleanup all allocated resources before returning. After returning it will 157*c8dee2aaSAndroid Build Coastguard Worker * assume that the underlying context may no longer be valid. 158*c8dee2aaSAndroid Build Coastguard Worker * 159*c8dee2aaSAndroid Build Coastguard Worker * The typical use case for this function is that the client is going to destroy the 3D context 160*c8dee2aaSAndroid Build Coastguard Worker * but can't guarantee that context will be destroyed first (perhaps because it may be ref'ed 161*c8dee2aaSAndroid Build Coastguard Worker * elsewhere by either the client or Skia objects). 162*c8dee2aaSAndroid Build Coastguard Worker * 163*c8dee2aaSAndroid Build Coastguard Worker * For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or VkInstance used to 164*c8dee2aaSAndroid Build Coastguard Worker * create the context must be alive before calling releaseResourcesAndAbandonContext. 165*c8dee2aaSAndroid Build Coastguard Worker */ 166*c8dee2aaSAndroid Build Coastguard Worker void releaseResourcesAndAbandonContext(); 167*c8dee2aaSAndroid Build Coastguard Worker 168*c8dee2aaSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////////////// 169*c8dee2aaSAndroid Build Coastguard Worker // Resource Cache 170*c8dee2aaSAndroid Build Coastguard Worker 171*c8dee2aaSAndroid Build Coastguard Worker /** DEPRECATED 172*c8dee2aaSAndroid Build Coastguard Worker * Return the current GPU resource cache limits. 173*c8dee2aaSAndroid Build Coastguard Worker * 174*c8dee2aaSAndroid Build Coastguard Worker * @param maxResources If non-null, will be set to -1. 175*c8dee2aaSAndroid Build Coastguard Worker * @param maxResourceBytes If non-null, returns maximum number of bytes of 176*c8dee2aaSAndroid Build Coastguard Worker * video memory that can be held in the cache. 177*c8dee2aaSAndroid Build Coastguard Worker */ 178*c8dee2aaSAndroid Build Coastguard Worker void getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const; 179*c8dee2aaSAndroid Build Coastguard Worker 180*c8dee2aaSAndroid Build Coastguard Worker /** 181*c8dee2aaSAndroid Build Coastguard Worker * Return the current GPU resource cache limit in bytes. 182*c8dee2aaSAndroid Build Coastguard Worker */ 183*c8dee2aaSAndroid Build Coastguard Worker size_t getResourceCacheLimit() const; 184*c8dee2aaSAndroid Build Coastguard Worker 185*c8dee2aaSAndroid Build Coastguard Worker /** 186*c8dee2aaSAndroid Build Coastguard Worker * Gets the current GPU resource cache usage. 187*c8dee2aaSAndroid Build Coastguard Worker * 188*c8dee2aaSAndroid Build Coastguard Worker * @param resourceCount If non-null, returns the number of resources that are held in the 189*c8dee2aaSAndroid Build Coastguard Worker * cache. 190*c8dee2aaSAndroid Build Coastguard Worker * @param maxResourceBytes If non-null, returns the total number of bytes of video memory held 191*c8dee2aaSAndroid Build Coastguard Worker * in the cache. 192*c8dee2aaSAndroid Build Coastguard Worker */ 193*c8dee2aaSAndroid Build Coastguard Worker void getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const; 194*c8dee2aaSAndroid Build Coastguard Worker 195*c8dee2aaSAndroid Build Coastguard Worker /** 196*c8dee2aaSAndroid Build Coastguard Worker * Gets the number of bytes in the cache consumed by purgeable (e.g. unlocked) resources. 197*c8dee2aaSAndroid Build Coastguard Worker */ 198*c8dee2aaSAndroid Build Coastguard Worker size_t getResourceCachePurgeableBytes() const; 199*c8dee2aaSAndroid Build Coastguard Worker 200*c8dee2aaSAndroid Build Coastguard Worker /** DEPRECATED 201*c8dee2aaSAndroid Build Coastguard Worker * Specify the GPU resource cache limits. If the current cache exceeds the maxResourceBytes 202*c8dee2aaSAndroid Build Coastguard Worker * limit, it will be purged (LRU) to keep the cache within the limit. 203*c8dee2aaSAndroid Build Coastguard Worker * 204*c8dee2aaSAndroid Build Coastguard Worker * @param maxResources Unused. 205*c8dee2aaSAndroid Build Coastguard Worker * @param maxResourceBytes The maximum number of bytes of video memory 206*c8dee2aaSAndroid Build Coastguard Worker * that can be held in the cache. 207*c8dee2aaSAndroid Build Coastguard Worker */ 208*c8dee2aaSAndroid Build Coastguard Worker void setResourceCacheLimits(int maxResources, size_t maxResourceBytes); 209*c8dee2aaSAndroid Build Coastguard Worker 210*c8dee2aaSAndroid Build Coastguard Worker /** 211*c8dee2aaSAndroid Build Coastguard Worker * Specify the GPU resource cache limit. If the cache currently exceeds this limit, 212*c8dee2aaSAndroid Build Coastguard Worker * it will be purged (LRU) to keep the cache within the limit. 213*c8dee2aaSAndroid Build Coastguard Worker * 214*c8dee2aaSAndroid Build Coastguard Worker * @param maxResourceBytes The maximum number of bytes of video memory 215*c8dee2aaSAndroid Build Coastguard Worker * that can be held in the cache. 216*c8dee2aaSAndroid Build Coastguard Worker */ 217*c8dee2aaSAndroid Build Coastguard Worker void setResourceCacheLimit(size_t maxResourceBytes); 218*c8dee2aaSAndroid Build Coastguard Worker 219*c8dee2aaSAndroid Build Coastguard Worker /** 220*c8dee2aaSAndroid Build Coastguard Worker * Frees GPU created by the context. Can be called to reduce GPU memory 221*c8dee2aaSAndroid Build Coastguard Worker * pressure. 222*c8dee2aaSAndroid Build Coastguard Worker */ 223*c8dee2aaSAndroid Build Coastguard Worker void freeGpuResources(); 224*c8dee2aaSAndroid Build Coastguard Worker 225*c8dee2aaSAndroid Build Coastguard Worker /** 226*c8dee2aaSAndroid Build Coastguard Worker * Purge GPU resources that haven't been used in the past 'msNotUsed' milliseconds or are 227*c8dee2aaSAndroid Build Coastguard Worker * otherwise marked for deletion, regardless of whether the context is under budget. 228*c8dee2aaSAndroid Build Coastguard Worker 229*c8dee2aaSAndroid Build Coastguard Worker * 230*c8dee2aaSAndroid Build Coastguard Worker * @param msNotUsed Only unlocked resources not used in these last milliseconds will be 231*c8dee2aaSAndroid Build Coastguard Worker * cleaned up. 232*c8dee2aaSAndroid Build Coastguard Worker * @param opts Specify which resources should be cleaned up. If kScratchResourcesOnly 233*c8dee2aaSAndroid Build Coastguard Worker * then, all unlocked scratch resources older than 'msNotUsed' will be purged 234*c8dee2aaSAndroid Build Coastguard Worker * but the unlocked resources with persistent data will remain. If 235*c8dee2aaSAndroid Build Coastguard Worker * kAllResources 236*c8dee2aaSAndroid Build Coastguard Worker */ 237*c8dee2aaSAndroid Build Coastguard Worker 238*c8dee2aaSAndroid Build Coastguard Worker void performDeferredCleanup( 239*c8dee2aaSAndroid Build Coastguard Worker std::chrono::milliseconds msNotUsed, 240*c8dee2aaSAndroid Build Coastguard Worker GrPurgeResourceOptions opts = GrPurgeResourceOptions::kAllResources); 241*c8dee2aaSAndroid Build Coastguard Worker 242*c8dee2aaSAndroid Build Coastguard Worker // Temporary compatibility API for Android. purgeResourcesNotUsedInMs(std::chrono::milliseconds msNotUsed)243*c8dee2aaSAndroid Build Coastguard Worker void purgeResourcesNotUsedInMs(std::chrono::milliseconds msNotUsed) { 244*c8dee2aaSAndroid Build Coastguard Worker this->performDeferredCleanup(msNotUsed); 245*c8dee2aaSAndroid Build Coastguard Worker } 246*c8dee2aaSAndroid Build Coastguard Worker 247*c8dee2aaSAndroid Build Coastguard Worker /** 248*c8dee2aaSAndroid Build Coastguard Worker * Purge unlocked resources from the cache until the the provided byte count has been reached 249*c8dee2aaSAndroid Build Coastguard Worker * or we have purged all unlocked resources. The default policy is to purge in LRU order, but 250*c8dee2aaSAndroid Build Coastguard Worker * can be overridden to prefer purging scratch resources (in LRU order) prior to purging other 251*c8dee2aaSAndroid Build Coastguard Worker * resource types. 252*c8dee2aaSAndroid Build Coastguard Worker * 253*c8dee2aaSAndroid Build Coastguard Worker * @param maxBytesToPurge the desired number of bytes to be purged. 254*c8dee2aaSAndroid Build Coastguard Worker * @param preferScratchResources If true scratch resources will be purged prior to other 255*c8dee2aaSAndroid Build Coastguard Worker * resource types. 256*c8dee2aaSAndroid Build Coastguard Worker */ 257*c8dee2aaSAndroid Build Coastguard Worker void purgeUnlockedResources(size_t bytesToPurge, bool preferScratchResources); 258*c8dee2aaSAndroid Build Coastguard Worker 259*c8dee2aaSAndroid Build Coastguard Worker /** 260*c8dee2aaSAndroid Build Coastguard Worker * This entry point is intended for instances where an app has been backgrounded or 261*c8dee2aaSAndroid Build Coastguard Worker * suspended. 262*c8dee2aaSAndroid Build Coastguard Worker * If 'scratchResourcesOnly' is true all unlocked scratch resources will be purged but the 263*c8dee2aaSAndroid Build Coastguard Worker * unlocked resources with persistent data will remain. If 'scratchResourcesOnly' is false 264*c8dee2aaSAndroid Build Coastguard Worker * then all unlocked resources will be purged. 265*c8dee2aaSAndroid Build Coastguard Worker * In either case, after the unlocked resources are purged a separate pass will be made to 266*c8dee2aaSAndroid Build Coastguard Worker * ensure that resource usage is under budget (i.e., even if 'scratchResourcesOnly' is true 267*c8dee2aaSAndroid Build Coastguard Worker * some resources with persistent data may be purged to be under budget). 268*c8dee2aaSAndroid Build Coastguard Worker * 269*c8dee2aaSAndroid Build Coastguard Worker * @param opts If kScratchResourcesOnly only unlocked scratch resources will be purged prior 270*c8dee2aaSAndroid Build Coastguard Worker * enforcing the budget requirements. 271*c8dee2aaSAndroid Build Coastguard Worker */ 272*c8dee2aaSAndroid Build Coastguard Worker void purgeUnlockedResources(GrPurgeResourceOptions opts); 273*c8dee2aaSAndroid Build Coastguard Worker 274*c8dee2aaSAndroid Build Coastguard Worker /* 275*c8dee2aaSAndroid Build Coastguard Worker * Gets the types of GPU stats supported by this Context. 276*c8dee2aaSAndroid Build Coastguard Worker */ 277*c8dee2aaSAndroid Build Coastguard Worker skgpu::GpuStatsFlags supportedGpuStats() const; 278*c8dee2aaSAndroid Build Coastguard Worker 279*c8dee2aaSAndroid Build Coastguard Worker /** 280*c8dee2aaSAndroid Build Coastguard Worker * Gets the maximum supported texture size. 281*c8dee2aaSAndroid Build Coastguard Worker */ 282*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::maxTextureSize; 283*c8dee2aaSAndroid Build Coastguard Worker 284*c8dee2aaSAndroid Build Coastguard Worker /** 285*c8dee2aaSAndroid Build Coastguard Worker * Gets the maximum supported render target size. 286*c8dee2aaSAndroid Build Coastguard Worker */ 287*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::maxRenderTargetSize; 288*c8dee2aaSAndroid Build Coastguard Worker 289*c8dee2aaSAndroid Build Coastguard Worker /** 290*c8dee2aaSAndroid Build Coastguard Worker * Can a SkImage be created with the given color type. 291*c8dee2aaSAndroid Build Coastguard Worker */ 292*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::colorTypeSupportedAsImage; 293*c8dee2aaSAndroid Build Coastguard Worker 294*c8dee2aaSAndroid Build Coastguard Worker /** 295*c8dee2aaSAndroid Build Coastguard Worker * Does this context support protected content? 296*c8dee2aaSAndroid Build Coastguard Worker */ 297*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::supportsProtectedContent; 298*c8dee2aaSAndroid Build Coastguard Worker 299*c8dee2aaSAndroid Build Coastguard Worker /** 300*c8dee2aaSAndroid Build Coastguard Worker * Can a SkSurface be created with the given color type. To check whether MSAA is supported 301*c8dee2aaSAndroid Build Coastguard Worker * use maxSurfaceSampleCountForColorType(). 302*c8dee2aaSAndroid Build Coastguard Worker */ 303*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::colorTypeSupportedAsSurface; 304*c8dee2aaSAndroid Build Coastguard Worker 305*c8dee2aaSAndroid Build Coastguard Worker /** 306*c8dee2aaSAndroid Build Coastguard Worker * Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA 307*c8dee2aaSAndroid Build Coastguard Worker * rendering is supported for the color type. 0 is returned if rendering to this color type 308*c8dee2aaSAndroid Build Coastguard Worker * is not supported at all. 309*c8dee2aaSAndroid Build Coastguard Worker */ 310*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::maxSurfaceSampleCountForColorType; 311*c8dee2aaSAndroid Build Coastguard Worker 312*c8dee2aaSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////////////// 313*c8dee2aaSAndroid Build Coastguard Worker // Misc. 314*c8dee2aaSAndroid Build Coastguard Worker 315*c8dee2aaSAndroid Build Coastguard Worker /** 316*c8dee2aaSAndroid Build Coastguard Worker * Inserts a list of GPU semaphores that the current GPU-backed API must wait on before 317*c8dee2aaSAndroid Build Coastguard Worker * executing any more commands on the GPU. We only guarantee blocking transfer and fragment 318*c8dee2aaSAndroid Build Coastguard Worker * shader work, but may block earlier stages as well depending on the backend.If this call 319*c8dee2aaSAndroid Build Coastguard Worker * returns false, then the GPU back-end will not wait on any passed in semaphores, and the 320*c8dee2aaSAndroid Build Coastguard Worker * client will still own the semaphores, regardless of the value of deleteSemaphoresAfterWait. 321*c8dee2aaSAndroid Build Coastguard Worker * 322*c8dee2aaSAndroid Build Coastguard Worker * If deleteSemaphoresAfterWait is false then Skia will not delete the semaphores. In this case 323*c8dee2aaSAndroid Build Coastguard Worker * it is the client's responsibility to not destroy or attempt to reuse the semaphores until it 324*c8dee2aaSAndroid Build Coastguard Worker * knows that Skia has finished waiting on them. This can be done by using finishedProcs on 325*c8dee2aaSAndroid Build Coastguard Worker * flush calls. 326*c8dee2aaSAndroid Build Coastguard Worker * 327*c8dee2aaSAndroid Build Coastguard Worker * This is not supported on the GL backend. 328*c8dee2aaSAndroid Build Coastguard Worker */ 329*c8dee2aaSAndroid Build Coastguard Worker bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores, 330*c8dee2aaSAndroid Build Coastguard Worker bool deleteSemaphoresAfterWait = true); 331*c8dee2aaSAndroid Build Coastguard Worker 332*c8dee2aaSAndroid Build Coastguard Worker /** 333*c8dee2aaSAndroid Build Coastguard Worker * Call to ensure all drawing to the context has been flushed and submitted to the underlying 3D 334*c8dee2aaSAndroid Build Coastguard Worker * API. This is equivalent to calling GrContext::flush with a default GrFlushInfo followed by 335*c8dee2aaSAndroid Build Coastguard Worker * GrContext::submit(sync). 336*c8dee2aaSAndroid Build Coastguard Worker */ 337*c8dee2aaSAndroid Build Coastguard Worker void flushAndSubmit(GrSyncCpu sync = GrSyncCpu::kNo) { 338*c8dee2aaSAndroid Build Coastguard Worker this->flush(GrFlushInfo()); 339*c8dee2aaSAndroid Build Coastguard Worker this->submit(sync); 340*c8dee2aaSAndroid Build Coastguard Worker } 341*c8dee2aaSAndroid Build Coastguard Worker 342*c8dee2aaSAndroid Build Coastguard Worker /** 343*c8dee2aaSAndroid Build Coastguard Worker * Call to ensure all drawing to the context has been flushed to underlying 3D API specific 344*c8dee2aaSAndroid Build Coastguard Worker * objects. A call to `submit` is always required to ensure work is actually sent to 345*c8dee2aaSAndroid Build Coastguard Worker * the gpu. Some specific API details: 346*c8dee2aaSAndroid Build Coastguard Worker * GL: Commands are actually sent to the driver, but glFlush is never called. Thus some 347*c8dee2aaSAndroid Build Coastguard Worker * sync objects from the flush will not be valid until a submission occurs. 348*c8dee2aaSAndroid Build Coastguard Worker * 349*c8dee2aaSAndroid Build Coastguard Worker * Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command 350*c8dee2aaSAndroid Build Coastguard Worker * buffer or encoder objects. However, these objects are not sent to the gpu until a 351*c8dee2aaSAndroid Build Coastguard Worker * submission occurs. 352*c8dee2aaSAndroid Build Coastguard Worker * 353*c8dee2aaSAndroid Build Coastguard Worker * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be 354*c8dee2aaSAndroid Build Coastguard Worker * submitted to the gpu during the next submit call (it is possible Skia failed to create a 355*c8dee2aaSAndroid Build Coastguard Worker * subset of the semaphores). The client should not wait on these semaphores until after submit 356*c8dee2aaSAndroid Build Coastguard Worker * has been called, and must keep them alive until then. If this call returns 357*c8dee2aaSAndroid Build Coastguard Worker * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on 358*c8dee2aaSAndroid Build Coastguard Worker * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in with 359*c8dee2aaSAndroid Build Coastguard Worker * the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the 360*c8dee2aaSAndroid Build Coastguard Worker * client is still responsible for deleting any initialized semaphores. 361*c8dee2aaSAndroid Build Coastguard Worker * Regardless of semaphore submission the context will still be flushed. It should be 362*c8dee2aaSAndroid Build Coastguard Worker * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not 363*c8dee2aaSAndroid Build Coastguard Worker * happen. It simply means there were no semaphores submitted to the GPU. A caller should only 364*c8dee2aaSAndroid Build Coastguard Worker * take this as a failure if they passed in semaphores to be submitted. 365*c8dee2aaSAndroid Build Coastguard Worker */ 366*c8dee2aaSAndroid Build Coastguard Worker GrSemaphoresSubmitted flush(const GrFlushInfo& info); 367*c8dee2aaSAndroid Build Coastguard Worker flush()368*c8dee2aaSAndroid Build Coastguard Worker void flush() { this->flush(GrFlushInfo()); } 369*c8dee2aaSAndroid Build Coastguard Worker 370*c8dee2aaSAndroid Build Coastguard Worker /** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not 371*c8dee2aaSAndroid Build Coastguard Worker * texture-backed (including promise texture images) or if the GrDirectContext does not 372*c8dee2aaSAndroid Build Coastguard Worker * have the same context ID as the context backing the image then this is a no-op. 373*c8dee2aaSAndroid Build Coastguard Worker * If the image was not used in any non-culled draws in the current queue of work for the 374*c8dee2aaSAndroid Build Coastguard Worker * passed GrDirectContext then this is a no-op unless the GrFlushInfo contains semaphores or 375*c8dee2aaSAndroid Build Coastguard Worker * a finish proc. Those are respected even when the image has not been used. 376*c8dee2aaSAndroid Build Coastguard Worker * @param image the non-null image to flush. 377*c8dee2aaSAndroid Build Coastguard Worker * @param info flush options 378*c8dee2aaSAndroid Build Coastguard Worker */ 379*c8dee2aaSAndroid Build Coastguard Worker GrSemaphoresSubmitted flush(const sk_sp<const SkImage>& image, const GrFlushInfo& info); 380*c8dee2aaSAndroid Build Coastguard Worker void flush(const sk_sp<const SkImage>& image); 381*c8dee2aaSAndroid Build Coastguard Worker 382*c8dee2aaSAndroid Build Coastguard Worker /** Version of flush() that uses a default GrFlushInfo. Also submits the flushed work to the 383*c8dee2aaSAndroid Build Coastguard Worker * GPU. 384*c8dee2aaSAndroid Build Coastguard Worker */ 385*c8dee2aaSAndroid Build Coastguard Worker void flushAndSubmit(const sk_sp<const SkImage>& image); 386*c8dee2aaSAndroid Build Coastguard Worker 387*c8dee2aaSAndroid Build Coastguard Worker /** Issues pending SkSurface commands to the GPU-backed API objects and resolves any SkSurface 388*c8dee2aaSAndroid Build Coastguard Worker * MSAA. A call to GrDirectContext::submit is always required to ensure work is actually sent 389*c8dee2aaSAndroid Build Coastguard Worker * to the gpu. Some specific API details: 390*c8dee2aaSAndroid Build Coastguard Worker * GL: Commands are actually sent to the driver, but glFlush is never called. Thus some 391*c8dee2aaSAndroid Build Coastguard Worker * sync objects from the flush will not be valid until a submission occurs. 392*c8dee2aaSAndroid Build Coastguard Worker * 393*c8dee2aaSAndroid Build Coastguard Worker * Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs corresponding command 394*c8dee2aaSAndroid Build Coastguard Worker * buffer or encoder objects. However, these objects are not sent to the gpu until a 395*c8dee2aaSAndroid Build Coastguard Worker * submission occurs. 396*c8dee2aaSAndroid Build Coastguard Worker * 397*c8dee2aaSAndroid Build Coastguard Worker * The work that is submitted to the GPU will be dependent on the BackendSurfaceAccess that is 398*c8dee2aaSAndroid Build Coastguard Worker * passed in. 399*c8dee2aaSAndroid Build Coastguard Worker * 400*c8dee2aaSAndroid Build Coastguard Worker * If BackendSurfaceAccess::kNoAccess is passed in all commands will be issued to the GPU. 401*c8dee2aaSAndroid Build Coastguard Worker * 402*c8dee2aaSAndroid Build Coastguard Worker * If BackendSurfaceAccess::kPresent is passed in and the backend API is not Vulkan, it is 403*c8dee2aaSAndroid Build Coastguard Worker * treated the same as kNoAccess. If the backend API is Vulkan, the VkImage that backs the 404*c8dee2aaSAndroid Build Coastguard Worker * SkSurface will be transferred back to its original queue. If the SkSurface was created by 405*c8dee2aaSAndroid Build Coastguard Worker * wrapping a VkImage, the queue will be set to the queue which was originally passed in on 406*c8dee2aaSAndroid Build Coastguard Worker * the GrVkImageInfo. Additionally, if the original queue was not external or foreign the 407*c8dee2aaSAndroid Build Coastguard Worker * layout of the VkImage will be set to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR. 408*c8dee2aaSAndroid Build Coastguard Worker * 409*c8dee2aaSAndroid Build Coastguard Worker * The GrFlushInfo describes additional options to flush. Please see documentation at 410*c8dee2aaSAndroid Build Coastguard Worker * GrFlushInfo for more info. 411*c8dee2aaSAndroid Build Coastguard Worker * 412*c8dee2aaSAndroid Build Coastguard Worker * If the return is GrSemaphoresSubmitted::kYes, only initialized GrBackendSemaphores will be 413*c8dee2aaSAndroid Build Coastguard Worker * submitted to the gpu during the next submit call (it is possible Skia failed to create a 414*c8dee2aaSAndroid Build Coastguard Worker * subset of the semaphores). The client should not wait on these semaphores until after submit 415*c8dee2aaSAndroid Build Coastguard Worker * has been called, but must keep them alive until then. If a submit flag was passed in with 416*c8dee2aaSAndroid Build Coastguard Worker * the flush these valid semaphores can we waited on immediately. If this call returns 417*c8dee2aaSAndroid Build Coastguard Worker * GrSemaphoresSubmitted::kNo, the GPU backend will not submit any semaphores to be signaled on 418*c8dee2aaSAndroid Build Coastguard Worker * the GPU. Thus the client should not have the GPU wait on any of the semaphores passed in 419*c8dee2aaSAndroid Build Coastguard Worker * with the GrFlushInfo. Regardless of whether semaphores were submitted to the GPU or not, the 420*c8dee2aaSAndroid Build Coastguard Worker * client is still responsible for deleting any initialized semaphores. 421*c8dee2aaSAndroid Build Coastguard Worker * Regardless of semaphore submission the context will still be flushed. It should be 422*c8dee2aaSAndroid Build Coastguard Worker * emphasized that a return value of GrSemaphoresSubmitted::kNo does not mean the flush did not 423*c8dee2aaSAndroid Build Coastguard Worker * happen. It simply means there were no semaphores submitted to the GPU. A caller should only 424*c8dee2aaSAndroid Build Coastguard Worker * take this as a failure if they passed in semaphores to be submitted. 425*c8dee2aaSAndroid Build Coastguard Worker * 426*c8dee2aaSAndroid Build Coastguard Worker * Pending surface commands are flushed regardless of the return result. 427*c8dee2aaSAndroid Build Coastguard Worker * 428*c8dee2aaSAndroid Build Coastguard Worker * @param surface The GPU backed surface to be flushed. Has no effect on a CPU-backed surface. 429*c8dee2aaSAndroid Build Coastguard Worker * @param access type of access the call will do on the backend object after flush 430*c8dee2aaSAndroid Build Coastguard Worker * @param info flush options 431*c8dee2aaSAndroid Build Coastguard Worker */ 432*c8dee2aaSAndroid Build Coastguard Worker GrSemaphoresSubmitted flush(SkSurface* surface, 433*c8dee2aaSAndroid Build Coastguard Worker SkSurfaces::BackendSurfaceAccess access, 434*c8dee2aaSAndroid Build Coastguard Worker const GrFlushInfo& info); 435*c8dee2aaSAndroid Build Coastguard Worker 436*c8dee2aaSAndroid Build Coastguard Worker /** 437*c8dee2aaSAndroid Build Coastguard Worker * Same as above except: 438*c8dee2aaSAndroid Build Coastguard Worker * 439*c8dee2aaSAndroid Build Coastguard Worker * If a skgpu::MutableTextureState is passed in, at the end of the flush we will transition 440*c8dee2aaSAndroid Build Coastguard Worker * the surface to be in the state requested by the skgpu::MutableTextureState. If the surface 441*c8dee2aaSAndroid Build Coastguard Worker * (or SkImage or GrBackendSurface wrapping the same backend object) is used again after this 442*c8dee2aaSAndroid Build Coastguard Worker * flush the state may be changed and no longer match what is requested here. This is often 443*c8dee2aaSAndroid Build Coastguard Worker * used if the surface will be used for presenting or external use and the client wants backend 444*c8dee2aaSAndroid Build Coastguard Worker * object to be prepped for that use. A finishedProc or semaphore on the GrFlushInfo will also 445*c8dee2aaSAndroid Build Coastguard Worker * include the work for any requested state change. 446*c8dee2aaSAndroid Build Coastguard Worker * 447*c8dee2aaSAndroid Build Coastguard Worker * If the backend API is Vulkan, the caller can set the skgpu::MutableTextureState's 448*c8dee2aaSAndroid Build Coastguard Worker * VkImageLayout to VK_IMAGE_LAYOUT_UNDEFINED or queueFamilyIndex to VK_QUEUE_FAMILY_IGNORED to 449*c8dee2aaSAndroid Build Coastguard Worker * tell Skia to not change those respective states. 450*c8dee2aaSAndroid Build Coastguard Worker * 451*c8dee2aaSAndroid Build Coastguard Worker * @param surface The GPU backed surface to be flushed. Has no effect on a CPU-backed surface. 452*c8dee2aaSAndroid Build Coastguard Worker * @param info flush options 453*c8dee2aaSAndroid Build Coastguard Worker * @param newState optional state change request after flush 454*c8dee2aaSAndroid Build Coastguard Worker */ 455*c8dee2aaSAndroid Build Coastguard Worker GrSemaphoresSubmitted flush(SkSurface* surface, 456*c8dee2aaSAndroid Build Coastguard Worker const GrFlushInfo& info, 457*c8dee2aaSAndroid Build Coastguard Worker const skgpu::MutableTextureState* newState = nullptr); 458*c8dee2aaSAndroid Build Coastguard Worker 459*c8dee2aaSAndroid Build Coastguard Worker /** Call to ensure all reads/writes of the surface have been issued to the underlying 3D API. 460*c8dee2aaSAndroid Build Coastguard Worker * Skia will correctly order its own draws and pixel operations. This must to be used to ensure 461*c8dee2aaSAndroid Build Coastguard Worker * correct ordering when the surface backing store is accessed outside Skia (e.g. direct use of 462*c8dee2aaSAndroid Build Coastguard Worker * the 3D API or a windowing system). This is equivalent to 463*c8dee2aaSAndroid Build Coastguard Worker * calling ::flush with a default GrFlushInfo followed by ::submit(syncCpu). 464*c8dee2aaSAndroid Build Coastguard Worker * 465*c8dee2aaSAndroid Build Coastguard Worker * Has no effect on a CPU-backed surface. 466*c8dee2aaSAndroid Build Coastguard Worker */ 467*c8dee2aaSAndroid Build Coastguard Worker void flushAndSubmit(SkSurface* surface, GrSyncCpu sync = GrSyncCpu::kNo); 468*c8dee2aaSAndroid Build Coastguard Worker 469*c8dee2aaSAndroid Build Coastguard Worker /** 470*c8dee2aaSAndroid Build Coastguard Worker * Flushes the given surface with the default GrFlushInfo. 471*c8dee2aaSAndroid Build Coastguard Worker * 472*c8dee2aaSAndroid Build Coastguard Worker * Has no effect on a CPU-backed surface. 473*c8dee2aaSAndroid Build Coastguard Worker */ 474*c8dee2aaSAndroid Build Coastguard Worker void flush(SkSurface* surface); 475*c8dee2aaSAndroid Build Coastguard Worker 476*c8dee2aaSAndroid Build Coastguard Worker /** 477*c8dee2aaSAndroid Build Coastguard Worker * Submit outstanding work to the gpu from all previously un-submitted flushes. The return 478*c8dee2aaSAndroid Build Coastguard Worker * value of the submit will indicate whether or not the submission to the GPU was successful. 479*c8dee2aaSAndroid Build Coastguard Worker * 480*c8dee2aaSAndroid Build Coastguard Worker * If the call returns true, all previously passed in semaphores in flush calls will have been 481*c8dee2aaSAndroid Build Coastguard Worker * submitted to the GPU and they can safely be waited on. The caller should wait on those 482*c8dee2aaSAndroid Build Coastguard Worker * semaphores or perform some other global synchronization before deleting the semaphores. 483*c8dee2aaSAndroid Build Coastguard Worker * 484*c8dee2aaSAndroid Build Coastguard Worker * If it returns false, then those same semaphores will not have been submitted and we will not 485*c8dee2aaSAndroid Build Coastguard Worker * try to submit them again. The caller is free to delete the semaphores at any time. 486*c8dee2aaSAndroid Build Coastguard Worker * 487*c8dee2aaSAndroid Build Coastguard Worker * If GrSubmitInfo::fSync flag is GrSyncCpu::kYes, this function will return once the gpu has 488*c8dee2aaSAndroid Build Coastguard Worker * finished with all submitted work. 489*c8dee2aaSAndroid Build Coastguard Worker * 490*c8dee2aaSAndroid Build Coastguard Worker * If GrSubmitInfo::fMarkBoundary flag is GrMarkFrameBoundary::kYes and the GPU supports a way 491*c8dee2aaSAndroid Build Coastguard Worker * to be notified about frame boundaries, then we will notify the GPU during/after the 492*c8dee2aaSAndroid Build Coastguard Worker * submission of work to the GPU. GrSubmitInfo::fFrameID is a frame ID that is passed to the 493*c8dee2aaSAndroid Build Coastguard Worker * GPU when marking a boundary. Ideally this value should be unique for each frame. Currently 494*c8dee2aaSAndroid Build Coastguard Worker * marking frame boundaries is only supported with the Vulkan backend and only if the 495*c8dee2aaSAndroid Build Coastguard Worker * VK_EXT_frame_boudnary extenstion is available. 496*c8dee2aaSAndroid Build Coastguard Worker */ 497*c8dee2aaSAndroid Build Coastguard Worker bool submit(const GrSubmitInfo&); 498*c8dee2aaSAndroid Build Coastguard Worker 499*c8dee2aaSAndroid Build Coastguard Worker bool submit(GrSyncCpu sync = GrSyncCpu::kNo) { 500*c8dee2aaSAndroid Build Coastguard Worker GrSubmitInfo info; 501*c8dee2aaSAndroid Build Coastguard Worker info.fSync = sync; 502*c8dee2aaSAndroid Build Coastguard Worker 503*c8dee2aaSAndroid Build Coastguard Worker return this->submit(info); 504*c8dee2aaSAndroid Build Coastguard Worker } 505*c8dee2aaSAndroid Build Coastguard Worker 506*c8dee2aaSAndroid Build Coastguard Worker 507*c8dee2aaSAndroid Build Coastguard Worker /** 508*c8dee2aaSAndroid Build Coastguard Worker * Checks whether any asynchronous work is complete and if so calls related callbacks. 509*c8dee2aaSAndroid Build Coastguard Worker */ 510*c8dee2aaSAndroid Build Coastguard Worker void checkAsyncWorkCompletion(); 511*c8dee2aaSAndroid Build Coastguard Worker 512*c8dee2aaSAndroid Build Coastguard Worker /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */ 513*c8dee2aaSAndroid Build Coastguard Worker // Chrome is using this! 514*c8dee2aaSAndroid Build Coastguard Worker void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const; 515*c8dee2aaSAndroid Build Coastguard Worker 516*c8dee2aaSAndroid Build Coastguard Worker bool supportsDistanceFieldText() const; 517*c8dee2aaSAndroid Build Coastguard Worker 518*c8dee2aaSAndroid Build Coastguard Worker void storeVkPipelineCacheData(); 519*c8dee2aaSAndroid Build Coastguard Worker 520*c8dee2aaSAndroid Build Coastguard Worker /** 521*c8dee2aaSAndroid Build Coastguard Worker * Retrieve the default GrBackendFormat for a given SkColorType and renderability. 522*c8dee2aaSAndroid Build Coastguard Worker * It is guaranteed that this backend format will be the one used by the following 523*c8dee2aaSAndroid Build Coastguard Worker * SkColorType and GrSurfaceCharacterization-based createBackendTexture methods. 524*c8dee2aaSAndroid Build Coastguard Worker * 525*c8dee2aaSAndroid Build Coastguard Worker * The caller should check that the returned format is valid. 526*c8dee2aaSAndroid Build Coastguard Worker */ 527*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::defaultBackendFormat; 528*c8dee2aaSAndroid Build Coastguard Worker 529*c8dee2aaSAndroid Build Coastguard Worker /** 530*c8dee2aaSAndroid Build Coastguard Worker * The explicitly allocated backend texture API allows clients to use Skia to create backend 531*c8dee2aaSAndroid Build Coastguard Worker * objects outside of Skia proper (i.e., Skia's caching system will not know about them.) 532*c8dee2aaSAndroid Build Coastguard Worker * 533*c8dee2aaSAndroid Build Coastguard Worker * It is the client's responsibility to delete all these objects (using deleteBackendTexture) 534*c8dee2aaSAndroid Build Coastguard Worker * before deleting the context used to create them. If the backend is Vulkan, the textures must 535*c8dee2aaSAndroid Build Coastguard Worker * be deleted before abandoning the context as well. Additionally, clients should only delete 536*c8dee2aaSAndroid Build Coastguard Worker * these objects on the thread for which that context is active. 537*c8dee2aaSAndroid Build Coastguard Worker * 538*c8dee2aaSAndroid Build Coastguard Worker * The client is responsible for ensuring synchronization between different uses 539*c8dee2aaSAndroid Build Coastguard Worker * of the backend object (i.e., wrapping it in a surface, rendering to it, deleting the 540*c8dee2aaSAndroid Build Coastguard Worker * surface, rewrapping it in a image and drawing the image will require explicit 541*c8dee2aaSAndroid Build Coastguard Worker * synchronization on the client's part). 542*c8dee2aaSAndroid Build Coastguard Worker */ 543*c8dee2aaSAndroid Build Coastguard Worker 544*c8dee2aaSAndroid Build Coastguard Worker /** 545*c8dee2aaSAndroid Build Coastguard Worker * If possible, create an uninitialized backend texture. The client should ensure that the 546*c8dee2aaSAndroid Build Coastguard Worker * returned backend texture is valid. 547*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend the layout of the created VkImage will be: 548*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_UNDEFINED. 549*c8dee2aaSAndroid Build Coastguard Worker */ 550*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(int width, 551*c8dee2aaSAndroid Build Coastguard Worker int height, 552*c8dee2aaSAndroid Build Coastguard Worker const GrBackendFormat&, 553*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 554*c8dee2aaSAndroid Build Coastguard Worker GrRenderable, 555*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 556*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 557*c8dee2aaSAndroid Build Coastguard Worker 558*c8dee2aaSAndroid Build Coastguard Worker /** 559*c8dee2aaSAndroid Build Coastguard Worker * If possible, create an uninitialized backend texture. The client should ensure that the 560*c8dee2aaSAndroid Build Coastguard Worker * returned backend texture is valid. 561*c8dee2aaSAndroid Build Coastguard Worker * If successful, the created backend texture will be compatible with the provided 562*c8dee2aaSAndroid Build Coastguard Worker * SkColorType. 563*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend the layout of the created VkImage will be: 564*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_UNDEFINED. 565*c8dee2aaSAndroid Build Coastguard Worker */ 566*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(int width, 567*c8dee2aaSAndroid Build Coastguard Worker int height, 568*c8dee2aaSAndroid Build Coastguard Worker SkColorType, 569*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 570*c8dee2aaSAndroid Build Coastguard Worker GrRenderable, 571*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 572*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 573*c8dee2aaSAndroid Build Coastguard Worker 574*c8dee2aaSAndroid Build Coastguard Worker /** 575*c8dee2aaSAndroid Build Coastguard Worker * If possible, create a backend texture initialized to a particular color. The client should 576*c8dee2aaSAndroid Build Coastguard Worker * ensure that the returned backend texture is valid. The client can pass in a finishedProc 577*c8dee2aaSAndroid Build Coastguard Worker * to be notified when the data has been uploaded by the gpu and the texture can be deleted. The 578*c8dee2aaSAndroid Build Coastguard Worker * client is required to call `submit` to send the upload work to the gpu. The 579*c8dee2aaSAndroid Build Coastguard Worker * finishedProc will always get called even if we failed to create the GrBackendTexture. 580*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend the layout of the created VkImage will be: 581*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 582*c8dee2aaSAndroid Build Coastguard Worker */ 583*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(int width, 584*c8dee2aaSAndroid Build Coastguard Worker int height, 585*c8dee2aaSAndroid Build Coastguard Worker const GrBackendFormat&, 586*c8dee2aaSAndroid Build Coastguard Worker const SkColor4f& color, 587*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 588*c8dee2aaSAndroid Build Coastguard Worker GrRenderable, 589*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 590*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 591*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr, 592*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 593*c8dee2aaSAndroid Build Coastguard Worker 594*c8dee2aaSAndroid Build Coastguard Worker /** 595*c8dee2aaSAndroid Build Coastguard Worker * If possible, create a backend texture initialized to a particular color. The client should 596*c8dee2aaSAndroid Build Coastguard Worker * ensure that the returned backend texture is valid. The client can pass in a finishedProc 597*c8dee2aaSAndroid Build Coastguard Worker * to be notified when the data has been uploaded by the gpu and the texture can be deleted. The 598*c8dee2aaSAndroid Build Coastguard Worker * client is required to call `submit` to send the upload work to the gpu. The 599*c8dee2aaSAndroid Build Coastguard Worker * finishedProc will always get called even if we failed to create the GrBackendTexture. 600*c8dee2aaSAndroid Build Coastguard Worker * If successful, the created backend texture will be compatible with the provided 601*c8dee2aaSAndroid Build Coastguard Worker * SkColorType. 602*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend the layout of the created VkImage will be: 603*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 604*c8dee2aaSAndroid Build Coastguard Worker */ 605*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(int width, 606*c8dee2aaSAndroid Build Coastguard Worker int height, 607*c8dee2aaSAndroid Build Coastguard Worker SkColorType, 608*c8dee2aaSAndroid Build Coastguard Worker const SkColor4f& color, 609*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 610*c8dee2aaSAndroid Build Coastguard Worker GrRenderable, 611*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 612*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 613*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr, 614*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 615*c8dee2aaSAndroid Build Coastguard Worker 616*c8dee2aaSAndroid Build Coastguard Worker /** 617*c8dee2aaSAndroid Build Coastguard Worker * If possible, create a backend texture initialized with the provided pixmap data. The client 618*c8dee2aaSAndroid Build Coastguard Worker * should ensure that the returned backend texture is valid. The client can pass in a 619*c8dee2aaSAndroid Build Coastguard Worker * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be 620*c8dee2aaSAndroid Build Coastguard Worker * deleted. The client is required to call `submit` to send the upload work to the gpu. 621*c8dee2aaSAndroid Build Coastguard Worker * The finishedProc will always get called even if we failed to create the GrBackendTexture. 622*c8dee2aaSAndroid Build Coastguard Worker * If successful, the created backend texture will be compatible with the provided 623*c8dee2aaSAndroid Build Coastguard Worker * pixmap(s). Compatible, in this case, means that the backend format will be the result 624*c8dee2aaSAndroid Build Coastguard Worker * of calling defaultBackendFormat on the base pixmap's colortype. The src data can be deleted 625*c8dee2aaSAndroid Build Coastguard Worker * when this call returns. 626*c8dee2aaSAndroid Build Coastguard Worker * If numLevels is 1 a non-mipmapped texture will result. If a mipmapped texture is desired 627*c8dee2aaSAndroid Build Coastguard Worker * the data for all the mipmap levels must be provided. In the mipmapped case all the 628*c8dee2aaSAndroid Build Coastguard Worker * colortypes of the provided pixmaps must be the same. Additionally, all the miplevels 629*c8dee2aaSAndroid Build Coastguard Worker * must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount). The 630*c8dee2aaSAndroid Build Coastguard Worker * GrSurfaceOrigin controls whether the pixmap data is vertically flipped in the texture. 631*c8dee2aaSAndroid Build Coastguard Worker * Note: the pixmap's alphatypes and colorspaces are ignored. 632*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend the layout of the created VkImage will be: 633*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 634*c8dee2aaSAndroid Build Coastguard Worker */ 635*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(const SkPixmap srcData[], 636*c8dee2aaSAndroid Build Coastguard Worker int numLevels, 637*c8dee2aaSAndroid Build Coastguard Worker GrSurfaceOrigin, 638*c8dee2aaSAndroid Build Coastguard Worker GrRenderable, 639*c8dee2aaSAndroid Build Coastguard Worker GrProtected, 640*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 641*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr, 642*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 643*c8dee2aaSAndroid Build Coastguard Worker 644*c8dee2aaSAndroid Build Coastguard Worker /** 645*c8dee2aaSAndroid Build Coastguard Worker * Convenience version createBackendTexture() that takes just a base level pixmap. 646*c8dee2aaSAndroid Build Coastguard Worker */ 647*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(const SkPixmap& srcData, 648*c8dee2aaSAndroid Build Coastguard Worker GrSurfaceOrigin textureOrigin, 649*c8dee2aaSAndroid Build Coastguard Worker GrRenderable renderable, 650*c8dee2aaSAndroid Build Coastguard Worker GrProtected isProtected, 651*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 652*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr, 653*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 654*c8dee2aaSAndroid Build Coastguard Worker 655*c8dee2aaSAndroid Build Coastguard Worker // Deprecated versions that do not take origin and assume top-left. 656*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(const SkPixmap srcData[], 657*c8dee2aaSAndroid Build Coastguard Worker int numLevels, 658*c8dee2aaSAndroid Build Coastguard Worker GrRenderable renderable, 659*c8dee2aaSAndroid Build Coastguard Worker GrProtected isProtected, 660*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 661*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr, 662*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 663*c8dee2aaSAndroid Build Coastguard Worker 664*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createBackendTexture(const SkPixmap& srcData, 665*c8dee2aaSAndroid Build Coastguard Worker GrRenderable renderable, 666*c8dee2aaSAndroid Build Coastguard Worker GrProtected isProtected, 667*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 668*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr, 669*c8dee2aaSAndroid Build Coastguard Worker std::string_view label = {}); 670*c8dee2aaSAndroid Build Coastguard Worker 671*c8dee2aaSAndroid Build Coastguard Worker /** 672*c8dee2aaSAndroid Build Coastguard Worker * If possible, updates a backend texture to be filled to a particular color. The client should 673*c8dee2aaSAndroid Build Coastguard Worker * check the return value to see if the update was successful. The client can pass in a 674*c8dee2aaSAndroid Build Coastguard Worker * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be 675*c8dee2aaSAndroid Build Coastguard Worker * deleted. The client is required to call `submit` to send the upload work to the gpu. 676*c8dee2aaSAndroid Build Coastguard Worker * The finishedProc will always get called even if we failed to update the GrBackendTexture. 677*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend after a successful update the layout of the created VkImage will be: 678*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 679*c8dee2aaSAndroid Build Coastguard Worker */ 680*c8dee2aaSAndroid Build Coastguard Worker bool updateBackendTexture(const GrBackendTexture&, 681*c8dee2aaSAndroid Build Coastguard Worker const SkColor4f& color, 682*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc, 683*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext); 684*c8dee2aaSAndroid Build Coastguard Worker 685*c8dee2aaSAndroid Build Coastguard Worker /** 686*c8dee2aaSAndroid Build Coastguard Worker * If possible, updates a backend texture to be filled to a particular color. The data in 687*c8dee2aaSAndroid Build Coastguard Worker * GrBackendTexture and passed in color is interpreted with respect to the passed in 688*c8dee2aaSAndroid Build Coastguard Worker * SkColorType. The client should check the return value to see if the update was successful. 689*c8dee2aaSAndroid Build Coastguard Worker * The client can pass in a finishedProc to be notified when the data has been uploaded by the 690*c8dee2aaSAndroid Build Coastguard Worker * gpu and the texture can be deleted. The client is required to call `submit` to send 691*c8dee2aaSAndroid Build Coastguard Worker * the upload work to the gpu. The finishedProc will always get called even if we failed to 692*c8dee2aaSAndroid Build Coastguard Worker * update the GrBackendTexture. 693*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend after a successful update the layout of the created VkImage will be: 694*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 695*c8dee2aaSAndroid Build Coastguard Worker */ 696*c8dee2aaSAndroid Build Coastguard Worker bool updateBackendTexture(const GrBackendTexture&, 697*c8dee2aaSAndroid Build Coastguard Worker SkColorType skColorType, 698*c8dee2aaSAndroid Build Coastguard Worker const SkColor4f& color, 699*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc, 700*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext); 701*c8dee2aaSAndroid Build Coastguard Worker 702*c8dee2aaSAndroid Build Coastguard Worker /** 703*c8dee2aaSAndroid Build Coastguard Worker * If possible, updates a backend texture filled with the provided pixmap data. The client 704*c8dee2aaSAndroid Build Coastguard Worker * should check the return value to see if the update was successful. The client can pass in a 705*c8dee2aaSAndroid Build Coastguard Worker * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be 706*c8dee2aaSAndroid Build Coastguard Worker * deleted. The client is required to call `submit` to send the upload work to the gpu. 707*c8dee2aaSAndroid Build Coastguard Worker * The finishedProc will always get called even if we failed to create the GrBackendTexture. 708*c8dee2aaSAndroid Build Coastguard Worker * The backend texture must be compatible with the provided pixmap(s). Compatible, in this case, 709*c8dee2aaSAndroid Build Coastguard Worker * means that the backend format is compatible with the base pixmap's colortype. The src data 710*c8dee2aaSAndroid Build Coastguard Worker * can be deleted when this call returns. 711*c8dee2aaSAndroid Build Coastguard Worker * If the backend texture is mip mapped, the data for all the mipmap levels must be provided. 712*c8dee2aaSAndroid Build Coastguard Worker * In the mipmapped case all the colortypes of the provided pixmaps must be the same. 713*c8dee2aaSAndroid Build Coastguard Worker * Additionally, all the miplevels must be sized correctly (please see 714*c8dee2aaSAndroid Build Coastguard Worker * SkMipmap::ComputeLevelSize and ComputeLevelCount). The GrSurfaceOrigin controls whether the 715*c8dee2aaSAndroid Build Coastguard Worker * pixmap data is vertically flipped in the texture. 716*c8dee2aaSAndroid Build Coastguard Worker * Note: the pixmap's alphatypes and colorspaces are ignored. 717*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend after a successful update the layout of the created VkImage will be: 718*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 719*c8dee2aaSAndroid Build Coastguard Worker */ 720*c8dee2aaSAndroid Build Coastguard Worker bool updateBackendTexture(const GrBackendTexture&, 721*c8dee2aaSAndroid Build Coastguard Worker const SkPixmap srcData[], 722*c8dee2aaSAndroid Build Coastguard Worker int numLevels, 723*c8dee2aaSAndroid Build Coastguard Worker GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin, 724*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 725*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr); 726*c8dee2aaSAndroid Build Coastguard Worker 727*c8dee2aaSAndroid Build Coastguard Worker /** 728*c8dee2aaSAndroid Build Coastguard Worker * Convenience version of updateBackendTexture that takes just a base level pixmap. 729*c8dee2aaSAndroid Build Coastguard Worker */ 730*c8dee2aaSAndroid Build Coastguard Worker bool updateBackendTexture(const GrBackendTexture& texture, 731*c8dee2aaSAndroid Build Coastguard Worker const SkPixmap& srcData, 732*c8dee2aaSAndroid Build Coastguard Worker GrSurfaceOrigin textureOrigin = kTopLeft_GrSurfaceOrigin, 733*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 734*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr) { 735*c8dee2aaSAndroid Build Coastguard Worker return this->updateBackendTexture(texture, 736*c8dee2aaSAndroid Build Coastguard Worker &srcData, 737*c8dee2aaSAndroid Build Coastguard Worker 1, 738*c8dee2aaSAndroid Build Coastguard Worker textureOrigin, 739*c8dee2aaSAndroid Build Coastguard Worker finishedProc, 740*c8dee2aaSAndroid Build Coastguard Worker finishedContext); 741*c8dee2aaSAndroid Build Coastguard Worker } 742*c8dee2aaSAndroid Build Coastguard Worker 743*c8dee2aaSAndroid Build Coastguard Worker // Deprecated version that does not take origin and assumes top-left. 744*c8dee2aaSAndroid Build Coastguard Worker bool updateBackendTexture(const GrBackendTexture& texture, 745*c8dee2aaSAndroid Build Coastguard Worker const SkPixmap srcData[], 746*c8dee2aaSAndroid Build Coastguard Worker int numLevels, 747*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc, 748*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext); 749*c8dee2aaSAndroid Build Coastguard Worker 750*c8dee2aaSAndroid Build Coastguard Worker /** 751*c8dee2aaSAndroid Build Coastguard Worker * Retrieve the GrBackendFormat for a given SkTextureCompressionType. This is 752*c8dee2aaSAndroid Build Coastguard Worker * guaranteed to match the backend format used by the following 753*c8dee2aaSAndroid Build Coastguard Worker * createCompressedBackendTexture methods that take a CompressionType. 754*c8dee2aaSAndroid Build Coastguard Worker * 755*c8dee2aaSAndroid Build Coastguard Worker * The caller should check that the returned format is valid. 756*c8dee2aaSAndroid Build Coastguard Worker */ 757*c8dee2aaSAndroid Build Coastguard Worker using GrRecordingContext::compressedBackendFormat; 758*c8dee2aaSAndroid Build Coastguard Worker 759*c8dee2aaSAndroid Build Coastguard Worker /** 760*c8dee2aaSAndroid Build Coastguard Worker *If possible, create a compressed backend texture initialized to a particular color. The 761*c8dee2aaSAndroid Build Coastguard Worker * client should ensure that the returned backend texture is valid. The client can pass in a 762*c8dee2aaSAndroid Build Coastguard Worker * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be 763*c8dee2aaSAndroid Build Coastguard Worker * deleted. The client is required to call `submit` to send the upload work to the gpu. 764*c8dee2aaSAndroid Build Coastguard Worker * The finishedProc will always get called even if we failed to create the GrBackendTexture. 765*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend the layout of the created VkImage will be: 766*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 767*c8dee2aaSAndroid Build Coastguard Worker */ 768*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createCompressedBackendTexture(int width, 769*c8dee2aaSAndroid Build Coastguard Worker int height, 770*c8dee2aaSAndroid Build Coastguard Worker const GrBackendFormat&, 771*c8dee2aaSAndroid Build Coastguard Worker const SkColor4f& color, 772*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 773*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 774*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 775*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr); 776*c8dee2aaSAndroid Build Coastguard Worker 777*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createCompressedBackendTexture(int width, 778*c8dee2aaSAndroid Build Coastguard Worker int height, 779*c8dee2aaSAndroid Build Coastguard Worker SkTextureCompressionType, 780*c8dee2aaSAndroid Build Coastguard Worker const SkColor4f& color, 781*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 782*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 783*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 784*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr); 785*c8dee2aaSAndroid Build Coastguard Worker 786*c8dee2aaSAndroid Build Coastguard Worker /** 787*c8dee2aaSAndroid Build Coastguard Worker * If possible, create a backend texture initialized with the provided raw data. The client 788*c8dee2aaSAndroid Build Coastguard Worker * should ensure that the returned backend texture is valid. The client can pass in a 789*c8dee2aaSAndroid Build Coastguard Worker * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be 790*c8dee2aaSAndroid Build Coastguard Worker * deleted. The client is required to call `submit` to send the upload work to the gpu. 791*c8dee2aaSAndroid Build Coastguard Worker * The finishedProc will always get called even if we failed to create the GrBackendTexture 792*c8dee2aaSAndroid Build Coastguard Worker * If numLevels is 1 a non-mipmapped texture will result. If a mipmapped texture is desired 793*c8dee2aaSAndroid Build Coastguard Worker * the data for all the mipmap levels must be provided. Additionally, all the miplevels 794*c8dee2aaSAndroid Build Coastguard Worker * must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount). 795*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend the layout of the created VkImage will be: 796*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 797*c8dee2aaSAndroid Build Coastguard Worker */ 798*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createCompressedBackendTexture(int width, 799*c8dee2aaSAndroid Build Coastguard Worker int height, 800*c8dee2aaSAndroid Build Coastguard Worker const GrBackendFormat&, 801*c8dee2aaSAndroid Build Coastguard Worker const void* data, 802*c8dee2aaSAndroid Build Coastguard Worker size_t dataSize, 803*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 804*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 805*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 806*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr); 807*c8dee2aaSAndroid Build Coastguard Worker 808*c8dee2aaSAndroid Build Coastguard Worker GrBackendTexture createCompressedBackendTexture(int width, 809*c8dee2aaSAndroid Build Coastguard Worker int height, 810*c8dee2aaSAndroid Build Coastguard Worker SkTextureCompressionType, 811*c8dee2aaSAndroid Build Coastguard Worker const void* data, 812*c8dee2aaSAndroid Build Coastguard Worker size_t dataSize, 813*c8dee2aaSAndroid Build Coastguard Worker skgpu::Mipmapped, 814*c8dee2aaSAndroid Build Coastguard Worker GrProtected = GrProtected::kNo, 815*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 816*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr); 817*c8dee2aaSAndroid Build Coastguard Worker 818*c8dee2aaSAndroid Build Coastguard Worker /** 819*c8dee2aaSAndroid Build Coastguard Worker * If possible, updates a backend texture filled with the provided color. If the texture is 820*c8dee2aaSAndroid Build Coastguard Worker * mipmapped, all levels of the mip chain will be updated to have the supplied color. The client 821*c8dee2aaSAndroid Build Coastguard Worker * should check the return value to see if the update was successful. The client can pass in a 822*c8dee2aaSAndroid Build Coastguard Worker * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be 823*c8dee2aaSAndroid Build Coastguard Worker * deleted. The client is required to call `submit` to send the upload work to the gpu. 824*c8dee2aaSAndroid Build Coastguard Worker * The finishedProc will always get called even if we failed to create the GrBackendTexture. 825*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend after a successful update the layout of the created VkImage will be: 826*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 827*c8dee2aaSAndroid Build Coastguard Worker */ 828*c8dee2aaSAndroid Build Coastguard Worker bool updateCompressedBackendTexture(const GrBackendTexture&, 829*c8dee2aaSAndroid Build Coastguard Worker const SkColor4f& color, 830*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc, 831*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext); 832*c8dee2aaSAndroid Build Coastguard Worker 833*c8dee2aaSAndroid Build Coastguard Worker /** 834*c8dee2aaSAndroid Build Coastguard Worker * If possible, updates a backend texture filled with the provided raw data. The client 835*c8dee2aaSAndroid Build Coastguard Worker * should check the return value to see if the update was successful. The client can pass in a 836*c8dee2aaSAndroid Build Coastguard Worker * finishedProc to be notified when the data has been uploaded by the gpu and the texture can be 837*c8dee2aaSAndroid Build Coastguard Worker * deleted. The client is required to call `submit` to send the upload work to the gpu. 838*c8dee2aaSAndroid Build Coastguard Worker * The finishedProc will always get called even if we failed to create the GrBackendTexture. 839*c8dee2aaSAndroid Build Coastguard Worker * If a mipmapped texture is passed in, the data for all the mipmap levels must be provided. 840*c8dee2aaSAndroid Build Coastguard Worker * Additionally, all the miplevels must be sized correctly (please see 841*c8dee2aaSAndroid Build Coastguard Worker * SkMipMap::ComputeLevelSize and ComputeLevelCount). 842*c8dee2aaSAndroid Build Coastguard Worker * For the Vulkan backend after a successful update the layout of the created VkImage will be: 843*c8dee2aaSAndroid Build Coastguard Worker * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL 844*c8dee2aaSAndroid Build Coastguard Worker */ 845*c8dee2aaSAndroid Build Coastguard Worker bool updateCompressedBackendTexture(const GrBackendTexture&, 846*c8dee2aaSAndroid Build Coastguard Worker const void* data, 847*c8dee2aaSAndroid Build Coastguard Worker size_t dataSize, 848*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc, 849*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext); 850*c8dee2aaSAndroid Build Coastguard Worker 851*c8dee2aaSAndroid Build Coastguard Worker /** 852*c8dee2aaSAndroid Build Coastguard Worker * Updates the state of the GrBackendTexture/RenderTarget to have the passed in 853*c8dee2aaSAndroid Build Coastguard Worker * skgpu::MutableTextureState. All objects that wrap the backend surface (i.e. SkSurfaces and 854*c8dee2aaSAndroid Build Coastguard Worker * SkImages) will also be aware of this state change. This call does not submit the state change 855*c8dee2aaSAndroid Build Coastguard Worker * to the gpu, but requires the client to call `submit` to send it to the GPU. The work 856*c8dee2aaSAndroid Build Coastguard Worker * for this call is ordered linearly with all other calls that require GrContext::submit to be 857*c8dee2aaSAndroid Build Coastguard Worker * called (e.g updateBackendTexture and flush). If finishedProc is not null then it will be 858*c8dee2aaSAndroid Build Coastguard Worker * called with finishedContext after the state transition is known to have occurred on the GPU. 859*c8dee2aaSAndroid Build Coastguard Worker * 860*c8dee2aaSAndroid Build Coastguard Worker * See skgpu::MutableTextureState to see what state can be set via this call. 861*c8dee2aaSAndroid Build Coastguard Worker * 862*c8dee2aaSAndroid Build Coastguard Worker * If the backend API is Vulkan, the caller can set the skgpu::MutableTextureState's 863*c8dee2aaSAndroid Build Coastguard Worker * VkImageLayout to VK_IMAGE_LAYOUT_UNDEFINED or queueFamilyIndex to VK_QUEUE_FAMILY_IGNORED to 864*c8dee2aaSAndroid Build Coastguard Worker * tell Skia to not change those respective states. 865*c8dee2aaSAndroid Build Coastguard Worker * 866*c8dee2aaSAndroid Build Coastguard Worker * If previousState is not null and this returns true, then Skia will have filled in 867*c8dee2aaSAndroid Build Coastguard Worker * previousState to have the values of the state before this call. 868*c8dee2aaSAndroid Build Coastguard Worker */ 869*c8dee2aaSAndroid Build Coastguard Worker bool setBackendTextureState(const GrBackendTexture&, 870*c8dee2aaSAndroid Build Coastguard Worker const skgpu::MutableTextureState&, 871*c8dee2aaSAndroid Build Coastguard Worker skgpu::MutableTextureState* previousState = nullptr, 872*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 873*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr); 874*c8dee2aaSAndroid Build Coastguard Worker bool setBackendRenderTargetState(const GrBackendRenderTarget&, 875*c8dee2aaSAndroid Build Coastguard Worker const skgpu::MutableTextureState&, 876*c8dee2aaSAndroid Build Coastguard Worker skgpu::MutableTextureState* previousState = nullptr, 877*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedProc finishedProc = nullptr, 878*c8dee2aaSAndroid Build Coastguard Worker GrGpuFinishedContext finishedContext = nullptr); 879*c8dee2aaSAndroid Build Coastguard Worker 880*c8dee2aaSAndroid Build Coastguard Worker void deleteBackendTexture(const GrBackendTexture&); 881*c8dee2aaSAndroid Build Coastguard Worker 882*c8dee2aaSAndroid Build Coastguard Worker // This interface allows clients to pre-compile shaders and populate the runtime program cache. 883*c8dee2aaSAndroid Build Coastguard Worker // The key and data blobs should be the ones passed to the PersistentCache, in SkSL format. 884*c8dee2aaSAndroid Build Coastguard Worker // 885*c8dee2aaSAndroid Build Coastguard Worker // Steps to use this API: 886*c8dee2aaSAndroid Build Coastguard Worker // 887*c8dee2aaSAndroid Build Coastguard Worker // 1) Create a GrDirectContext as normal, but set fPersistentCache on GrContextOptions to 888*c8dee2aaSAndroid Build Coastguard Worker // something that will save the cached shader blobs. Set fShaderCacheStrategy to kSkSL. This 889*c8dee2aaSAndroid Build Coastguard Worker // will ensure that the blobs are SkSL, and are suitable for pre-compilation. 890*c8dee2aaSAndroid Build Coastguard Worker // 2) Run your application, and save all of the key/data pairs that are fed to the cache. 891*c8dee2aaSAndroid Build Coastguard Worker // 892*c8dee2aaSAndroid Build Coastguard Worker // 3) Switch over to shipping your application. Include the key/data pairs from above. 893*c8dee2aaSAndroid Build Coastguard Worker // 4) At startup (or any convenient time), call precompileShader for each key/data pair. 894*c8dee2aaSAndroid Build Coastguard Worker // This will compile the SkSL to create a GL program, and populate the runtime cache. 895*c8dee2aaSAndroid Build Coastguard Worker // 896*c8dee2aaSAndroid Build Coastguard Worker // This is only guaranteed to work if the context/device used in step #2 are created in the 897*c8dee2aaSAndroid Build Coastguard Worker // same way as the one used in step #4, and the same GrContextOptions are specified. 898*c8dee2aaSAndroid Build Coastguard Worker // Using cached shader blobs on a different device or driver are undefined. 899*c8dee2aaSAndroid Build Coastguard Worker bool precompileShader(const SkData& key, const SkData& data); 900*c8dee2aaSAndroid Build Coastguard Worker 901*c8dee2aaSAndroid Build Coastguard Worker #ifdef SK_ENABLE_DUMP_GPU 902*c8dee2aaSAndroid Build Coastguard Worker /** Returns a string with detailed information about the context & GPU, in JSON format. */ 903*c8dee2aaSAndroid Build Coastguard Worker SkString dump() const; 904*c8dee2aaSAndroid Build Coastguard Worker #endif 905*c8dee2aaSAndroid Build Coastguard Worker 906*c8dee2aaSAndroid Build Coastguard Worker class DirectContextID { 907*c8dee2aaSAndroid Build Coastguard Worker public: 908*c8dee2aaSAndroid Build Coastguard Worker static GrDirectContext::DirectContextID Next(); 909*c8dee2aaSAndroid Build Coastguard Worker DirectContextID()910*c8dee2aaSAndroid Build Coastguard Worker DirectContextID() : fID(SK_InvalidUniqueID) {} 911*c8dee2aaSAndroid Build Coastguard Worker 912*c8dee2aaSAndroid Build Coastguard Worker bool operator==(const DirectContextID& that) const { return fID == that.fID; } 913*c8dee2aaSAndroid Build Coastguard Worker bool operator!=(const DirectContextID& that) const { return !(*this == that); } 914*c8dee2aaSAndroid Build Coastguard Worker makeInvalid()915*c8dee2aaSAndroid Build Coastguard Worker void makeInvalid() { fID = SK_InvalidUniqueID; } isValid()916*c8dee2aaSAndroid Build Coastguard Worker bool isValid() const { return fID != SK_InvalidUniqueID; } 917*c8dee2aaSAndroid Build Coastguard Worker 918*c8dee2aaSAndroid Build Coastguard Worker private: DirectContextID(uint32_t id)919*c8dee2aaSAndroid Build Coastguard Worker constexpr DirectContextID(uint32_t id) : fID(id) {} 920*c8dee2aaSAndroid Build Coastguard Worker uint32_t fID; 921*c8dee2aaSAndroid Build Coastguard Worker }; 922*c8dee2aaSAndroid Build Coastguard Worker directContextID()923*c8dee2aaSAndroid Build Coastguard Worker DirectContextID directContextID() const { return fDirectContextID; } 924*c8dee2aaSAndroid Build Coastguard Worker 925*c8dee2aaSAndroid Build Coastguard Worker // Provides access to functions that aren't part of the public API. 926*c8dee2aaSAndroid Build Coastguard Worker GrDirectContextPriv priv(); 927*c8dee2aaSAndroid Build Coastguard Worker const GrDirectContextPriv priv() const; // NOLINT(readability-const-return-type) 928*c8dee2aaSAndroid Build Coastguard Worker 929*c8dee2aaSAndroid Build Coastguard Worker protected: 930*c8dee2aaSAndroid Build Coastguard Worker GrDirectContext(GrBackendApi backend, 931*c8dee2aaSAndroid Build Coastguard Worker const GrContextOptions& options, 932*c8dee2aaSAndroid Build Coastguard Worker sk_sp<GrContextThreadSafeProxy> proxy); 933*c8dee2aaSAndroid Build Coastguard Worker 934*c8dee2aaSAndroid Build Coastguard Worker bool init() override; 935*c8dee2aaSAndroid Build Coastguard Worker onGetAtlasManager()936*c8dee2aaSAndroid Build Coastguard Worker GrAtlasManager* onGetAtlasManager() { return fAtlasManager.get(); } 937*c8dee2aaSAndroid Build Coastguard Worker #if !defined(SK_ENABLE_OPTIMIZE_SIZE) 938*c8dee2aaSAndroid Build Coastguard Worker skgpu::ganesh::SmallPathAtlasMgr* onGetSmallPathAtlasMgr(); 939*c8dee2aaSAndroid Build Coastguard Worker #endif 940*c8dee2aaSAndroid Build Coastguard Worker asDirectContext()941*c8dee2aaSAndroid Build Coastguard Worker GrDirectContext* asDirectContext() override { return this; } 942*c8dee2aaSAndroid Build Coastguard Worker 943*c8dee2aaSAndroid Build Coastguard Worker private: 944*c8dee2aaSAndroid Build Coastguard Worker // This call will make sure out work on the GPU is finished and will execute any outstanding 945*c8dee2aaSAndroid Build Coastguard Worker // asynchronous work (e.g. calling finished procs, freeing resources, etc.) related to the 946*c8dee2aaSAndroid Build Coastguard Worker // outstanding work on the gpu. The main use currently for this function is when tearing down or 947*c8dee2aaSAndroid Build Coastguard Worker // abandoning the context. 948*c8dee2aaSAndroid Build Coastguard Worker // 949*c8dee2aaSAndroid Build Coastguard Worker // When we finish up work on the GPU it could trigger callbacks to the client. In the case we 950*c8dee2aaSAndroid Build Coastguard Worker // are abandoning the context we don't want the client to be able to use the GrDirectContext to 951*c8dee2aaSAndroid Build Coastguard Worker // issue more commands during the callback. Thus before calling this function we set the 952*c8dee2aaSAndroid Build Coastguard Worker // GrDirectContext's state to be abandoned. However, we need to be able to get by the abaonded 953*c8dee2aaSAndroid Build Coastguard Worker // check in the call to know that it is safe to execute this. The shouldExecuteWhileAbandoned 954*c8dee2aaSAndroid Build Coastguard Worker // bool is used for this signal. 955*c8dee2aaSAndroid Build Coastguard Worker void syncAllOutstandingGpuWork(bool shouldExecuteWhileAbandoned); 956*c8dee2aaSAndroid Build Coastguard Worker 957*c8dee2aaSAndroid Build Coastguard Worker // This delete callback needs to be the first thing on the GrDirectContext so that it is the 958*c8dee2aaSAndroid Build Coastguard Worker // last thing destroyed. The callback may signal the client to clean up things that may need 959*c8dee2aaSAndroid Build Coastguard Worker // to survive the lifetime of some of the other objects on the GrDirectCotnext. So make sure 960*c8dee2aaSAndroid Build Coastguard Worker // we don't call it until all else has been destroyed. 961*c8dee2aaSAndroid Build Coastguard Worker class DeleteCallbackHelper { 962*c8dee2aaSAndroid Build Coastguard Worker public: DeleteCallbackHelper(GrDirectContextDestroyedContext context,GrDirectContextDestroyedProc proc)963*c8dee2aaSAndroid Build Coastguard Worker DeleteCallbackHelper(GrDirectContextDestroyedContext context, 964*c8dee2aaSAndroid Build Coastguard Worker GrDirectContextDestroyedProc proc) 965*c8dee2aaSAndroid Build Coastguard Worker : fContext(context), fProc(proc) {} 966*c8dee2aaSAndroid Build Coastguard Worker ~DeleteCallbackHelper()967*c8dee2aaSAndroid Build Coastguard Worker ~DeleteCallbackHelper() { 968*c8dee2aaSAndroid Build Coastguard Worker if (fProc) { 969*c8dee2aaSAndroid Build Coastguard Worker fProc(fContext); 970*c8dee2aaSAndroid Build Coastguard Worker } 971*c8dee2aaSAndroid Build Coastguard Worker } 972*c8dee2aaSAndroid Build Coastguard Worker 973*c8dee2aaSAndroid Build Coastguard Worker private: 974*c8dee2aaSAndroid Build Coastguard Worker GrDirectContextDestroyedContext fContext; 975*c8dee2aaSAndroid Build Coastguard Worker GrDirectContextDestroyedProc fProc; 976*c8dee2aaSAndroid Build Coastguard Worker }; 977*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<DeleteCallbackHelper> fDeleteCallbackHelper; 978*c8dee2aaSAndroid Build Coastguard Worker 979*c8dee2aaSAndroid Build Coastguard Worker const DirectContextID fDirectContextID; 980*c8dee2aaSAndroid Build Coastguard Worker // fTaskGroup must appear before anything that uses it (e.g. fGpu), so that it is destroyed 981*c8dee2aaSAndroid Build Coastguard Worker // after all of its users. Clients of fTaskGroup will generally want to ensure that they call 982*c8dee2aaSAndroid Build Coastguard Worker // wait() on it as they are being destroyed, to avoid the possibility of pending tasks being 983*c8dee2aaSAndroid Build Coastguard Worker // invoked after objects they depend upon have already been destroyed. 984*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<SkTaskGroup> fTaskGroup; 985*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<sktext::gpu::StrikeCache> fStrikeCache; 986*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<GrGpu> fGpu; 987*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<GrResourceCache> fResourceCache; 988*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<GrResourceProvider> fResourceProvider; 989*c8dee2aaSAndroid Build Coastguard Worker 990*c8dee2aaSAndroid Build Coastguard Worker // This is incremented before we start calling ReleaseProcs from GrSurfaces and decremented 991*c8dee2aaSAndroid Build Coastguard Worker // after. A ReleaseProc may trigger code causing another resource to get freed so we to track 992*c8dee2aaSAndroid Build Coastguard Worker // the count to know if we in a ReleaseProc at any level. When this is set to a value greated 993*c8dee2aaSAndroid Build Coastguard Worker // than zero we will not allow abandonContext calls to be made on the context. 994*c8dee2aaSAndroid Build Coastguard Worker int fInsideReleaseProcCnt = 0; 995*c8dee2aaSAndroid Build Coastguard Worker 996*c8dee2aaSAndroid Build Coastguard Worker bool fDidTestPMConversions; 997*c8dee2aaSAndroid Build Coastguard Worker // true if the PM/UPM conversion succeeded; false otherwise 998*c8dee2aaSAndroid Build Coastguard Worker bool fPMUPMConversionsRoundTrip; 999*c8dee2aaSAndroid Build Coastguard Worker 1000*c8dee2aaSAndroid Build Coastguard Worker GrContextOptions::PersistentCache* fPersistentCache; 1001*c8dee2aaSAndroid Build Coastguard Worker 1002*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<GrClientMappedBufferManager> fMappedBufferManager; 1003*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<GrAtlasManager> fAtlasManager; 1004*c8dee2aaSAndroid Build Coastguard Worker 1005*c8dee2aaSAndroid Build Coastguard Worker #if !defined(SK_ENABLE_OPTIMIZE_SIZE) 1006*c8dee2aaSAndroid Build Coastguard Worker std::unique_ptr<skgpu::ganesh::SmallPathAtlasMgr> fSmallPathAtlasMgr; 1007*c8dee2aaSAndroid Build Coastguard Worker #endif 1008*c8dee2aaSAndroid Build Coastguard Worker 1009*c8dee2aaSAndroid Build Coastguard Worker friend class GrDirectContextPriv; 1010*c8dee2aaSAndroid Build Coastguard Worker }; 1011*c8dee2aaSAndroid Build Coastguard Worker 1012*c8dee2aaSAndroid Build Coastguard Worker 1013*c8dee2aaSAndroid Build Coastguard Worker #endif 1014