Remove origin from GrSurfaceProxy.
Bug: skia:9556
Change-Id: Ic95a3a6b11e1ff8a6f6b2f5c5aeb9037b72aae90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270840
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index d9cbf6e..533bca8 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -155,49 +155,54 @@
// Must make copies of member variables to capture in the lambda since this image generator may
// be deleted before we actually execute the lambda.
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- [refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
- grColorType](
- GrResourceProvider* resourceProvider) -> GrSurfaceProxy::LazyCallbackResult {
- if (refHelper->fSemaphore) {
- resourceProvider->priv().gpu()->waitSemaphore(refHelper->fSemaphore.get());
- }
+ [
+ refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture,
+ grColorType
+ ](GrResourceProvider * resourceProvider)
+ ->GrSurfaceProxy::LazyCallbackResult {
+ if (refHelper->fSemaphore) {
+ resourceProvider->priv().gpu()->waitSemaphore(
+ refHelper->fSemaphore.get());
+ }
- // If a client re-draws the same image multiple times, the texture we return
- // will be cached and re-used. If they draw a subset, though, we may be
- // re-called. In that case, we want to re-use the borrowed texture we've
- // previously created.
- sk_sp<GrTexture> tex;
- SkASSERT(refHelper->fBorrowedTextureKey.isValid());
- auto surf = resourceProvider->findByUniqueKey<GrSurface>(
- refHelper->fBorrowedTextureKey);
- if (surf) {
- SkASSERT(surf->asTexture());
- tex = sk_ref_sp(surf->asTexture());
- } else {
- // We just gained access to the texture. If we're on the original context, we
- // could use the original texture, but we'd have no way of detecting that it's
- // no longer in-use. So we always make a wrapped copy, where the release proc
- // informs us that the context is done with it. This is unfortunate - we'll have
- // two texture objects referencing the same GPU object. However, no client can
- // ever see the original texture, so this should be safe.
- // We make the texture uncacheable so that the release proc is called ASAP.
- tex = resourceProvider->wrapBackendTexture(
- backendTexture, grColorType, kBorrow_GrWrapOwnership,
- GrWrapCacheable::kNo, kRead_GrIOType);
- if (!tex) {
- return {};
- }
- tex->setRelease(releaseProcHelper);
- tex->resourcePriv().setUniqueKey(refHelper->fBorrowedTextureKey);
- }
- // We use keys to avoid re-wrapping the GrBackendTexture in a GrTexture. This is
- // unrelated to the whatever SkImage key may be assigned to the proxy.
- return {std::move(tex), true, GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
- },
+ // If a client re-draws the same image multiple times, the texture we return
+ // will be cached and re-used. If they draw a subset, though, we may be
+ // re-called. In that case, we want to re-use the borrowed texture we've
+ // previously created.
+ sk_sp<GrTexture> tex;
+ SkASSERT(refHelper->fBorrowedTextureKey.isValid());
+ auto surf = resourceProvider->findByUniqueKey<GrSurface>(
+ refHelper->fBorrowedTextureKey);
+ if (surf) {
+ SkASSERT(surf->asTexture());
+ tex = sk_ref_sp(surf->asTexture());
+ } else {
+ // We just gained access to the texture. If we're on the original
+ // context, we could use the original texture, but we'd have no way of
+ // detecting that it's no longer in-use. So we always make a wrapped
+ // copy, where the release proc informs us that the context is done with
+ // it. This is unfortunate - we'll have two texture objects referencing
+ // the same GPU object. However, no client can ever see the original
+ // texture, so this should be safe. We make the texture uncacheable so
+ // that the release proc is called ASAP.
+ tex = resourceProvider->wrapBackendTexture(
+ backendTexture, grColorType, kBorrow_GrWrapOwnership,
+ GrWrapCacheable::kNo, kRead_GrIOType);
+ if (!tex) {
+ return {};
+ }
+ tex->setRelease(releaseProcHelper);
+ tex->resourcePriv().setUniqueKey(refHelper->fBorrowedTextureKey);
+ }
+ // We use keys to avoid re-wrapping the GrBackendTexture in a GrTexture.
+ // This is unrelated to the whatever SkImage key may be assigned to the
+ // proxy.
+ return {std::move(tex), true,
+ GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
+ },
backendFormat, fBackendTexture.dimensions(), readSwizzle, GrRenderable::kNo, 1,
- fSurfaceOrigin, mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly,
- SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
- GrSurfaceProxy::UseAllocator::kYes);
+ mipMapped, mipMapsStatus, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact,
+ SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
if (!proxy) {
return {};
}