blob: 0a45d605d6c14e286d1d49e5c36501b893bc4e8a [file] [log] [blame]
Robert Phillips1afd4cd2018-01-08 13:40:32 -05001/*
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#include "GrProxyProvider.h"
9
10#include "GrCaps.h"
Robert Phillips0bd24dc2018-01-16 08:06:32 -050011#include "GrRenderTarget.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050012#include "GrResourceKey.h"
13#include "GrResourceProvider.h"
14#include "GrSurfaceProxy.h"
15#include "GrSurfaceProxyPriv.h"
16#include "GrTexture.h"
17#include "GrTextureProxyCacheAccess.h"
Robert Phillips0bd24dc2018-01-16 08:06:32 -050018#include "GrTextureRenderTargetProxy.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050019#include "../private/GrSingleOwner.h"
Brian Osmand29dcd12018-09-13 15:04:29 -040020#include "SkAutoPixmapStorage.h"
Greg Daniela4ead652018-02-07 10:21:48 -050021#include "SkBitmap.h"
Greg Daniel9d86f1d2018-01-29 09:33:59 -050022#include "SkGr.h"
23#include "SkImage.h"
24#include "SkImage_Base.h"
Greg Daniela4ead652018-02-07 10:21:48 -050025#include "SkImageInfoPriv.h"
26#include "SkImagePriv.h"
Robert Phillips0bd24dc2018-01-16 08:06:32 -050027#include "SkMipMap.h"
Greg Daniela4ead652018-02-07 10:21:48 -050028#include "SkTraceEvent.h"
Robert Phillips1afd4cd2018-01-08 13:40:32 -050029
30#define ASSERT_SINGLE_OWNER \
31 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
32
33GrProxyProvider::GrProxyProvider(GrResourceProvider* resourceProvider,
34 GrResourceCache* resourceCache,
35 sk_sp<const GrCaps> caps,
36 GrSingleOwner* owner)
37 : fResourceProvider(resourceProvider)
38 , fResourceCache(resourceCache)
Robert Phillips4d120512018-01-19 13:22:07 -050039 , fAbandoned(false)
Robert Phillips1afd4cd2018-01-08 13:40:32 -050040 , fCaps(caps)
Brian Salomon238069b2018-07-11 15:58:57 -040041 , fContextUniqueID(resourceCache->contextUniqueID())
Robert Phillips1afd4cd2018-01-08 13:40:32 -050042#ifdef SK_DEBUG
43 , fSingleOwner(owner)
44#endif
45{
Brian Salomon238069b2018-07-11 15:58:57 -040046 SkASSERT(fResourceProvider);
47 SkASSERT(fResourceCache);
48 SkASSERT(fCaps);
49 SkASSERT(fSingleOwner);
50}
Robert Phillips1afd4cd2018-01-08 13:40:32 -050051
Brian Salomon238069b2018-07-11 15:58:57 -040052GrProxyProvider::GrProxyProvider(uint32_t contextUniqueID,
53 sk_sp<const GrCaps> caps,
54 GrSingleOwner* owner)
55 : fResourceProvider(nullptr)
56 , fResourceCache(nullptr)
57 , fAbandoned(false)
58 , fCaps(caps)
59 , fContextUniqueID(contextUniqueID)
60#ifdef SK_DEBUG
61 , fSingleOwner(owner)
62#endif
63{
64 SkASSERT(fContextUniqueID != SK_InvalidUniqueID);
65 SkASSERT(fCaps);
66 SkASSERT(fSingleOwner);
Robert Phillips1afd4cd2018-01-08 13:40:32 -050067}
68
69GrProxyProvider::~GrProxyProvider() {
Robert Phillips0790f8a2018-09-18 13:11:03 -040070 if (fResourceCache) {
71 // In DDL-mode a proxy provider can still have extant uniquely keyed proxies (since
72 // they need their unique keys to, potentially, find a cached resource when the
73 // DDL is played) but, in non-DDL-mode they should all have been cleaned up by this point.
74 SkASSERT(!fUniquelyKeyedProxies.count());
75 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -050076}
77
Robert Phillipsadbe1322018-01-17 13:35:46 -050078bool GrProxyProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
Robert Phillips1afd4cd2018-01-08 13:40:32 -050079 ASSERT_SINGLE_OWNER
80 SkASSERT(key.isValid());
81 if (this->isAbandoned() || !proxy) {
Robert Phillipsadbe1322018-01-17 13:35:46 -050082 return false;
Robert Phillips1afd4cd2018-01-08 13:40:32 -050083 }
84
85 // If there is already a GrResource with this key then the caller has violated the normal
86 // usage pattern of uniquely keyed resources (e.g., they have created one w/o first seeing
87 // if it already existed in the cache).
Robert Phillipsd5f9cdd2018-01-31 09:29:48 -050088 SkASSERT(!fResourceCache || !fResourceCache->findAndRefUniqueResource(key));
Robert Phillips1afd4cd2018-01-08 13:40:32 -050089
Robert Phillips1afd4cd2018-01-08 13:40:32 -050090 SkASSERT(!fUniquelyKeyedProxies.find(key)); // multiple proxies can't get the same key
91
92 proxy->cacheAccess().setUniqueKey(this, key);
93 SkASSERT(proxy->getUniqueKey() == key);
94 fUniquelyKeyedProxies.add(proxy);
Robert Phillipsadbe1322018-01-17 13:35:46 -050095 return true;
Robert Phillips1afd4cd2018-01-08 13:40:32 -050096}
97
98void GrProxyProvider::adoptUniqueKeyFromSurface(GrTextureProxy* proxy, const GrSurface* surf) {
99 SkASSERT(surf->getUniqueKey().isValid());
100 proxy->cacheAccess().setUniqueKey(this, surf->getUniqueKey());
101 SkASSERT(proxy->getUniqueKey() == surf->getUniqueKey());
102 // multiple proxies can't get the same key
103 SkASSERT(!fUniquelyKeyedProxies.find(surf->getUniqueKey()));
104 fUniquelyKeyedProxies.add(proxy);
105}
106
107void GrProxyProvider::removeUniqueKeyFromProxy(const GrUniqueKey& key, GrTextureProxy* proxy) {
108 ASSERT_SINGLE_OWNER
109 if (this->isAbandoned() || !proxy) {
110 return;
111 }
Robert Phillips0790f8a2018-09-18 13:11:03 -0400112
Robert Phillips427966a2018-12-20 17:20:43 -0500113 this->processInvalidUniqueKey(key, proxy, GrProxyProvider::InvalidateGPUResource::kYes);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500114}
115
116sk_sp<GrTextureProxy> GrProxyProvider::findProxyByUniqueKey(const GrUniqueKey& key,
117 GrSurfaceOrigin origin) {
118 ASSERT_SINGLE_OWNER
119
120 if (this->isAbandoned()) {
121 return nullptr;
122 }
123
124 sk_sp<GrTextureProxy> result = sk_ref_sp(fUniquelyKeyedProxies.find(key));
125 if (result) {
126 SkASSERT(result->origin() == origin);
127 }
128 return result;
129}
130
Robert Phillipsadbe1322018-01-17 13:35:46 -0500131sk_sp<GrTextureProxy> GrProxyProvider::createWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) {
132#ifdef SK_DEBUG
133 if (tex->getUniqueKey().isValid()) {
134 SkASSERT(!this->findProxyByUniqueKey(tex->getUniqueKey(), origin));
135 }
136#endif
137
138 if (tex->asRenderTarget()) {
139 return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin));
140 } else {
141 return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin));
142 }
143}
144
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500145sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniqueKey& key,
146 GrSurfaceOrigin origin) {
147 ASSERT_SINGLE_OWNER
148
149 if (this->isAbandoned()) {
150 return nullptr;
151 }
152
153 sk_sp<GrTextureProxy> result = this->findProxyByUniqueKey(key, origin);
154 if (result) {
155 return result;
156 }
157
Robert Phillipsd5f9cdd2018-01-31 09:29:48 -0500158 if (!fResourceCache) {
159 return nullptr;
160 }
161
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500162 GrGpuResource* resource = fResourceCache->findAndRefUniqueResource(key);
163 if (!resource) {
164 return nullptr;
165 }
166
167 sk_sp<GrTexture> texture(static_cast<GrSurface*>(resource)->asTexture());
168 SkASSERT(texture);
169
Robert Phillipsadbe1322018-01-17 13:35:46 -0500170 result = this->createWrapped(std::move(texture), origin);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500171 SkASSERT(result->getUniqueKey() == key);
Robert Phillipsadbe1322018-01-17 13:35:46 -0500172 // createWrapped should've added this for us
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500173 SkASSERT(fUniquelyKeyedProxies.find(key));
174 return result;
175}
176
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500177sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImage,
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400178 GrSurfaceDescFlags descFlags,
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500179 int sampleCnt,
Greg Danielfb3abcd2018-02-02 15:48:33 -0500180 SkBudgeted budgeted,
Chris Daltond004e0b2018-09-27 09:28:03 -0600181 SkBackingFit fit,
182 GrInternalSurfaceFlags surfaceFlags) {
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500183 ASSERT_SINGLE_OWNER
184 SkASSERT(srcImage);
185
186 if (this->isAbandoned()) {
187 return nullptr;
188 }
189
Brian Osmand29dcd12018-09-13 15:04:29 -0400190 SkImageInfo info = as_IB(srcImage)->onImageInfo();
191 GrPixelConfig config = SkImageInfo2GrPixelConfig(info);
Greg Danielf87651e2018-02-21 11:36:53 -0500192
Greg Daniel0a7aa142018-02-21 13:02:32 -0500193 if (kUnknown_GrPixelConfig == config) {
194 return nullptr;
195 }
196
Greg Daniel4065d452018-11-16 15:43:41 -0500197 GrBackendFormat format = fCaps->getBackendFormatFromColorType(info.colorType());
198 if (!format.isValid()) {
199 return nullptr;
200 }
201
Brian Osmand29dcd12018-09-13 15:04:29 -0400202 if (!this->caps()->isConfigTexturable(config)) {
203 SkBitmap copy8888;
204 if (!copy8888.tryAllocPixels(info.makeColorType(kRGBA_8888_SkColorType)) ||
205 !srcImage->readPixels(copy8888.pixmap(), 0, 0)) {
206 return nullptr;
207 }
208 copy8888.setImmutable();
209 srcImage = SkMakeImageFromRasterBitmap(copy8888, kNever_SkCopyPixelsMode);
210 config = kRGBA_8888_GrPixelConfig;
211 }
212
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400213 if (SkToBool(descFlags & kRenderTarget_GrSurfaceFlag)) {
Greg Danielf87651e2018-02-21 11:36:53 -0500214 sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, config);
215 if (!sampleCnt) {
216 return nullptr;
217 }
218 }
219
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400220 if (SkToBool(descFlags & kRenderTarget_GrSurfaceFlag)) {
Greg Daniel2a303902018-02-20 10:25:54 -0500221 if (fCaps->usesMixedSamples() && sampleCnt > 1) {
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400222 surfaceFlags |= GrInternalSurfaceFlags::kMixedSampled;
Greg Daniel2a303902018-02-20 10:25:54 -0500223 }
Greg Daniel2a303902018-02-20 10:25:54 -0500224 }
225
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500226 GrSurfaceDesc desc;
227 desc.fWidth = srcImage->width();
228 desc.fHeight = srcImage->height();
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400229 desc.fFlags = descFlags;
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500230 desc.fSampleCnt = sampleCnt;
Greg Danielf87651e2018-02-21 11:36:53 -0500231 desc.fConfig = config;
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500232
233 sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
Chris Daltond004e0b2018-09-27 09:28:03 -0600234 [desc, budgeted, srcImage, fit, surfaceFlags](GrResourceProvider* resourceProvider) {
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500235 if (!resourceProvider) {
Greg Daniel0a375db2018-02-01 12:21:39 -0500236 // Nothing to clean up here. Once the proxy (and thus lambda) is deleted the ref
237 // on srcImage will be released.
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500238 return sk_sp<GrTexture>();
239 }
240 SkPixmap pixMap;
241 SkAssertResult(srcImage->peekPixels(&pixMap));
242 GrMipLevel mipLevel = { pixMap.addr(), pixMap.rowBytes() };
243
Chris Daltond004e0b2018-09-27 09:28:03 -0600244 auto resourceProviderFlags = GrResourceProvider::Flags::kNone;
245 if (surfaceFlags & GrInternalSurfaceFlags::kNoPendingIO) {
246 resourceProviderFlags |= GrResourceProvider::Flags::kNoPendingIO;
247 }
248 return resourceProvider->createTexture(desc, budgeted, fit, mipLevel,
249 resourceProviderFlags);
Brian Salomon2a4f9832018-03-03 22:43:43 -0500250 },
Greg Daniel4065d452018-11-16 15:43:41 -0500251 format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, surfaceFlags, fit, budgeted);
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500252
Greg Daniel92cbf3f2018-04-12 16:50:17 -0400253 if (!proxy) {
254 return nullptr;
255 }
256
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500257 if (fResourceProvider) {
258 // In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however
259 // we're better off instantiating the proxy immediately here.
260 if (!proxy->priv().doLazyInstantiation(fResourceProvider)) {
261 return nullptr;
262 }
263 }
Robert Phillipsc1b60662018-06-26 10:20:08 -0400264
265 SkASSERT(proxy->width() == desc.fWidth);
266 SkASSERT(proxy->height() == desc.fHeight);
Greg Daniel9d86f1d2018-01-29 09:33:59 -0500267 return proxy;
268}
269
Greg Daniel4065d452018-11-16 15:43:41 -0500270sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrBackendFormat& format,
271 const GrSurfaceDesc& desc,
Brian Salomon2a4f9832018-03-03 22:43:43 -0500272 GrSurfaceOrigin origin,
Greg Daniel30815082018-02-09 16:08:30 -0500273 SkBudgeted budgeted) {
Robert Phillips579f0942018-01-08 14:53:35 -0500274 ASSERT_SINGLE_OWNER
275
276 if (this->isAbandoned()) {
277 return nullptr;
278 }
279
Greg Daniel4065d452018-11-16 15:43:41 -0500280 return this->createProxy(format, desc, origin, GrMipMapped::kYes, SkBackingFit::kExact,
281 budgeted, GrInternalSurfaceFlags::kNone);
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500282}
283
Brian Osman2b23c4b2018-06-01 12:25:08 -0400284sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitmap& bitmap) {
285 if (!SkImageInfoIsValid(bitmap.info())) {
Greg Daniela4ead652018-02-07 10:21:48 -0500286 return nullptr;
287 }
288
Brian Osmanbc6b9cb2018-09-13 13:43:25 -0400289 ATRACE_ANDROID_FRAMEWORK("Upload MipMap Texture [%ux%u]", bitmap.width(), bitmap.height());
Greg Daniela4ead652018-02-07 10:21:48 -0500290
291 // In non-ddl we will always instantiate right away. Thus we never want to copy the SkBitmap
292 // even if its mutable. In ddl, if the bitmap is mutable then we must make a copy since the
293 // upload of the data to the gpu can happen at anytime and the bitmap may change by then.
Robert Phillips5c4b33b2018-03-20 16:23:08 -0400294 SkCopyPixelsMode copyMode = this->recordingDDL() ? kIfMutable_SkCopyPixelsMode
295 : kNever_SkCopyPixelsMode;
Greg Daniela4ead652018-02-07 10:21:48 -0500296 sk_sp<SkImage> baseLevel = SkMakeImageFromRasterBitmap(bitmap, copyMode);
Greg Daniela4ead652018-02-07 10:21:48 -0500297 if (!baseLevel) {
298 return nullptr;
299 }
300
Brian Osmanbc6b9cb2018-09-13 13:43:25 -0400301 // This was never going to have mips anyway
302 if (0 == SkMipMap::ComputeLevelCount(baseLevel->width(), baseLevel->height())) {
Brian Salomon58389b92018-03-07 13:01:25 -0500303 return this->createTextureProxy(baseLevel, kNone_GrSurfaceFlags, 1, SkBudgeted::kYes,
304 SkBackingFit::kExact);
Greg Daniela4ead652018-02-07 10:21:48 -0500305 }
306
Greg Daniel4065d452018-11-16 15:43:41 -0500307 const GrBackendFormat format = fCaps->getBackendFormatFromColorType(bitmap.info().colorType());
308 if (!format.isValid()) {
309 return nullptr;
310 }
311
Brian Osmand29dcd12018-09-13 15:04:29 -0400312 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info());
313 if (!this->caps()->isConfigTexturable(desc.fConfig)) {
314 SkBitmap copy8888;
315 if (!copy8888.tryAllocPixels(bitmap.info().makeColorType(kRGBA_8888_SkColorType)) ||
316 !bitmap.readPixels(copy8888.pixmap())) {
317 return nullptr;
318 }
319 copy8888.setImmutable();
320 baseLevel = SkMakeImageFromRasterBitmap(copy8888, kNever_SkCopyPixelsMode);
321 desc.fConfig = kRGBA_8888_GrPixelConfig;
322 }
323
324 SkPixmap pixmap;
325 SkAssertResult(baseLevel->peekPixels(&pixmap));
326 sk_sp<SkMipMap> mipmaps(SkMipMap::Build(pixmap, nullptr));
Brian Osmanbc6b9cb2018-09-13 13:43:25 -0400327 if (!mipmaps) {
328 return nullptr;
329 }
330
Greg Daniela4ead652018-02-07 10:21:48 -0500331 sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
Brian Osman1b97f132018-09-13 17:33:48 +0000332 [desc, baseLevel, mipmaps](GrResourceProvider* resourceProvider) {
Greg Daniela4ead652018-02-07 10:21:48 -0500333 if (!resourceProvider) {
334 return sk_sp<GrTexture>();
335 }
336
Brian Osman1b97f132018-09-13 17:33:48 +0000337 const int mipLevelCount = mipmaps->countLevels() + 1;
338 std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
339
Greg Daniela4ead652018-02-07 10:21:48 -0500340 SkPixmap pixmap;
341 SkAssertResult(baseLevel->peekPixels(&pixmap));
342
343 // DDL TODO: Instead of copying all this info into GrMipLevels we should just plumb
344 // the use of SkMipMap down through Ganesh.
345 texels[0].fPixels = pixmap.addr();
346 texels[0].fRowBytes = pixmap.rowBytes();
347
348 for (int i = 1; i < mipLevelCount; ++i) {
349 SkMipMap::Level generatedMipLevel;
350 mipmaps->getLevel(i - 1, &generatedMipLevel);
351 texels[i].fPixels = generatedMipLevel.fPixmap.addr();
352 texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
353 SkASSERT(texels[i].fPixels);
354 }
355
Brian Salomon58389b92018-03-07 13:01:25 -0500356 return resourceProvider->createTexture(desc, SkBudgeted::kYes, texels.get(),
Brian Osman2b23c4b2018-06-01 12:25:08 -0400357 mipLevelCount);
Brian Salomon2a4f9832018-03-03 22:43:43 -0500358 },
Greg Daniel4065d452018-11-16 15:43:41 -0500359 format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, SkBackingFit::kExact,
360 SkBudgeted::kYes);
Greg Daniela4ead652018-02-07 10:21:48 -0500361
Greg Daniel92cbf3f2018-04-12 16:50:17 -0400362 if (!proxy) {
363 return nullptr;
364 }
365
Greg Daniela4ead652018-02-07 10:21:48 -0500366 if (fResourceProvider) {
367 // In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however
368 // we're better off instantiating the proxy immediately here.
369 if (!proxy->priv().doLazyInstantiation(fResourceProvider)) {
370 return nullptr;
371 }
372 }
373 return proxy;
374}
375
Greg Daniel4065d452018-11-16 15:43:41 -0500376sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format,
377 const GrSurfaceDesc& desc,
Brian Salomon2a4f9832018-03-03 22:43:43 -0500378 GrSurfaceOrigin origin,
Greg Danielf6f7b672018-02-15 13:06:26 -0500379 GrMipMapped mipMapped,
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500380 SkBackingFit fit,
381 SkBudgeted budgeted,
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400382 GrInternalSurfaceFlags surfaceFlags) {
Greg Danielf6f7b672018-02-15 13:06:26 -0500383 if (GrMipMapped::kYes == mipMapped) {
384 // SkMipMap doesn't include the base level in the level count so we have to add 1
385 int mipCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1;
386 if (1 == mipCount) {
387 mipMapped = GrMipMapped::kNo;
388 }
389 }
390
391 if (!this->caps()->validateSurfaceDesc(desc, mipMapped)) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500392 return nullptr;
393 }
Brian Salomon3a2cc2c2018-02-03 00:25:12 +0000394 GrSurfaceDesc copyDesc = desc;
Brian Salomonbdecacf2018-02-02 20:32:49 -0500395 if (desc.fFlags & kRenderTarget_GrSurfaceFlag) {
396 copyDesc.fSampleCnt =
397 this->caps()->getRenderTargetSampleCount(desc.fSampleCnt, desc.fConfig);
398 }
Brian Salomon3a2cc2c2018-02-03 00:25:12 +0000399
Brian Salomonbdecacf2018-02-02 20:32:49 -0500400 if (copyDesc.fFlags & kRenderTarget_GrSurfaceFlag) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500401 // We know anything we instantiate later from this deferred path will be
402 // both texturable and renderable
Greg Daniel4065d452018-11-16 15:43:41 -0500403 return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*this->caps(), format, copyDesc,
404 origin, mipMapped,
Brian Salomon7226c232018-07-30 13:13:17 -0400405 fit, budgeted, surfaceFlags));
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500406 }
407
Greg Daniel4065d452018-11-16 15:43:41 -0500408 return sk_sp<GrTextureProxy>(new GrTextureProxy(format, copyDesc, origin, mipMapped,
Brian Salomon7226c232018-07-30 13:13:17 -0400409 fit, budgeted, surfaceFlags));
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500410}
411
Brian Salomon7578f3e2018-03-07 14:39:54 -0500412sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
413 GrSurfaceOrigin origin,
414 GrWrapOwnership ownership,
Brian Salomonc67c31c2018-12-06 10:00:03 -0500415 GrIOType ioType,
Brian Salomon7578f3e2018-03-07 14:39:54 -0500416 ReleaseProc releaseProc,
417 ReleaseContext releaseCtx) {
Brian Salomonc67c31c2018-12-06 10:00:03 -0500418 SkASSERT(ioType != kWrite_GrIOType);
Robert Phillipsf9bec202018-01-16 09:21:01 -0500419 if (this->isAbandoned()) {
420 return nullptr;
421 }
422
Brian Salomonf7778972018-03-08 10:13:17 -0500423 // This is only supported on a direct GrContext.
424 if (!fResourceProvider) {
425 return nullptr;
426 }
427
Brian Salomonc67c31c2018-12-06 10:00:03 -0500428 sk_sp<GrTexture> tex = fResourceProvider->wrapBackendTexture(backendTex, ownership, ioType);
Brian Salomonf7778972018-03-08 10:13:17 -0500429 if (!tex) {
430 return nullptr;
431 }
Robert Phillipsadbe1322018-01-17 13:35:46 -0500432
Greg Daniel6a0176b2018-01-30 09:28:44 -0500433 sk_sp<GrReleaseProcHelper> releaseHelper;
434 if (releaseProc) {
435 releaseHelper.reset(new GrReleaseProcHelper(releaseProc, releaseCtx));
Brian Salomonf7778972018-03-08 10:13:17 -0500436 // This gives the texture a ref on the releaseHelper
437 tex->setRelease(releaseHelper);
Greg Daniel6a0176b2018-01-30 09:28:44 -0500438 }
439
Brian Salomonf7778972018-03-08 10:13:17 -0500440 SkASSERT(!tex->asRenderTarget()); // Strictly a GrTexture
441 // Make sure we match how we created the proxy with SkBudgeted::kNo
442 SkASSERT(SkBudgeted::kNo == tex->resourcePriv().isBudgeted());
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500443
Brian Salomonf7778972018-03-08 10:13:17 -0500444 return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin));
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500445}
446
Brian Salomon7578f3e2018-03-07 14:39:54 -0500447sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
Brian Salomon02bd2952018-03-07 15:20:21 -0500448 const GrBackendTexture& backendTex, GrSurfaceOrigin origin, int sampleCnt,
449 GrWrapOwnership ownership) {
Robert Phillipsf9bec202018-01-16 09:21:01 -0500450 if (this->isAbandoned()) {
451 return nullptr;
452 }
453
Brian Salomonf7778972018-03-08 10:13:17 -0500454 // This is only supported on a direct GrContext.
455 if (!fResourceProvider) {
456 return nullptr;
457 }
458
Greg Daniel6abda432018-02-15 14:55:00 -0500459 sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, backendTex.config());
Greg Danielf87651e2018-02-21 11:36:53 -0500460 if (!sampleCnt) {
461 return nullptr;
462 }
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500463
Brian Salomonf7778972018-03-08 10:13:17 -0500464 sk_sp<GrTexture> tex =
465 fResourceProvider->wrapRenderableBackendTexture(backendTex, sampleCnt, ownership);
466 if (!tex) {
467 return nullptr;
Greg Daniel2a303902018-02-20 10:25:54 -0500468 }
469
Brian Salomonf7778972018-03-08 10:13:17 -0500470 SkASSERT(tex->asRenderTarget()); // A GrTextureRenderTarget
471 // Make sure we match how we created the proxy with SkBudgeted::kNo
472 SkASSERT(SkBudgeted::kNo == tex->resourcePriv().isBudgeted());
Greg Daniel6abda432018-02-15 14:55:00 -0500473
Brian Salomonf7778972018-03-08 10:13:17 -0500474 return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin));
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500475}
476
Brian Salomon7578f3e2018-03-07 14:39:54 -0500477sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendRenderTarget(
478 const GrBackendRenderTarget& backendRT, GrSurfaceOrigin origin) {
Robert Phillipsf9bec202018-01-16 09:21:01 -0500479 if (this->isAbandoned()) {
480 return nullptr;
481 }
482
Brian Salomonf7778972018-03-08 10:13:17 -0500483 // This is only supported on a direct GrContext.
484 if (!fResourceProvider) {
485 return nullptr;
Greg Daniel2a303902018-02-20 10:25:54 -0500486 }
487
Brian Salomonf7778972018-03-08 10:13:17 -0500488 sk_sp<GrRenderTarget> rt = fResourceProvider->wrapBackendRenderTarget(backendRT);
489 if (!rt) {
490 return nullptr;
Greg Daniel2a303902018-02-20 10:25:54 -0500491 }
Brian Salomonf7778972018-03-08 10:13:17 -0500492 SkASSERT(!rt->asTexture()); // A GrRenderTarget that's not textureable
493 SkASSERT(!rt->getUniqueKey().isValid());
494 // Make sure we match how we created the proxy with SkBudgeted::kNo
495 SkASSERT(SkBudgeted::kNo == rt->resourcePriv().isBudgeted());
496
497 return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(std::move(rt), origin));
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500498}
499
Brian Salomon7578f3e2018-03-07 14:39:54 -0500500sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
501 const GrBackendTexture& backendTex, GrSurfaceOrigin origin, int sampleCnt) {
Robert Phillipsf9bec202018-01-16 09:21:01 -0500502 if (this->isAbandoned()) {
503 return nullptr;
504 }
505
Brian Salomonf7778972018-03-08 10:13:17 -0500506 // This is only supported on a direct GrContext.
507 if (!fResourceProvider) {
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500508 return nullptr;
509 }
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500510
Brian Salomonf7778972018-03-08 10:13:17 -0500511 sk_sp<GrRenderTarget> rt =
512 fResourceProvider->wrapBackendTextureAsRenderTarget(backendTex, sampleCnt);
513 if (!rt) {
514 return nullptr;
Greg Danielf87651e2018-02-21 11:36:53 -0500515 }
Brian Salomonf7778972018-03-08 10:13:17 -0500516 SkASSERT(!rt->asTexture()); // A GrRenderTarget that's not textureable
517 SkASSERT(!rt->getUniqueKey().isValid());
Greg Danielb46add82019-01-02 14:51:29 -0500518 // This proxy should be unbudgeted because we're just wrapping an external resource
Brian Salomonf7778972018-03-08 10:13:17 -0500519 SkASSERT(SkBudgeted::kNo == rt->resourcePriv().isBudgeted());
Greg Danielf87651e2018-02-21 11:36:53 -0500520
Brian Salomonf7778972018-03-08 10:13:17 -0500521 return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(rt), origin));
Robert Phillips0bd24dc2018-01-16 08:06:32 -0500522}
523
Greg Danielb46add82019-01-02 14:51:29 -0500524sk_sp<GrRenderTargetProxy> GrProxyProvider::wrapVulkanSecondaryCBAsRenderTarget(
525 const SkImageInfo& imageInfo, const GrVkDrawableInfo& vkInfo) {
526 if (this->isAbandoned()) {
527 return nullptr;
528 }
529
530 // This is only supported on a direct GrContext.
531 if (!fResourceProvider) {
532 return nullptr;
533 }
534
535 sk_sp<GrRenderTarget> rt = fResourceProvider->wrapVulkanSecondaryCBAsRenderTarget(imageInfo,
536 vkInfo);
537
538 if (!rt) {
539 return nullptr;
540 }
541 SkASSERT(!rt->asTexture()); // A GrRenderTarget that's not textureable
542 SkASSERT(!rt->getUniqueKey().isValid());
543 // This proxy should be unbudgeted because we're just wrapping an external resource
544 SkASSERT(SkBudgeted::kNo == rt->resourcePriv().isBudgeted());
545
546 // All Vulkan surfaces uses top left origins.
547 return sk_sp<GrRenderTargetProxy>(
548 new GrRenderTargetProxy(std::move(rt),
549 kTopLeft_GrSurfaceOrigin,
550 GrRenderTargetProxy::WrapsVkSecondaryCB::kYes));
551}
552
Robert Phillips777707b2018-01-17 11:40:14 -0500553sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
Greg Daniel4065d452018-11-16 15:43:41 -0500554 const GrBackendFormat& format,
Robert Phillips777707b2018-01-17 11:40:14 -0500555 const GrSurfaceDesc& desc,
Brian Salomon2a4f9832018-03-03 22:43:43 -0500556 GrSurfaceOrigin origin,
Brian Salomon7226c232018-07-30 13:13:17 -0400557 GrMipMapped mipMapped,
Brian Salomon7226c232018-07-30 13:13:17 -0400558 SkBackingFit fit,
Brian Salomon2a4f9832018-03-03 22:43:43 -0500559 SkBudgeted budgeted) {
Greg Daniel4065d452018-11-16 15:43:41 -0500560 return this->createLazyProxy(std::move(callback), format, desc, origin, mipMapped,
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400561 GrInternalSurfaceFlags::kNone, fit, budgeted);
Greg Daniel2a303902018-02-20 10:25:54 -0500562}
563
564sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
Greg Daniel4065d452018-11-16 15:43:41 -0500565 const GrBackendFormat& format,
Greg Daniel2a303902018-02-20 10:25:54 -0500566 const GrSurfaceDesc& desc,
Brian Salomon2a4f9832018-03-03 22:43:43 -0500567 GrSurfaceOrigin origin,
Greg Daniel2a303902018-02-20 10:25:54 -0500568 GrMipMapped mipMapped,
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400569 GrInternalSurfaceFlags surfaceFlags,
Brian Salomon7226c232018-07-30 13:13:17 -0400570 SkBackingFit fit,
571 SkBudgeted budgeted) {
Greg Daniela8d92112018-03-09 12:05:04 -0500572 // For non-ddl draws always make lazy proxy's single use.
573 LazyInstantiationType lazyType = fResourceProvider ? LazyInstantiationType::kSingleUse
574 : LazyInstantiationType::kMultipleUse;
Greg Daniel4065d452018-11-16 15:43:41 -0500575 return this->createLazyProxy(std::move(callback), format, desc, origin, mipMapped, surfaceFlags,
576 fit, budgeted, lazyType);
Greg Daniela8d92112018-03-09 12:05:04 -0500577}
578
579sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
Greg Daniel4065d452018-11-16 15:43:41 -0500580 const GrBackendFormat& format,
Greg Daniela8d92112018-03-09 12:05:04 -0500581 const GrSurfaceDesc& desc,
582 GrSurfaceOrigin origin,
583 GrMipMapped mipMapped,
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400584 GrInternalSurfaceFlags surfaceFlags,
Brian Salomon7226c232018-07-30 13:13:17 -0400585 SkBackingFit fit,
586 SkBudgeted budgeted,
Greg Daniela8d92112018-03-09 12:05:04 -0500587 LazyInstantiationType lazyType) {
Robert Phillips777707b2018-01-17 11:40:14 -0500588 SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
589 (desc.fWidth > 0 && desc.fHeight > 0));
Greg Daniel92cbf3f2018-04-12 16:50:17 -0400590
591 if (desc.fWidth > fCaps->maxTextureSize() || desc.fHeight > fCaps->maxTextureSize()) {
592 return nullptr;
593 }
594
Greg Daniel457469c2018-02-08 15:05:44 -0500595
Greg Daniel2a303902018-02-20 10:25:54 -0500596#ifdef SK_DEBUG
597 if (SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags)) {
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400598 if (SkToBool(surfaceFlags & GrInternalSurfaceFlags::kMixedSampled)) {
Greg Daniel2a303902018-02-20 10:25:54 -0500599 SkASSERT(fCaps->usesMixedSamples() && desc.fSampleCnt > 1);
600 }
Greg Daniel2a303902018-02-20 10:25:54 -0500601 }
602#endif
603
Brian Salomon2a4f9832018-03-03 22:43:43 -0500604 return sk_sp<GrTextureProxy>(
605 SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags)
Greg Daniel4065d452018-11-16 15:43:41 -0500606 ? new GrTextureRenderTargetProxy(std::move(callback), lazyType, format, desc,
607 origin, mipMapped, fit, budgeted, surfaceFlags)
608 : new GrTextureProxy(std::move(callback), lazyType, format, desc, origin,
609 mipMapped, fit, budgeted, surfaceFlags));
Robert Phillips777707b2018-01-17 11:40:14 -0500610}
611
Robert Phillipse8fabb22018-02-04 14:33:21 -0500612sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy(
Greg Daniel4065d452018-11-16 15:43:41 -0500613 LazyInstantiateCallback&& callback, const GrBackendFormat& format,
614 const GrSurfaceDesc& desc, GrSurfaceOrigin origin, GrInternalSurfaceFlags surfaceFlags,
615 const TextureInfo* textureInfo, SkBackingFit fit, SkBudgeted budgeted) {
Robert Phillipse8fabb22018-02-04 14:33:21 -0500616 SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
617 (desc.fWidth > 0 && desc.fHeight > 0));
Greg Daniel92cbf3f2018-04-12 16:50:17 -0400618
619 if (desc.fWidth > fCaps->maxRenderTargetSize() || desc.fHeight > fCaps->maxRenderTargetSize()) {
620 return nullptr;
621 }
622
Greg Daniel2a303902018-02-20 10:25:54 -0500623 SkASSERT(SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags));
Greg Daniel457469c2018-02-08 15:05:44 -0500624
Greg Daniel2a303902018-02-20 10:25:54 -0500625#ifdef SK_DEBUG
Robert Phillipsfe0253f2018-03-16 16:47:25 -0400626 if (SkToBool(surfaceFlags & GrInternalSurfaceFlags::kMixedSampled)) {
Greg Daniel2a303902018-02-20 10:25:54 -0500627 SkASSERT(fCaps->usesMixedSamples() && desc.fSampleCnt > 1);
628 }
Greg Daniel2a303902018-02-20 10:25:54 -0500629#endif
630
Greg Daniel457469c2018-02-08 15:05:44 -0500631 using LazyInstantiationType = GrSurfaceProxy::LazyInstantiationType;
632 // For non-ddl draws always make lazy proxy's single use.
633 LazyInstantiationType lazyType = fResourceProvider ? LazyInstantiationType::kSingleUse
634 : LazyInstantiationType::kMultipleUse;
635
Brian Salomon7226c232018-07-30 13:13:17 -0400636 if (textureInfo) {
637 return sk_sp<GrRenderTargetProxy>(new GrTextureRenderTargetProxy(
Greg Daniel4065d452018-11-16 15:43:41 -0500638 std::move(callback), lazyType, format, desc, origin, textureInfo->fMipMapped,
639 fit, budgeted, surfaceFlags));
Robert Phillipse8fabb22018-02-04 14:33:21 -0500640 }
641
Brian Salomon2a4f9832018-03-03 22:43:43 -0500642 return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(
Greg Daniel4065d452018-11-16 15:43:41 -0500643 std::move(callback), lazyType, format, desc, origin, fit, budgeted, surfaceFlags));
Robert Phillipse8fabb22018-02-04 14:33:21 -0500644}
645
Chris Dalton4c458b12018-06-16 17:22:59 -0600646sk_sp<GrTextureProxy> GrProxyProvider::MakeFullyLazyProxy(LazyInstantiateCallback&& callback,
Greg Daniel4065d452018-11-16 15:43:41 -0500647 const GrBackendFormat& format,
Chris Dalton4c458b12018-06-16 17:22:59 -0600648 Renderable renderable,
649 GrSurfaceOrigin origin,
650 GrPixelConfig config,
651 const GrCaps& caps) {
Robert Phillips777707b2018-01-17 11:40:14 -0500652 GrSurfaceDesc desc;
Greg Daniele3204862018-04-16 11:24:10 -0400653 GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNoPendingIO;
Robert Phillips777707b2018-01-17 11:40:14 -0500654 if (Renderable::kYes == renderable) {
655 desc.fFlags = kRenderTarget_GrSurfaceFlag;
656 }
Robert Phillips777707b2018-01-17 11:40:14 -0500657 desc.fWidth = -1;
658 desc.fHeight = -1;
659 desc.fConfig = config;
Brian Salomonbdecacf2018-02-02 20:32:49 -0500660 desc.fSampleCnt = 1;
Robert Phillips777707b2018-01-17 11:40:14 -0500661
Chris Dalton4c458b12018-06-16 17:22:59 -0600662 return sk_sp<GrTextureProxy>(
663 (Renderable::kYes == renderable)
Brian Salomon7226c232018-07-30 13:13:17 -0400664 ? new GrTextureRenderTargetProxy(
Greg Daniel4065d452018-11-16 15:43:41 -0500665 std::move(callback), LazyInstantiationType::kSingleUse, format, desc,
666 origin, GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes,
667 surfaceFlags)
Chris Dalton4c458b12018-06-16 17:22:59 -0600668 : new GrTextureProxy(std::move(callback), LazyInstantiationType::kSingleUse,
Greg Daniel4065d452018-11-16 15:43:41 -0500669 format, desc, origin, GrMipMapped::kNo,
Brian Salomon7226c232018-07-30 13:13:17 -0400670 SkBackingFit::kApprox, SkBudgeted::kYes, surfaceFlags));
Robert Phillips777707b2018-01-17 11:40:14 -0500671}
672
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500673bool GrProxyProvider::IsFunctionallyExact(GrSurfaceProxy* proxy) {
Brian Salomonfd98c2c2018-07-31 17:25:29 -0400674 const bool isInstantiated = proxy->isInstantiated();
Robert Phillipsdb3b9792018-06-12 15:18:00 -0400675 // A proxy is functionally exact if:
676 // it is exact (obvs)
677 // when it is instantiated it will be exact (i.e., power of two dimensions)
678 // it is already instantiated and the proxy covers the entire backing surface
679 return proxy->priv().isExact() ||
680 (!isInstantiated && SkIsPow2(proxy->width()) && SkIsPow2(proxy->height())) ||
681 (isInstantiated && proxy->worstCaseWidth() == proxy->width() &&
682 proxy->worstCaseHeight() == proxy->height());
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500683}
684
Robert Phillips427966a2018-12-20 17:20:43 -0500685void GrProxyProvider::processInvalidUniqueKey(const GrUniqueKey& key, GrTextureProxy* proxy,
686 InvalidateGPUResource invalidateGPUResource) {
687 if (!proxy) {
688 proxy = fUniquelyKeyedProxies.find(key);
689 }
690
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500691 // Note: this method is called for the whole variety of GrGpuResources so often 'key'
692 // will not be in 'fUniquelyKeyedProxies'.
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500693 if (proxy) {
Robert Phillips427966a2018-12-20 17:20:43 -0500694 SkASSERT(proxy->getUniqueKey().isValid());
695 SkASSERT(proxy->getUniqueKey() == key);
696
697 fUniquelyKeyedProxies.remove(key);
698 proxy->cacheAccess().clearUniqueKey();
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500699 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500700
Robert Phillips427966a2018-12-20 17:20:43 -0500701 if (InvalidateGPUResource::kNo == invalidateGPUResource) {
702 return;
703 }
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500704
Robert Phillips427966a2018-12-20 17:20:43 -0500705 if (proxy && proxy->isInstantiated()) {
Brian Salomonfd98c2c2018-07-31 17:25:29 -0400706 GrSurface* surface = proxy->peekSurface();
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500707 if (surface) {
708 surface->resourcePriv().removeUniqueKey();
Robert Phillips427966a2018-12-20 17:20:43 -0500709 return;
710 }
711 }
712
713 if (fResourceProvider) {
714 sk_sp<GrGpuResource> resource = fResourceProvider->findByUniqueKey<GrGpuResource>(key);
715 if (resource) {
716 resource->resourcePriv().removeUniqueKey();
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500717 }
718 }
719}
720
Robert Phillips0790f8a2018-09-18 13:11:03 -0400721void GrProxyProvider::orphanAllUniqueKeys() {
722 UniquelyKeyedProxyHash::Iter iter(&fUniquelyKeyedProxies);
723 for (UniquelyKeyedProxyHash::Iter iter(&fUniquelyKeyedProxies); !iter.done(); ++iter) {
724 GrTextureProxy& tmp = *iter;
725
726 tmp.fProxyProvider = nullptr;
727 }
728}
729
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500730void GrProxyProvider::removeAllUniqueKeys() {
731 UniquelyKeyedProxyHash::Iter iter(&fUniquelyKeyedProxies);
732 for (UniquelyKeyedProxyHash::Iter iter(&fUniquelyKeyedProxies); !iter.done(); ++iter) {
733 GrTextureProxy& tmp = *iter;
734
Robert Phillips427966a2018-12-20 17:20:43 -0500735 this->processInvalidUniqueKey(tmp.getUniqueKey(), &tmp,
736 GrProxyProvider::InvalidateGPUResource::kNo);
Robert Phillips1afd4cd2018-01-08 13:40:32 -0500737 }
738 SkASSERT(!fUniquelyKeyedProxies.count());
739}