Skip to content

Commit c767209

Browse files
egdanielSkia Commit-Bot
authored andcommitted
Have gpu yuv code speak in views.
Bug: skia:9556 Change-Id: Iaa071d53248dfcd6d9e1bd88b24c8b39e133ced2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269148 Reviewed-by: Jim Van Verth <[email protected]> Commit-Queue: Greg Daniel <[email protected]>
1 parent f51a52b commit c767209

10 files changed

+126
-137
lines changed

gm/yuvtorgbeffect.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,15 @@ class YUVtoRGBEffect : public GpuGM {
9595

9696
DrawResult onDraw(GrContext* context, GrRenderTargetContext* renderTargetContext,
9797
SkCanvas* canvas, SkString* errorMsg) override {
98-
sk_sp<GrTextureProxy> proxies[3];
98+
GrSurfaceProxyView views[3];
9999

100100
for (int i = 0; i < 3; ++i) {
101101
GrBitmapTextureMaker maker(context, fBitmaps[i]);
102-
auto[view, grCT] = maker.view(GrMipMapped::kNo);
103-
if (!view.proxy()) {
102+
std::tie(views[i], std::ignore) = maker.view(GrMipMapped::kNo);
103+
if (!views[i]) {
104104
*errorMsg = "Failed to create proxy";
105105
return DrawResult::kFail;
106106
}
107-
proxies[i] = view.asTextureProxyRef();
108107
}
109108

110109
for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpace; ++space) {
@@ -127,7 +126,7 @@ class YUVtoRGBEffect : public GpuGM {
127126
};
128127
const auto& caps = *context->priv().caps();
129128
std::unique_ptr<GrFragmentProcessor> fp(GrYUVtoRGBEffect::Make(
130-
proxies, yuvaIndices, static_cast<SkYUVColorSpace>(space),
129+
views, yuvaIndices, static_cast<SkYUVColorSpace>(space),
131130
GrSamplerState::Filter::kNearest, caps));
132131
if (fp) {
133132
GrPaint grPaint;
@@ -212,16 +211,15 @@ class YUVNV12toRGBEffect : public GpuGM {
212211

213212
DrawResult onDraw(GrContext* context, GrRenderTargetContext* renderTargetContext,
214213
SkCanvas* canvas, SkString* errorMsg) override {
215-
sk_sp<GrTextureProxy> proxies[2];
214+
GrSurfaceProxyView views[2];
216215

217216
for (int i = 0; i < 2; ++i) {
218217
GrBitmapTextureMaker maker(context, fBitmaps[i]);
219-
auto[view, grCT] = maker.view(GrMipMapped::kNo);
220-
if (!view.proxy()) {
218+
std::tie(views[i], std::ignore) = maker.view(GrMipMapped::kNo);
219+
if (!views[i]) {
221220
*errorMsg = "Failed to create proxy";
222221
return DrawResult::kFail;
223222
}
224-
proxies[i] = view.asTextureProxyRef();
225223
}
226224

227225
SkYUVAIndex yuvaIndices[4] = {
@@ -242,7 +240,7 @@ class YUVNV12toRGBEffect : public GpuGM {
242240
GrPaint grPaint;
243241
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
244242
const auto& caps = *context->priv().caps();
245-
auto fp = GrYUVtoRGBEffect::Make(proxies, yuvaIndices,
243+
auto fp = GrYUVtoRGBEffect::Make(views, yuvaIndices,
246244
static_cast<SkYUVColorSpace>(space),
247245
GrSamplerState::Filter::kNearest, caps);
248246
if (fp) {
@@ -309,16 +307,15 @@ class YUVtoRGBDomainEffect : public GpuGM {
309307

310308
DrawResult onDraw(GrContext* context, GrRenderTargetContext* renderTargetContext,
311309
SkCanvas* canvas, SkString* errorMsg) override {
312-
sk_sp<GrTextureProxy> proxies[3];
310+
GrSurfaceProxyView views[3];
313311

314312
for (int i = 0; i < 3; ++i) {
315313
GrBitmapTextureMaker maker(context, fBitmaps[i]);
316-
auto[view, grCT] = maker.view(GrMipMapped::kNo);
317-
if (!view.proxy()) {
314+
std::tie(views[i], std::ignore) = maker.view(GrMipMapped::kNo);
315+
if (!views[i]) {
318316
*errorMsg = "Failed to create proxy";
319317
return DrawResult::kFail;
320318
}
321-
proxies[i] = view.asTextureProxyRef();
322319
}
323320

324321
// Draw a 2x2 grid of the YUV images.
@@ -353,7 +350,7 @@ class YUVtoRGBDomainEffect : public GpuGM {
353350
const SkRect* domainPtr = j > 0 ? &domain : nullptr;
354351
const auto& caps = *context->priv().caps();
355352
std::unique_ptr<GrFragmentProcessor> fp(
356-
GrYUVtoRGBEffect::Make(proxies, yuvaIndices, kJPEG_SkYUVColorSpace,
353+
GrYUVtoRGBEffect::Make(views, yuvaIndices, kJPEG_SkYUVColorSpace,
357354
kFilters[i], caps, SkMatrix::I(), domainPtr));
358355
if (fp) {
359356
GrPaint grPaint;

src/gpu/GrImageTextureMaker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ std::unique_ptr<GrFragmentProcessor> GrYUVAImageTextureMaker::createFragmentProc
119119
}
120120

121121
const auto& caps = *fImage->context()->priv().caps();
122-
auto fp = GrYUVtoRGBEffect::Make(fImage->fProxies, fImage->fYUVAIndices, fImage->fYUVColorSpace,
122+
auto fp = GrYUVtoRGBEffect::Make(fImage->fViews, fImage->fYUVAIndices, fImage->fYUVColorSpace,
123123
filter, caps, textureMatrix, domain);
124124
if (fImage->fFromColorSpace) {
125125
fp = GrColorSpaceXformEffect::Make(std::move(fp), fImage->fFromColorSpace.get(),

src/gpu/GrYUVProvider.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ GrSurfaceProxyView GrYUVProvider::refAsTextureProxyView(GrRecordingContext* ctx,
120120
return {};
121121
}
122122

123-
sk_sp<GrTextureProxy> yuvTextureProxies[SkYUVASizeInfo::kMaxCount];
123+
GrSurfaceProxyView yuvViews[SkYUVASizeInfo::kMaxCount];
124124
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; ++i) {
125125
if (yuvSizeInfo.fSizes[i].isEmpty()) {
126126
SkASSERT(!yuvSizeInfo.fWidthBytes[i]);
@@ -153,14 +153,13 @@ GrSurfaceProxyView GrYUVProvider::refAsTextureProxyView(GrRecordingContext* ctx,
153153
bitmap.setImmutable();
154154

155155
GrBitmapTextureMaker maker(ctx, bitmap, GrBitmapTextureMaker::Cached::kNo, fit);
156-
auto[view, grCT] = maker.view(GrMipMapped::kNo);
157-
yuvTextureProxies[i] = view.asTextureProxyRef();
156+
std::tie(yuvViews[i], std::ignore) = maker.view(GrMipMapped::kNo);
158157

159-
if (!yuvTextureProxies[i]) {
158+
if (!yuvViews[i]) {
160159
return {};
161160
}
162161

163-
SkASSERT(yuvTextureProxies[i]->dimensions() == yuvSizeInfo.fSizes[i]);
162+
SkASSERT(yuvViews[i].proxy()->dimensions() == yuvSizeInfo.fSizes[i]);
164163
}
165164

166165
// TODO: investigate preallocating mip maps here
@@ -173,7 +172,7 @@ GrSurfaceProxyView GrYUVProvider::refAsTextureProxyView(GrRecordingContext* ctx,
173172

174173
GrPaint paint;
175174
const auto& caps = *ctx->priv().caps();
176-
auto yuvToRgbProcessor = GrYUVtoRGBEffect::Make(yuvTextureProxies, yuvaIndices, yuvColorSpace,
175+
auto yuvToRgbProcessor = GrYUVtoRGBEffect::Make(yuvViews, yuvaIndices, yuvColorSpace,
177176
GrSamplerState::Filter::kNearest, caps);
178177
paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor));
179178

src/gpu/effects/GrYUVtoRGBEffect.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "src/sksl/SkSLCPP.h"
1616
#include "src/sksl/SkSLUtil.h"
1717

18-
std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(const sk_sp<GrTextureProxy> proxies[],
18+
std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(GrSurfaceProxyView views[],
1919
const SkYUVAIndex yuvaIndices[4],
2020
SkYUVColorSpace yuvColorSpace,
2121
GrSamplerState::Filter filterMode,
@@ -25,7 +25,8 @@ std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(const sk_sp<GrTextur
2525
int numPlanes;
2626
SkAssertResult(SkYUVAIndex::AreValidIndices(yuvaIndices, &numPlanes));
2727

28-
const SkISize YDimensions = proxies[yuvaIndices[SkYUVAIndex::kY_Index].fIndex]->dimensions();
28+
const SkISize YDimensions =
29+
views[yuvaIndices[SkYUVAIndex::kY_Index].fIndex].proxy()->dimensions();
2930

3031
// This promotion of nearest to bilinear for UV planes exists to mimic libjpeg[-turbo]'s
3132
// do_fancy_upsampling option. However, skbug.com/9693.
@@ -34,7 +35,7 @@ std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(const sk_sp<GrTextur
3435
: GrSamplerState::Filter::kBilerp;
3536
std::unique_ptr<GrFragmentProcessor> planeFPs[4];
3637
for (int i = 0; i < numPlanes; ++i) {
37-
SkISize dimensions = proxies[i]->dimensions();
38+
SkISize dimensions = views[i].proxy()->dimensions();
3839
SkTCopyOnFirstWrite<SkMatrix> planeMatrix(&localMatrix);
3940
GrSamplerState::Filter planeFilter = filterMode;
4041
SkRect planeDomain;
@@ -65,15 +66,12 @@ std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::Make(const sk_sp<GrTextur
6566
planeDomain = *domain;
6667
}
6768

68-
GrSurfaceOrigin origin = proxies[i]->origin();
69-
GrSwizzle swizzle = proxies[i]->textureSwizzle();
70-
GrSurfaceProxyView view(proxies[i], origin, swizzle);
7169
if (domain) {
7270
SkASSERT(planeFilter != GrSamplerState::Filter::kMipMap);
73-
planeFPs[i] = GrTextureEffect::MakeSubset(std::move(view), kUnknown_SkAlphaType,
71+
planeFPs[i] = GrTextureEffect::MakeSubset(views[i], kUnknown_SkAlphaType,
7472
*planeMatrix, planeFilter, planeDomain, caps);
7573
} else {
76-
planeFPs[i] = GrTextureEffect::Make(std::move(view), kUnknown_SkAlphaType, *planeMatrix,
74+
planeFPs[i] = GrTextureEffect::Make(views[i], kUnknown_SkAlphaType, *planeMatrix,
7775
planeFilter);
7876
}
7977
}

src/gpu/effects/GrYUVtoRGBEffect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GrYUVtoRGBEffect : public GrFragmentProcessor {
2020
// to the multi-planar, varying resolution images that it has to sample. If 'domain' is provided
2121
// it is the Y plane's domain. This will automatically inset for bilinear filtering, and only
2222
// the clamp wrap mode is supported.
23-
static std::unique_ptr<GrFragmentProcessor> Make(const sk_sp<GrTextureProxy> proxies[],
23+
static std::unique_ptr<GrFragmentProcessor> Make(GrSurfaceProxyView views[],
2424
const SkYUVAIndex indices[4],
2525
SkYUVColorSpace yuvColorSpace,
2626
GrSamplerState::Filter filterMode,

src/image/SkImage_Gpu.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,15 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorS
271271
return nullptr;
272272
}
273273

274-
sk_sp<GrTextureProxy> tempTextureProxies[4];
274+
GrSurfaceProxyView tempViews[4];
275275
if (!SkImage_GpuBase::MakeTempTextureProxies(ctx, yuvaTextures, numTextures, yuvaIndices,
276-
origin, tempTextureProxies)) {
276+
origin, tempViews)) {
277277
return nullptr;
278278
}
279279

280280
const SkRect rect = SkRect::MakeIWH(size.width(), size.height());
281281
if (!RenderYUVAToRGBA(ctx, renderTargetContext, rect, yuvColorSpace, nullptr,
282-
tempTextureProxies, yuvaIndices)) {
282+
tempViews, yuvaIndices)) {
283283
return nullptr;
284284
}
285285

0 commit comments

Comments
 (0)