Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 | |
Robert Phillips | 4e105e2 | 2020-07-16 09:18:50 -0400 | [diff] [blame] | 8 | #include "include/gpu/GrDirectContext.h" |
Robert Phillips | b7bfbc2 | 2020-07-01 12:55:01 -0400 | [diff] [blame] | 9 | #include "include/gpu/GrRecordingContext.h" |
Ben Wagner | 21bca28 | 2019-05-15 10:15:52 -0400 | [diff] [blame] | 10 | #include "src/core/SkMessageBus.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrBackendTextureImageGenerator.h" |
Adlai Holler | a069304 | 2020-10-14 11:23:11 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrDirectContextPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/GrGpu.h" |
| 14 | #include "src/gpu/GrProxyProvider.h" |
| 15 | #include "src/gpu/GrRecordingContextPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "src/gpu/GrResourceCache.h" |
| 17 | #include "src/gpu/GrResourceProvider.h" |
| 18 | #include "src/gpu/GrResourceProviderPriv.h" |
| 19 | #include "src/gpu/GrSemaphore.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 20 | #include "src/gpu/GrTexture.h" |
Adlai Holler | 9e2c50e | 2021-02-09 14:41:52 -0500 | [diff] [blame] | 21 | #include "src/gpu/GrTextureProxyPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 22 | #include "src/gpu/SkGr.h" |
| 23 | #include "src/gpu/gl/GrGLTexture.h" |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 24 | |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 25 | GrBackendTextureImageGenerator::RefHelper::RefHelper( |
| 26 | GrTexture* texture, |
| 27 | GrDirectContext::DirectContextID owningContextID, |
| 28 | std::unique_ptr<GrSemaphore> semaphore) |
Brian Salomon | b916b7b | 2019-04-01 13:34:34 -0400 | [diff] [blame] | 29 | : fOriginalTexture(texture) |
| 30 | , fOwningContextID(owningContextID) |
| 31 | , fBorrowingContextReleaseProc(nullptr) |
Greg Daniel | 301015c | 2019-11-18 14:06:46 -0500 | [diff] [blame] | 32 | , fSemaphore(std::move(semaphore)) {} |
Brian Salomon | b916b7b | 2019-04-01 13:34:34 -0400 | [diff] [blame] | 33 | |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 34 | GrBackendTextureImageGenerator::RefHelper::~RefHelper() { |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 35 | SkASSERT(!fBorrowingContextID.isValid()); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 36 | |
| 37 | // Generator has been freed, and no one is borrowing the texture. Notify the original cache |
| 38 | // that it can free the last ref, so it happens on the correct thread. |
Robert Phillips | ddc2148 | 2019-10-16 14:30:09 -0400 | [diff] [blame] | 39 | GrTextureFreedMessage msg { fOriginalTexture, fOwningContextID }; |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 40 | SkMessageBus<GrTextureFreedMessage, GrDirectContext::DirectContextID>::Post(msg); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 41 | } |
| 42 | |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 43 | std::unique_ptr<SkImageGenerator> |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 44 | GrBackendTextureImageGenerator::Make(sk_sp<GrTexture> texture, GrSurfaceOrigin origin, |
Greg Daniel | 301015c | 2019-11-18 14:06:46 -0500 | [diff] [blame] | 45 | std::unique_ptr<GrSemaphore> semaphore, SkColorType colorType, |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 46 | SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) { |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 47 | GrDirectContext* dContext = texture->getContext(); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 48 | |
| 49 | // Attach our texture to this context's resource cache. This ensures that deletion will happen |
| 50 | // in the correct thread/context. This adds the only ref to the texture that will persist from |
| 51 | // this point. That ref will be released when the generator's RefHelper is freed. |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 52 | dContext->priv().getResourceCache()->insertDelayedTextureUnref(texture.get()); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 53 | |
Robert Phillips | b67821d | 2017-12-13 15:00:45 -0500 | [diff] [blame] | 54 | GrBackendTexture backendTexture = texture->getBackendTexture(); |
Robert Phillips | c80b0e9 | 2019-07-23 10:27:09 -0400 | [diff] [blame] | 55 | |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 56 | if (!dContext->priv().caps()->areColorTypeAndFormatCompatible( |
Robert Phillips | 62221e7 | 2019-07-24 15:07:38 -0400 | [diff] [blame] | 57 | SkColorTypeToGrColorType(colorType), backendTexture.getBackendFormat())) { |
| 58 | return nullptr; |
Brian Osman | 052ef69 | 2018-03-27 09:56:31 -0400 | [diff] [blame] | 59 | } |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 60 | |
| 61 | SkImageInfo info = SkImageInfo::Make(texture->width(), texture->height(), colorType, alphaType, |
| 62 | std::move(colorSpace)); |
| 63 | return std::unique_ptr<SkImageGenerator>(new GrBackendTextureImageGenerator( |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 64 | info, texture.get(), origin, dContext->directContextID(), |
Robert Phillips | fd0d970 | 2019-02-01 10:19:42 -0500 | [diff] [blame] | 65 | std::move(semaphore), backendTexture)); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 66 | } |
| 67 | |
Greg Daniel | 301015c | 2019-11-18 14:06:46 -0500 | [diff] [blame] | 68 | GrBackendTextureImageGenerator::GrBackendTextureImageGenerator( |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 69 | const SkImageInfo& info, |
| 70 | GrTexture* texture, |
| 71 | GrSurfaceOrigin origin, |
| 72 | GrDirectContext::DirectContextID owningContextID, |
| 73 | std::unique_ptr<GrSemaphore> semaphore, |
| 74 | const GrBackendTexture& backendTex) |
Brian Salomon | b916b7b | 2019-04-01 13:34:34 -0400 | [diff] [blame] | 75 | : INHERITED(info) |
Greg Daniel | 301015c | 2019-11-18 14:06:46 -0500 | [diff] [blame] | 76 | , fRefHelper(new RefHelper(texture, owningContextID, std::move(semaphore))) |
Brian Salomon | b916b7b | 2019-04-01 13:34:34 -0400 | [diff] [blame] | 77 | , fBackendTexture(backendTex) |
Brian Salomon | b916b7b | 2019-04-01 13:34:34 -0400 | [diff] [blame] | 78 | , fSurfaceOrigin(origin) {} |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 79 | |
| 80 | GrBackendTextureImageGenerator::~GrBackendTextureImageGenerator() { |
| 81 | fRefHelper->unref(); |
| 82 | } |
| 83 | |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 84 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 85 | |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 86 | void GrBackendTextureImageGenerator::ReleaseRefHelper_TextureReleaseProc(void* ctx) { |
| 87 | RefHelper* refHelper = static_cast<RefHelper*>(ctx); |
| 88 | SkASSERT(refHelper); |
| 89 | |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 90 | refHelper->fBorrowingContextReleaseProc = nullptr; |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 91 | refHelper->fBorrowingContextID.makeInvalid(); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 92 | refHelper->unref(); |
| 93 | } |
| 94 | |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 95 | GrSurfaceProxyView GrBackendTextureImageGenerator::onGenerateTexture( |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 96 | GrRecordingContext* rContext, |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 97 | const SkImageInfo& info, |
| 98 | const SkIPoint& origin, |
Brian Salomon | 7e67dca | 2020-07-21 09:27:25 -0400 | [diff] [blame] | 99 | GrMipmapped mipMapped, |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 100 | GrImageTexGenPolicy texGenPolicy) { |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 101 | SkASSERT(rContext); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 102 | |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 103 | // We currently limit GrBackendTextureImageGenerators to direct contexts since |
| 104 | // only Flutter uses them and doesn't use recording/DDL contexts. Ideally, the |
| 105 | // cross context texture functionality can be subsumed by the thread-safe cache |
| 106 | // working with utility contexts. |
| 107 | auto dContext = rContext->asDirectContext(); |
| 108 | if (!dContext) { |
| 109 | return {}; |
| 110 | } |
| 111 | |
| 112 | if (dContext->backend() != fBackendTexture.backend()) { |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 113 | return {}; |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 114 | } |
Brian Osman | 052ef69 | 2018-03-27 09:56:31 -0400 | [diff] [blame] | 115 | if (info.colorType() != this->getInfo().colorType()) { |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 116 | return {}; |
Brian Osman | 052ef69 | 2018-03-27 09:56:31 -0400 | [diff] [blame] | 117 | } |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 118 | |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 119 | auto proxyProvider = dContext->priv().proxyProvider(); |
Robert Phillips | 777707b | 2018-01-17 11:40:14 -0500 | [diff] [blame] | 120 | |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 121 | fBorrowingMutex.acquire(); |
Brian Salomon | b2c5dae | 2019-03-04 10:25:17 -0500 | [diff] [blame] | 122 | sk_sp<GrRefCntedCallback> releaseProcHelper; |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 123 | if (fRefHelper->fBorrowingContextID.isValid()) { |
| 124 | if (fRefHelper->fBorrowingContextID != dContext->directContextID()) { |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 125 | fBorrowingMutex.release(); |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 126 | rContext->priv().printWarningMessage( |
Chris Dalton | 5a5fe79 | 2020-02-15 11:41:30 -0700 | [diff] [blame] | 127 | "GrBackendTextureImageGenerator: Trying to use texture on two GrContexts!\n"); |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 128 | return {}; |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 129 | } else { |
| 130 | SkASSERT(fRefHelper->fBorrowingContextReleaseProc); |
| 131 | // Ref the release proc to be held by the proxy we make below |
| 132 | releaseProcHelper = sk_ref_sp(fRefHelper->fBorrowingContextReleaseProc); |
Greg Daniel | 966db9e | 2018-01-12 13:15:06 -0500 | [diff] [blame] | 133 | } |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 134 | } else { |
| 135 | SkASSERT(!fRefHelper->fBorrowingContextReleaseProc); |
| 136 | // The ref we add to fRefHelper here will be passed into and owned by the |
Brian Salomon | b2c5dae | 2019-03-04 10:25:17 -0500 | [diff] [blame] | 137 | // GrRefCntedCallback. |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 138 | fRefHelper->ref(); |
Brian Salomon | 694ff17 | 2020-11-04 16:54:28 -0500 | [diff] [blame] | 139 | releaseProcHelper = |
| 140 | GrRefCntedCallback::Make(ReleaseRefHelper_TextureReleaseProc, fRefHelper); |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 141 | fRefHelper->fBorrowingContextReleaseProc = releaseProcHelper.get(); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 142 | } |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 143 | fRefHelper->fBorrowingContextID = dContext->directContextID(); |
Brian Salomon | b916b7b | 2019-04-01 13:34:34 -0400 | [diff] [blame] | 144 | if (!fRefHelper->fBorrowedTextureKey.isValid()) { |
| 145 | static const auto kDomain = GrUniqueKey::GenerateDomain(); |
| 146 | GrUniqueKey::Builder builder(&fRefHelper->fBorrowedTextureKey, kDomain, 1); |
| 147 | builder[0] = this->uniqueID(); |
| 148 | } |
Greg Daniel | abba998 | 2018-02-01 10:07:57 -0500 | [diff] [blame] | 149 | fBorrowingMutex.release(); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 150 | |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 151 | SkASSERT(fRefHelper->fBorrowingContextID == dContext->directContextID()); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 152 | |
Robert Phillips | c80b0e9 | 2019-07-23 10:27:09 -0400 | [diff] [blame] | 153 | GrBackendFormat backendFormat = fBackendTexture.getBackendFormat(); |
| 154 | SkASSERT(backendFormat.isValid()); |
| 155 | |
| 156 | GrColorType grColorType = SkColorTypeToGrColorType(info.colorType()); |
| 157 | |
Brian Salomon | 40a4062 | 2020-07-21 10:32:07 -0400 | [diff] [blame] | 158 | GrMipmapped textureIsMipMapped = fBackendTexture.hasMipmaps() ? GrMipmapped::kYes |
Brian Salomon | 7e67dca | 2020-07-21 09:27:25 -0400 | [diff] [blame] | 159 | : GrMipmapped::kNo; |
Greg Daniel | e728f67 | 2018-01-17 10:52:04 -0500 | [diff] [blame] | 160 | |
Chris Dalton | 95d8ceb | 2019-07-30 11:17:59 -0600 | [diff] [blame] | 161 | // Ganesh assumes that, when wrapping a mipmapped backend texture from a client, that its |
| 162 | // mipmaps are fully fleshed out. |
Brian Salomon | 40a4062 | 2020-07-21 10:32:07 -0400 | [diff] [blame] | 163 | GrMipmapStatus mipmapStatus = fBackendTexture.hasMipmaps() |
Brian Salomon | a6db510 | 2020-07-21 09:56:23 -0400 | [diff] [blame] | 164 | ? GrMipmapStatus::kValid : GrMipmapStatus::kNotAllocated; |
Chris Dalton | 95d8ceb | 2019-07-30 11:17:59 -0600 | [diff] [blame] | 165 | |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 166 | GrSwizzle readSwizzle = dContext->priv().caps()->getReadSwizzle(backendFormat, grColorType); |
Greg Daniel | ce3ddaa | 2020-01-22 16:58:15 -0500 | [diff] [blame] | 167 | |
Brian Salomon | b6a3a3b | 2019-04-01 12:29:34 -0400 | [diff] [blame] | 168 | // Must make copies of member variables to capture in the lambda since this image generator may |
| 169 | // be deleted before we actually execute the lambda. |
Brian Salomon | 8a78e9c | 2020-03-27 10:42:15 -0400 | [diff] [blame] | 170 | sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy( |
| 171 | [refHelper = fRefHelper, releaseProcHelper, backendTexture = fBackendTexture]( |
Brian Salomon | 63410e9 | 2020-03-23 18:32:50 -0400 | [diff] [blame] | 172 | GrResourceProvider* resourceProvider, |
| 173 | const GrSurfaceProxy::LazySurfaceDesc&) -> GrSurfaceProxy::LazyCallbackResult { |
Brian Salomon | 8a78e9c | 2020-03-27 10:42:15 -0400 | [diff] [blame] | 174 | if (refHelper->fSemaphore) { |
| 175 | resourceProvider->priv().gpu()->waitSemaphore(refHelper->fSemaphore.get()); |
| 176 | } |
Greg Daniel | e728f67 | 2018-01-17 10:52:04 -0500 | [diff] [blame] | 177 | |
Brian Salomon | 8a78e9c | 2020-03-27 10:42:15 -0400 | [diff] [blame] | 178 | // If a client re-draws the same image multiple times, the texture we return |
| 179 | // will be cached and re-used. If they draw a subset, though, we may be |
| 180 | // re-called. In that case, we want to re-use the borrowed texture we've |
| 181 | // previously created. |
| 182 | sk_sp<GrTexture> tex; |
| 183 | SkASSERT(refHelper->fBorrowedTextureKey.isValid()); |
| 184 | auto surf = resourceProvider->findByUniqueKey<GrSurface>( |
| 185 | refHelper->fBorrowedTextureKey); |
| 186 | if (surf) { |
| 187 | SkASSERT(surf->asTexture()); |
| 188 | tex = sk_ref_sp(surf->asTexture()); |
| 189 | } else { |
| 190 | // We just gained access to the texture. If we're on the original |
| 191 | // context, we could use the original texture, but we'd have no way of |
| 192 | // detecting that it's no longer in-use. So we always make a wrapped |
| 193 | // copy, where the release proc informs us that the context is done with |
| 194 | // it. This is unfortunate - we'll have two texture objects referencing |
| 195 | // the same GPU object. However, no client can ever see the original |
| 196 | // texture, so this should be safe. We make the texture uncacheable so |
| 197 | // that the release proc is called ASAP. |
| 198 | tex = resourceProvider->wrapBackendTexture( |
| 199 | backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, |
| 200 | kRead_GrIOType); |
| 201 | if (!tex) { |
| 202 | return {}; |
| 203 | } |
| 204 | tex->setRelease(releaseProcHelper); |
| 205 | tex->resourcePriv().setUniqueKey(refHelper->fBorrowedTextureKey); |
| 206 | } |
| 207 | // We use keys to avoid re-wrapping the GrBackendTexture in a GrTexture. |
| 208 | // This is unrelated to the whatever SkImage key may be assigned to the |
| 209 | // proxy. |
| 210 | return {std::move(tex), true, GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced}; |
| 211 | }, |
Greg Daniel | c113f00 | 2020-08-26 13:28:22 -0400 | [diff] [blame] | 212 | backendFormat, fBackendTexture.dimensions(), textureIsMipMapped, mipmapStatus, |
| 213 | GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo, |
Brian Salomon | 8a78e9c | 2020-03-27 10:42:15 -0400 | [diff] [blame] | 214 | GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); |
Greg Daniel | e320486 | 2018-04-16 11:24:10 -0400 | [diff] [blame] | 215 | if (!proxy) { |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 216 | return {}; |
Greg Daniel | e320486 | 2018-04-16 11:24:10 -0400 | [diff] [blame] | 217 | } |
| 218 | |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 219 | if (texGenPolicy == GrImageTexGenPolicy::kDraw && origin.isZero() && |
| 220 | info.dimensions() == fBackendTexture.dimensions() && |
Brian Salomon | 8c82a87 | 2020-07-21 12:09:58 -0400 | [diff] [blame] | 221 | (mipMapped == GrMipmapped::kNo || proxy->mipmapped() == GrMipmapped::kYes)) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 222 | // If the caller wants the entire texture and we have the correct mip support, we're done |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 223 | return GrSurfaceProxyView(std::move(proxy), fSurfaceOrigin, readSwizzle); |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 224 | } else { |
Greg Daniel | 4c6f9b7 | 2019-06-06 13:40:59 -0400 | [diff] [blame] | 225 | SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height()); |
Greg Daniel | 4c6f9b7 | 2019-06-06 13:40:59 -0400 | [diff] [blame] | 226 | |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 227 | SkBudgeted budgeted = texGenPolicy == GrImageTexGenPolicy::kNew_Uncached_Unbudgeted |
| 228 | ? SkBudgeted::kNo |
| 229 | : SkBudgeted::kYes; |
| 230 | |
Robert Phillips | d074b62 | 2021-03-15 08:49:24 -0400 | [diff] [blame] | 231 | auto copy = GrSurfaceProxy::Copy(dContext, |
Brian Salomon | 982127b | 2021-01-21 10:43:35 -0500 | [diff] [blame] | 232 | std::move(proxy), |
| 233 | fSurfaceOrigin, |
| 234 | mipMapped, |
| 235 | subset, |
| 236 | SkBackingFit::kExact, |
| 237 | budgeted); |
Brian Salomon | c524378 | 2020-04-02 12:50:34 -0400 | [diff] [blame] | 238 | return {std::move(copy), fSurfaceOrigin, readSwizzle}; |
Brian Osman | 13dddce | 2017-05-09 13:19:50 -0400 | [diff] [blame] | 239 | } |
| 240 | } |