robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 GrSurfaceProxy_DEFINED |
| 9 | #define GrSurfaceProxy_DEFINED |
| 10 | |
Ben Wagner | d5148e3 | 2018-07-16 17:44:06 -0400 | [diff] [blame] | 11 | #include "../private/SkNoncopyable.h" |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 12 | #include "GrBackendSurface.h" |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 13 | #include "GrGpuResource.h" |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 14 | #include "GrSurface.h" |
Brian Salomon | b6a3a3b | 2019-04-01 12:29:34 -0400 | [diff] [blame] | 15 | #include "GrTexture.h" |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 16 | #include "SkRect.h" |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 17 | |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 18 | class GrCaps; |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 19 | class GrContext_Base; |
Robert Phillips | c589b0b | 2017-04-17 07:53:07 -0400 | [diff] [blame] | 20 | class GrOpList; |
Robert Phillips | d44146b | 2019-02-15 14:44:28 -0500 | [diff] [blame] | 21 | class GrRecordingContext; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 22 | class GrRenderTargetOpList; |
| 23 | class GrRenderTargetProxy; |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 24 | class GrResourceProvider; |
Robert Phillips | d46697a | 2017-01-25 12:10:37 -0500 | [diff] [blame] | 25 | class GrSurfaceContext; |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 26 | class GrSurfaceProxyPriv; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 27 | class GrTextureOpList; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 28 | class GrTextureProxy; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 29 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 30 | // This class replicates the functionality GrIORef<GrSurface> but tracks the |
| 31 | // utilitization for later resource allocation (for the deferred case) and |
| 32 | // forwards on the utilization in the wrapped case |
| 33 | class GrIORefProxy : public SkNoncopyable { |
| 34 | public: |
| 35 | void ref() const { |
| 36 | this->validate(); |
| 37 | |
| 38 | ++fRefCnt; |
| 39 | if (fTarget) { |
| 40 | fTarget->ref(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | void unref() const { |
| 45 | this->validate(); |
| 46 | |
| 47 | if (fTarget) { |
| 48 | fTarget->unref(); |
| 49 | } |
| 50 | |
Robert Phillips | b6deea8 | 2017-05-11 14:14:30 -0400 | [diff] [blame] | 51 | --fRefCnt; |
| 52 | this->didRemoveRefOrPendingIO(); |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 53 | } |
| 54 | |
Chris Dalton | a32a3c3 | 2017-12-05 10:05:21 -0700 | [diff] [blame] | 55 | #ifdef SK_DEBUG |
| 56 | bool isUnique_debugOnly() const { // For asserts. |
| 57 | SkASSERT(fRefCnt >= 0 && fPendingWrites >= 0 && fPendingReads >= 0); |
| 58 | return 1 == fRefCnt + fPendingWrites + fPendingReads; |
| 59 | } |
| 60 | #endif |
| 61 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 62 | void release() { |
Greg Daniel | 4684f82 | 2018-03-08 15:27:36 -0500 | [diff] [blame] | 63 | // The proxy itself may still have multiple refs. It can be owned by an SkImage and multiple |
| 64 | // SkDeferredDisplayLists at the same time if we are using DDLs. |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 65 | SkASSERT(0 == fPendingReads); |
| 66 | SkASSERT(0 == fPendingWrites); |
| 67 | |
Robert Phillips | e4aae34 | 2018-03-14 10:26:57 -0400 | [diff] [blame] | 68 | // In the current hybrid world, the proxy and backing surface are ref/unreffed in |
Brian Salomon | 0d60676 | 2019-01-25 09:58:38 -0500 | [diff] [blame] | 69 | // synchrony. Each ref we've added or removed to the proxy was mirrored to the backing |
| 70 | // surface. Though, that backing surface could be owned by other proxies as well. Remove |
| 71 | // a ref from the backing surface for each ref the proxy has since we are about to remove |
| 72 | // our pointer to the surface. If this proxy is reinstantiated then all the proxy's refs |
| 73 | // get transferred to the (possibly new) backing surface. |
| 74 | for (int refs = fRefCnt; refs; --refs) { |
Robert Phillips | e4aae34 | 2018-03-14 10:26:57 -0400 | [diff] [blame] | 75 | fTarget->unref(); |
| 76 | } |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 77 | fTarget = nullptr; |
| 78 | } |
| 79 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 80 | void validate() const { |
Robert Phillips | b6deea8 | 2017-05-11 14:14:30 -0400 | [diff] [blame] | 81 | #ifdef SK_DEBUG |
| 82 | SkASSERT(fRefCnt >= 0); |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 83 | SkASSERT(fPendingReads >= 0); |
| 84 | SkASSERT(fPendingWrites >= 0); |
| 85 | SkASSERT(fRefCnt + fPendingReads + fPendingWrites >= 1); |
| 86 | |
| 87 | if (fTarget) { |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 88 | // The backing GrSurface can have more refs than the proxy if the proxy |
| 89 | // started off wrapping an external resource (that came in with refs). |
| 90 | // The GrSurface should never have fewer refs than the proxy however. |
| 91 | SkASSERT(fTarget->fRefCnt >= fRefCnt); |
Robert Phillips | b6deea8 | 2017-05-11 14:14:30 -0400 | [diff] [blame] | 92 | SkASSERT(fTarget->fPendingReads >= fPendingReads); |
| 93 | SkASSERT(fTarget->fPendingWrites >= fPendingWrites); |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 94 | } |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 95 | #endif |
| 96 | } |
| 97 | |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 98 | int32_t getBackingRefCnt_TestOnly() const; |
| 99 | int32_t getPendingReadCnt_TestOnly() const; |
| 100 | int32_t getPendingWriteCnt_TestOnly() const; |
| 101 | |
Brian Salomon | cf75b00 | 2017-08-16 10:42:09 -0400 | [diff] [blame] | 102 | void addPendingRead() const { |
| 103 | this->validate(); |
| 104 | |
| 105 | ++fPendingReads; |
| 106 | if (fTarget) { |
| 107 | fTarget->addPendingRead(); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | void completedRead() const { |
| 112 | this->validate(); |
| 113 | |
| 114 | if (fTarget) { |
| 115 | fTarget->completedRead(); |
| 116 | } |
| 117 | |
| 118 | --fPendingReads; |
| 119 | this->didRemoveRefOrPendingIO(); |
| 120 | } |
| 121 | |
| 122 | void addPendingWrite() const { |
| 123 | this->validate(); |
| 124 | |
| 125 | ++fPendingWrites; |
| 126 | if (fTarget) { |
| 127 | fTarget->addPendingWrite(); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | void completedWrite() const { |
| 132 | this->validate(); |
| 133 | |
| 134 | if (fTarget) { |
| 135 | fTarget->completedWrite(); |
| 136 | } |
| 137 | |
| 138 | --fPendingWrites; |
| 139 | this->didRemoveRefOrPendingIO(); |
| 140 | } |
| 141 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 142 | protected: |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 143 | GrIORefProxy() : fTarget(nullptr), fRefCnt(1), fPendingReads(0), fPendingWrites(0) {} |
| 144 | GrIORefProxy(sk_sp<GrSurface> surface) : fRefCnt(1), fPendingReads(0), fPendingWrites(0) { |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 145 | // Since we're manually forwarding on refs & unrefs we don't want sk_sp doing |
| 146 | // anything extra. |
| 147 | fTarget = surface.release(); |
| 148 | } |
| 149 | virtual ~GrIORefProxy() { |
| 150 | // We don't unref 'fTarget' here since the 'unref' method will already |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 151 | // have forwarded on the unref call that got us here. |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 152 | } |
| 153 | |
Brian Salomon | 01ceae9 | 2019-04-02 11:49:54 -0400 | [diff] [blame] | 154 | // Privileged method that allows going from ref count = 0 to ref count = 1. |
Brian Salomon | 2c791fc | 2019-04-02 11:52:03 -0400 | [diff] [blame^] | 155 | void addInitialRef(GrResourceCache* cache) const { |
Brian Salomon | 01ceae9 | 2019-04-02 11:49:54 -0400 | [diff] [blame] | 156 | this->validate(); |
| 157 | ++fRefCnt; |
| 158 | if (fTarget) { |
Brian Salomon | 2c791fc | 2019-04-02 11:52:03 -0400 | [diff] [blame^] | 159 | fTarget->proxyAccess().ref(cache); |
Brian Salomon | 01ceae9 | 2019-04-02 11:49:54 -0400 | [diff] [blame] | 160 | } |
| 161 | } |
| 162 | |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 163 | // This GrIORefProxy was deferred before but has just been instantiated. To |
| 164 | // make all the reffing & unreffing work out we now need to transfer any deferred |
| 165 | // refs & unrefs to the new GrSurface |
| 166 | void transferRefs() { |
| 167 | SkASSERT(fTarget); |
Brian Salomon | 2c791fc | 2019-04-02 11:52:03 -0400 | [diff] [blame^] | 168 | // Make sure we're going to take some ownership of our target. |
| 169 | SkASSERT(fRefCnt > 0 || fPendingReads > 0 || fPendingWrites > 0); |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 170 | |
Brian Salomon | 2c791fc | 2019-04-02 11:52:03 -0400 | [diff] [blame^] | 171 | // Transfer pending read/writes first so that if we decrement the target's ref cnt we don't |
| 172 | // cause a purge of the target. |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 173 | fTarget->fPendingReads += fPendingReads; |
| 174 | fTarget->fPendingWrites += fPendingWrites; |
Brian Salomon | 2c791fc | 2019-04-02 11:52:03 -0400 | [diff] [blame^] | 175 | SkASSERT(fTarget->fRefCnt > 0); |
| 176 | SkASSERT(fRefCnt >= 0); |
| 177 | // Don't xfer the proxy's creation ref. If we're going to subtract a ref do it via unref() |
| 178 | // so that proper cache notifications occur. |
| 179 | if (!fRefCnt) { |
| 180 | fTarget->unref(); |
| 181 | } else { |
| 182 | fTarget->fRefCnt += (fRefCnt - 1); |
| 183 | } |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 184 | } |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 185 | |
Robert Phillips | 715d08c | 2018-07-18 13:56:48 -0400 | [diff] [blame] | 186 | int32_t internalGetProxyRefCnt() const { |
| 187 | return fRefCnt; |
| 188 | } |
| 189 | |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 190 | bool internalHasPendingIO() const { |
| 191 | if (fTarget) { |
| 192 | return fTarget->internalHasPendingIO(); |
| 193 | } |
| 194 | |
| 195 | return SkToBool(fPendingWrites | fPendingReads); |
| 196 | } |
| 197 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 198 | bool internalHasPendingWrite() const { |
| 199 | if (fTarget) { |
| 200 | return fTarget->internalHasPendingWrite(); |
| 201 | } |
| 202 | |
| 203 | return SkToBool(fPendingWrites); |
| 204 | } |
| 205 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 206 | // For deferred proxies this will be null. For wrapped proxies it will point to the |
| 207 | // wrapped resource. |
| 208 | GrSurface* fTarget; |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 209 | |
| 210 | private: |
| 211 | // This class is used to manage conversion of refs to pending reads/writes. |
Brian Salomon | ee78396 | 2018-08-01 09:55:10 -0400 | [diff] [blame] | 212 | template <typename> friend class GrProxyRef; |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 213 | |
Robert Phillips | b6deea8 | 2017-05-11 14:14:30 -0400 | [diff] [blame] | 214 | void didRemoveRefOrPendingIO() const { |
| 215 | if (0 == fPendingReads && 0 == fPendingWrites && 0 == fRefCnt) { |
| 216 | delete this; |
| 217 | } |
robertphillips | 1125a03 | 2016-11-16 11:17:17 -0800 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | mutable int32_t fRefCnt; |
| 221 | mutable int32_t fPendingReads; |
| 222 | mutable int32_t fPendingWrites; |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | class GrSurfaceProxy : public GrIORefProxy { |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 226 | public: |
Brian Salomon | b6a3a3b | 2019-04-01 12:29:34 -0400 | [diff] [blame] | 227 | /** |
| 228 | * Some lazy proxy callbacks want to set their own (or no key) on the GrSurfaces they return. |
| 229 | * Others want the GrSurface's key to be kept in sync with the proxy's key. This enum controls |
| 230 | * the key relationship between proxies and their targets. |
| 231 | */ |
| 232 | enum class LazyInstantiationKeyMode { |
| 233 | /** |
| 234 | * Don't key the GrSurface with the proxy's key. The lazy instantiation callback is free to |
| 235 | * return a GrSurface that already has a unique key unrelated to the proxy's key. |
| 236 | */ |
| 237 | kUnsynced, |
| 238 | /** |
| 239 | * Keep the GrSurface's unique key in sync with the proxy's unique key. The GrSurface |
| 240 | * returned from the lazy instantiation callback must not have a unique key or have the same |
| 241 | * same unique key as the proxy. If the proxy is later assigned a key it is in turn assigned |
| 242 | * to the GrSurface. |
| 243 | */ |
| 244 | kSynced |
| 245 | }; |
| 246 | |
| 247 | struct LazyInstantiationResult { |
| 248 | LazyInstantiationResult() = default; |
| 249 | LazyInstantiationResult(const LazyInstantiationResult&) = default; |
| 250 | LazyInstantiationResult(LazyInstantiationResult&& that) = default; |
| 251 | LazyInstantiationResult(sk_sp<GrSurface> surf, |
| 252 | LazyInstantiationKeyMode mode = LazyInstantiationKeyMode::kSynced) |
| 253 | : fSurface(std::move(surf)), fKeyMode(mode) {} |
| 254 | LazyInstantiationResult(sk_sp<GrTexture> tex) |
| 255 | : LazyInstantiationResult(sk_sp<GrSurface>(std::move(tex))) {} |
| 256 | |
| 257 | LazyInstantiationResult& operator=(const LazyInstantiationResult&) = default; |
| 258 | LazyInstantiationResult& operator=(LazyInstantiationResult&&) = default; |
| 259 | |
| 260 | sk_sp<GrSurface> fSurface; |
| 261 | LazyInstantiationKeyMode fKeyMode = LazyInstantiationKeyMode::kSynced; |
| 262 | }; |
| 263 | |
| 264 | using LazyInstantiateCallback = std::function<LazyInstantiationResult(GrResourceProvider*)>; |
| 265 | |
Greg Daniel | 457469c | 2018-02-08 15:05:44 -0500 | [diff] [blame] | 266 | enum class LazyInstantiationType { |
Brian Salomon | 967df20 | 2018-12-07 11:15:53 -0500 | [diff] [blame] | 267 | kSingleUse, // Instantiation callback is allowed to be called only once. |
| 268 | kMultipleUse, // Instantiation callback can be called multiple times. |
Brian Salomon | 876a017 | 2019-03-08 11:12:14 -0500 | [diff] [blame] | 269 | kDeinstantiate, // Instantiation callback can be called multiple times, |
| 270 | // but we will deinstantiate the proxy after every flush. |
Greg Daniel | 457469c | 2018-02-08 15:05:44 -0500 | [diff] [blame] | 271 | }; |
| 272 | |
Greg Daniel | 65fa8ca | 2018-01-10 17:06:31 -0500 | [diff] [blame] | 273 | enum class LazyState { |
Greg Daniel | 0a375db | 2018-02-01 12:21:39 -0500 | [diff] [blame] | 274 | kNot, // The proxy is instantiated or does not have a lazy callback |
Greg Daniel | 65fa8ca | 2018-01-10 17:06:31 -0500 | [diff] [blame] | 275 | kPartially, // The proxy has a lazy callback but knows basic information about itself. |
| 276 | kFully, // The proxy has a lazy callback and also doesn't know its width, height, etc. |
| 277 | }; |
| 278 | |
| 279 | LazyState lazyInstantiationState() const { |
Greg Daniel | 0a375db | 2018-02-01 12:21:39 -0500 | [diff] [blame] | 280 | if (fTarget || !SkToBool(fLazyInstantiateCallback)) { |
Greg Daniel | 65fa8ca | 2018-01-10 17:06:31 -0500 | [diff] [blame] | 281 | return LazyState::kNot; |
| 282 | } else { |
| 283 | if (fWidth <= 0) { |
| 284 | SkASSERT(fHeight <= 0); |
| 285 | return LazyState::kFully; |
| 286 | } else { |
| 287 | SkASSERT(fHeight > 0); |
| 288 | return LazyState::kPartially; |
| 289 | } |
| 290 | } |
| 291 | } |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 292 | |
| 293 | GrPixelConfig config() const { return fConfig; } |
Greg Daniel | 65fa8ca | 2018-01-10 17:06:31 -0500 | [diff] [blame] | 294 | int width() const { |
| 295 | SkASSERT(LazyState::kFully != this->lazyInstantiationState()); |
| 296 | return fWidth; |
| 297 | } |
| 298 | int height() const { |
| 299 | SkASSERT(LazyState::kFully != this->lazyInstantiationState()); |
| 300 | return fHeight; |
| 301 | } |
Brian Salomon | 7eae3e0 | 2018-08-07 14:02:38 +0000 | [diff] [blame] | 302 | |
| 303 | SkISize isize() const { return {fWidth, fHeight}; } |
| 304 | |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 305 | int worstCaseWidth() const; |
| 306 | int worstCaseHeight() const; |
Brian Salomon | d8eb7b6 | 2018-05-25 10:08:05 -0400 | [diff] [blame] | 307 | /** |
| 308 | * Helper that gets the width and height of the surface as a bounding rectangle. |
| 309 | */ |
| 310 | SkRect getBoundsRect() const { |
| 311 | SkASSERT(LazyState::kFully != this->lazyInstantiationState()); |
| 312 | return SkRect::MakeIWH(this->width(), this->height()); |
| 313 | } |
| 314 | /** |
| 315 | * Helper that gets the worst case width and height of the surface as a bounding rectangle. |
| 316 | */ |
| 317 | SkRect getWorstCaseBoundsRect() const { |
| 318 | SkASSERT(LazyState::kFully != this->lazyInstantiationState()); |
| 319 | return SkRect::MakeIWH(this->worstCaseWidth(), this->worstCaseHeight()); |
| 320 | } |
| 321 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 322 | GrSurfaceOrigin origin() const { |
Brian Salomon | bb5711a | 2017-05-17 13:49:59 -0400 | [diff] [blame] | 323 | SkASSERT(kTopLeft_GrSurfaceOrigin == fOrigin || kBottomLeft_GrSurfaceOrigin == fOrigin); |
| 324 | return fOrigin; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 325 | } |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 326 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 327 | const GrBackendFormat& backendFormat() const { return fFormat; } |
| 328 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 329 | class UniqueID { |
| 330 | public: |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 331 | static UniqueID InvalidID() { |
| 332 | return UniqueID(uint32_t(SK_InvalidUniqueID)); |
| 333 | } |
| 334 | |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 335 | // wrapped |
| 336 | explicit UniqueID(const GrGpuResource::UniqueID& id) : fID(id.asUInt()) { } |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 337 | // deferred and lazy-callback |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 338 | UniqueID() : fID(GrGpuResource::CreateUniqueID()) { } |
| 339 | |
| 340 | uint32_t asUInt() const { return fID; } |
| 341 | |
| 342 | bool operator==(const UniqueID& other) const { |
| 343 | return fID == other.fID; |
| 344 | } |
| 345 | bool operator!=(const UniqueID& other) const { |
| 346 | return !(*this == other); |
| 347 | } |
| 348 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 349 | void makeInvalid() { fID = SK_InvalidUniqueID; } |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 350 | bool isInvalid() const { return SK_InvalidUniqueID == fID; } |
| 351 | |
| 352 | private: |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 353 | explicit UniqueID(uint32_t id) : fID(id) {} |
| 354 | |
| 355 | uint32_t fID; |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | /* |
| 359 | * The contract for the uniqueID is: |
| 360 | * for wrapped resources: |
| 361 | * the uniqueID will match that of the wrapped resource |
| 362 | * |
| 363 | * for deferred resources: |
| 364 | * the uniqueID will be different from the real resource, when it is allocated |
| 365 | * the proxy's uniqueID will not change across the instantiate call |
| 366 | * |
| 367 | * the uniqueIDs of the proxies and the resources draw from the same pool |
| 368 | * |
| 369 | * What this boils down to is that the uniqueID of a proxy can be used to consistently |
| 370 | * track/identify a proxy but should never be used to distinguish between |
| 371 | * resources and proxies - beware! |
| 372 | */ |
| 373 | UniqueID uniqueID() const { return fUniqueID; } |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 374 | |
Robert Phillips | 159e3c6 | 2017-06-19 12:02:00 -0400 | [diff] [blame] | 375 | UniqueID underlyingUniqueID() const { |
| 376 | if (fTarget) { |
| 377 | return UniqueID(fTarget->uniqueID()); |
| 378 | } |
| 379 | |
| 380 | return fUniqueID; |
| 381 | } |
| 382 | |
Robert Phillips | 73cc4e8 | 2019-04-01 07:46:13 -0400 | [diff] [blame] | 383 | virtual bool instantiate(GrResourceProvider* resourceProvider, |
| 384 | bool dontForceNoPendingIO = false) = 0; |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 385 | |
Brian Salomon | 967df20 | 2018-12-07 11:15:53 -0500 | [diff] [blame] | 386 | void deinstantiate(); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 387 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 388 | /** |
Brian Salomon | 7d94bb5 | 2018-10-12 14:37:19 -0400 | [diff] [blame] | 389 | * Proxies that are already instantiated and whose backing surface cannot be recycled to |
| 390 | * instantiate other proxies do not need to be considered by GrResourceAllocator. |
| 391 | */ |
| 392 | bool canSkipResourceAllocator() const; |
| 393 | |
| 394 | /** |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 395 | * @return the texture proxy associated with the surface proxy, may be NULL. |
| 396 | */ |
| 397 | virtual GrTextureProxy* asTextureProxy() { return nullptr; } |
| 398 | virtual const GrTextureProxy* asTextureProxy() const { return nullptr; } |
| 399 | |
| 400 | /** |
| 401 | * @return the render target proxy associated with the surface proxy, may be NULL. |
| 402 | */ |
| 403 | virtual GrRenderTargetProxy* asRenderTargetProxy() { return nullptr; } |
| 404 | virtual const GrRenderTargetProxy* asRenderTargetProxy() const { return nullptr; } |
| 405 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 406 | bool isInstantiated() const { return SkToBool(fTarget); } |
| 407 | |
| 408 | // If the proxy is already instantiated, return its backing GrTexture; if not, return null. |
| 409 | GrSurface* peekSurface() const { return fTarget; } |
| 410 | |
| 411 | // If this is a texture proxy and the proxy is already instantiated, return its backing |
| 412 | // GrTexture; if not, return null. |
| 413 | GrTexture* peekTexture() const { return fTarget ? fTarget->asTexture() : nullptr; } |
| 414 | |
| 415 | // If this is a render target proxy and the proxy is already instantiated, return its backing |
| 416 | // GrRenderTarget; if not, return null. |
| 417 | GrRenderTarget* peekRenderTarget() const { |
| 418 | return fTarget ? fTarget->asRenderTarget() : nullptr; |
| 419 | } |
| 420 | |
robertphillips | 13a7eee | 2016-08-31 15:06:24 -0700 | [diff] [blame] | 421 | /** |
| 422 | * Does the resource count against the resource budget? |
| 423 | */ |
| 424 | SkBudgeted isBudgeted() const { return fBudgeted; } |
| 425 | |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 426 | /** |
| 427 | * The pixel values of this proxy's surface cannot be modified (e.g. doesn't support write |
Brian Salomon | 9cadc31 | 2018-12-05 15:09:19 -0500 | [diff] [blame] | 428 | * pixels or MIP map level regen). Read-only proxies also bypass interval tracking and |
| 429 | * assignment in GrResourceAllocator. |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 430 | */ |
| 431 | bool readOnly() const { return fSurfaceFlags & GrInternalSurfaceFlags::kReadOnly; } |
| 432 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 433 | void setLastOpList(GrOpList* opList); |
| 434 | GrOpList* getLastOpList() { return fLastOpList; } |
| 435 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 436 | GrRenderTargetOpList* getLastRenderTargetOpList(); |
| 437 | GrTextureOpList* getLastTextureOpList(); |
| 438 | |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 439 | /** |
Robert Phillips | f5442bb | 2017-04-17 14:18:34 -0400 | [diff] [blame] | 440 | * Retrieves the amount of GPU memory that will be or currently is used by this resource |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 441 | * in bytes. It is approximate since we aren't aware of additional padding or copies made |
| 442 | * by the driver. |
| 443 | * |
| 444 | * @return the amount of GPU memory used in bytes |
| 445 | */ |
| 446 | size_t gpuMemorySize() const { |
Greg Daniel | 65fa8ca | 2018-01-10 17:06:31 -0500 | [diff] [blame] | 447 | SkASSERT(LazyState::kFully != this->lazyInstantiationState()); |
Brian Salomon | bb5711a | 2017-05-17 13:49:59 -0400 | [diff] [blame] | 448 | if (fTarget) { |
| 449 | return fTarget->gpuMemorySize(); |
| 450 | } |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 451 | if (kInvalidGpuMemorySize == fGpuMemorySize) { |
Brian Salomon | bb5711a | 2017-05-17 13:49:59 -0400 | [diff] [blame] | 452 | fGpuMemorySize = this->onUninstantiatedGpuMemorySize(); |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 453 | SkASSERT(kInvalidGpuMemorySize != fGpuMemorySize); |
| 454 | } |
| 455 | return fGpuMemorySize; |
| 456 | } |
| 457 | |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 458 | // Helper function that creates a temporary SurfaceContext to perform the copy |
Brian Salomon | fee3f9b | 2018-12-19 12:34:12 -0500 | [diff] [blame] | 459 | // The copy is is not a render target and not multisampled. |
Robert Phillips | d44146b | 2019-02-15 14:44:28 -0500 | [diff] [blame] | 460 | static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src, GrMipMapped, |
| 461 | SkIRect srcRect, SkBackingFit, SkBudgeted); |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 462 | |
| 463 | // Copy the entire 'src' |
Robert Phillips | d44146b | 2019-02-15 14:44:28 -0500 | [diff] [blame] | 464 | static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src, GrMipMapped, |
| 465 | SkBackingFit, SkBudgeted); |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 466 | |
| 467 | // Test-only entry point - should decrease in use as proxies propagate |
Robert Phillips | d44146b | 2019-02-15 14:44:28 -0500 | [diff] [blame] | 468 | static sk_sp<GrSurfaceContext> TestCopy(GrRecordingContext* context, |
| 469 | const GrSurfaceDesc& dstDesc, |
Brian Salomon | 2a4f983 | 2018-03-03 22:43:43 -0500 | [diff] [blame] | 470 | GrSurfaceOrigin, GrSurfaceProxy* srcProxy); |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 471 | |
Robert Phillips | eaa8625 | 2016-11-08 13:49:39 +0000 | [diff] [blame] | 472 | bool isWrapped_ForTesting() const; |
| 473 | |
Robert Phillips | 292a6b2 | 2019-02-14 14:49:02 -0500 | [diff] [blame] | 474 | SkDEBUGCODE(void validate(GrContext_Base*) const;) |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 475 | |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 476 | // Provides access to functions that aren't part of the public API. |
Robert Phillips | 420c4cf | 2017-09-28 09:00:45 -0400 | [diff] [blame] | 477 | inline GrSurfaceProxyPriv priv(); |
| 478 | inline const GrSurfaceProxyPriv priv() const; |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 479 | |
Brian Salomon | 01ceae9 | 2019-04-02 11:49:54 -0400 | [diff] [blame] | 480 | /** |
| 481 | * Provides privileged access to select callers to be able to add a ref to a GrSurfaceProxy |
| 482 | * with zero refs. |
| 483 | */ |
| 484 | class FirstRefAccess; |
| 485 | inline FirstRefAccess firstRefAccess(); |
| 486 | |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 487 | GrInternalSurfaceFlags testingOnly_getFlags() const; |
| 488 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 489 | protected: |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 490 | // Deferred version |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 491 | GrSurfaceProxy(const GrBackendFormat& format, const GrSurfaceDesc& desc, |
| 492 | GrSurfaceOrigin origin, SkBackingFit fit, |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 493 | SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags) |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 494 | : GrSurfaceProxy(nullptr, LazyInstantiationType::kSingleUse, format, desc, origin, fit, |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 495 | budgeted, surfaceFlags) { |
Robert Phillips | 294870f | 2016-11-11 12:38:40 -0500 | [diff] [blame] | 496 | // Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources |
robertphillips | 8abb370 | 2016-08-31 14:04:06 -0700 | [diff] [blame] | 497 | } |
| 498 | |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 499 | // Lazy-callback version |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 500 | GrSurfaceProxy(LazyInstantiateCallback&&, LazyInstantiationType, |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 501 | const GrBackendFormat& format, const GrSurfaceDesc&, GrSurfaceOrigin, |
| 502 | SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 503 | |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 504 | // Wrapped version. |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 505 | GrSurfaceProxy(sk_sp<GrSurface>, GrSurfaceOrigin, SkBackingFit); |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 506 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 507 | virtual ~GrSurfaceProxy(); |
| 508 | |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 509 | friend class GrSurfaceProxyPriv; |
| 510 | |
| 511 | // Methods made available via GrSurfaceProxyPriv |
Robert Phillips | 715d08c | 2018-07-18 13:56:48 -0400 | [diff] [blame] | 512 | int32_t getProxyRefCnt() const { |
| 513 | return this->internalGetProxyRefCnt(); |
| 514 | } |
| 515 | |
Robert Phillips | 757914d | 2017-01-25 15:48:30 -0500 | [diff] [blame] | 516 | bool hasPendingIO() const { |
| 517 | return this->internalHasPendingIO(); |
| 518 | } |
| 519 | |
Robert Phillips | 7ee385e | 2017-03-30 08:02:11 -0400 | [diff] [blame] | 520 | bool hasPendingWrite() const { |
| 521 | return this->internalHasPendingWrite(); |
| 522 | } |
| 523 | |
Robert Phillips | 57aa367 | 2017-07-21 11:38:13 -0400 | [diff] [blame] | 524 | void computeScratchKey(GrScratchKey*) const; |
| 525 | |
Robert Phillips | 5af44de | 2017-07-18 14:49:38 -0400 | [diff] [blame] | 526 | virtual sk_sp<GrSurface> createSurface(GrResourceProvider*) const = 0; |
| 527 | void assign(sk_sp<GrSurface> surface); |
| 528 | |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 529 | sk_sp<GrSurface> createSurfaceImpl(GrResourceProvider*, int sampleCnt, bool needsStencil, |
Robert Phillips | 73cc4e8 | 2019-04-01 07:46:13 -0400 | [diff] [blame] | 530 | GrSurfaceDescFlags, GrMipMapped, |
| 531 | bool forceNoPendingIO) const; |
Robert Phillips | 5af44de | 2017-07-18 14:49:38 -0400 | [diff] [blame] | 532 | |
Robert Phillips | 6504813 | 2017-08-10 08:44:49 -0400 | [diff] [blame] | 533 | bool instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt, bool needsStencil, |
Robert Phillips | 73cc4e8 | 2019-04-01 07:46:13 -0400 | [diff] [blame] | 534 | GrSurfaceDescFlags descFlags, GrMipMapped, const GrUniqueKey*, |
| 535 | bool dontForceNoPendingIO); |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 536 | |
Greg Daniel | e320486 | 2018-04-16 11:24:10 -0400 | [diff] [blame] | 537 | // In many cases these flags aren't actually known until the proxy has been instantiated. |
| 538 | // However, Ganesh frequently needs to change its behavior based on these settings. For |
| 539 | // internally create proxies we will know these properties ahead of time. For wrapped |
| 540 | // proxies we will copy the properties off of the GrSurface. For lazy proxies we force the |
| 541 | // call sites to provide the required information ahead of time. At instantiation time |
| 542 | // we verify that the assumed properties match the actual properties. |
| 543 | GrInternalSurfaceFlags fSurfaceFlags; |
| 544 | |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 545 | private: |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 546 | // For wrapped resources, 'fFormat', 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always |
| 547 | // be filled in from the wrapped resource. |
| 548 | GrBackendFormat fFormat; |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 549 | GrPixelConfig fConfig; |
| 550 | int fWidth; |
| 551 | int fHeight; |
| 552 | GrSurfaceOrigin fOrigin; |
| 553 | SkBackingFit fFit; // always kApprox for lazy-callback resources |
| 554 | // always kExact for wrapped resources |
| 555 | mutable SkBudgeted fBudgeted; // always kYes for lazy-callback resources |
| 556 | // set from the backing resource for wrapped resources |
| 557 | // mutable bc of SkSurface/SkImage wishy-washiness |
Robert Phillips | a4c41b3 | 2017-03-15 13:02:45 -0400 | [diff] [blame] | 558 | |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 559 | const UniqueID fUniqueID; // set from the backing resource for wrapped resources |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 560 | |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 561 | LazyInstantiateCallback fLazyInstantiateCallback; |
Greg Daniel | 457469c | 2018-02-08 15:05:44 -0500 | [diff] [blame] | 562 | // If this is set to kSingleuse, then after one call to fLazyInstantiateCallback we will cleanup |
| 563 | // the lazy callback and then delete it. This will allow for any refs and resources being held |
| 564 | // by the standard function to be released. This is specifically useful in non-dll cases where |
| 565 | // we make lazy proxies and instantiate them immediately. |
| 566 | // Note: This is ignored if fLazyInstantiateCallback is null. |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 567 | LazyInstantiationType fLazyInstantiationType; |
Greg Daniel | 849dce1 | 2018-04-24 14:32:53 -0400 | [diff] [blame] | 568 | |
| 569 | SkDEBUGCODE(void validateSurface(const GrSurface*);) |
| 570 | SkDEBUGCODE(virtual void onValidateSurface(const GrSurface*) = 0;) |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 571 | |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 572 | static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0); |
Robert Phillips | 29e52f1 | 2016-11-03 10:19:14 -0400 | [diff] [blame] | 573 | SkDEBUGCODE(size_t getRawGpuMemorySize_debugOnly() const { return fGpuMemorySize; }) |
| 574 | |
Brian Salomon | bb5711a | 2017-05-17 13:49:59 -0400 | [diff] [blame] | 575 | virtual size_t onUninstantiatedGpuMemorySize() const = 0; |
Robert Phillips | 29e52f1 | 2016-11-03 10:19:14 -0400 | [diff] [blame] | 576 | |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 577 | bool fNeedsClear; |
Brian Salomon | d17b4a6 | 2017-05-23 16:53:47 -0400 | [diff] [blame] | 578 | |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 579 | // This entry is lazily evaluated so, when the proxy wraps a resource, the resource |
| 580 | // will be called but, when the proxy is deferred, it will compute the answer itself. |
| 581 | // If the proxy computes its own answer that answer is checked (in debug mode) in |
| 582 | // the instantiation method. |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 583 | mutable size_t fGpuMemorySize; |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 584 | |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 585 | // The last opList that wrote to or is currently going to write to this surface |
Robert Phillips | b6deea8 | 2017-05-11 14:14:30 -0400 | [diff] [blame] | 586 | // The opList can be closed (e.g., no surface context is currently bound |
| 587 | // to this proxy). |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 588 | // This back-pointer is required so that we can add a dependancy between |
| 589 | // the opList used to create the current contents of this surface |
| 590 | // and the opList of a destination surface to which this one is being drawn or copied. |
Robert Phillips | 6cdc22c | 2017-05-11 16:29:14 -0400 | [diff] [blame] | 591 | // This pointer is unreffed. OpLists own a ref on their surface proxies. |
Robert Phillips | fe0253f | 2018-03-16 16:47:25 -0400 | [diff] [blame] | 592 | GrOpList* fLastOpList; |
Robert Phillips | f2361d2 | 2016-10-25 14:20:06 -0400 | [diff] [blame] | 593 | |
Robert Phillips | c7635fa | 2016-10-28 13:25:24 -0400 | [diff] [blame] | 594 | typedef GrIORefProxy INHERITED; |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 595 | }; |
| 596 | |
Brian Salomon | 01ceae9 | 2019-04-02 11:49:54 -0400 | [diff] [blame] | 597 | class GrSurfaceProxy::FirstRefAccess { |
| 598 | private: |
Brian Salomon | 2c791fc | 2019-04-02 11:52:03 -0400 | [diff] [blame^] | 599 | void ref(GrResourceCache* cache) { fProxy->addInitialRef(cache); } |
Brian Salomon | 01ceae9 | 2019-04-02 11:49:54 -0400 | [diff] [blame] | 600 | |
| 601 | FirstRefAccess(GrSurfaceProxy* proxy) : fProxy(proxy) {} |
| 602 | |
| 603 | // No taking addresses of this type. |
| 604 | const FirstRefAccess* operator&() const = delete; |
| 605 | FirstRefAccess* operator&() = delete; |
| 606 | |
| 607 | GrSurfaceProxy* fProxy; |
| 608 | |
| 609 | friend class GrSurfaceProxy; |
| 610 | friend class GrProxyProvider; |
| 611 | friend class GrDeinstantiateProxyTracker; |
| 612 | }; |
| 613 | |
| 614 | inline GrSurfaceProxy::FirstRefAccess GrSurfaceProxy::firstRefAccess() { |
| 615 | return FirstRefAccess(this); |
| 616 | } |
| 617 | |
robertphillips | 76948d4 | 2016-05-04 12:47:41 -0700 | [diff] [blame] | 618 | #endif |