Skip to content

Commit 52ea577

Browse files
Adlai-HollerSkia Commit-Bot
authored andcommitted
Migrate MakeFromYUVATexturesCopy* to GrRecordingContext
These methods aren't used by our clients – plus we're only de-powering the arg here so we should do fine on canaries. Bug: skia:104662 Change-Id: I2ff5a4e06a5e82458148d555b6dc8643e7e5f60f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306336 Auto-Submit: Adlai Holler <adlai@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
1 parent 3e03e11 commit 52ea577

File tree

8 files changed

+60
-55
lines changed

8 files changed

+60
-55
lines changed

gm/imagefromyuvtextures.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,33 +169,33 @@ class ImageFromYUVTextures : public GpuGM {
169169
releaseContext);
170170
}
171171

172-
sk_sp<SkImage> createReferenceImage(GrDirectContext* context) {
173-
auto planeReleaseContext = new YUVABackendReleaseContext(context);
172+
sk_sp<SkImage> createReferenceImage(GrDirectContext* dContext) {
173+
auto planeReleaseContext = new YUVABackendReleaseContext(dContext);
174174
SkYUVAIndex indices[4];
175175

176-
if (!CreateYUVBackendTextures(context, fYUVABmps, indices, planeReleaseContext)) {
177-
YUVABackendReleaseContext::Unwind(context, planeReleaseContext, false);
176+
if (!CreateYUVBackendTextures(dContext, fYUVABmps, indices, planeReleaseContext)) {
177+
YUVABackendReleaseContext::Unwind(dContext, planeReleaseContext, false);
178178
return nullptr;
179179
}
180180

181-
auto rgbaReleaseContext = new YUVABackendReleaseContext(context);
181+
auto rgbaReleaseContext = new YUVABackendReleaseContext(dContext);
182182

183-
GrBackendTexture resultTexture = context->createBackendTexture(
183+
GrBackendTexture resultTexture = dContext->createBackendTexture(
184184
fRGBABmp.dimensions().width(), fRGBABmp.dimensions().height(),
185185
kRGBA_8888_SkColorType, SkColors::kTransparent,
186186
GrMipmapped::kNo, GrRenderable::kYes, GrProtected::kNo,
187187
YUVABackendReleaseContext::CreationCompleteProc(0),
188188
rgbaReleaseContext);
189189
if (!resultTexture.isValid()) {
190-
YUVABackendReleaseContext::Unwind(context, planeReleaseContext, false);
191-
YUVABackendReleaseContext::Unwind(context, rgbaReleaseContext, false);
190+
YUVABackendReleaseContext::Unwind(dContext, planeReleaseContext, false);
191+
YUVABackendReleaseContext::Unwind(dContext, rgbaReleaseContext, false);
192192
return nullptr;
193193
}
194194

195195
rgbaReleaseContext->set(0, resultTexture);
196196

197197
auto tmp = SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
198-
context,
198+
dContext,
199199
kJPEG_SkYUVColorSpace,
200200
planeReleaseContext->beTextures(),
201201
indices,
@@ -205,7 +205,7 @@ class ImageFromYUVTextures : public GpuGM {
205205
nullptr,
206206
YUVABackendReleaseContext::Release,
207207
rgbaReleaseContext);
208-
YUVABackendReleaseContext::Unwind(context, planeReleaseContext, true);
208+
YUVABackendReleaseContext::Unwind(dContext, planeReleaseContext, true);
209209
return tmp;
210210
}
211211

include/core/SkImage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class SK_API SkImage : public SkRefCnt {
421421
@param imageColorSpace range of colors of the resulting image; may be nullptr
422422
@return created SkImage, or nullptr
423423
*/
424-
static sk_sp<SkImage> MakeFromYUVATexturesCopy(GrContext* context,
424+
static sk_sp<SkImage> MakeFromYUVATexturesCopy(GrRecordingContext* context,
425425
SkYUVColorSpace yuvColorSpace,
426426
const GrBackendTexture yuvaTextures[],
427427
const SkYUVAIndex yuvaIndices[4],
@@ -447,7 +447,7 @@ class SK_API SkImage : public SkRefCnt {
447447
@return created SkImage, or nullptr
448448
*/
449449
static sk_sp<SkImage> MakeFromYUVATexturesCopyWithExternalBackend(
450-
GrContext* context,
450+
GrRecordingContext* context,
451451
SkYUVColorSpace yuvColorSpace,
452452
const GrBackendTexture yuvaTextures[],
453453
const SkYUVAIndex yuvaIndices[4],

src/image/SkImage.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -573,27 +573,27 @@ sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx,
573573
return nullptr;
574574
}
575575

576-
sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrContext* context,
577-
SkYUVColorSpace yuvColorSpace,
578-
const GrBackendTexture yuvaTextures[],
579-
const SkYUVAIndex yuvaIndices[4],
580-
SkISize imageSize,
581-
GrSurfaceOrigin imageOrigin,
582-
sk_sp<SkColorSpace> imageColorSpace) {
576+
sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrRecordingContext*,
577+
SkYUVColorSpace,
578+
const GrBackendTexture[],
579+
const SkYUVAIndex[4],
580+
SkISize,
581+
GrSurfaceOrigin,
582+
sk_sp<SkColorSpace>) {
583583
return nullptr;
584584
}
585585

586586
sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
587-
GrContext* context,
588-
SkYUVColorSpace yuvColorSpace,
589-
const GrBackendTexture yuvaTextures[],
590-
const SkYUVAIndex yuvaIndices[4],
591-
SkISize imageSize,
592-
GrSurfaceOrigin imageOrigin,
593-
const GrBackendTexture& backendTexture,
594-
sk_sp<SkColorSpace> imageColorSpace,
595-
TextureReleaseProc textureReleaseProc,
596-
ReleaseContext releaseContext) {
587+
GrRecordingContext*,
588+
SkYUVColorSpace,
589+
const GrBackendTexture[],
590+
const SkYUVAIndex[4],
591+
SkISize,
592+
GrSurfaceOrigin,
593+
const GrBackendTexture&,
594+
sk_sp<SkColorSpace>,
595+
TextureReleaseProc,
596+
ReleaseContext) {
597597
return nullptr;
598598
}
599599

src/image/SkImage_Gpu.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ sk_sp<SkImage> SkImage::MakeTextureFromCompressed(GrDirectContext* direct, sk_sp
306306
colorType, kOpaque_SkAlphaType, nullptr);
307307
}
308308

309-
sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorSpace yuvColorSpace,
309+
sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrRecordingContext* rContext,
310+
SkYUVColorSpace yuvColorSpace,
310311
const GrBackendTexture yuvaTextures[],
311312
const SkYUVAIndex yuvaIndices[4], SkISize size,
312313
GrSurfaceOrigin origin,
@@ -319,45 +320,48 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorS
319320
}
320321

321322
GrSurfaceProxyView tempViews[4];
322-
if (!SkImage_GpuBase::MakeTempTextureProxies(ctx, yuvaTextures, numTextures, yuvaIndices,
323+
if (!SkImage_GpuBase::MakeTempTextureProxies(rContext, yuvaTextures, numTextures, yuvaIndices,
323324
origin, tempViews, nullptr)) {
324325
return nullptr;
325326
}
326327

327328
const SkRect rect = SkRect::MakeIWH(size.width(), size.height());
328-
if (!RenderYUVAToRGBA(ctx, renderTargetContext, rect, yuvColorSpace, nullptr,
329+
const GrCaps& caps = *rContext->priv().caps();
330+
if (!RenderYUVAToRGBA(caps, renderTargetContext, rect, yuvColorSpace, nullptr,
329331
tempViews, yuvaIndices)) {
330332
return nullptr;
331333
}
332334

333335
SkColorType ct = GrColorTypeToSkColorType(renderTargetContext->colorInfo().colorType());
334336
SkAlphaType at = GetAlphaTypeFromYUVAIndices(yuvaIndices);
337+
// TODO: Remove this use of backdoor.
338+
GrContext* backdoorGrCtx = rContext->priv().backdoor();
335339
// MDB: this call is okay bc we know 'renderTargetContext' was exact
336-
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID,
340+
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(backdoorGrCtx), kNeedNewImageUniqueID,
337341
renderTargetContext->readSurfaceView(), ct, at,
338342
renderTargetContext->colorInfo().refColorSpace());
339343
}
340344

341-
sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrContext* ctx,
345+
sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrRecordingContext* rContext,
342346
SkYUVColorSpace yuvColorSpace,
343347
const GrBackendTexture yuvaTextures[],
344348
const SkYUVAIndex yuvaIndices[4],
345349
SkISize imageSize,
346350
GrSurfaceOrigin imageOrigin,
347351
sk_sp<SkColorSpace> imageColorSpace) {
348352
auto renderTargetContext = GrRenderTargetContext::Make(
349-
ctx, GrColorType::kRGBA_8888, std::move(imageColorSpace), SkBackingFit::kExact,
353+
rContext, GrColorType::kRGBA_8888, std::move(imageColorSpace), SkBackingFit::kExact,
350354
imageSize, 1, GrMipmapped::kNo, GrProtected::kNo, imageOrigin);
351355
if (!renderTargetContext) {
352356
return nullptr;
353357
}
354358

355-
return SkImage_Gpu::ConvertYUVATexturesToRGB(ctx, yuvColorSpace, yuvaTextures, yuvaIndices,
359+
return SkImage_Gpu::ConvertYUVATexturesToRGB(rContext, yuvColorSpace, yuvaTextures, yuvaIndices,
356360
imageSize, imageOrigin, renderTargetContext.get());
357361
}
358362

359363
sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
360-
GrContext* ctx,
364+
GrRecordingContext* rContext,
361365
SkYUVColorSpace yuvColorSpace,
362366
const GrBackendTexture yuvaTextures[],
363367
const SkYUVAIndex yuvaIndices[4],
@@ -367,7 +371,7 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
367371
sk_sp<SkColorSpace> imageColorSpace,
368372
TextureReleaseProc textureReleaseProc,
369373
ReleaseContext releaseContext) {
370-
const GrCaps* caps = ctx->priv().caps();
374+
const GrCaps* caps = rContext->priv().caps();
371375

372376
sk_sp<GrRefCntedCallback> releaseHelper;
373377
if (textureReleaseProc) {
@@ -389,13 +393,13 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopyWithExternalBackend(
389393
// Needs to create a render target with external texture
390394
// in order to draw to it for the yuv->rgb conversion.
391395
auto renderTargetContext = GrRenderTargetContext::MakeFromBackendTexture(
392-
ctx, grColorType, std::move(imageColorSpace), backendTexture, 1, imageOrigin,
396+
rContext, grColorType, std::move(imageColorSpace), backendTexture, 1, imageOrigin,
393397
nullptr, std::move(releaseHelper));
394398
if (!renderTargetContext) {
395399
return nullptr;
396400
}
397401

398-
return SkImage_Gpu::ConvertYUVATexturesToRGB(ctx, yuvColorSpace, yuvaTextures, yuvaIndices,
402+
return SkImage_Gpu::ConvertYUVATexturesToRGB(rContext, yuvColorSpace, yuvaTextures, yuvaIndices,
399403
imageSize, imageOrigin, renderTargetContext.get());
400404
}
401405

src/image/SkImage_Gpu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ class SkImage_Gpu : public SkImage_GpuBase {
8484
PromiseImageTextureContext textureContext,
8585
PromiseImageApiVersion);
8686

87-
static sk_sp<SkImage> ConvertYUVATexturesToRGB(GrContext*, SkYUVColorSpace yuvColorSpace,
88-
const GrBackendTexture yuvaTextures[],
89-
const SkYUVAIndex yuvaIndices[4],
90-
SkISize imageSize, GrSurfaceOrigin imageOrigin,
87+
static sk_sp<SkImage> ConvertYUVATexturesToRGB(GrRecordingContext*, SkYUVColorSpace,
88+
const GrBackendTexture [],
89+
const SkYUVAIndex [4],
90+
SkISize, GrSurfaceOrigin,
9191
GrRenderTargetContext*);
9292

9393
private:

src/image/SkImage_GpuBase.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ bool SkImage_GpuBase::onIsValid(GrRecordingContext* context) const {
261261
return true;
262262
}
263263

264-
bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx,
264+
bool SkImage_GpuBase::MakeTempTextureProxies(GrRecordingContext* rContext,
265265
const GrBackendTexture yuvaTextures[],
266266
int numTextures,
267267
const SkYUVAIndex yuvaIndices[4],
268268
GrSurfaceOrigin imageOrigin,
269269
GrSurfaceProxyView tempViews[4],
270270
sk_sp<GrRefCntedCallback> releaseHelper) {
271-
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
271+
GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
272272
for (int textureIndex = 0; textureIndex < numTextures; ++textureIndex) {
273273
const GrBackendFormat& backendFormat = yuvaTextures[textureIndex].getBackendFormat();
274274
if (!backendFormat.isValid()) {
@@ -305,7 +305,8 @@ bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx,
305305
return true;
306306
}
307307

308-
bool SkImage_GpuBase::RenderYUVAToRGBA(GrContext* ctx, GrRenderTargetContext* renderTargetContext,
308+
bool SkImage_GpuBase::RenderYUVAToRGBA(const GrCaps& caps,
309+
GrRenderTargetContext* renderTargetContext,
309310
const SkRect& rect, SkYUVColorSpace yuvColorSpace,
310311
sk_sp<GrColorSpaceXform> colorSpaceXform,
311312
GrSurfaceProxyView views[4],
@@ -318,7 +319,6 @@ bool SkImage_GpuBase::RenderYUVAToRGBA(GrContext* ctx, GrRenderTargetContext* re
318319
GrPaint paint;
319320
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
320321

321-
const auto& caps = *ctx->priv().caps();
322322
auto fp = GrYUVtoRGBEffect::Make(views, yuvaIndices, yuvColorSpace,
323323
GrSamplerState::Filter::kNearest, caps);
324324
if (colorSpaceXform) {

src/image/SkImage_GpuBase.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class SkImage_GpuBase : public SkImage_Base {
5454
sk_sp<SkColorSpace> cs);
5555
static bool ValidateCompressedBackendTexture(const GrCaps*, const GrBackendTexture& tex,
5656
SkAlphaType);
57-
static bool MakeTempTextureProxies(GrContext* ctx, const GrBackendTexture yuvaTextures[],
57+
static bool MakeTempTextureProxies(GrRecordingContext*, const GrBackendTexture yuvaTextures[],
5858
int numTextures, const SkYUVAIndex [4],
5959
GrSurfaceOrigin imageOrigin,
6060
GrSurfaceProxyView tempViews[4],
@@ -86,11 +86,11 @@ class SkImage_GpuBase : public SkImage_Base {
8686
PromiseImageTextureFulfillProc, PromiseImageTextureReleaseProc,
8787
PromiseImageTextureDoneProc, PromiseImageTextureContext, PromiseImageApiVersion);
8888

89-
static bool RenderYUVAToRGBA(GrContext* ctx, GrRenderTargetContext* renderTargetContext,
90-
const SkRect& rect, SkYUVColorSpace yuvColorSpace,
91-
sk_sp<GrColorSpaceXform> colorSpaceXform,
92-
GrSurfaceProxyView views[4],
93-
const SkYUVAIndex yuvaIndices[4]);
89+
static bool RenderYUVAToRGBA(const GrCaps&, GrRenderTargetContext*,
90+
const SkRect&, SkYUVColorSpace,
91+
sk_sp<GrColorSpaceXform>,
92+
GrSurfaceProxyView [4],
93+
const SkYUVAIndex [4]);
9494

9595
// TODO: Migrate this to something much weaker, such as GrContextThreadSafeProxy.
9696
sk_sp<GrContext> fContext;

src/image/SkImage_GpuYUVA.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ void SkImage_GpuYUVA::flattenToRGB(GrRecordingContext* context) const {
171171
this->colorSpace(), this->alphaType());
172172
}
173173
const SkRect rect = SkRect::MakeIWH(this->width(), this->height());
174-
if (!RenderYUVAToRGBA(fContext.get(), renderTargetContext.get(), rect, fYUVColorSpace,
174+
const GrCaps& caps = *context->priv().caps();
175+
if (!RenderYUVAToRGBA(caps, renderTargetContext.get(), rect, fYUVColorSpace,
175176
std::move(colorSpaceXform), fViews, fYUVAIndices)) {
176177
return;
177178
}

0 commit comments

Comments
 (0)