aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Phillips <robertphillips@google.com>2018-10-04 09:10:29 -0400
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2018-10-04 14:14:23 +0000
commit66a97349346857503209252b67290a852dccb797 (patch)
treec4c65b9caf7af3e15a993789fd18545805701f0f
parent4429a4f82cfeb2e63593b81ff373f6f1a5702b7c (diff)
downloadskqp-66a97349346857503209252b67290a852dccb797.tar.gz
Make SkYUVAIndex publicly accessible
Change-Id: I3da7c566cdf9256e57ac7e7f30fee18b9c1a144d Reviewed-on: https://skia-review.googlesource.com/c/159460 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r--gm/wacky_yuv_formats.cpp36
-rw-r--r--gn/core.gni1
-rw-r--r--include/core/SkYUVAIndex.h49
-rw-r--r--src/core/SkImagePriv.h44
-rw-r--r--src/image/SkImage_Gpu.cpp33
-rw-r--r--src/image/SkImage_Gpu.h1
-rw-r--r--src/image/SkImage_GpuYUVA.h2
-rw-r--r--tools/DDLPromiseImageHelper.cpp10
8 files changed, 92 insertions, 84 deletions
diff --git a/gm/wacky_yuv_formats.cpp b/gm/wacky_yuv_formats.cpp
index 9fe6dc3525..f421e2013e 100644
--- a/gm/wacky_yuv_formats.cpp
+++ b/gm/wacky_yuv_formats.cpp
@@ -10,8 +10,8 @@
#include "SkColorPriv.h"
#include "SkImageGenerator.h"
-#include "SkImagePriv.h"
#include "SkPath.h"
+#include "SkYUVAIndex.h"
static const int kTileWidthHeight = 128;
static const int kLabelWidth = 64;
@@ -280,13 +280,13 @@ static void create_YUV(const PlaneData& planes, YUVFormat yuvFormat,
resultBMs[nextLayer++] = yuvaFull;
yuvaIndices[0].fIndex = 0;
- yuvaIndices[0].fChannel = kB_SkImageSourceChannel;
+ yuvaIndices[0].fChannel = SkColorChannel::kR;
yuvaIndices[1].fIndex = 0;
- yuvaIndices[1].fChannel = kG_SkImageSourceChannel;
+ yuvaIndices[1].fChannel = SkColorChannel::kG;
yuvaIndices[2].fIndex = 0;
- yuvaIndices[2].fChannel = kR_SkImageSourceChannel;
+ yuvaIndices[2].fChannel = SkColorChannel::kG;
yuvaIndices[3].fIndex = 0;
- yuvaIndices[3].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[3].fChannel = SkColorChannel::kA;
break;
}
case kNV12_YUVFormat: {
@@ -307,11 +307,11 @@ static void create_YUV(const PlaneData& planes, YUVFormat yuvFormat,
resultBMs[nextLayer++] = uvQuarter;
yuvaIndices[0].fIndex = 0;
- yuvaIndices[0].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[0].fChannel = SkColorChannel::kA;
yuvaIndices[1].fIndex = 1;
- yuvaIndices[1].fChannel = kR_SkImageSourceChannel;
+ yuvaIndices[1].fChannel = SkColorChannel::kR;
yuvaIndices[2].fIndex = 1;
- yuvaIndices[2].fChannel = kG_SkImageSourceChannel;
+ yuvaIndices[2].fChannel = SkColorChannel::kG;
break;
}
case kNV21_YUVFormat: {
@@ -332,11 +332,11 @@ static void create_YUV(const PlaneData& planes, YUVFormat yuvFormat,
resultBMs[nextLayer++] = vuQuarter;
yuvaIndices[0].fIndex = 0;
- yuvaIndices[0].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[0].fChannel = SkColorChannel::kA;
yuvaIndices[1].fIndex = 1;
- yuvaIndices[1].fChannel = kG_SkImageSourceChannel;
+ yuvaIndices[1].fChannel = SkColorChannel::kG;
yuvaIndices[2].fIndex = 1;
- yuvaIndices[2].fChannel = kR_SkImageSourceChannel;
+ yuvaIndices[2].fChannel = SkColorChannel::kR;
break;
}
case kI420_YUVFormat:
@@ -345,11 +345,11 @@ static void create_YUV(const PlaneData& planes, YUVFormat yuvFormat,
resultBMs[nextLayer++] = planes.fVQuarter;
yuvaIndices[0].fIndex = 0;
- yuvaIndices[0].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[0].fChannel = SkColorChannel::kA;
yuvaIndices[1].fIndex = 1;
- yuvaIndices[1].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[1].fChannel = SkColorChannel::kA;
yuvaIndices[2].fIndex = 2;
- yuvaIndices[2].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[2].fChannel = SkColorChannel::kA;
break;
case kYV12_YUVFormat:
resultBMs[nextLayer++] = planes.fYFull;
@@ -357,11 +357,11 @@ static void create_YUV(const PlaneData& planes, YUVFormat yuvFormat,
resultBMs[nextLayer++] = planes.fUQuarter;
yuvaIndices[0].fIndex = 0;
- yuvaIndices[0].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[0].fChannel = SkColorChannel::kA;
yuvaIndices[1].fIndex = 2;
- yuvaIndices[1].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[1].fChannel = SkColorChannel::kA;
yuvaIndices[2].fIndex = 1;
- yuvaIndices[2].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[2].fChannel = SkColorChannel::kA;
break;
}
@@ -372,7 +372,7 @@ static void create_YUV(const PlaneData& planes, YUVFormat yuvFormat,
resultBMs[nextLayer] = planes.fAFull;
yuvaIndices[3].fIndex = nextLayer;
- yuvaIndices[3].fChannel = kA_SkImageSourceChannel;
+ yuvaIndices[3].fChannel = SkColorChannel::kA;
}
}
diff --git a/gn/core.gni b/gn/core.gni
index aa02b8e4ba..1a617aedfe 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -438,6 +438,7 @@ skia_core_sources = [
"$_include/core/SkTypes.h",
"$_include/core/SkUnPreMultiply.h",
"$_include/core/SkVertices.h",
+ "$_include/core/SkYUVAIndex.h",
"$_src/jumper/SkJumper.cpp",
diff --git a/include/core/SkYUVAIndex.h b/include/core/SkYUVAIndex.h
new file mode 100644
index 0000000000..62d80bdc18
--- /dev/null
+++ b/include/core/SkYUVAIndex.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkYUVAIndex_DEFINED
+#define SkYUVAIndex_DEFINED
+
+#include "SkTypes.h"
+
+/** \enum SkColorChannel
+ Describes different color channels one can manipulate
+*/
+enum class SkColorChannel {
+ kR, // the red channel
+ kG, // the green channel
+ kB, // the blue channel
+ kA, // the alpha channel
+
+ kLastEnum = kA,
+};
+
+/** \struct SkYUVAIndex
+ Describes from which image source and which channel to read each individual YUVA plane.
+
+ SkYUVAIndex contains a index for which image source to read from and a enum for which channel
+ to read from.
+*/
+struct SK_API SkYUVAIndex {
+ // Index in the array of SkYUVAIndex
+ enum Index {
+ kY_Index = 0,
+ kU_Index = 1,
+ kV_Index = 2,
+ kA_Index = 3
+ };
+
+ /** The index is a number between -1..3 which definies which image source to read from, where -1
+ * means the image source doesn't exist. The assumption is we will always have image sources for
+ * each of YUV planes, but optionally have image source for A plane. */
+ int fIndex;
+ /** The channel describes from which channel to read the info from. Currently we only deal with
+ * YUV and NV12 and channel info is ignored. */
+ SkColorChannel fChannel;
+};
+
+#endif
diff --git a/src/core/SkImagePriv.h b/src/core/SkImagePriv.h
index 4a89bd9a1e..1fd7675726 100644
--- a/src/core/SkImagePriv.h
+++ b/src/core/SkImagePriv.h
@@ -89,48 +89,4 @@ SkIRect SkImage_getSubset(const SkImage*);
*/
sk_sp<SkImage> SkImageMakeRasterCopyAndAssignColorSpace(const SkImage*, SkColorSpace*);
-/** \enum SkImageInfo::SkImageSourceChannel
- Describes different channels we could read from image source.
-*/
-enum SkImageSourceChannel {
- /** Describes the red channel; */
- kR_SkImageSourceChannel,
-
- /** Describes the green channel; */
- kG_SkImageSourceChannel,
-
- /** Describes the blue channel; */
- kB_SkImageSourceChannel,
-
- /** Describes the alpha channel; */
- kA_SkImageSourceChannel,
-
- /** Utility value */
- kLastEnum_SkImageSourceChannel = kA_SkImageSourceChannel,
-};
-
-/** \struct SkYUVAIndex
- Describes from which image source and which channel to read each individual YUVA plane.
-
- SkYUVAIndex contains a index for which image source to read from and a enum for which channel
- to read from.
-*/
-struct SK_API SkYUVAIndex {
- // Index in the array of SkYUVAIndex
- enum Index {
- kY_Index = 0,
- kU_Index = 1,
- kV_Index = 2,
- kA_Index = 3
- };
-
- /** The index is a number between -1..3 which definies which image source to read from, where -1
- * means the image source doesn't exist. The assumption is we will always have image sources for
- * each of YUV planes, but optionally have image source for A plane. */
- int fIndex;
- /** The channel describes from which channel to read the info from. Currently we only deal with
- * YUV and NV12 and channel info is ignored. */
- SkImageSourceChannel fChannel;
-};
-
#endif
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index aa70299a9c..b1cc2fc06b 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -42,6 +42,7 @@
#include "SkPixelRef.h"
#include "SkReadPixelsRec.h"
#include "SkTraceEvent.h"
+#include "SkYUVAIndex.h"
#include "effects/GrYUVtoRGBEffect.h"
#include "gl/GrGLTexture.h"
@@ -454,10 +455,10 @@ sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace
sk_sp<SkColorSpace> imageColorSpace) {
// TODO: SkImageSourceChannel input is being ingored right now. Setup correctly in the future.
SkYUVAIndex yuvaIndices[4] = {
- SkYUVAIndex{0, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{1, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{2, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{-1, SkImageSourceChannel::kA_SkImageSourceChannel}};
+ SkYUVAIndex{0, SkColorChannel::kA},
+ SkYUVAIndex{1, SkColorChannel::kA},
+ SkYUVAIndex{2, SkColorChannel::kA},
+ SkYUVAIndex{-1, SkColorChannel::kA}};
SkISize size{yuvTextures[0].width(), yuvTextures[0].height()};
return SkImage_Gpu::MakeFromYUVATexturesCopyImpl(ctx, colorSpace, yuvTextures, yuvaIndices,
size, origin, std::move(imageColorSpace));
@@ -468,10 +469,10 @@ sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopyWithExternalBackend(
GrSurfaceOrigin origin, const GrBackendTexture backendTexture,
sk_sp<SkColorSpace> imageColorSpace) {
SkYUVAIndex yuvaIndices[4] = {
- SkYUVAIndex{0, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{1, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{2, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{-1, SkImageSourceChannel::kA_SkImageSourceChannel}};
+ SkYUVAIndex{0, SkColorChannel::kA},
+ SkYUVAIndex{1, SkColorChannel::kA},
+ SkYUVAIndex{2, SkColorChannel::kA},
+ SkYUVAIndex{-1, SkColorChannel::kA}};
SkISize size{yuvTextures[0].width(), yuvTextures[0].height()};
return SkImage_Gpu::MakeFromYUVATexturesCopyWithExternalBackendImpl(
ctx, colorSpace, yuvTextures, yuvaIndices, size, origin, backendTexture,
@@ -484,10 +485,10 @@ sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopy(GrContext* ctx, SkYUVColorSpace
sk_sp<SkColorSpace> imageColorSpace) {
// TODO: SkImageSourceChannel input is being ingored right now. Setup correctly in the future.
SkYUVAIndex yuvaIndices[4] = {
- SkYUVAIndex{0, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{1, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{1, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{-1, SkImageSourceChannel::kA_SkImageSourceChannel}};
+ SkYUVAIndex{0, SkColorChannel::kA},
+ SkYUVAIndex{1, SkColorChannel::kA},
+ SkYUVAIndex{1, SkColorChannel::kA},
+ SkYUVAIndex{-1, SkColorChannel::kA}};
SkISize size{nv12Textures[0].width(), nv12Textures[0].height()};
return SkImage_Gpu::MakeFromYUVATexturesCopyImpl(ctx, colorSpace, nv12Textures, yuvaIndices,
size, origin, std::move(imageColorSpace));
@@ -501,10 +502,10 @@ sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopyWithExternalBackend(
const GrBackendTexture backendTexture,
sk_sp<SkColorSpace> imageColorSpace) {
SkYUVAIndex yuvaIndices[4] = {
- SkYUVAIndex{0, SkImageSourceChannel::kLastEnum_SkImageSourceChannel},
- SkYUVAIndex{1, SkImageSourceChannel::kLastEnum_SkImageSourceChannel},
- SkYUVAIndex{1, SkImageSourceChannel::kLastEnum_SkImageSourceChannel},
- SkYUVAIndex{-1, SkImageSourceChannel::kLastEnum_SkImageSourceChannel}};
+ SkYUVAIndex{0, SkColorChannel::kA},
+ SkYUVAIndex{1, SkColorChannel::kA},
+ SkYUVAIndex{1, SkColorChannel::kA},
+ SkYUVAIndex{-1, SkColorChannel::kA}};
SkISize size{nv12Textures[0].width(), nv12Textures[0].height()};
return SkImage_Gpu::MakeFromYUVATexturesCopyWithExternalBackendImpl(
ctx, colorSpace, nv12Textures, yuvaIndices, size, origin, backendTexture,
diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h
index 87892c40c7..1f477fde08 100644
--- a/src/image/SkImage_Gpu.h
+++ b/src/image/SkImage_Gpu.h
@@ -19,6 +19,7 @@
class GrTexture;
class SkBitmap;
+struct SkYUVAIndex;
class SkImage_Gpu : public SkImage_Base {
public:
diff --git a/src/image/SkImage_GpuYUVA.h b/src/image/SkImage_GpuYUVA.h
index 92917832d5..204d62ddd2 100644
--- a/src/image/SkImage_GpuYUVA.h
+++ b/src/image/SkImage_GpuYUVA.h
@@ -11,8 +11,8 @@
#include "GrBackendSurface.h"
#include "GrContext.h"
#include "SkCachedData.h"
-#include "SkImagePriv.h"
#include "SkImage_Base.h"
+#include "SkYUVAIndex.h"
class GrTexture;
diff --git a/tools/DDLPromiseImageHelper.cpp b/tools/DDLPromiseImageHelper.cpp
index 51225b32de..dd97f940cc 100644
--- a/tools/DDLPromiseImageHelper.cpp
+++ b/tools/DDLPromiseImageHelper.cpp
@@ -13,7 +13,7 @@
#include "SkCachedData.h"
#include "SkDeferredDisplayListRecorder.h"
#include "SkImage_Base.h"
-#include "SkImagePriv.h"
+#include "SkYUVAIndex.h"
#include "SkYUVSizeInfo.h"
DDLPromiseImageHelper::PromiseImageCallbackContext::~PromiseImageCallbackContext() {
@@ -151,10 +151,10 @@ sk_sp<SkImage> DDLPromiseImageHelper::PromiseImageCreator(const void* rawData,
}
SkYUVAIndex yuvaIndices[4] = {
- SkYUVAIndex{0, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{1, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{2, SkImageSourceChannel::kA_SkImageSourceChannel},
- SkYUVAIndex{-1, SkImageSourceChannel::kA_SkImageSourceChannel}
+ SkYUVAIndex{0, SkColorChannel::kA},
+ SkYUVAIndex{1, SkColorChannel::kA},
+ SkYUVAIndex{2, SkColorChannel::kA},
+ SkYUVAIndex{-1, SkColorChannel::kA}
};
int tempWidth = curImage.backendTexture(0).width();