52Image_YUVA::Image_YUVA(
const YUVAProxies& proxies,
57 yuva_alpha_type(yuvaInfo),
58 std::move(imageColorSpace)),
60 , fProxies(
std::move(proxies))
62 , fUVSubsampleFactors(
SkYUVAInfo::SubsamplingFactors(yuvaInfo.subsampling())) {
70 if (fProxies[i].proxy()->mipmapped() == Mipmapped::kNo) {
71 fMipmapped = Mipmapped::kNo;
73 if (fProxies[i].proxy()->isProtected()) {
74 fProtected = Protected::kYes;
79Image_YUVA::~Image_YUVA() =
default;
95 const int numPlanes = yuvaInfo.
numPlanes();
101 for (
int i = 0; i < numPlanes; ++i) {
102 if (!planes[i] || !caps->
isTexturable(planes[i].proxy()->textureInfo())) {
105 if (planes[i].dimensions() != planeDimensions[i]) {
108 pixmapChannelmasks[i] = caps->
channelMask(planes[i].proxy()->textureInfo());
115 expectedPlanes != numPlanes) {
119 if (planes[locations[
kY].fPlane].dimensions() != yuvaInfo.
dimensions()) {
123 if (planes[locations[kU].fPlane].dimensions() != planes[locations[kV].fPlane].dimensions()) {
127 if (locations[
kA].fPlane >= 0 &&
128 planes[locations[
kA].fPlane].dimensions() != yuvaInfo.
dimensions()) {
138 YUVAProxies channelProxies;
140 auto [plane, channel] = locations[i];
144 Swizzle channelSwizzle = planes[plane].swizzle().selectChannelInR((
int) channel);
145 channelProxies[i] = planes[plane].replaceSwizzle(channelSwizzle);
146 }
else if (i ==
kA) {
148 channelProxies[i] = {};
150 SKGPU_LOG_W(
"YUVA channel %d does not have a valid location", i);
157 std::move(imageColorSpace)));
169 for (
int i = 0; i < yuvaInfo.
numPlanes(); ++i) {
170 planes[i] = AsView(
images[i]);
177 if (
images[i]->isAlphaOnly()) {
186 for (
int plane = 0; plane < yuvaInfo.
numPlanes(); ++plane) {
194size_t Image_YUVA::textureSize()
const {
207 for (
int j = 0; j < i - 1; ++j) {
208 if (fProxies[i].proxy() == fProxies[j].proxy()) {
214 if (fProxies[i].proxy()->isInstantiated()) {
215 size += fProxies[i].proxy()->texture()->gpuMemorySize();
217 size += fProxies[i].proxy()->uninstantiatedGpuMemorySize();
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SKGPU_LOG_W(fmt,...)
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static unsigned repeat(SkFixed fx, int max)
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static bool SkImageInfoIsValid(const SkImageInfo &info)
static SkImage_Base * as_IB(SkImage *image)
static constexpr auto kAssumedColorType
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
static constexpr int kMaxPlanes
YUVALocations toYUVALocations(const uint32_t *channelFlags) const
std::tuple< int, int > planeSubsamplingFactors(int planeIdx) const
int planeDimensions(SkISize planeDimensions[kMaxPlanes]) const
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
static constexpr int kYUVAChannelCount
SkISize dimensions() const
virtual uint32_t channelMask(const TextureInfo &) const =0
bool isTexturable(const TextureInfo &) const
void linkDevices(const Image_Base *)
TextureProxyView makeSwizzle(Swizzle swizzle) const &
std::array< MockImage, 3 > images
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static bool AreValidLocations(const SkYUVAInfo::YUVALocations &locations, int *numPlanes=nullptr)