Replace use of SkYUVSizeInfo with SkYUVASizeInfo

Bug: skia:7903
Change-Id: If5acd50711ed8bd4a49efcb93db66fd3d14c8992
Reviewed-on: https://skia-review.googlesource.com/c/164681
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Jim Van Verth 2018-10-29 16:26:02 -04:00 committed by Skia Commit-Bot
parent 52a7154551
commit e24b587a00
28 changed files with 147 additions and 227 deletions

View File

@ -503,13 +503,13 @@ public:
YUVGenerator(const SkImageInfo& ii,
SkYUVColorSpace yuvColorSpace,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkBitmap bitmaps[SkYUVSizeInfo::kMaxCount])
SkBitmap bitmaps[SkYUVASizeInfo::kMaxCount])
: SkImageGenerator(ii)
, fYUVColorSpace(yuvColorSpace) {
memcpy(fYUVAIndices, yuvaIndices, sizeof(fYUVAIndices));
SkAssertResult(SkYUVAIndex::AreValidIndices(fYUVAIndices, &fNumBitmaps));
SkASSERT(fNumBitmaps > 0 && fNumBitmaps <= SkYUVSizeInfo::kMaxCount);
SkASSERT(fNumBitmaps > 0 && fNumBitmaps <= SkYUVASizeInfo::kMaxCount);
for (int i = 0; i < fNumBitmaps; ++i) {
fYUVBitmaps[i] = bitmaps[i];
@ -568,7 +568,7 @@ protected:
return fFlattened.readPixels(info, pixels, rowBytes, 0, 0);
}
bool onQueryYUVA8(SkYUVSizeInfo* size,
bool onQueryYUVA8(SkYUVASizeInfo* size,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* yuvColorSpace) const override {
@ -581,7 +581,7 @@ protected:
size->fSizes[i].fHeight = fYUVBitmaps[i].height();
size->fWidthBytes[i] = fYUVBitmaps[i].rowBytes();
}
for ( ; i < SkYUVSizeInfo::kMaxCount; ++i) {
for ( ; i < SkYUVASizeInfo::kMaxCount; ++i) {
size->fSizes[i].fWidth = 0;
size->fSizes[i].fHeight = 0;
size->fWidthBytes[i] = 0;
@ -590,8 +590,8 @@ protected:
return true;
}
bool onGetYUVA8Planes(const SkYUVSizeInfo&, const SkYUVAIndex[SkYUVAIndex::kIndexCount],
void* planes[SkYUVSizeInfo::kMaxCount]) override {
bool onGetYUVA8Planes(const SkYUVASizeInfo&, const SkYUVAIndex[SkYUVAIndex::kIndexCount],
void* planes[SkYUVASizeInfo::kMaxCount]) override {
for (int i = 0; i < fNumBitmaps; ++i) {
planes[i] = fYUVBitmaps[i].getPixels();
}
@ -602,7 +602,7 @@ private:
SkYUVColorSpace fYUVColorSpace;
SkYUVAIndex fYUVAIndices[SkYUVAIndex::kIndexCount];
int fNumBitmaps;
SkBitmap fYUVBitmaps[SkYUVSizeInfo::kMaxCount];
SkBitmap fYUVBitmaps[SkYUVASizeInfo::kMaxCount];
SkBitmap fFlattened;
};

View File

@ -323,7 +323,7 @@ skia_core_sources = [
"$_src/core/SkXfermodeInterpretation.h",
"$_src/core/SkYUVPlanesCache.cpp",
"$_src/core/SkYUVPlanesCache.h",
"$_src/core/SkYUVSizeInfo.cpp",
"$_src/core/SkYUVASizeInfo.cpp",
"$_src/image/SkImage.cpp",
@ -417,7 +417,7 @@ skia_core_sources = [
"$_include/core/SkUnPreMultiply.h",
"$_include/core/SkVertices.h",
"$_include/core/SkYUVAIndex.h",
"$_include/core/SkYUVSizeInfo.h",
"$_include/core/SkYUVASizeInfo.h",
"$_src/opts/SkBlitMask_opts.h",
"$_src/opts/SkBlitRow_opts.h",

View File

@ -20,7 +20,7 @@
#include "SkSize.h"
#include "SkStream.h"
#include "SkTypes.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
#include <vector>
@ -357,7 +357,7 @@ public:
* @param colorSpace Output parameter. If non-NULL this is set to kJPEG,
* otherwise this is ignored.
*/
bool queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
bool queryYUV8(SkYUVASizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
if (nullptr == sizeInfo) {
return false;
}
@ -385,7 +385,7 @@ public:
* recommendation (but not smaller).
* @param planes Memory for each of the Y, U, and V planes.
*/
Result getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[SkYUVSizeInfo::kMaxCount]) {
Result getYUV8Planes(const SkYUVASizeInfo& sizeInfo, void* planes[SkYUVASizeInfo::kMaxCount]) {
if (!planes || !planes[0] || !planes[1] || !planes[2]) {
return kInvalidInput;
}
@ -720,12 +720,12 @@ protected:
void* pixels, size_t rowBytes, const Options&,
int* rowsDecoded) = 0;
virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const {
virtual bool onQueryYUV8(SkYUVASizeInfo*, SkYUVColorSpace*) const {
return false;
}
virtual Result onGetYUV8Planes(const SkYUVSizeInfo&,
void*[SkYUVSizeInfo::kMaxCount] /*planes*/) {
virtual Result onGetYUV8Planes(const SkYUVASizeInfo&,
void*[SkYUVASizeInfo::kMaxCount] /*planes*/) {
return kUnimplemented;
}

View File

@ -23,7 +23,7 @@ class SkCanvas;
class SkImage;
class SkSurface;
struct SkYUVAIndex;
struct SkYUVSizeInfo;
struct SkYUVASizeInfo;
/*
* This class is intended to be used as:

View File

@ -12,6 +12,7 @@
#include "SkColor.h"
#include "SkImage.h"
#include "SkImageInfo.h"
#include "SkYUVAIndex.h"
#include "SkYUVASizeInfo.h"
class GrContext;
@ -91,7 +92,7 @@ public:
* @param yuvaIndices How the YUVA planes are organized/used
* @param colorSpace Output parameter.
*/
bool queryYUVA8(SkYUVSizeInfo* sizeInfo,
bool queryYUVA8(SkYUVASizeInfo* sizeInfo,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* colorSpace) const;
@ -107,7 +108,7 @@ public:
* @param planes Memory for the Y, U, V, and A planes. Note that, depending on the
* settings in yuvaIndices, anywhere from 1..4 planes could be returned.
*/
bool getYUVA8Planes(const SkYUVSizeInfo& sizeInfo,
bool getYUVA8Planes(const SkYUVASizeInfo& sizeInfo,
const SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
void* planes[]);
@ -170,13 +171,10 @@ protected:
struct Options {};
virtual bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) { return false; }
virtual bool onIsValid(GrContext*) const { return true; }
virtual bool onQueryYUVA8(SkYUVSizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount],
virtual bool onQueryYUVA8(SkYUVASizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount],
SkYUVColorSpace*) const { return false; }
virtual bool onGetYUVA8Planes(const SkYUVSizeInfo&, const SkYUVAIndex[SkYUVAIndex::kIndexCount],
virtual bool onGetYUVA8Planes(const SkYUVASizeInfo&, const SkYUVAIndex[SkYUVAIndex::kIndexCount],
void*[4] /*planes*/) { return false; }
// Deprecated methods
virtual bool onQueryYUV8(SkYUVSizeInfo*, SkYUVColorSpace*) const { return false; }
virtual bool onGetYUV8Planes(const SkYUVSizeInfo&, void*[3] /*planes*/) { return false; }
#if SK_SUPPORT_GPU
enum class TexGenType {
kNone, //image generator does not implement onGenerateTexture

View File

@ -8,8 +8,54 @@
#ifndef SkYUVASizeInfo_DEFINED
#define SkYUVASizeInfo_DEFINED
#include "SkYUVSizeInfo.h"
#include "SkImageInfo.h"
#include "SkSize.h"
using SkYUVASizeInfo = SkYUVSizeInfo;
struct SkYUVASizeInfo {
static constexpr auto kMaxCount = 4;
SkISize fSizes[kMaxCount];
/**
* While the widths of the Y, U, V and A planes are not restricted, the
* implementation often requires that the width of the memory allocated
* for each plane be a multiple of 8.
*
* This struct allows us to inform the client how many "widthBytes"
* that we need. Note that we use the new idea of "widthBytes"
* because this idea is distinct from "rowBytes" (used elsewhere in
* Skia). "rowBytes" allow the last row of the allocation to not
* include any extra padding, while, in this case, every single row of
* the allocation must be at least "widthBytes".
*/
size_t fWidthBytes[kMaxCount];
bool operator==(const SkYUVASizeInfo& that) const {
for (int i = 0; i < kMaxCount; ++i) {
SkASSERT((!fSizes[i].isEmpty() && fWidthBytes[i]) ||
(fSizes[i].isEmpty() && !fWidthBytes[i]));
if (fSizes[i] != that.fSizes[i] || fWidthBytes[i] != that.fWidthBytes[i]) {
return false;
}
}
return true;
}
size_t computeTotalBytes() const {
size_t totalBytes = 0;
for (int i = 0; i < kMaxCount; ++i) {
SkASSERT((!fSizes[i].isEmpty() && fWidthBytes[i]) ||
(fSizes[i].isEmpty() && !fWidthBytes[i]));
totalBytes += fWidthBytes[i] * fSizes[i].height();
}
return totalBytes;
}
void computePlanes(void* base, void* planes[kMaxCount]) const;
};
#endif // SkYUVASizeInfo_DEFINED

View File

@ -1,62 +0,0 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkYUVSizeInfo_DEFINED
#define SkYUVSizeInfo_DEFINED
#include "SkImageInfo.h"
#include "SkSize.h"
#include "SkYUVAIndex.h"
struct SkYUVSizeInfo {
static constexpr auto kMaxCount = 4;
SkISize fSizes[kMaxCount];
/**
* While the widths of the Y, U, V and A planes are not restricted, the
* implementation often requires that the width of the memory allocated
* for each plane be a multiple of 8.
*
* This struct allows us to inform the client how many "widthBytes"
* that we need. Note that we use the new idea of "widthBytes"
* because this idea is distinct from "rowBytes" (used elsewhere in
* Skia). "rowBytes" allow the last row of the allocation to not
* include any extra padding, while, in this case, every single row of
* the allocation must be at least "widthBytes".
*/
size_t fWidthBytes[kMaxCount];
bool operator==(const SkYUVSizeInfo& that) const {
for (int i = 0; i < kMaxCount; ++i) {
SkASSERT((!fSizes[i].isEmpty() && fWidthBytes[i]) ||
(fSizes[i].isEmpty() && !fWidthBytes[i]));
if (fSizes[i] != that.fSizes[i] || fWidthBytes[i] != that.fWidthBytes[i]) {
return false;
}
}
return true;
}
size_t computeTotalBytes() const {
size_t totalBytes = 0;
for (int i = 0; i < kMaxCount; ++i) {
SkASSERT((!fSizes[i].isEmpty() && fWidthBytes[i]) ||
(fSizes[i].isEmpty() && !fWidthBytes[i]));
totalBytes += fWidthBytes[i] * fSizes[i].height();
}
return totalBytes;
}
void computePlanes(void* base, void* planes[kMaxCount]) const;
};
#endif // SkYUVSizeInfo_DEFINED

View File

@ -59,7 +59,7 @@ bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& requestInfo, void* re
return SkPixmapPriv::Orient(dst, fCodec->getOrigin(), decode);
}
bool SkCodecImageGenerator::onQueryYUVA8(SkYUVSizeInfo* sizeInfo,
bool SkCodecImageGenerator::onQueryYUVA8(SkYUVASizeInfo* sizeInfo,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* colorSpace) const {
// This image generator always returns 3 separate non-interleaved planes
@ -75,7 +75,7 @@ bool SkCodecImageGenerator::onQueryYUVA8(SkYUVSizeInfo* sizeInfo,
return fCodec->queryYUV8(sizeInfo, colorSpace);
}
bool SkCodecImageGenerator::onGetYUVA8Planes(const SkYUVSizeInfo& sizeInfo,
bool SkCodecImageGenerator::onGetYUVA8Planes(const SkYUVASizeInfo& sizeInfo,
const SkYUVAIndex indices[SkYUVAIndex::kIndexCount],
void* planes[]) {
SkCodec::Result result = fCodec->getYUV8Planes(sizeInfo, planes);

View File

@ -26,9 +26,9 @@ protected:
const SkImageInfo& info, void* pixels, size_t rowBytes, const Options& opts) override;
bool onQueryYUVA8(
SkYUVSizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount], SkYUVColorSpace*) const override;
SkYUVASizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount], SkYUVColorSpace*) const override;
bool onGetYUVA8Planes(const SkYUVSizeInfo&, const SkYUVAIndex[SkYUVAIndex::kIndexCount],
bool onGetYUVA8Planes(const SkYUVASizeInfo&, const SkYUVAIndex[SkYUVAIndex::kIndexCount],
void* planes[]) override;
private:

View File

@ -839,7 +839,7 @@ static bool is_yuv_supported(jpeg_decompress_struct* dinfo) {
(4 == hSampY && 2 == vSampY);
}
bool SkJpegCodec::onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
bool SkJpegCodec::onQueryYUV8(SkYUVASizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
jpeg_decompress_struct* dinfo = fDecoderMgr->dinfo();
if (!is_yuv_supported(dinfo)) {
return false;
@ -861,9 +861,9 @@ bool SkJpegCodec::onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpa
return true;
}
SkCodec::Result SkJpegCodec::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo,
void* planes[SkYUVSizeInfo::kMaxCount]) {
SkYUVSizeInfo defaultInfo;
SkCodec::Result SkJpegCodec::onGetYUV8Planes(const SkYUVASizeInfo& sizeInfo,
void* planes[SkYUVASizeInfo::kMaxCount]) {
SkYUVASizeInfo defaultInfo;
// This will check is_yuv_supported(), so we don't need to here.
bool supportsYUV = this->onQueryYUV8(&defaultInfo, nullptr);
@ -962,7 +962,7 @@ SkCodec::Result SkJpegCodec::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo,
// this requirement using a dummy row buffer.
// FIXME: Should SkCodec have an extra memory buffer that can be shared among
// all of the implementations that use temporary/garbage memory?
SkAutoTMalloc<JSAMPLE> dummyRow(sizeInfo.fWidthBytes[SkYUVAIndex::kY_Index]);
SkAutoTMalloc<JSAMPLE> dummyRow(sizeInfo.fWidthBytes[0]);
for (int i = remainingRows; i < numYRowsPerBlock; i++) {
rowptrs[i] = dummyRow.get();
}

View File

@ -44,10 +44,10 @@ protected:
Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options&,
int*) override;
bool onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const override;
bool onQueryYUV8(SkYUVASizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const override;
Result onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo,
void* planes[SkYUVSizeInfo::kMaxCount]) override;
Result onGetYUV8Planes(const SkYUVASizeInfo& sizeInfo,
void* planes[SkYUVASizeInfo::kMaxCount]) override;
SkEncodedImageFormat onGetEncodedFormat() const override {
return SkEncodedImageFormat::kJPEG;

View File

@ -64,7 +64,7 @@ sk_sp<SkImage> SkDeferredDisplayListRecorder::makeYUVAPromiseTexture(
#include "SkImage_Gpu.h"
#include "SkImage_GpuYUVA.h"
#include "SkSurface_Gpu.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
SkDeferredDisplayListRecorder::SkDeferredDisplayListRecorder(const SkSurfaceCharacterization& c)
: fCharacterization(c) {

View File

@ -30,78 +30,19 @@ bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t r
return this->onGetPixels(info, pixels, rowBytes, defaultOpts);
}
bool SkImageGenerator::queryYUVA8(SkYUVSizeInfo* sizeInfo,
bool SkImageGenerator::queryYUVA8(SkYUVASizeInfo* sizeInfo,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* colorSpace) const {
SkASSERT(sizeInfo);
if (!this->onQueryYUVA8(sizeInfo, yuvaIndices, colorSpace)) {
// try the deprecated method and make a guess at the other data
if (this->onQueryYUV8(sizeInfo, colorSpace)) {
// take a guess at the number of planes
int numPlanes = 3; // onQueryYUV8 only supports up to 3 channels
for (int i = 0; i < 3; ++i) {
if (sizeInfo->fSizes[i].isEmpty()) {
numPlanes = i;
break;
}
}
if (!numPlanes) {
return false;
}
switch (numPlanes) {
case 1:
// Assume 3 interleaved planes
yuvaIndices[SkYUVAIndex::kY_Index].fIndex = 0;
yuvaIndices[SkYUVAIndex::kY_Index].fChannel = SkColorChannel::kR;
yuvaIndices[SkYUVAIndex::kU_Index].fIndex = 0;
yuvaIndices[SkYUVAIndex::kU_Index].fChannel = SkColorChannel::kG;
yuvaIndices[SkYUVAIndex::kV_Index].fIndex = 0;
yuvaIndices[SkYUVAIndex::kV_Index].fChannel = SkColorChannel::kB;
yuvaIndices[SkYUVAIndex::kA_Index].fIndex = -1;
yuvaIndices[SkYUVAIndex::kA_Index].fChannel = SkColorChannel::kR;
break;
case 2:
// Assume Y plane and interleaved UV plane (NV12)
yuvaIndices[SkYUVAIndex::kY_Index].fIndex = 0;
yuvaIndices[SkYUVAIndex::kY_Index].fChannel = SkColorChannel::kR;
yuvaIndices[SkYUVAIndex::kU_Index].fIndex = 1;
yuvaIndices[SkYUVAIndex::kU_Index].fChannel = SkColorChannel::kR;
yuvaIndices[SkYUVAIndex::kV_Index].fIndex = 1;
yuvaIndices[SkYUVAIndex::kV_Index].fChannel = SkColorChannel::kG;
yuvaIndices[SkYUVAIndex::kA_Index].fIndex = -1;
yuvaIndices[SkYUVAIndex::kA_Index].fChannel = SkColorChannel::kR;
break;
case 3:
default:
// Assume 3 separate non-interleaved planes
yuvaIndices[SkYUVAIndex::kY_Index].fIndex = 0;
yuvaIndices[SkYUVAIndex::kY_Index].fChannel = SkColorChannel::kR;
yuvaIndices[SkYUVAIndex::kU_Index].fIndex = 1;
yuvaIndices[SkYUVAIndex::kU_Index].fChannel = SkColorChannel::kR;
yuvaIndices[SkYUVAIndex::kV_Index].fIndex = 2;
yuvaIndices[SkYUVAIndex::kV_Index].fChannel = SkColorChannel::kR;
yuvaIndices[SkYUVAIndex::kA_Index].fIndex = -1;
yuvaIndices[SkYUVAIndex::kA_Index].fChannel = SkColorChannel::kR;
break;
}
// clear fourth element in sizeInfo to ensure it's initialized
sizeInfo->fSizes[3].fWidth = sizeInfo->fSizes[3].fHeight = sizeInfo->fWidthBytes[3] = 0;
return true;
}
return false;
}
return true;
return this->onQueryYUVA8(sizeInfo, yuvaIndices, colorSpace);
}
bool SkImageGenerator::getYUVA8Planes(const SkYUVSizeInfo& sizeInfo,
bool SkImageGenerator::getYUVA8Planes(const SkYUVASizeInfo& sizeInfo,
const SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
void* planes[SkYUVSizeInfo::kMaxCount]) {
void* planes[SkYUVASizeInfo::kMaxCount]) {
for (int i = 0; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; ++i) {
SkASSERT(sizeInfo.fSizes[i].fWidth >= 0);
SkASSERT(sizeInfo.fSizes[i].fHeight >= 0);
SkASSERT(sizeInfo.fWidthBytes[i] >= (size_t) sizeInfo.fSizes[i].fWidth);
@ -114,10 +55,7 @@ bool SkImageGenerator::getYUVA8Planes(const SkYUVSizeInfo& sizeInfo,
SkASSERT(planes[i]);
}
if (!this->onGetYUVA8Planes(sizeInfo, yuvaIndices, planes)) {
return this->onGetYUV8Planes(sizeInfo, planes);
}
return true;
return this->onGetYUVA8Planes(sizeInfo, yuvaIndices, planes);
}
#if SK_SUPPORT_GPU

View File

@ -5,19 +5,19 @@
* found in the LICENSE file.
*/
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
#include "SkTemplates.h"
void SkYUVSizeInfo::computePlanes(void* base, void* planes[SkYUVSizeInfo::kMaxCount]) const {
void SkYUVASizeInfo::computePlanes(void* base, void* planes[SkYUVASizeInfo::kMaxCount]) const {
planes[0] = base;
int i = 1;
for (; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (; i < SkYUVASizeInfo::kMaxCount; ++i) {
if (fSizes[i].isEmpty()) {
break;
}
planes[i] = SkTAddOffset<void>(planes[i - 1], fWidthBytes[i - 1] * fSizes[i - 1].height());
}
for (; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (; i < SkYUVASizeInfo::kMaxCount; ++i) {
planes[i] = nullptr;
}
}

View File

@ -11,7 +11,7 @@
#include "SkCachedData.h"
#include "SkImageInfo.h"
#include "SkYUVAIndex.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
class SkResourceCache;
@ -25,7 +25,7 @@ public:
* fColorSpace: color space that will be used for the YUV -> RGB conversion.
*/
struct Info {
SkYUVSizeInfo fSizeInfo;
SkYUVASizeInfo fSizeInfo;
SkYUVAIndex fYUVAIndices[SkYUVAIndex::kIndexCount];
SkYUVColorSpace fColorSpace;
};

View File

@ -21,20 +21,20 @@
#include "SkYUVAIndex.h"
#include "effects/GrYUVtoRGBEffect.h"
sk_sp<SkCachedData> GrYUVProvider::getPlanes(SkYUVSizeInfo* size,
sk_sp<SkCachedData> GrYUVProvider::getPlanes(SkYUVASizeInfo* size,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* colorSpace,
const void* constPlanes[SkYUVSizeInfo::kMaxCount]) {
const void* constPlanes[SkYUVASizeInfo::kMaxCount]) {
sk_sp<SkCachedData> data;
SkYUVPlanesCache::Info yuvInfo;
data.reset(SkYUVPlanesCache::FindAndRef(this->onGetID(), &yuvInfo));
void* planes[SkYUVSizeInfo::kMaxCount];
void* planes[SkYUVASizeInfo::kMaxCount];
if (data.get()) {
planes[0] = (void*)data->data(); // we should always have at least one plane
for (int i = 1; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = 1; i < SkYUVASizeInfo::kMaxCount; ++i) {
if (!yuvInfo.fSizeInfo.fWidthBytes[i]) {
SkASSERT(!yuvInfo.fSizeInfo.fWidthBytes[i] &&
!yuvInfo.fSizeInfo.fSizes[i].fHeight);
@ -53,7 +53,7 @@ sk_sp<SkCachedData> GrYUVProvider::getPlanes(SkYUVSizeInfo* size,
// Allocate the memory for YUVA
size_t totalSize(0);
for (int i = 0; i < SkYUVSizeInfo::kMaxCount; i++) {
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; i++) {
SkASSERT((yuvInfo.fSizeInfo.fWidthBytes[i] && yuvInfo.fSizeInfo.fSizes[i].fHeight) ||
(!yuvInfo.fSizeInfo.fWidthBytes[i] && !yuvInfo.fSizeInfo.fSizes[i].fHeight));
@ -64,7 +64,7 @@ sk_sp<SkCachedData> GrYUVProvider::getPlanes(SkYUVSizeInfo* size,
planes[0] = data->writable_data();
for (int i = 1; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = 1; i < SkYUVASizeInfo::kMaxCount; ++i) {
if (!yuvInfo.fSizeInfo.fWidthBytes[i]) {
SkASSERT(!yuvInfo.fSizeInfo.fWidthBytes[i] &&
!yuvInfo.fSizeInfo.fSizes[i].fHeight);
@ -104,10 +104,10 @@ void GrYUVProvider::YUVGen_DataReleaseProc(const void*, void* data) {
sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrSurfaceDesc& desc,
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace) {
SkYUVSizeInfo yuvSizeInfo;
SkYUVASizeInfo yuvSizeInfo;
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount];
SkYUVColorSpace yuvColorSpace;
const void* planes[SkYUVSizeInfo::kMaxCount];
const void* planes[SkYUVASizeInfo::kMaxCount];
sk_sp<SkCachedData> dataStorage = this->getPlanes(&yuvSizeInfo, yuvaIndices,
&yuvColorSpace, planes);
@ -115,8 +115,8 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrS
return nullptr;
}
sk_sp<GrTextureProxy> yuvTextureProxies[SkYUVSizeInfo::kMaxCount];
for (int i = 0; i < SkYUVSizeInfo::kMaxCount; ++i) {
sk_sp<GrTextureProxy> yuvTextureProxies[SkYUVASizeInfo::kMaxCount];
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; ++i) {
if (yuvSizeInfo.fSizes[i].isEmpty()) {
SkASSERT(!yuvSizeInfo.fWidthBytes[i]);
continue;

View File

@ -10,14 +10,14 @@
#include "GrTypes.h"
#include "SkImageInfo.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVAIndex.h"
#include "SkYUVASizeInfo.h"
class GrContext;
struct GrSurfaceDesc;
class GrTexture;
class GrTextureProxy;
class SkCachedData;
struct SkYUVAIndex;
/**
* There are at least 2 different ways to extract/retrieve YUV planar data...
@ -44,8 +44,8 @@ public:
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace);
sk_sp<SkCachedData> getPlanes(SkYUVSizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount],
SkYUVColorSpace*, const void* planes[SkYUVSizeInfo::kMaxCount]);
sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[SkYUVAIndex::kIndexCount],
SkYUVColorSpace*, const void* planes[SkYUVASizeInfo::kMaxCount]);
private:
virtual uint32_t onGetID() const = 0;
@ -61,7 +61,7 @@ private:
* @param yuvaIndices How the YUVA planes are used/organized
* @param colorSpace Output parameter.
*/
virtual bool onQueryYUVA8(SkYUVSizeInfo* sizeInfo,
virtual bool onQueryYUVA8(SkYUVASizeInfo* sizeInfo,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* colorSpace) const = 0;
@ -76,7 +76,7 @@ private:
* @param yuvaIndices How the YUVA planes are used/organized
* @param planes Memory for each of the Y, U, V, and A planes.
*/
virtual bool onGetYUVA8Planes(const SkYUVSizeInfo& sizeInfo,
virtual bool onGetYUVA8Planes(const SkYUVASizeInfo& sizeInfo,
const SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
void* planes[]) = 0;

View File

@ -220,7 +220,7 @@ bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode ) const {
return as_IB(this)->onAsLegacyBitmap(bitmap);
}
sk_sp<SkCachedData> SkImage_Base::getPlanes(SkYUVSizeInfo*, SkYUVAIndex[4],
sk_sp<SkCachedData> SkImage_Base::getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4],
SkYUVColorSpace*, const void*[4]) {
return nullptr;
}

View File

@ -23,7 +23,7 @@ class GrTexture;
class GrSamplerState;
class SkCachedData;
struct SkYUVSizeInfo;
struct SkYUVASizeInfo;
enum {
kNeedNewImageUniqueID = 0
@ -70,7 +70,7 @@ public:
virtual sk_sp<SkImage> onMakeSubset(const SkIRect&) const = 0;
virtual sk_sp<SkCachedData> getPlanes(SkYUVSizeInfo*, SkYUVAIndex[4],
virtual sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4],
SkYUVColorSpace*, const void* planes[4]);
virtual sk_sp<SkData> onRefEncoded() const { return nullptr; }

View File

@ -16,7 +16,7 @@
#include "GrTexture.h"
#include "SkImage_Gpu.h"
#include "SkImage_GpuYUVA.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
#include "effects/GrYUVtoRGBEffect.h"
SkImage_GpuYUVA::SkImage_GpuYUVA(sk_sp<GrContext> context, int width, int height, uint32_t uniqueID,
@ -156,7 +156,7 @@ sk_sp<SkImage> SkImage_GpuYUVA::MakePromiseYUVATexture(GrContext* context,
return nullptr;
}
}
for (int i = numTextures; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = numTextures; i < SkYUVASizeInfo::kMaxCount; ++i) {
if (!yuvaSizes[i].isEmpty()) {
return nullptr;
}

View File

@ -15,7 +15,7 @@
#include "SkYUVAIndex.h"
class GrTexture;
struct SkYUVSizeInfo;
struct SkYUVASizeInfo;
// Wraps the 3 or 4 planes of a YUVA image for consumption by the GPU.
// Initially any direct rendering will be done by passing the individual planes to a shader.

View File

@ -296,12 +296,12 @@ public:
private:
uint32_t onGetID() const override { return fGen->uniqueID(); }
bool onQueryYUVA8(SkYUVSizeInfo* sizeInfo,
bool onQueryYUVA8(SkYUVASizeInfo* sizeInfo,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* colorSpace) const override {
return fGen->queryYUVA8(sizeInfo, yuvaIndices, colorSpace);
}
bool onGetYUVA8Planes(const SkYUVSizeInfo& sizeInfo,
bool onGetYUVA8Planes(const SkYUVASizeInfo& sizeInfo,
const SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
void* planes[]) override {
return fGen->getYUVA8Planes(sizeInfo, yuvaIndices, planes);
@ -329,10 +329,10 @@ static void set_key_on_proxy(GrProxyProvider* proxyProvider,
}
}
sk_sp<SkCachedData> SkImage_Lazy::getPlanes(SkYUVSizeInfo* yuvaSizeInfo,
sk_sp<SkCachedData> SkImage_Lazy::getPlanes(SkYUVASizeInfo* yuvaSizeInfo,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
SkYUVColorSpace* yuvColorSpace,
const void* planes[SkYUVSizeInfo::kMaxCount]) {
const void* planes[SkYUVASizeInfo::kMaxCount]) {
ScopedGenerator generator(fSharedGenerator);
Generator_GrYUVProvider provider(generator);

View File

@ -48,7 +48,7 @@ public:
sk_sp<GrTextureProxy> asTextureProxyRef(GrContext*,
const GrSamplerState&,
SkScalar scaleAdjust[2]) const override;
sk_sp<SkCachedData> getPlanes(SkYUVSizeInfo*, SkYUVAIndex[4],
sk_sp<SkCachedData> getPlanes(SkYUVASizeInfo*, SkYUVAIndex[4],
SkYUVColorSpace*, const void* planes[4]) override;
#endif
sk_sp<SkData> onRefEncoded() const override;

View File

@ -62,7 +62,7 @@ public:
DEF_TEST(ImageGenerator, reporter) {
MyImageGenerator ig;
SkYUVSizeInfo sizeInfo;
SkYUVASizeInfo sizeInfo;
sizeInfo.fSizes[0] = SkISize::Make(200, 200);
sizeInfo.fSizes[1] = SkISize::Make(100, 100);
sizeInfo.fSizes[2] = SkISize::Make( 50, 50);

View File

@ -32,7 +32,7 @@ DEF_TEST(YUVPlanesCache, reporter) {
SkResourceCache cache(1024);
SkYUVPlanesCache::Info yuvInfo;
for (int i = 0; i < SkYUVSizeInfo::kMaxCount; i++) {
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; i++) {
yuvInfo.fSizeInfo.fSizes[i].fWidth = 20 * (i + 1);
yuvInfo.fSizeInfo.fSizes[i].fHeight = 10 * (i + 1);
yuvInfo.fSizeInfo.fWidthBytes[i] = 80 * (i + 1);

View File

@ -10,7 +10,7 @@
#include "SkCodec.h"
#include "SkStream.h"
#include "SkTemplates.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
#include "Test.h"
static void codec_yuv(skiatest::Reporter* reporter,
@ -27,7 +27,7 @@ static void codec_yuv(skiatest::Reporter* reporter,
}
// Test queryYUV8()
SkYUVSizeInfo info;
SkYUVASizeInfo info;
{
bool success = codec->queryYUV8(nullptr, nullptr);
@ -38,7 +38,7 @@ static void codec_yuv(skiatest::Reporter* reporter,
return;
}
for (int i = 0; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; ++i) {
REPORTER_ASSERT(reporter, info.fSizes[i] == expectedSizes[i]);
REPORTER_ASSERT(reporter,
info.fWidthBytes[i] == (uint32_t) SkAlign8(info.fSizes[i].width()));
@ -53,7 +53,7 @@ static void codec_yuv(skiatest::Reporter* reporter,
return;
}
for (int i = 0; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; ++i) {
REPORTER_ASSERT(reporter, info.fSizes[i] == expectedSizes[i]);
REPORTER_ASSERT(reporter,
info.fWidthBytes[i] == (uint32_t) SkAlign8(info.fSizes[i].width()));
@ -65,7 +65,7 @@ static void codec_yuv(skiatest::Reporter* reporter,
size_t totalBytes = info.computeTotalBytes();
SkAutoMalloc storage(totalBytes);
void* planes[SkYUVSizeInfo::kMaxCount];
void* planes[SkYUVASizeInfo::kMaxCount];
info.computePlanes(storage.get(), planes);

View File

@ -14,7 +14,7 @@
#include "SkDeferredDisplayListRecorder.h"
#include "SkImage_Base.h"
#include "SkYUVAIndex.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
DDLPromiseImageHelper::PromiseImageCallbackContext::~PromiseImageCallbackContext() {
GrGpu* gpu = fContext->contextPriv().getGpu();
@ -142,9 +142,9 @@ sk_sp<SkImage> DDLPromiseImageHelper::PromiseImageCreator(const void* rawData,
sk_sp<SkImage> image;
if (curImage.isYUV()) {
GrBackendFormat backendFormats[SkYUVSizeInfo::kMaxCount];
void* contexts[SkYUVSizeInfo::kMaxCount] = { nullptr, nullptr, nullptr, nullptr };
SkISize sizes[SkYUVSizeInfo::kMaxCount];
GrBackendFormat backendFormats[SkYUVASizeInfo::kMaxCount];
void* contexts[SkYUVASizeInfo::kMaxCount] = { nullptr, nullptr, nullptr, nullptr };
SkISize sizes[SkYUVASizeInfo::kMaxCount];
// TODO: store this value somewhere?
int textureCount;
SkAssertResult(SkYUVAIndex::AreValidIndices(curImage.yuvaIndices(), &textureCount));
@ -155,7 +155,7 @@ sk_sp<SkImage> DDLPromiseImageHelper::PromiseImageCreator(const void* rawData,
contexts[i] = curImage.refCallbackContext(i).release();
sizes[i].set(curImage.yuvPixmap(i).width(), curImage.yuvPixmap(i).height());
}
for (int i = textureCount; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = textureCount; i < SkYUVASizeInfo::kMaxCount; ++i) {
sizes[i] = SkISize::MakeEmpty();
}
@ -219,17 +219,17 @@ int DDLPromiseImageHelper::addImage(SkImage* image) {
image->uniqueID(),
overallII);
SkYUVSizeInfo yuvaSizeInfo;
SkYUVASizeInfo yuvaSizeInfo;
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount];
SkYUVColorSpace yuvColorSpace;
const void* planes[SkYUVSizeInfo::kMaxCount];
const void* planes[SkYUVASizeInfo::kMaxCount];
sk_sp<SkCachedData> yuvData = ib->getPlanes(&yuvaSizeInfo, yuvaIndices, &yuvColorSpace, planes);
if (yuvData) {
newImageInfo.setYUVData(std::move(yuvData), yuvaIndices, yuvColorSpace);
// determine colortypes from index data
// for testing we only ever use A8 or RGBA8888
SkColorType colorTypes[SkYUVSizeInfo::kMaxCount] = {
SkColorType colorTypes[SkYUVASizeInfo::kMaxCount] = {
kUnknown_SkColorType, kUnknown_SkColorType,
kUnknown_SkColorType, kUnknown_SkColorType
};
@ -246,7 +246,7 @@ int DDLPromiseImageHelper::addImage(SkImage* image) {
}
}
for (int i = 0; i < SkYUVSizeInfo::kMaxCount; ++i) {
for (int i = 0; i < SkYUVASizeInfo::kMaxCount; ++i) {
if (yuvaSizeInfo.fSizes[i].isEmpty()) {
SkASSERT(!yuvaSizeInfo.fWidthBytes[i] && kUnknown_SkColorType == colorTypes[i]);
continue;

View File

@ -14,7 +14,7 @@
#include "GrBackendSurface.h"
#include "SkCachedData.h"
#include "SkYUVAIndex.h"
#include "SkYUVSizeInfo.h"
#include "SkYUVASizeInfo.h"
class GrContext;
class SkDeferredDisplayListRecorder;
@ -124,7 +124,7 @@ private:
}
const SkPixmap& yuvPixmap(int index) const {
SkASSERT(this->isYUV());
SkASSERT(index >= 0 && index < SkYUVSizeInfo::kMaxCount);
SkASSERT(index >= 0 && index < SkYUVASizeInfo::kMaxCount);
return fYUVPlanes[index];
}
const SkBitmap& normalBitmap() const {
@ -133,22 +133,22 @@ private:
}
void setCallbackContext(int index, sk_sp<PromiseImageCallbackContext> callbackContext) {
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVSizeInfo::kMaxCount : 1));
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVASizeInfo::kMaxCount : 1));
fCallbackContexts[index] = callbackContext;
}
PromiseImageCallbackContext* callbackContext(int index) {
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVSizeInfo::kMaxCount : 1));
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVASizeInfo::kMaxCount : 1));
return fCallbackContexts[index].get();
}
sk_sp<PromiseImageCallbackContext> refCallbackContext(int index) const {
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVSizeInfo::kMaxCount : 1));
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVASizeInfo::kMaxCount : 1));
return fCallbackContexts[index];
}
const GrCaps* caps() const { return fCallbackContexts[0]->caps(); }
const GrBackendTexture& backendTexture(int index) const {
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVSizeInfo::kMaxCount : 1));
SkASSERT(index >= 0 && index < (this->isYUV() ? SkYUVASizeInfo::kMaxCount : 1));
return fCallbackContexts[index]->backendTexture();
}
@ -163,7 +163,7 @@ private:
}
void addYUVPlane(int index, const SkImageInfo& ii, const void* plane, size_t widthBytes) {
SkASSERT(this->isYUV());
SkASSERT(index >= 0 && index < SkYUVSizeInfo::kMaxCount);
SkASSERT(index >= 0 && index < SkYUVASizeInfo::kMaxCount);
fYUVPlanes[index].reset(ii, plane, widthBytes);
}
@ -180,10 +180,10 @@ private:
sk_sp<SkCachedData> fYUVData; // when !null, this is a YUV image
SkYUVColorSpace fYUVColorSpace = kJPEG_SkYUVColorSpace;
SkYUVAIndex fYUVAIndices[SkYUVAIndex::kIndexCount];
SkPixmap fYUVPlanes[SkYUVSizeInfo::kMaxCount];
SkPixmap fYUVPlanes[SkYUVASizeInfo::kMaxCount];
// Up to SkYUVSizeInfo::kMaxCount for a YUVA image. Only one for a normal image.
sk_sp<PromiseImageCallbackContext> fCallbackContexts[SkYUVSizeInfo::kMaxCount];
// Up to SkYUVASizeInfo::kMaxCount for a YUVA image. Only one for a normal image.
sk_sp<PromiseImageCallbackContext> fCallbackContexts[SkYUVASizeInfo::kMaxCount];
};
// This stack-based context allows each thread to re-inflate the image indices into