Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrProxyProvider_DEFINED |
| 9 | #define GrProxyProvider_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/gpu/GrTypes.h" |
| 12 | #include "include/private/GrResourceKey.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/core/SkTDynamicHash.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 14 | #include "src/gpu/GrTextureProxy.h" |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 15 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 16 | class GrImageContext; |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 17 | class GrBackendRenderTarget; |
Greg Daniel | a4ead65 | 2018-02-07 10:21:48 -0500 | [diff] [blame] | 18 | class SkBitmap; |
Greg Daniel | 9d86f1d | 2018-01-29 09:33:59 -0500 | [diff] [blame] | 19 | class SkImage; |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 20 | |
| 21 | /* |
| 22 | * A factory for creating GrSurfaceProxy-derived objects. |
| 23 | */ |
| 24 | class GrProxyProvider { |
| 25 | public: |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 26 | using UseAllocator = GrSurfaceProxy::UseAllocator; |
| 27 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 28 | GrProxyProvider(GrImageContext*); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 29 | |
| 30 | ~GrProxyProvider(); |
| 31 | |
| 32 | /* |
| 33 | * Assigns a unique key to a proxy. The proxy will be findable via this key using |
| 34 | * findProxyByUniqueKey(). It is an error if an existing proxy already has a key. |
| 35 | */ |
Robert Phillips | adbe132 | 2018-01-17 13:35:46 -0500 | [diff] [blame] | 36 | bool assignUniqueKeyToProxy(const GrUniqueKey&, GrTextureProxy*); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 37 | |
| 38 | /* |
| 39 | * Sets the unique key of the provided proxy to the unique key of the surface. The surface must |
| 40 | * have a valid unique key. |
| 41 | */ |
| 42 | void adoptUniqueKeyFromSurface(GrTextureProxy* proxy, const GrSurface*); |
| 43 | |
| 44 | /* |
| 45 | * Removes a unique key from a proxy. If the proxy has already been instantiated, it will |
| 46 | * also remove the unique key from the target GrSurface. |
| 47 | */ |
Chris Dalton | 2de13dd | 2019-01-03 15:11:59 -0700 | [diff] [blame] | 48 | void removeUniqueKeyFromProxy(GrTextureProxy*); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * Finds a proxy by unique key. |
| 52 | */ |
| 53 | sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin); |
| 54 | |
| 55 | /* |
| 56 | * Finds a proxy by unique key or creates a new one that wraps a resource matching the unique |
Brian Salomon | 2af3e70 | 2019-08-11 19:10:31 -0400 | [diff] [blame] | 57 | * key. GrColorType is required to set the proxy's texture swizzle on creation. For any key, |
| 58 | * each call that might result in a cache hit must provide the same colorType as the call that |
| 59 | * caused a cache miss and created the proxy. |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 60 | */ |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 61 | sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, |
| 62 | GrColorType colorType, |
| 63 | GrSurfaceOrigin, |
| 64 | UseAllocator = UseAllocator::kYes); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 65 | |
| 66 | /* |
Greg Daniel | 9d86f1d | 2018-01-29 09:33:59 -0500 | [diff] [blame] | 67 | * Create an un-mipmapped texture proxy with data. The SkImage must be a raster backend image. |
| 68 | * Since the SkImage is ref counted, we simply take a ref on it to keep the data alive until we |
| 69 | * actually upload the data to the gpu. |
| 70 | */ |
Chris Dalton | d004e0b | 2018-09-27 09:28:03 -0600 | [diff] [blame] | 71 | sk_sp<GrTextureProxy> createTextureProxy( |
Brian Salomon | 96b383a | 2019-08-13 16:55:41 -0400 | [diff] [blame] | 72 | sk_sp<SkImage> srcImage, int sampleCnt, SkBudgeted, SkBackingFit, |
Chris Dalton | d004e0b | 2018-09-27 09:28:03 -0600 | [diff] [blame] | 73 | GrInternalSurfaceFlags = GrInternalSurfaceFlags::kNone); |
Greg Daniel | 9d86f1d | 2018-01-29 09:33:59 -0500 | [diff] [blame] | 74 | |
| 75 | /* |
Brian Osman | de49665 | 2019-03-22 13:42:33 -0400 | [diff] [blame] | 76 | * Creates a new texture proxy for the bitmap, optionally with mip levels generated by the cpu. |
Greg Daniel | a4ead65 | 2018-02-07 10:21:48 -0500 | [diff] [blame] | 77 | */ |
Brian Osman | de49665 | 2019-03-22 13:42:33 -0400 | [diff] [blame] | 78 | sk_sp<GrTextureProxy> createProxyFromBitmap(const SkBitmap& bitmap, GrMipMapped); |
Greg Daniel | a4ead65 | 2018-02-07 10:21:48 -0500 | [diff] [blame] | 79 | |
| 80 | /* |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 81 | * Create a GrSurfaceProxy without any data. |
| 82 | */ |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 83 | sk_sp<GrTextureProxy> createProxy(const GrBackendFormat&, |
| 84 | const GrSurfaceDesc&, |
| 85 | GrRenderable, |
| 86 | int renderTargetSampleCnt, |
| 87 | GrSurfaceOrigin, |
| 88 | GrMipMapped, |
| 89 | SkBackingFit, |
| 90 | SkBudgeted, |
| 91 | GrProtected, |
| 92 | GrInternalSurfaceFlags = GrInternalSurfaceFlags::kNone, |
| 93 | UseAllocator useAllocator = UseAllocator::kYes); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 94 | |
Jim Van Verth | ee06b33 | 2019-01-18 10:36:32 -0500 | [diff] [blame] | 95 | /* |
Brian Salomon | bb8dde8 | 2019-06-27 10:52:13 -0400 | [diff] [blame] | 96 | * Create a texture proxy from compressed texture data. |
Jim Van Verth | ee06b33 | 2019-01-18 10:36:32 -0500 | [diff] [blame] | 97 | */ |
Brian Salomon | bb8dde8 | 2019-06-27 10:52:13 -0400 | [diff] [blame] | 98 | sk_sp<GrTextureProxy> createCompressedTextureProxy(int width, int height, SkBudgeted budgeted, |
| 99 | SkImage::CompressionType compressionType, |
| 100 | sk_sp<SkData> data); |
Jim Van Verth | ee06b33 | 2019-01-18 10:36:32 -0500 | [diff] [blame] | 101 | |
Robert Phillips | adbe132 | 2018-01-17 13:35:46 -0500 | [diff] [blame] | 102 | // These match the definitions in SkImage & GrTexture.h, for whence they came |
| 103 | typedef void* ReleaseContext; |
| 104 | typedef void (*ReleaseProc)(ReleaseContext); |
| 105 | |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 106 | /* |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 107 | * Create a texture proxy that wraps a (non-renderable) backend texture. GrIOType must be |
| 108 | * kRead or kRW. |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 109 | */ |
Robert Phillips | c80b0e9 | 2019-07-23 10:27:09 -0400 | [diff] [blame] | 110 | sk_sp<GrTextureProxy> wrapBackendTexture(const GrBackendTexture&, GrColorType, GrSurfaceOrigin, |
Brian Salomon | aa6ca0a | 2019-01-24 16:03:07 -0500 | [diff] [blame] | 111 | GrWrapOwnership, GrWrapCacheable, GrIOType, |
| 112 | ReleaseProc = nullptr, ReleaseContext = nullptr); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 113 | |
| 114 | /* |
| 115 | * Create a texture proxy that wraps a backend texture and is both texture-able and renderable |
| 116 | */ |
Brian Salomon | aa6ca0a | 2019-01-24 16:03:07 -0500 | [diff] [blame] | 117 | sk_sp<GrTextureProxy> wrapRenderableBackendTexture(const GrBackendTexture&, GrSurfaceOrigin, |
Robert Phillips | 0902c98 | 2019-07-16 07:47:56 -0400 | [diff] [blame] | 118 | int sampleCnt, GrColorType, |
| 119 | GrWrapOwnership, GrWrapCacheable, |
| 120 | ReleaseProc = nullptr, |
Brian Salomon | 6c1205a | 2019-06-14 11:49:03 -0400 | [diff] [blame] | 121 | ReleaseContext = nullptr); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 122 | |
| 123 | /* |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 124 | * Create a render target proxy that wraps a backend render target |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 125 | */ |
Robert Phillips | c80b0e9 | 2019-07-23 10:27:09 -0400 | [diff] [blame] | 126 | sk_sp<GrSurfaceProxy> wrapBackendRenderTarget(const GrBackendRenderTarget&, GrColorType, |
| 127 | GrSurfaceOrigin, |
Brian Salomon | 6c1205a | 2019-06-14 11:49:03 -0400 | [diff] [blame] | 128 | ReleaseProc = nullptr, ReleaseContext = nullptr); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 129 | |
| 130 | /* |
Brian Salomon | 7578f3e | 2018-03-07 14:39:54 -0500 | [diff] [blame] | 131 | * Create a render target proxy that wraps a backend texture |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 132 | */ |
Robert Phillips | c80b0e9 | 2019-07-23 10:27:09 -0400 | [diff] [blame] | 133 | sk_sp<GrSurfaceProxy> wrapBackendTextureAsRenderTarget(const GrBackendTexture&, |
| 134 | GrColorType, |
| 135 | GrSurfaceOrigin, |
Brian Salomon | 7578f3e | 2018-03-07 14:39:54 -0500 | [diff] [blame] | 136 | int sampleCnt); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 137 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 138 | sk_sp<GrRenderTargetProxy> wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&, |
| 139 | const GrVkDrawableInfo&); |
| 140 | |
Brian Salomon | b6a3a3b | 2019-04-01 12:29:34 -0400 | [diff] [blame] | 141 | using LazyInstantiationKeyMode = GrSurfaceProxy::LazyInstantiationKeyMode; |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 142 | using LazyCallbackResult = GrSurfaceProxy::LazyCallbackResult; |
Brian Salomon | b6a3a3b | 2019-04-01 12:29:34 -0400 | [diff] [blame] | 143 | using LazyInstantiateCallback = GrSurfaceProxy::LazyInstantiateCallback; |
Robert Phillips | e8fabb2 | 2018-02-04 14:33:21 -0500 | [diff] [blame] | 144 | |
Brian Salomon | 7226c23 | 2018-07-30 13:13:17 -0400 | [diff] [blame] | 145 | struct TextureInfo { |
| 146 | GrMipMapped fMipMapped; |
| 147 | GrTextureType fTextureType; |
| 148 | }; |
| 149 | |
Robert Phillips | 777707b | 2018-01-17 11:40:14 -0500 | [diff] [blame] | 150 | /** |
| 151 | * Creates a texture proxy that will be instantiated by a user-supplied callback during flush. |
| 152 | * (Stencil is not supported by this method.) The width and height must either both be greater |
| 153 | * than 0 or both less than or equal to zero. A non-positive value is a signal that the width |
| 154 | * and height are currently unknown. |
| 155 | * |
| 156 | * When called, the callback must be able to cleanup any resources that it captured at creation. |
| 157 | * It also must support being passed in a null GrResourceProvider. When this happens, the |
| 158 | * callback should cleanup any resources it captured and return an empty sk_sp<GrTextureProxy>. |
| 159 | */ |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 160 | sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, |
| 161 | const GrBackendFormat&, |
| 162 | const GrSurfaceDesc&, |
| 163 | GrRenderable, |
| 164 | int renderTargetSampleCnt, |
| 165 | GrSurfaceOrigin, |
| 166 | GrMipMapped, |
| 167 | GrMipMapsStatus, |
| 168 | GrInternalSurfaceFlags, |
| 169 | SkBackingFit, |
| 170 | SkBudgeted, |
| 171 | GrProtected, |
| 172 | UseAllocator); |
Brian Salomon | 7226c23 | 2018-07-30 13:13:17 -0400 | [diff] [blame] | 173 | |
| 174 | /** A null TextureInfo indicates a non-textureable render target. */ |
Robert Phillips | e8fabb2 | 2018-02-04 14:33:21 -0500 | [diff] [blame] | 175 | sk_sp<GrRenderTargetProxy> createLazyRenderTargetProxy(LazyInstantiateCallback&&, |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 176 | const GrBackendFormat&, |
Greg Daniel | 2a30390 | 2018-02-20 10:25:54 -0500 | [diff] [blame] | 177 | const GrSurfaceDesc&, |
Brian Salomon | 27b4d8d | 2019-07-22 14:23:45 -0400 | [diff] [blame] | 178 | int renderTargetSampleCnt, |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 179 | GrSurfaceOrigin origin, |
Brian Salomon | 7226c23 | 2018-07-30 13:13:17 -0400 | [diff] [blame] | 180 | GrInternalSurfaceFlags, |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 181 | const TextureInfo*, |
| 182 | GrMipMapsStatus, |
| 183 | SkBackingFit, |
| 184 | SkBudgeted, |
| 185 | GrProtected, |
| 186 | bool wrapsVkSecondaryCB, |
| 187 | UseAllocator useAllocator); |
Robert Phillips | e8fabb2 | 2018-02-04 14:33:21 -0500 | [diff] [blame] | 188 | |
Chris Dalton | 4c458b1 | 2018-06-16 17:22:59 -0600 | [diff] [blame] | 189 | /** |
| 190 | * Fully lazy proxies have unspecified width and height. Methods that rely on those values |
| 191 | * (e.g., width, height, getBoundsRect) should be avoided. |
| 192 | */ |
Brian Salomon | e8a766b | 2019-07-19 14:24:36 -0400 | [diff] [blame] | 193 | static sk_sp<GrTextureProxy> MakeFullyLazyProxy(LazyInstantiateCallback&&, |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 194 | const GrBackendFormat&, |
| 195 | GrRenderable, |
| 196 | int renderTargetSampleCnt, |
| 197 | GrProtected, |
| 198 | GrSurfaceOrigin, |
| 199 | GrPixelConfig, |
| 200 | const GrCaps&, |
| 201 | UseAllocator); |
Chris Dalton | 4c458b1 | 2018-06-16 17:22:59 -0600 | [diff] [blame] | 202 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 203 | // 'proxy' is about to be used as a texture src or drawn to. This query can be used to |
| 204 | // determine if it is going to need a texture domain or a full clear. |
| 205 | static bool IsFunctionallyExact(GrSurfaceProxy* proxy); |
| 206 | |
Robert Phillips | 427966a | 2018-12-20 17:20:43 -0500 | [diff] [blame] | 207 | enum class InvalidateGPUResource : bool { kNo = false, kYes = true }; |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 208 | |
Robert Phillips | 427966a | 2018-12-20 17:20:43 -0500 | [diff] [blame] | 209 | /* |
| 210 | * This method ensures that, if a proxy w/ the supplied unique key exists, it is removed from |
| 211 | * the proxy provider's map and its unique key is removed. If 'invalidateSurface' is true, it |
| 212 | * will independently ensure that the unique key is removed from any GrGpuResources that may |
| 213 | * have it. |
| 214 | * |
| 215 | * If 'proxy' is provided (as an optimization to stop re-looking it up), its unique key must be |
| 216 | * valid and match the provided unique key. |
| 217 | * |
| 218 | * This method is called if either the proxy attached to the unique key is being deleted |
| 219 | * (in which case we don't want it cluttering up the hash table) or the client has indicated |
| 220 | * that it will never refer to the unique key again. |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 221 | */ |
Chris Dalton | 2de13dd | 2019-01-03 15:11:59 -0700 | [diff] [blame] | 222 | void processInvalidUniqueKey(const GrUniqueKey&, GrTextureProxy*, InvalidateGPUResource); |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 223 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 224 | // TODO: remove these entry points - it is a bit sloppy to be getting context info from here |
| 225 | uint32_t contextID() const; |
| 226 | const GrCaps* caps() const; |
| 227 | sk_sp<const GrCaps> refCaps() const; |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 228 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 229 | int numUniqueKeyProxies_TestOnly() const; |
| 230 | |
Robert Phillips | 0790f8a | 2018-09-18 13:11:03 -0400 | [diff] [blame] | 231 | // This is called on a DDL's proxyprovider when the DDL is finished. The uniquely keyed |
| 232 | // proxies need to keep their unique key but cannot hold on to the proxy provider unique |
| 233 | // pointer. |
| 234 | void orphanAllUniqueKeys(); |
| 235 | // This is only used by GrContext::releaseResourcesAndAbandonContext() |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 236 | void removeAllUniqueKeys(); |
| 237 | |
Greg Daniel | 7e1912a | 2018-02-08 09:15:33 -0500 | [diff] [blame] | 238 | /** |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 239 | * Does the proxy provider have access to a GrDirectContext? If so, proxies will be |
| 240 | * instantiated immediately. |
Greg Daniel | 7e1912a | 2018-02-08 09:15:33 -0500 | [diff] [blame] | 241 | */ |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 242 | bool renderingDirectly() const; |
Greg Daniel | 7e1912a | 2018-02-08 09:15:33 -0500 | [diff] [blame] | 243 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 244 | #if GR_TEST_UTILS |
Chris Dalton | d004e0b | 2018-09-27 09:28:03 -0600 | [diff] [blame] | 245 | /* |
| 246 | * Create a texture proxy that is backed by an instantiated GrSurface. |
Brian Salomon | 4eb38b7 | 2019-08-05 12:58:39 -0400 | [diff] [blame] | 247 | * TODO: Remove GrColorType. Currently used to infer a GrPixelConfig. |
Chris Dalton | d004e0b | 2018-09-27 09:28:03 -0600 | [diff] [blame] | 248 | */ |
Brian Salomon | 4eb38b7 | 2019-08-05 12:58:39 -0400 | [diff] [blame] | 249 | sk_sp<GrTextureProxy> testingOnly_createInstantiatedProxy(const SkISize& size, |
| 250 | GrColorType colorType, |
| 251 | const GrBackendFormat& format, |
| 252 | GrRenderable renderable, |
Brian Salomon | 27b4d8d | 2019-07-22 14:23:45 -0400 | [diff] [blame] | 253 | int renderTargetSampleCnt, |
Brian Salomon | 4eb38b7 | 2019-08-05 12:58:39 -0400 | [diff] [blame] | 254 | GrSurfaceOrigin origin, |
| 255 | SkBackingFit fit, |
| 256 | SkBudgeted budgeted, |
| 257 | GrProtected isProtected); |
| 258 | |
| 259 | /** Version of above that picks the default format for the color type. */ |
| 260 | sk_sp<GrTextureProxy> testingOnly_createInstantiatedProxy(const SkISize& size, |
| 261 | GrColorType colorType, |
| 262 | GrRenderable renderable, |
| 263 | int renderTargetSampleCnt, |
| 264 | GrSurfaceOrigin origin, |
| 265 | SkBackingFit fit, |
| 266 | SkBudgeted budgeted, |
| 267 | GrProtected isProtected); |
| 268 | |
Brian Salomon | 2af3e70 | 2019-08-11 19:10:31 -0400 | [diff] [blame] | 269 | sk_sp<GrTextureProxy> testingOnly_createWrapped(sk_sp<GrTexture>, GrColorType, GrSurfaceOrigin); |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 270 | #endif |
Chris Dalton | d004e0b | 2018-09-27 09:28:03 -0600 | [diff] [blame] | 271 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 272 | private: |
Robert Phillips | adbe132 | 2018-01-17 13:35:46 -0500 | [diff] [blame] | 273 | friend class GrAHardwareBufferImageGenerator; // for createWrapped |
Chris Dalton | d004e0b | 2018-09-27 09:28:03 -0600 | [diff] [blame] | 274 | friend class GrResourceProvider; // for createWrapped |
Robert Phillips | adbe132 | 2018-01-17 13:35:46 -0500 | [diff] [blame] | 275 | |
Robert Phillips | a9162df | 2019-02-11 14:12:03 -0500 | [diff] [blame] | 276 | bool isAbandoned() const; |
| 277 | |
Brian Salomon | 2af3e70 | 2019-08-11 19:10:31 -0400 | [diff] [blame] | 278 | // GrColorType is used to determine the proxy's texture swizzle. |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 279 | sk_sp<GrTextureProxy> createWrapped(sk_sp<GrTexture> tex, GrColorType, GrSurfaceOrigin origin, |
| 280 | UseAllocator useAllocator); |
Robert Phillips | adbe132 | 2018-01-17 13:35:46 -0500 | [diff] [blame] | 281 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 282 | struct UniquelyKeyedProxyHashTraits { |
| 283 | static const GrUniqueKey& GetKey(const GrTextureProxy& p) { return p.getUniqueKey(); } |
| 284 | |
| 285 | static uint32_t Hash(const GrUniqueKey& key) { return key.hash(); } |
| 286 | }; |
| 287 | typedef SkTDynamicHash<GrTextureProxy, GrUniqueKey, UniquelyKeyedProxyHashTraits> UniquelyKeyedProxyHash; |
| 288 | |
| 289 | // This holds the texture proxies that have unique keys. The resourceCache does not get a ref |
| 290 | // on these proxies but they must send a message to the resourceCache when they are deleted. |
| 291 | UniquelyKeyedProxyHash fUniquelyKeyedProxies; |
| 292 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 293 | GrImageContext* fImageContext; |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | #endif |