blob: 3bd42cf1233a2c6fcf94bf9866e5d155a97ce980 [file] [log] [blame]
Jim Van Verth8026ccc2018-10-04 13:10:39 -04001/*
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 "GrBackendSurface.h"
9#include "GrClip.h"
10#include "GrContext.h"
11#include "GrContextPriv.h"
12#include "GrRenderTargetContext.h"
13#include "GrTexture.h"
14#include "GrTextureAdjuster.h"
Jim Van Verth0e671942018-11-09 12:03:57 -050015#include "effects/GrYUVtoRGBEffect.h"
Jim Van Verth8026ccc2018-10-04 13:10:39 -040016#include "SkBitmapCache.h"
17#include "SkImage_Gpu.h"
18#include "SkImage_GpuBase.h"
Jim Van Verth8bbce0e2018-10-08 14:34:52 -040019#include "SkReadPixelsRec.h"
Jim Van Verth8026ccc2018-10-04 13:10:39 -040020
21SkImage_GpuBase::SkImage_GpuBase(sk_sp<GrContext> context, int width, int height, uint32_t uniqueID,
22 SkAlphaType at, SkBudgeted budgeted, sk_sp<SkColorSpace> cs)
23 : INHERITED(width, height, uniqueID)
24 , fContext(std::move(context))
25 , fAlphaType(at)
26 , fBudgeted(budgeted)
27 , fColorSpace(std::move(cs)) {}
28
29SkImage_GpuBase::~SkImage_GpuBase() {}
30
31//////////////////////////////////////////////////////////////////////////////////////////////////
32
33bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendTexture& tex,
34 GrPixelConfig* config, SkColorType ct, SkAlphaType at,
35 sk_sp<SkColorSpace> cs) {
36 if (!tex.isValid()) {
37 return false;
38 }
39 // TODO: Create a SkImageColorInfo struct for color, alpha, and color space so we don't need to
40 // create a fake image info here.
41 SkImageInfo info = SkImageInfo::Make(1, 1, ct, at, cs);
42 if (!SkImageInfoIsValid(info)) {
43 return false;
44 }
45
46 return ctx->contextPriv().caps()->validateBackendTexture(tex, ct, config);
47}
48
49//////////////////////////////////////////////////////////////////////////////////////////////////
50
Brian Osmane50cdf02018-10-19 13:02:14 -040051bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {
Jim Van Verth8026ccc2018-10-04 13:10:39 -040052 if (!fContext->contextPriv().resourceProvider()) {
53 // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
54 return false;
55 }
56
Jim Van Verth8026ccc2018-10-04 13:10:39 -040057 const auto desc = SkBitmapCacheDesc::Make(this);
58 if (SkBitmapCache::Find(desc, dst)) {
Jim Van Verth8026ccc2018-10-04 13:10:39 -040059 SkASSERT(dst->isImmutable());
60 SkASSERT(dst->getPixels());
61 return true;
62 }
63
64 SkBitmapCache::RecPtr rec = nullptr;
65 SkPixmap pmap;
66 if (kAllow_CachingHint == chint) {
67 rec = SkBitmapCache::Alloc(desc, this->onImageInfo(), &pmap);
68 if (!rec) {
69 return false;
70 }
71 } else {
72 if (!dst->tryAllocPixels(this->onImageInfo()) || !dst->peekPixels(&pmap)) {
73 return false;
74 }
75 }
76
77 sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(
78 this->asTextureProxyRef(),
79 fColorSpace);
80 if (!sContext) {
81 return false;
82 }
83
84 if (!sContext->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), 0, 0)) {
85 return false;
86 }
87
88 if (rec) {
89 SkBitmapCache::Add(std::move(rec), dst);
90 this->notifyAddedToRasterCache();
91 }
92 return true;
93}
94
95sk_sp<SkImage> SkImage_GpuBase::onMakeSubset(const SkIRect& subset) const {
96 sk_sp<GrSurfaceProxy> proxy = this->asTextureProxyRef();
97
98 GrSurfaceDesc desc;
99 desc.fWidth = subset.width();
100 desc.fHeight = subset.height();
101 desc.fConfig = proxy->config();
102
Greg Daniel4065d452018-11-16 15:43:41 -0500103 GrBackendFormat format = proxy->backendFormat().makeTexture2D();
104 if (!format.isValid()) {
105 return nullptr;
106 }
107
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400108 sk_sp<GrSurfaceContext> sContext(fContext->contextPriv().makeDeferredSurfaceContext(
Greg Daniel4065d452018-11-16 15:43:41 -0500109 format, desc, proxy->origin(), GrMipMapped::kNo, SkBackingFit::kExact, fBudgeted));
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400110 if (!sContext) {
111 return nullptr;
112 }
113
114 if (!sContext->copy(proxy.get(), subset, SkIPoint::Make(0, 0))) {
115 return nullptr;
116 }
117
118 // MDB: this call is okay bc we know 'sContext' was kExact
119 return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID,
120 fAlphaType, sContext->asTextureProxyRef(),
121 fColorSpace, fBudgeted);
122}
123
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400124static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
125 switch (info.colorType()) {
126 case kRGBA_8888_SkColorType:
127 case kBGRA_8888_SkColorType:
128 break;
129 default:
130 return; // nothing to do
131 }
132
133 // SkColor is not necesarily RGBA or BGRA, but it is one of them on little-endian,
134 // and in either case, the alpha-byte is always in the same place, so we can safely call
135 // SkPreMultiplyColor()
136 //
137 SkColor* row = (SkColor*)pixels;
138 for (int y = 0; y < info.height(); ++y) {
139 for (int x = 0; x < info.width(); ++x) {
140 row[x] = SkPreMultiplyColor(row[x]);
141 }
142 row = (SkColor*)((char*)(row)+rowBytes);
143 }
144}
145
146bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
147 int srcX, int srcY, CachingHint) const {
148 if (!fContext->contextPriv().resourceProvider()) {
149 // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
150 return false;
151 }
152
153 if (!SkImageInfoValidConversion(dstInfo, this->onImageInfo())) {
154 return false;
155 }
156
157 SkReadPixelsRec rec(dstInfo, dstPixels, dstRB, srcX, srcY);
158 if (!rec.trim(this->width(), this->height())) {
159 return false;
160 }
161
162 // TODO: this seems to duplicate code in GrTextureContext::onReadPixels and
163 // GrRenderTargetContext::onReadPixels
164 uint32_t flags = 0;
165 if (kUnpremul_SkAlphaType == rec.fInfo.alphaType() && kPremul_SkAlphaType == fAlphaType) {
166 // let the GPU perform this transformation for us
167 flags = GrContextPriv::kUnpremul_PixelOpsFlag;
168 }
169
170 sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(
171 this->asTextureProxyRef(), fColorSpace);
172 if (!sContext) {
173 return false;
174 }
175
176 if (!sContext->readPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY, flags)) {
177 return false;
178 }
179
180 // do we have to manually fix-up the alpha channel?
181 // src dst
182 // unpremul premul fix manually
183 // premul unpremul done by kUnpremul_PixelOpsFlag
184 // all other combos need to change.
185 //
186 // Should this be handled by Ganesh? todo:?
187 //
188 if (kPremul_SkAlphaType == rec.fInfo.alphaType() && kUnpremul_SkAlphaType == fAlphaType) {
189 apply_premul(rec.fInfo, rec.fPixels, rec.fRowBytes);
190 }
191 return true;
192}
193
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400194sk_sp<GrTextureProxy> SkImage_GpuBase::asTextureProxyRef(GrContext* context,
195 const GrSamplerState& params,
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400196 SkScalar scaleAdjust[2]) const {
197 if (context->uniqueID() != fContext->uniqueID()) {
198 SkASSERT(0);
199 return nullptr;
200 }
201
202 GrTextureAdjuster adjuster(fContext.get(), this->asTextureProxyRef(), fAlphaType,
203 this->uniqueID(), fColorSpace.get());
Brian Osman6064e1c2018-10-19 14:27:54 -0400204 return adjuster.refTextureProxyForParams(params, scaleAdjust);
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400205}
206
207GrBackendTexture SkImage_GpuBase::onGetBackendTexture(bool flushPendingGrContextIO,
208 GrSurfaceOrigin* origin) const {
209 sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef();
210 SkASSERT(proxy);
211
212 if (!fContext->contextPriv().resourceProvider() && !proxy->isInstantiated()) {
213 // This image was created with a DDL context and cannot be instantiated.
214 return GrBackendTexture();
215}
216
217 if (!proxy->instantiate(fContext->contextPriv().resourceProvider())) {
218 return GrBackendTexture(); // invalid
219 }
220
221 GrTexture* texture = proxy->peekTexture();
222
223 if (texture) {
224 if (flushPendingGrContextIO) {
225 fContext->contextPriv().prepareSurfaceForExternalIO(proxy.get());
226 }
227 if (origin) {
228 *origin = proxy->origin();
229 }
230 return texture->getBackendTexture();
231 }
232 return GrBackendTexture(); // invalid
233}
234
235GrTexture* SkImage_GpuBase::onGetTexture() const {
236 GrTextureProxy* proxy = this->peekProxy();
237 if (!proxy) {
238 return nullptr;
239 }
240
241 sk_sp<GrTextureProxy> proxyRef = this->asTextureProxyRef();
242 if (!fContext->contextPriv().resourceProvider() && !proxyRef->isInstantiated()) {
243 // This image was created with a DDL context and cannot be instantiated.
244 return nullptr;
245 }
246
247 if (!proxy->instantiate(fContext->contextPriv().resourceProvider())) {
248 return nullptr;
249 }
250
251 return proxy->peekTexture();
252}
253
254sk_sp<SkImage> SkImage_GpuBase::onMakeColorSpace(sk_sp<SkColorSpace> target) const {
Brian Osmanbe686f02018-10-12 11:18:02 -0400255 auto xform = GrColorSpaceXformEffect::Make(fColorSpace.get(), fAlphaType,
256 target.get(), fAlphaType);
Brian Osmanb4ae4992018-10-18 11:16:14 -0400257 SkASSERT(xform);
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400258
Brian Osman9c111352018-10-16 10:18:26 -0400259 sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef();
260
Greg Daniel4065d452018-11-16 15:43:41 -0500261 GrBackendFormat format = proxy->backendFormat().makeTexture2D();
262 if (!format.isValid()) {
263 return nullptr;
264 }
265
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400266 sk_sp<GrRenderTargetContext> renderTargetContext(
Brian Osman9c111352018-10-16 10:18:26 -0400267 fContext->contextPriv().makeDeferredRenderTargetContextWithFallback(
Greg Daniel4065d452018-11-16 15:43:41 -0500268 format, SkBackingFit::kExact, this->width(), this->height(),
269 proxy->config(), nullptr));
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400270 if (!renderTargetContext) {
271 return nullptr;
272 }
273
274 GrPaint paint;
275 paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
Brian Osman9c111352018-10-16 10:18:26 -0400276 paint.addColorTextureProcessor(std::move(proxy), SkMatrix::I());
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400277 paint.addColorFragmentProcessor(std::move(xform));
278
Brian Osmanb4ae4992018-10-18 11:16:14 -0400279 renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(),
280 SkRect::MakeIWH(this->width(), this->height()));
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400281 if (!renderTargetContext->asTextureProxy()) {
282 return nullptr;
283 }
284
285 // MDB: this call is okay bc we know 'renderTargetContext' was exact
286 return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID,
Brian Osmanbe686f02018-10-12 11:18:02 -0400287 fAlphaType, renderTargetContext->asTextureProxyRef(),
Jim Van Verth8026ccc2018-10-04 13:10:39 -0400288 std::move(target), fBudgeted);
289}
290
291bool SkImage_GpuBase::onIsValid(GrContext* context) const {
292 // The base class has already checked that context isn't abandoned (if it's not nullptr)
293 if (fContext->abandoned()) {
294 return false;
295 }
296
297 if (context && context != fContext.get()) {
298 return false;
299 }
300
301 return true;
302}
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400303
Jim Van Verth0e671942018-11-09 12:03:57 -0500304bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx, const GrBackendTexture yuvaTextures[],
Jim Van Verth53275362018-11-09 15:42:35 -0500305 int numTextures, const SkYUVAIndex yuvaIndices[4],
306 GrSurfaceOrigin imageOrigin,
Jim Van Verth0e671942018-11-09 12:03:57 -0500307 sk_sp<GrTextureProxy> tempTextureProxies[4]) {
308 GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
309
310 // We need to make a copy of the input backend textures because we need to preserve the result
311 // of validate_backend_texture.
312 GrBackendTexture yuvaTexturesCopy[4];
313 for (int textureIndex = 0; textureIndex < numTextures; ++textureIndex) {
314 yuvaTexturesCopy[textureIndex] = yuvaTextures[textureIndex];
315 if (!ctx->contextPriv().caps()->getYUVAConfigFromBackendTexture(
316 yuvaTexturesCopy[textureIndex],
317 &yuvaTexturesCopy[textureIndex].fConfig)) {
318 return false;
319 }
320 SkASSERT(yuvaTexturesCopy[textureIndex].isValid());
321
322 tempTextureProxies[textureIndex] =
Brian Salomonc67c31c2018-12-06 10:00:03 -0500323 proxyProvider->wrapBackendTexture(yuvaTexturesCopy[textureIndex], imageOrigin,
324 kBorrow_GrWrapOwnership, kRead_GrIOType);
Jim Van Verth0e671942018-11-09 12:03:57 -0500325 if (!tempTextureProxies[textureIndex]) {
326 return false;
327 }
Jim Van Verth53275362018-11-09 15:42:35 -0500328
329 // Check that each texture contains the channel data for the corresponding YUVA index
330 GrPixelConfig config = yuvaTexturesCopy[textureIndex].fConfig;
331 for (int yuvaIndex = 0; yuvaIndex < SkYUVAIndex::kIndexCount; ++yuvaIndex) {
332 if (yuvaIndices[yuvaIndex].fIndex == textureIndex) {
333 switch (yuvaIndices[yuvaIndex].fChannel) {
334 case SkColorChannel::kR:
335 if (kAlpha_8_as_Alpha_GrPixelConfig == config) {
336 return false;
337 }
338 break;
339 case SkColorChannel::kG:
340 case SkColorChannel::kB:
341 if (kAlpha_8_as_Alpha_GrPixelConfig == config ||
342 kAlpha_8_as_Red_GrPixelConfig == config) {
343 return false;
344 }
345 break;
346 case SkColorChannel::kA:
347 default:
348 if (kRGB_888_GrPixelConfig == config) {
349 return false;
350 }
351 break;
352 }
353 }
354 }
Jim Van Verth0e671942018-11-09 12:03:57 -0500355 }
356
357 return true;
358}
359
360bool SkImage_GpuBase::RenderYUVAToRGBA(GrContext* ctx, GrRenderTargetContext* renderTargetContext,
361 const SkRect& rect, SkYUVColorSpace yuvColorSpace,
362 const sk_sp<GrTextureProxy> proxies[4],
363 const SkYUVAIndex yuvaIndices[4]) {
364 SkASSERT(renderTargetContext);
365 if (!renderTargetContext->asSurfaceProxy()) {
366 return false;
367 }
368
369 GrPaint paint;
370 paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
371
Jim Van Verth0e671942018-11-09 12:03:57 -0500372 paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Make(proxies, yuvaIndices,
373 yuvColorSpace,
374 GrSamplerState::Filter::kNearest));
375
376 renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), rect);
377
378 // DDL TODO: in the promise image version we must not flush here
379 ctx->contextPriv().flushSurfaceWrites(renderTargetContext->asSurfaceProxy());
380
381 return true;
382}
383
Brian Salomonbe5a0932018-12-10 10:03:26 -0500384sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
385 GrContext* context, int width, int height, GrSurfaceOrigin origin, GrPixelConfig config,
386 GrBackendFormat backendFormat, GrMipMapped mipMapped,
387 SkImage_GpuBase::TextureFulfillProc fulfillProc,
388 SkImage_GpuBase::TextureReleaseProc releaseProc, SkImage_GpuBase::PromiseDoneProc doneProc,
389 SkImage_GpuBase::TextureContext textureContext) {
390 SkASSERT(context);
391 SkASSERT(width > 0 && height > 0);
392 SkASSERT(doneProc);
393
394 if (!fulfillProc || !releaseProc) {
395 doneProc(textureContext);
396 return nullptr;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400397 }
398
Brian Salomonbe5a0932018-12-10 10:03:26 -0500399 if (mipMapped == GrMipMapped::kYes &&
400 GrTextureTypeHasRestrictedSampling(backendFormat.textureType())) {
401 // It is invalid to have a GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE and have mips as
402 // well.
403 doneProc(textureContext);
404 return nullptr;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400405 }
Brian Salomonbe5a0932018-12-10 10:03:26 -0500406
407 /**
408 * This helper class manages the ref counting for the the ReleaseProc and DoneProc for promise
409 * images. It holds a weak ref on the ReleaseProc (hard refs are owned by GrTextures). The weak
410 * ref allows us to reuse an outstanding ReleaseProc (because we dropped our GrTexture but the
411 * GrTexture isn't done on the GPU) without needing to call FulfillProc again. It also holds a
412 * hard ref on the DoneProc. The idea is that after every flush we may call the ReleaseProc so
413 * that the client can free up their GPU memory if they want to. The life time of the DoneProc
414 * matches that of any outstanding ReleaseProc as well as the PromiseLazyInstantiateCallback.
415 * Thus we won't call the DoneProc until all ReleaseProcs are finished and we are finished with
416 * the PromiseImageHelper (i.e. won't call FulfillProc again).
417 */
418 class PromiseLazyInstantiateCallback {
419 public:
420 PromiseLazyInstantiateCallback(SkImage_GpuBase::TextureFulfillProc fulfillProc,
421 SkImage_GpuBase::TextureReleaseProc releaseProc,
422 SkImage_GpuBase::PromiseDoneProc doneProc,
423 SkImage_GpuBase::TextureContext context,
424 GrPixelConfig config)
425 : fFulfillProc(fulfillProc)
426 , fReleaseProc(releaseProc)
427 , fContext(context)
428 , fConfig(config) {
429 fDoneHelper.reset(new GrReleaseProcHelper(doneProc, context));
430 }
431
432 sk_sp<GrSurface> operator()(GrResourceProvider* resourceProvider) {
433 if (!resourceProvider) {
434 this->reset();
435 return sk_sp<GrTexture>();
436 }
437
438 // Releases the promise helper if there are no outstanding hard refs. This means that we
439 // don't have any ReleaseProcs waiting to be called so we will need to do a fulfill.
440 if (fReleaseHelper && fReleaseHelper->weak_expired()) {
441 this->resetReleaseHelper();
442 }
443
444 sk_sp<GrTexture> tex;
445 if (!fReleaseHelper) {
446 fFulfillProc(fContext, &fBackendTex);
447 fBackendTex.fConfig = fConfig;
448 if (!fBackendTex.isValid()) {
449 // Even though the GrBackendTexture is not valid, we must call the release
450 // proc to keep our contract of always calling Fulfill and Release in pairs.
451 fReleaseProc(fContext);
452 return sk_sp<GrTexture>();
453 }
454
455 tex = resourceProvider->wrapBackendTexture(fBackendTex, kBorrow_GrWrapOwnership,
456 kRead_GrIOType);
457 if (!tex) {
458 // Even though the GrBackendTexture is not valid, we must call the release
459 // proc to keep our contract of always calling Fulfill and Release in pairs.
460 fReleaseProc(fContext);
461 return sk_sp<GrTexture>();
462 }
463 fReleaseHelper =
464 new SkPromiseReleaseProcHelper(fReleaseProc, fContext, fDoneHelper);
465 // Take a weak ref
466 fReleaseHelper->weak_ref();
467 } else {
468 SkASSERT(fBackendTex.isValid());
469 tex = resourceProvider->wrapBackendTexture(fBackendTex, kBorrow_GrWrapOwnership,
470 kRead_GrIOType);
471 if (!tex) {
472 // We weren't able to make a texture here, but since we are in this branch
473 // of the calls (promiseHelper.fReleaseHelper is valid) there is already a
474 // texture out there which will call the release proc so we don't need to
475 // call it here.
476 return sk_sp<GrTexture>();
477 }
478
479 SkAssertResult(fReleaseHelper->try_ref());
480 }
481 SkASSERT(tex);
482 // Pass the hard ref off to the texture
483 tex->setRelease(sk_sp<GrReleaseProcHelper>(fReleaseHelper));
484 return std::move(tex);
485 }
486
487 private:
488 void reset() {
489 this->resetReleaseHelper();
490 fDoneHelper.reset();
491 }
492
493 // Weak unrefs fReleaseHelper and sets it to null
494 void resetReleaseHelper() {
495 if (fReleaseHelper) {
496 fReleaseHelper->weak_unref();
497 fReleaseHelper = nullptr;
498 }
499 }
500
501 SkImage_GpuBase::TextureFulfillProc fFulfillProc;
502 SkImage_GpuBase::TextureReleaseProc fReleaseProc;
503 SkImage_GpuBase::TextureContext fContext;
504
505 GrPixelConfig fConfig;
506 // We cache the GrBackendTexture so that if we deleted the GrTexture but the the release
507 // proc has yet not been called (this can happen on Vulkan), then we can create a new
508 // texture without needing to call the fulfill proc again.
509 GrBackendTexture fBackendTex;
510 // The fReleaseHelper is used to track a weak ref on the release proc. This helps us make
511 // sure we are always pairing fulfill and release proc calls correctly.
512 SkPromiseReleaseProcHelper* fReleaseHelper = nullptr;
513 // We don't want to call the fDoneHelper until we are done with the PromiseImageHelper and
514 // all ReleaseHelpers are finished. Thus we hold a hard ref here and we will pass a hard ref
515 // to each fReleaseHelper we make.
516 sk_sp<GrReleaseProcHelper> fDoneHelper;
517 } callback(fulfillProc, releaseProc, doneProc, textureContext, config);
518
519 GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
520
521 GrSurfaceDesc desc;
522 desc.fWidth = width;
523 desc.fHeight = height;
524 desc.fConfig = config;
525
526 // We pass kReadOnly here since we should treat content of the client's texture as immutable.
527 return proxyProvider->createLazyProxy(std::move(callback), backendFormat, desc, origin,
528 mipMapped, GrInternalSurfaceFlags::kReadOnly,
529 SkBackingFit::kExact, SkBudgeted::kNo,
530 GrSurfaceProxy::LazyInstantiationType::kDeinstantiate);
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400531}