Skip to content

Commit be8004d

Browse files
bsalomonSkia Commit-Bot
authored andcommitted
Revert "New variant of SkImage::MakeFromYUVATextures."
This reverts commit fea1223. Reason for revert: MSAN/SwiftShader failure Original change's description: > New variant of SkImage::MakeFromYUVATextures. > > Takes a new type GrYUVATextures. This a set of GrBackendTextures and > SkYUVAInfo that have been pre-validated to be compatible. > > Bug: skia:10632 > > Change-Id: Id252f8662ede0f268e88fd40dc1b0b8f4ab6345f > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317762 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Jim Van Verth <jvanverth@google.com> > Reviewed-by: Robert Phillips <robertphillips@google.com> TBR=jvanverth@google.com,bsalomon@google.com,robertphillips@google.com Change-Id: I5350d4f9b1eda0503fb0af9db8575a734bdc811f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:10632 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327922 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
1 parent f60a76e commit be8004d

File tree

10 files changed

+18
-225
lines changed

10 files changed

+18
-225
lines changed

RELEASE_NOTES.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ This file includes a list of high level updates for each milestone release.
66

77
Milestone 88
88
------------
9-
* <insert new release notes here>
109

11-
* New variant of SkImage::MakeFromYUVATextures. Takes a new type GrYUVATextures
12-
which wraps an SkYUVAInfo and compatible set of GrBackendTextures. The provides
13-
a more complete and structured specification of the planar configuration. Previous
14-
version is deprecated.
10+
* <insert new release notes here>
1511

1612
* SkTPin() removed from public API.
1713

gn/gpu.gni

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ skia_gpu_sources = [
1919
"$_include/gpu/GrDriverBugWorkarounds.h",
2020
"$_include/gpu/GrRecordingContext.h",
2121
"$_include/gpu/GrTypes.h",
22-
"$_include/gpu/GrYUVABackendTextures.h",
2322

2423
# Private includes
2524
"$_include/private/GrContext.h",
@@ -270,7 +269,6 @@ skia_gpu_sources = [
270269
"$_src/gpu/GrWindowRectsState.h",
271270
"$_src/gpu/GrXferProcessor.cpp",
272271
"$_src/gpu/GrXferProcessor.h",
273-
"$_src/gpu/GrYUVABackendTextures.cpp",
274272

275273
# Ops
276274
"$_src/gpu/effects/GrBezierEffect.cpp",

include/core/SkImage.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class GrContext;
3838
class GrDirectContext;
3939
class GrRecordingContext;
4040
class GrContextThreadSafeProxy;
41-
class GrYUVABackendTextures;
4241

4342
struct SkYUVAIndex;
4443

@@ -409,30 +408,7 @@ class SK_API SkImage : public SkRefCnt {
409408
SkAlphaType alphaType = kPremul_SkAlphaType,
410409
sk_sp<SkColorSpace> colorSpace = nullptr);
411410

412-
/** Creates an SkImage from YUV[A] planar textures. This requires that the textures stay valid
413-
for the lifetime of the image. The ReleaseContext can be used to know when it is safe to
414-
either delete or overwrite the textures. If ReleaseProc is provided it is also called before
415-
return on failure.
416-
417-
@param context GPU context
418-
@param yuvaTextures A set of textures containing YUVA data and a description of the
419-
data and transformation to RGBA.
420-
@param imageColorSpace range of colors of the resulting image after conversion to RGB;
421-
may be nullptr
422-
@param textureReleaseProc called when the backend textures can be released
423-
@param releaseContext state passed to textureReleaseProc
424-
@return created SkImage, or nullptr
425-
*/
426-
static sk_sp<SkImage> MakeFromYUVATextures(GrRecordingContext* context,
427-
const GrYUVABackendTextures& yuvaTextures,
428-
sk_sp<SkColorSpace> imageColorSpace = nullptr,
429-
TextureReleaseProc textureReleaseProc = nullptr,
430-
ReleaseContext releaseContext = nullptr);
431-
432-
/**
433-
Deprecated. Use version that takes GrYUVABackendTextures.
434-
435-
Creates an SkImage by storing the specified YUVA planes into an image, to be rendered
411+
/** Creates an SkImage by storing the specified YUVA planes into an image, to be rendered
436412
via multitexturing.
437413
438414
When all the provided backend textures can be released 'textureReleaseProc' will be called

include/core/SkYUVAInfo.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class SK_API SkYUVAInfo {
3939
* this expands.
4040
*/
4141
enum class PlanarConfig {
42-
kUnknown,
43-
4442
kY_U_V_444, ///< Plane 0: Y, Plane 1: U, Plane 2: V
4543
kY_U_V_422, ///< Plane 0: Y, Plane 1: U, Plane 2: V
4644
kY_U_V_420, ///< Plane 0: Y, Plane 1: U, Plane 2: V
@@ -179,12 +177,10 @@ class SK_API SkYUVAInfo {
179177
bool operator==(const SkYUVAInfo& that) const;
180178
bool operator!=(const SkYUVAInfo& that) const { return !(*this == that); }
181179

182-
bool isValid() const { return fPlanarConfig != PlanarConfig::kUnknown; }
183-
184180
private:
185181
SkISize fDimensions = {0, 0};
186182

187-
PlanarConfig fPlanarConfig = PlanarConfig::kUnknown;
183+
PlanarConfig fPlanarConfig = PlanarConfig::kY_U_V_444;
188184

189185
SkYUVColorSpace fYUVColorSpace = SkYUVColorSpace::kIdentity_SkYUVColorSpace;
190186

@@ -200,8 +196,6 @@ class SK_API SkYUVAInfo {
200196

201197
constexpr int SkYUVAInfo::NumPlanes(PlanarConfig planarConfig) {
202198
switch (planarConfig) {
203-
case PlanarConfig::kUnknown: return 0;
204-
205199
case PlanarConfig::kY_U_V_444: return 3;
206200
case PlanarConfig::kY_U_V_422: return 3;
207201
case PlanarConfig::kY_U_V_420: return 3;
@@ -229,9 +223,6 @@ constexpr int SkYUVAInfo::NumPlanes(PlanarConfig planarConfig) {
229223

230224
constexpr int SkYUVAInfo::NumChannelsInPlane(PlanarConfig config, int i) {
231225
switch (config) {
232-
case PlanarConfig::kUnknown:
233-
return 0;
234-
235226
case SkYUVAInfo::PlanarConfig::kY_U_V_444:
236227
case SkYUVAInfo::PlanarConfig::kY_U_V_422:
237228
case SkYUVAInfo::PlanarConfig::kY_U_V_420:

include/gpu/GrYUVABackendTextures.h

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/core/SkYUVAInfo.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
int SkYUVAInfo::PlaneDimensions(SkISize imageDimensions,
1212
PlanarConfig planarConfig,
1313
SkEncodedOrigin origin,
14-
SkISize planeDimensions[SkYUVAInfo::kMaxPlanes]) {
14+
SkISize* planeDimensions) {
1515
int w = imageDimensions.width();
1616
int h = imageDimensions.height();
1717
if (origin >= kLeftTop_SkEncodedOrigin) {
@@ -21,12 +21,6 @@ int SkYUVAInfo::PlaneDimensions(SkISize imageDimensions,
2121
auto down2 = [](int x) { return (x + 1)/2; };
2222
auto down4 = [](int x) { return (x + 3)/4; };
2323
switch (planarConfig) {
24-
case PlanarConfig::kUnknown:
25-
planeDimensions[0] =
26-
planeDimensions[1] =
27-
planeDimensions[2] =
28-
planeDimensions[3] = {0, 0};
29-
return 0;
3024
case PlanarConfig::kY_U_V_444:
3125
planeDimensions[0] = planeDimensions[1] = planeDimensions[2] = {w, h};
3226
planeDimensions[3] = {0, 0};
@@ -131,9 +125,6 @@ bool SkYUVAInfo::GetYUVAIndices(PlanarConfig config,
131125
struct Location {int plane, chanIdx;};
132126
const Location* locations = nullptr;
133127
switch (config) {
134-
case PlanarConfig::kUnknown:
135-
return false;
136-
137128
case PlanarConfig::kY_U_V_444:
138129
case PlanarConfig::kY_U_V_422:
139130
case PlanarConfig::kY_U_V_420:
@@ -219,8 +210,6 @@ bool SkYUVAInfo::GetYUVAIndices(PlanarConfig config,
219210

220211
bool SkYUVAInfo::HasAlpha(PlanarConfig planarConfig) {
221212
switch (planarConfig) {
222-
case PlanarConfig::kUnknown: return false;
223-
224213
case PlanarConfig::kY_U_V_444: return false;
225214
case PlanarConfig::kY_U_V_422: return false;
226215
case PlanarConfig::kY_U_V_420: return false;
@@ -258,20 +247,11 @@ SkYUVAInfo::SkYUVAInfo(SkISize dimensions,
258247
, fYUVColorSpace(yuvColorSpace)
259248
, fOrigin(origin)
260249
, fSitingX(sitingX)
261-
, fSitingY(sitingY) {
262-
if (fDimensions.width() <= 0 ||
263-
fDimensions.height() <= 0 ||
264-
planarConfig == PlanarConfig::kUnknown) {
265-
*this = {};
266-
SkASSERT(!this->isValid());
267-
return;
268-
}
269-
SkASSERT(this->isValid());
270-
}
250+
, fSitingY(sitingY) {}
271251

272252
size_t SkYUVAInfo::computeTotalBytes(const size_t rowBytes[kMaxPlanes],
273253
size_t planeSizes[kMaxPlanes]) const {
274-
if (!this->isValid()) {
254+
if (fDimensions.isEmpty()) {
275255
return 0;
276256
}
277257
SkSafeMath safe;

src/core/SkYUVAPixmaps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ SkYUVAPixmapInfo::SkYUVAPixmapInfo(const SkYUVAInfo& yuvaInfo,
8080
const SkColorType colorTypes[kMaxPlanes],
8181
const size_t rowBytes[kMaxPlanes])
8282
: fYUVAInfo(yuvaInfo) {
83-
if (!yuvaInfo.isValid()) {
83+
if (yuvaInfo.dimensions().isEmpty()) {
8484
*this = {};
8585
SkASSERT(!this->isValid());
8686
return;

src/gpu/GrYUVABackendTextures.cpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/image/SkImage_GpuYUVA.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "include/core/SkYUVASizeInfo.h"
1414
#include "include/gpu/GrDirectContext.h"
1515
#include "include/gpu/GrRecordingContext.h"
16-
#include "include/gpu/GrYUVABackendTextures.h"
1716
#include "src/core/SkAutoPixmapStorage.h"
1817
#include "src/core/SkMipmap.h"
1918
#include "src/core/SkScopeExit.h"
@@ -235,45 +234,6 @@ sk_sp<SkImage> SkImage_GpuYUVA::onReinterpretColorSpace(sk_sp<SkColorSpace> newC
235234

236235
//////////////////////////////////////////////////////////////////////////////////////////////////
237236

238-
sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrRecordingContext* context,
239-
const GrYUVABackendTextures& yuvaTextures,
240-
sk_sp<SkColorSpace> imageColorSpace,
241-
TextureReleaseProc textureReleaseProc,
242-
ReleaseContext releaseContext) {
243-
sk_sp<GrRefCntedCallback> releaseHelper;
244-
if (textureReleaseProc) {
245-
releaseHelper.reset(new GrRefCntedCallback(textureReleaseProc, releaseContext));
246-
}
247-
248-
SkYUVAIndex yuvaIndices[4];
249-
yuvaTextures.toYUVAIndices(yuvaIndices);
250-
int numTextures;
251-
if (!SkYUVAIndex::AreValidIndices(yuvaIndices, &numTextures)) {
252-
return nullptr;
253-
}
254-
SkASSERT(numTextures == yuvaTextures.numPlanes());
255-
256-
GrSurfaceProxyView tempViews[4];
257-
if (!SkImage_GpuBase::MakeTempTextureProxies(context,
258-
yuvaTextures.textures().data(),
259-
numTextures,
260-
yuvaIndices,
261-
yuvaTextures.textureOrigin(),
262-
tempViews,
263-
std::move(releaseHelper))) {
264-
return nullptr;
265-
}
266-
267-
return sk_make_sp<SkImage_GpuYUVA>(sk_ref_sp(context),
268-
yuvaTextures.yuvaInfo().dimensions(),
269-
kNeedNewImageUniqueID,
270-
yuvaTextures.yuvaInfo().yuvColorSpace(),
271-
tempViews,
272-
numTextures,
273-
yuvaIndices,
274-
imageColorSpace);
275-
}
276-
277237
sk_sp<SkImage> SkImage::MakeFromYUVATextures(GrContext* ctx,
278238
SkYUVColorSpace colorSpace,
279239
const GrBackendTexture yuvaTextures[],

tools/gpu/YUVUtils.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "include/core/SkColorPriv.h"
1111
#include "include/core/SkData.h"
1212
#include "include/gpu/GrRecordingContext.h"
13-
#include "include/gpu/GrYUVABackendTextures.h"
1413
#include "src/codec/SkCodecImageGenerator.h"
1514
#include "src/core/SkYUVMath.h"
1615
#include "src/gpu/GrDirectContextPriv.h"
@@ -227,23 +226,30 @@ bool LazyYUVImage::ensureYUVImage(GrRecordingContext* rContext, Type type) {
227226
if (auto direct = rContext->asDirectContext()) {
228227
sk_sp<sk_gpu_test::ManagedBackendTexture> mbets[SkYUVAInfo::kMaxPlanes];
229228
GrBackendTexture textures[SkYUVAInfo::kMaxPlanes];
229+
uint32_t componentFlags[SkYUVAInfo::kMaxPlanes] = {};
230230
for (int i = 0; i < fPixmaps.numPlanes(); ++i) {
231231
mbets[i] = sk_gpu_test::ManagedBackendTexture::MakeWithData(
232232
direct, fPixmaps.plane(i), GrRenderable::kNo, GrProtected::kNo);
233233
if (mbets[i]) {
234234
textures[i] = mbets[i]->texture();
235+
componentFlags[i] = textures[i].getBackendFormat().channelMask();
235236
} else {
236237
return false;
237238
}
238239
}
239-
GrYUVABackendTextures yuvaTextures(fPixmaps.yuvaInfo(),
240-
textures,
241-
kTopLeft_GrSurfaceOrigin);
240+
SkYUVAIndex indices[SkYUVAIndex::kIndexCount];
241+
if (!fPixmaps.yuvaInfo().toYUVAIndices(componentFlags, indices)) {
242+
return false;
243+
}
242244
void* relContext =
243245
sk_gpu_test::ManagedBackendTexture::MakeYUVAReleaseContext(mbets);
244246
fYUVImage[idx] = SkImage::MakeFromYUVATextures(
245247
direct,
246-
yuvaTextures,
248+
fPixmaps.yuvaInfo().yuvColorSpace(),
249+
textures,
250+
indices,
251+
fPixmaps.yuvaInfo().dimensions(),
252+
kTopLeft_GrSurfaceOrigin,
247253
fColorSpace,
248254
sk_gpu_test::ManagedBackendTexture::ReleaseProc,
249255
relContext);

0 commit comments

Comments
 (0)