blob: 7eef7162953a0675b4973c48707dc2d394ff2226 [file] [log] [blame]
Jim Van Verthf49262d2018-10-02 12:07:20 -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 <cstddef>
9#include <cstring>
10#include <type_traits>
11
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/core/SkYUVASizeInfo.h"
13#include "include/gpu/GrContext.h"
14#include "include/gpu/GrTexture.h"
15#include "include/private/GrRecordingContext.h"
16#include "src/core/SkAutoPixmapStorage.h"
17#include "src/core/SkMipMap.h"
18#include "src/core/SkScopeExit.h"
19#include "src/gpu/GrClip.h"
20#include "src/gpu/GrContextPriv.h"
21#include "src/gpu/GrGpu.h"
22#include "src/gpu/GrRecordingContextPriv.h"
23#include "src/gpu/GrRenderTargetContext.h"
24#include "src/gpu/GrTextureProducer.h"
25#include "src/gpu/SkGr.h"
26#include "src/gpu/effects/GrYUVtoRGBEffect.h"
27#include "src/image/SkImage_Gpu.h"
28#include "src/image/SkImage_GpuYUVA.h"
Jim Van Verthf49262d2018-10-02 12:07:20 -040029
Brian Salomon5ad6fd32019-03-21 15:30:08 -040030static constexpr auto kAssumedColorType = kRGBA_8888_SkColorType;
31
Jim Van Verthcea39022018-10-12 16:15:34 -040032SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrContext> context, int width, int height, uint32_t uniqueID,
Jim Van Verthf49262d2018-10-02 12:07:20 -040033 SkYUVColorSpace colorSpace, sk_sp<GrTextureProxy> proxies[],
Jim Van Verth0e671942018-11-09 12:03:57 -050034 int numProxies, const SkYUVAIndex yuvaIndices[4],
Brian Salomonf05e6d32018-12-20 08:41:41 -050035 GrSurfaceOrigin origin, sk_sp<SkColorSpace> imageColorSpace)
Brian Salomon5ad6fd32019-03-21 15:30:08 -040036 : INHERITED(std::move(context), width, height, uniqueID, kAssumedColorType,
Jim Van Verth8026ccc2018-10-04 13:10:39 -040037 // If an alpha channel is present we always switch to kPremul. This is because,
38 // although the planar data is always un-premul, the final interleaved RGB image
39 // is/would-be premul.
Brian Salomon5ad6fd32019-03-21 15:30:08 -040040 GetAlphaTypeFromYUVAIndices(yuvaIndices), std::move(imageColorSpace))
Jim Van Verth0e671942018-11-09 12:03:57 -050041 , fNumProxies(numProxies)
Jim Van Verth8026ccc2018-10-04 13:10:39 -040042 , fYUVColorSpace(colorSpace)
43 , fOrigin(origin) {
Jim Van Verth0e671942018-11-09 12:03:57 -050044 // The caller should have done this work, just verifying
45 SkDEBUGCODE(int textureCount;)
46 SkASSERT(SkYUVAIndex::AreValidIndices(yuvaIndices, &textureCount));
47 SkASSERT(textureCount == fNumProxies);
48
49 for (int i = 0; i < numProxies; ++i) {
Jim Van Verthf49262d2018-10-02 12:07:20 -040050 fProxies[i] = std::move(proxies[i]);
51 }
52 memcpy(fYUVAIndices, yuvaIndices, 4*sizeof(SkYUVAIndex));
Jim Van Verthf49262d2018-10-02 12:07:20 -040053}
54
Jim Van Verth3e4c2f32019-01-11 13:32:45 -050055// For onMakeColorSpace()
56SkImage_GpuYUVA::SkImage_GpuYUVA(const SkImage_GpuYUVA* image, sk_sp<SkColorSpace> targetCS)
Brian Salomon5ad6fd32019-03-21 15:30:08 -040057 : INHERITED(image->fContext, image->width(), image->height(), kNeedNewImageUniqueID,
58 kAssumedColorType,
59 // If an alpha channel is present we always switch to kPremul. This is because,
60 // although the planar data is always un-premul, the final interleaved RGB image
61 // is/would-be premul.
62 GetAlphaTypeFromYUVAIndices(image->fYUVAIndices), std::move(targetCS))
63 , fNumProxies(image->fNumProxies)
64 , fYUVColorSpace(image->fYUVColorSpace)
65 , fOrigin(image->fOrigin)
66 // Since null fFromColorSpace means no GrColorSpaceXform, we turn a null
67 // image->refColorSpace() into an explicit SRGB.
68 , fFromColorSpace(image->colorSpace() ? image->refColorSpace() : SkColorSpace::MakeSRGB()) {
69 // The caller should have done this work, just verifying
Jim Van Verth3e4c2f32019-01-11 13:32:45 -050070 SkDEBUGCODE(int textureCount;)
71 SkASSERT(SkYUVAIndex::AreValidIndices(image->fYUVAIndices, &textureCount));
72 SkASSERT(textureCount == fNumProxies);
73
Brian Salomonad8efda2019-05-10 09:22:49 -040074 if (image->fRGBProxy) {
75 fRGBProxy = image->fRGBProxy; // we ref in this case, not move
76 } else {
77 for (int i = 0; i < fNumProxies; ++i) {
78 fProxies[i] = image->fProxies[i]; // we ref in this case, not move
79 }
Jim Van Verth3e4c2f32019-01-11 13:32:45 -050080 }
81 memcpy(fYUVAIndices, image->fYUVAIndices, 4 * sizeof(SkYUVAIndex));
82}
83
Jim Van Verthf49262d2018-10-02 12:07:20 -040084SkImage_GpuYUVA::~SkImage_GpuYUVA() {}
85
Robert Phillips8defcc12019-03-05 15:58:59 -050086bool SkImage_GpuYUVA::setupMipmapsForPlanes(GrRecordingContext* context) const {
Brian Salomonad8efda2019-05-10 09:22:49 -040087 // We shouldn't get here if the planes were already flattened to RGBA.
88 SkASSERT(fProxies[0] && !fRGBProxy);
Robert Phillips8defcc12019-03-05 15:58:59 -050089 if (!context || !fContext->priv().matches(context)) {
90 return false;
91 }
92
Jim Van Verth0e671942018-11-09 12:03:57 -050093 for (int i = 0; i < fNumProxies; ++i) {
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040094 GrTextureProducer::CopyParams copyParams;
95 int mipCount = SkMipMap::ComputeLevelCount(fProxies[i]->width(), fProxies[i]->height());
Robert Phillips9da87e02019-02-04 13:26:26 -050096 if (mipCount && GrGpu::IsACopyNeededForMips(fContext->priv().caps(),
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040097 fProxies[i].get(),
98 GrSamplerState::Filter::kMipMap,
99 &copyParams)) {
Robert Phillips8defcc12019-03-05 15:58:59 -0500100 auto mippedProxy = GrCopyBaseMipMapToTextureProxy(context, fProxies[i].get());
Jim Van Verthf542cab2018-11-07 12:08:21 -0500101 if (!mippedProxy) {
102 return false;
103 }
104 fProxies[i] = mippedProxy;
Jim Van Verth30e0d7f2018-11-02 13:36:42 -0400105 }
106 }
107 return true;
108}
109
Jim Van Verthf49262d2018-10-02 12:07:20 -0400110//////////////////////////////////////////////////////////////////////////////////////////////////
Jim Van Verthf49262d2018-10-02 12:07:20 -0400111
Brian Salomonf9a1fdf2019-05-09 10:30:12 -0400112GrSemaphoresSubmitted SkImage_GpuYUVA::onFlush(GrContext* context, const GrFlushInfo& info) {
113 if (!context || !fContext->priv().matches(context) || fContext->abandoned()) {
114 return GrSemaphoresSubmitted::kNo;
115 }
116
Brian Salomonad8efda2019-05-10 09:22:49 -0400117 GrSurfaceProxy* proxies[4] = {fProxies[0].get(), fProxies[1].get(),
118 fProxies[2].get(), fProxies[3].get()};
Brian Salomonf9a1fdf2019-05-09 10:30:12 -0400119 int numProxies = fNumProxies;
120 if (fRGBProxy) {
Brian Salomonad8efda2019-05-10 09:22:49 -0400121 // Either we've already flushed the flattening draw or the flattening is unflushed. In the
122 // latter case it should still be ok to just pass fRGBProxy because it in turn depends on
123 // the planar proxies and will cause all of their work to flush as well.
124 proxies[0] = fRGBProxy.get();
125 numProxies = 1;
Brian Salomonf9a1fdf2019-05-09 10:30:12 -0400126 }
127 return context->priv().flushSurfaces(proxies, numProxies, info);
128}
129
Robert Phillips193c4212019-03-04 12:18:53 -0500130GrTextureProxy* SkImage_GpuYUVA::peekProxy() const {
131 return fRGBProxy.get();
132}
133
Robert Phillips6603a172019-03-05 12:35:44 -0500134sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef(GrRecordingContext* context) const {
135 if (fRGBProxy) {
136 return fRGBProxy;
Jim Van Verthf49262d2018-10-02 12:07:20 -0400137 }
138
Robert Phillips6603a172019-03-05 12:35:44 -0500139 if (!context || !fContext->priv().matches(context)) {
140 return nullptr;
141 }
142
Robert Phillips6603a172019-03-05 12:35:44 -0500143 // Needs to create a render target in order to draw to it for the yuv->rgb conversion.
144 sk_sp<GrRenderTargetContext> renderTargetContext(
Brian Salomon5ad6fd32019-03-21 15:30:08 -0400145 context->priv().makeDeferredRenderTargetContext(
Brian Salomon27ae52c2019-07-03 11:27:44 -0400146 SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888,
147 this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin));
Robert Phillips6603a172019-03-05 12:35:44 -0500148 if (!renderTargetContext) {
149 return nullptr;
150 }
151
Brian Salomon5ad6fd32019-03-21 15:30:08 -0400152 sk_sp<GrColorSpaceXform> colorSpaceXform;
153 if (fFromColorSpace) {
154 colorSpaceXform = GrColorSpaceXform::Make(fFromColorSpace.get(), this->alphaType(),
155 this->colorSpace(), this->alphaType());
156 }
Robert Phillips6603a172019-03-05 12:35:44 -0500157 const SkRect rect = SkRect::MakeIWH(this->width(), this->height());
158 if (!RenderYUVAToRGBA(fContext.get(), renderTargetContext.get(), rect, fYUVColorSpace,
159 std::move(colorSpaceXform), fProxies, fYUVAIndices)) {
160 return nullptr;
161 }
162
163 fRGBProxy = renderTargetContext->asTextureProxyRef();
Brian Salomonad8efda2019-05-10 09:22:49 -0400164 for (auto& p : fProxies) {
165 p.reset();
166 }
Jim Van Verthf49262d2018-10-02 12:07:20 -0400167 return fRGBProxy;
168}
169
Robert Phillips6603a172019-03-05 12:35:44 -0500170sk_sp<GrTextureProxy> SkImage_GpuYUVA::asMippedTextureProxyRef(GrRecordingContext* context) const {
171 if (!context || !fContext->priv().matches(context)) {
172 return nullptr;
173 }
174
Jim Van Verth803a5022018-11-05 15:55:53 -0500175 // if invalid or already has miplevels
Robert Phillips6603a172019-03-05 12:35:44 -0500176 auto proxy = this->asTextureProxyRef(context);
Jim Van Verth803a5022018-11-05 15:55:53 -0500177 if (!proxy || GrMipMapped::kYes == fRGBProxy->mipMapped()) {
178 return proxy;
179 }
180
181 // need to generate mips for the proxy
Robert Phillips8defcc12019-03-05 15:58:59 -0500182 if (auto mippedProxy = GrCopyBaseMipMapToTextureProxy(context, proxy.get())) {
Jim Van Verth803a5022018-11-05 15:55:53 -0500183 fRGBProxy = mippedProxy;
184 return mippedProxy;
185 }
186
187 // failed to generate mips
188 return nullptr;
189}
190
Jim Van Verth9bf81202018-10-30 15:53:36 -0400191//////////////////////////////////////////////////////////////////////////////////////////////////
192
Robert Phillips6603a172019-03-05 12:35:44 -0500193sk_sp<SkImage> SkImage_GpuYUVA::onMakeColorTypeAndColorSpace(GrRecordingContext*,
194 SkColorType,
Brian Osmanf48c9962019-01-14 11:15:50 -0500195 sk_sp<SkColorSpace> targetCS) const {
196 // We explicitly ignore color type changes, for now.
197
Jim Van Verth3e4c2f32019-01-11 13:32:45 -0500198 // we may need a mutex here but for now we expect usage to be in a single thread
199 if (fOnMakeColorSpaceTarget &&
Brian Osmanf48c9962019-01-14 11:15:50 -0500200 SkColorSpace::Equals(targetCS.get(), fOnMakeColorSpaceTarget.get())) {
Jim Van Verth3e4c2f32019-01-11 13:32:45 -0500201 return fOnMakeColorSpaceResult;
202 }
Brian Osmanf48c9962019-01-14 11:15:50 -0500203 sk_sp<SkImage> result = sk_sp<SkImage>(new SkImage_GpuYUVA(this, targetCS));
Jim Van Verth3e4c2f32019-01-11 13:32:45 -0500204 if (result) {
Brian Osmanf48c9962019-01-14 11:15:50 -0500205 fOnMakeColorSpaceTarget = targetCS;
Jim Van Verth3e4c2f32019-01-11 13:32:45 -0500206 fOnMakeColorSpaceResult = result;
207 }
208 return result;
209}
210
211//////////////////////////////////////////////////////////////////////////////////////////////////
212
Jim Van Verth9bf81202018-10-30 15:53:36 -0400213sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrContext* ctx,
214 SkYUVColorSpace colorSpace,
215 const GrBackendTexture yuvaTextures[],
216 const SkYUVAIndex yuvaIndices[4],
217 SkISize imageSize,
218 GrSurfaceOrigin imageOrigin,
219 sk_sp<SkColorSpace> imageColorSpace) {
Jim Van Verth0e671942018-11-09 12:03:57 -0500220 int numTextures;
221 if (!SkYUVAIndex::AreValidIndices(yuvaIndices, &numTextures)) {
222 return nullptr;
Jim Van Verth9bf81202018-10-30 15:53:36 -0400223 }
224
Jim Van Verth0e671942018-11-09 12:03:57 -0500225 sk_sp<GrTextureProxy> tempTextureProxies[4];
Jim Van Verth53275362018-11-09 15:42:35 -0500226 if (!SkImage_GpuBase::MakeTempTextureProxies(ctx, yuvaTextures, numTextures, yuvaIndices,
227 imageOrigin, tempTextureProxies)) {
Jim Van Verth0e671942018-11-09 12:03:57 -0500228 return nullptr;
Jim Van Verth9bf81202018-10-30 15:53:36 -0400229 }
230
231 return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(ctx), imageSize.width(), imageSize.height(),
232 kNeedNewImageUniqueID, colorSpace, tempTextureProxies,
Brian Salomonf05e6d32018-12-20 08:41:41 -0500233 numTextures, yuvaIndices, imageOrigin, imageColorSpace);
Jim Van Verth9bf81202018-10-30 15:53:36 -0400234}
Jim Van Verthc8429ad2018-11-20 11:12:37 -0500235
236sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(
237 GrContext* context, SkYUVColorSpace yuvColorSpace, const SkPixmap yuvaPixmaps[],
238 const SkYUVAIndex yuvaIndices[4], SkISize imageSize, GrSurfaceOrigin imageOrigin,
239 bool buildMips, bool limitToMaxTextureSize, sk_sp<SkColorSpace> imageColorSpace) {
Mike Reed6a5f7e22019-05-23 15:30:07 -0400240 if (!context) {
241 return nullptr; // until we impl this for raster backend
242 }
243
Jim Van Verthc8429ad2018-11-20 11:12:37 -0500244 int numPixmaps;
245 if (!SkYUVAIndex::AreValidIndices(yuvaIndices, &numPixmaps)) {
246 return nullptr;
247 }
248
Brian Osman7dcc6162019-03-25 10:12:57 -0400249 if (!context->priv().caps()->mipMapSupport()) {
250 buildMips = false;
251 }
252
Jim Van Verthc8429ad2018-11-20 11:12:37 -0500253 // Make proxies
Robert Phillips9da87e02019-02-04 13:26:26 -0500254 GrProxyProvider* proxyProvider = context->priv().proxyProvider();
Jim Van Verthc8429ad2018-11-20 11:12:37 -0500255 sk_sp<GrTextureProxy> tempTextureProxies[4];
256 for (int i = 0; i < numPixmaps; ++i) {
257 const SkPixmap* pixmap = &yuvaPixmaps[i];
258 SkAutoPixmapStorage resized;
Robert Phillips9da87e02019-02-04 13:26:26 -0500259 int maxTextureSize = context->priv().caps()->maxTextureSize();
Jim Van Verthc8429ad2018-11-20 11:12:37 -0500260 int maxDim = SkTMax(yuvaPixmaps[i].width(), yuvaPixmaps[i].height());
261 if (limitToMaxTextureSize && maxDim > maxTextureSize) {
262 float scale = static_cast<float>(maxTextureSize) / maxDim;
263 int newWidth = SkTMin(static_cast<int>(yuvaPixmaps[i].width() * scale),
264 maxTextureSize);
265 int newHeight = SkTMin(static_cast<int>(yuvaPixmaps[i].height() * scale),
266 maxTextureSize);
267 SkImageInfo info = yuvaPixmaps[i].info().makeWH(newWidth, newHeight);
268 if (!resized.tryAlloc(info) ||
269 !yuvaPixmaps[i].scalePixels(resized, kLow_SkFilterQuality)) {
270 return nullptr;
271 }
272 pixmap = &resized;
273 }
274 // Turn the pixmap into a GrTextureProxy
Brian Osman7dcc6162019-03-25 10:12:57 -0400275 SkBitmap bmp;
276 bmp.installPixels(*pixmap);
277 GrMipMapped mipMapped = buildMips ? GrMipMapped::kYes : GrMipMapped::kNo;
278 tempTextureProxies[i] = proxyProvider->createProxyFromBitmap(bmp, mipMapped);
Jim Van Verthc8429ad2018-11-20 11:12:37 -0500279 if (!tempTextureProxies[i]) {
280 return nullptr;
281 }
282 }
283
284 return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(context), imageSize.width(), imageSize.height(),
285 kNeedNewImageUniqueID, yuvColorSpace, tempTextureProxies,
Brian Salomonf05e6d32018-12-20 08:41:41 -0500286 numPixmaps, yuvaIndices, imageOrigin, imageColorSpace);
Jim Van Verthc8429ad2018-11-20 11:12:37 -0500287}
288
289
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400290/////////////////////////////////////////////////////////////////////////////////////////////////
Brian Salomoncdd8a0a2019-01-10 12:09:52 -0500291sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(
292 GrContext* context,
293 SkYUVColorSpace yuvColorSpace,
294 const GrBackendFormat yuvaFormats[],
295 const SkISize yuvaSizes[],
296 const SkYUVAIndex yuvaIndices[4],
297 int imageWidth,
298 int imageHeight,
299 GrSurfaceOrigin imageOrigin,
300 sk_sp<SkColorSpace> imageColorSpace,
301 PromiseImageTextureFulfillProc textureFulfillProc,
302 PromiseImageTextureReleaseProc textureReleaseProc,
303 PromiseImageTextureDoneProc promiseDoneProc,
Brian Salomon0cc57542019-03-08 13:28:46 -0500304 PromiseImageTextureContext textureContexts[],
305 PromiseImageApiVersion version) {
Jim Van Verthf00b1622018-10-10 13:03:23 -0400306 int numTextures;
307 bool valid = SkYUVAIndex::AreValidIndices(yuvaIndices, &numTextures);
308
Brian Salomonbe5a0932018-12-10 10:03:26 -0500309 // The contract here is that if 'promiseDoneProc' is passed in it should always be called,
310 // even if creation of the SkImage fails. Once we call MakePromiseImageLazyProxy it takes
311 // responsibility for calling the done proc.
312 if (!promiseDoneProc) {
313 return nullptr;
Jim Van Verthf00b1622018-10-10 13:03:23 -0400314 }
Brian Salomonbe5a0932018-12-10 10:03:26 -0500315 int proxiesCreated = 0;
316 SkScopeExit callDone([promiseDoneProc, textureContexts, numTextures, &proxiesCreated]() {
317 for (int i = proxiesCreated; i < numTextures; ++i) {
318 promiseDoneProc(textureContexts[i]);
319 }
320 });
Jim Van Verthf00b1622018-10-10 13:03:23 -0400321
322 if (!valid) {
323 return nullptr;
324 }
Robert Phillipsef85d192018-10-09 11:24:09 -0400325
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400326 if (!context) {
327 return nullptr;
328 }
329
Greg Kaiser9a2169e2019-02-10 17:29:46 -0800330 if (imageWidth <= 0 || imageHeight <= 0) {
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400331 return nullptr;
332 }
333
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400334 SkAlphaType at = (-1 != yuvaIndices[SkYUVAIndex::kA_Index].fIndex) ? kPremul_SkAlphaType
335 : kOpaque_SkAlphaType;
Brian Salomon5ad6fd32019-03-21 15:30:08 -0400336 SkImageInfo info = SkImageInfo::Make(imageWidth, imageHeight, kAssumedColorType,
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400337 at, imageColorSpace);
338 if (!SkImageInfoIsValid(info)) {
339 return nullptr;
340 }
341
Jim Van Verthf9f07352018-10-24 10:32:20 -0400342 // verify sizes with expected texture count
Jim Van Verth8f11e432018-10-18 14:36:59 -0400343 for (int i = 0; i < numTextures; ++i) {
Jim Van Verthf9f07352018-10-24 10:32:20 -0400344 if (yuvaSizes[i].isEmpty()) {
Jim Van Verth8f11e432018-10-18 14:36:59 -0400345 return nullptr;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400346 }
347 }
Jim Van Verthe24b5872018-10-29 16:26:02 -0400348 for (int i = numTextures; i < SkYUVASizeInfo::kMaxCount; ++i) {
Jim Van Verthf9f07352018-10-24 10:32:20 -0400349 if (!yuvaSizes[i].isEmpty()) {
Jim Van Verth8f11e432018-10-18 14:36:59 -0400350 return nullptr;
351 }
Jim Van Verthf99a6742018-10-18 16:13:18 +0000352 }
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400353
354 // Get lazy proxies
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400355 sk_sp<GrTextureProxy> proxies[4];
Jim Van Verthf00b1622018-10-10 13:03:23 -0400356 for (int texIdx = 0; texIdx < numTextures; ++texIdx) {
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400357 GrColorType colorType = context->priv().caps()->getYUVAColorTypeFromBackendFormat(
358 yuvaFormats[texIdx]);
359 if (GrColorType::kUnknown == colorType) {
Jim Van Verthf00b1622018-10-10 13:03:23 -0400360 return nullptr;
361 }
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400362
Brian Salomonbe5a0932018-12-10 10:03:26 -0500363 proxies[texIdx] = MakePromiseImageLazyProxy(
Robert Phillipsc80b0e92019-07-23 10:27:09 -0400364 context, yuvaSizes[texIdx].width(), yuvaSizes[texIdx].height(), imageOrigin,
365 colorType, yuvaFormats[texIdx], GrMipMapped::kNo, textureFulfillProc,
366 textureReleaseProc, promiseDoneProc, textureContexts[texIdx], version);
Brian Salomonbe5a0932018-12-10 10:03:26 -0500367 ++proxiesCreated;
Jim Van Verthf00b1622018-10-10 13:03:23 -0400368 if (!proxies[texIdx]) {
369 return nullptr;
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400370 }
371 }
372
Jim Van Verthcea39022018-10-12 16:15:34 -0400373 return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(context), imageWidth, imageHeight,
Jim Van Verth0e671942018-11-09 12:03:57 -0500374 kNeedNewImageUniqueID, yuvColorSpace, proxies, numTextures,
Brian Salomonf05e6d32018-12-20 08:41:41 -0500375 yuvaIndices, imageOrigin, std::move(imageColorSpace));
Jim Van Verth8bbce0e2018-10-08 14:34:52 -0400376}