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