87d42e5d12
Tunnels through SkImageGenerator as well. The new SkCodec interface doesn't assume three 8 bit planes. New SkYUVASpec more clearly defines chroma subsampling and siting of the planes. The intent is to use this for other YUVA APIs as well, in particular SkImage factories in the future. In this change we convert to the SkYUVASpec to SkYUVASizeInfo and SkYUVAIndex[4] representation. But the intent is to use the SkYUVASpec representation throughout the pipeline once legacy APIs are removed. orientation GM is replicated to test a variety of chroma subsampling configs. Bug: skia:10632 Change-Id: I3fad35752b87cac16c51b24824331f2ae7d458d3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309658 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
59 lines
1.9 KiB
C
59 lines
1.9 KiB
C
/*
|
|
* 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 SkYUVASizeInfo_DEFINED
|
|
#define SkYUVASizeInfo_DEFINED
|
|
|
|
#include "include/codec/SkEncodedOrigin.h"
|
|
#include "include/core/SkImageInfo.h"
|
|
#include "include/core/SkSize.h"
|
|
|
|
struct SK_API 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] = {};
|
|
|
|
/**
|
|
* YUVA data often comes from formats like JPEG that support EXIF orientation.
|
|
* Code that operates on the raw YUV data often needs to know that orientation.
|
|
*/
|
|
SkEncodedOrigin fOrigin = kDefault_SkEncodedOrigin;
|
|
|
|
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;
|
|
|
|
void computePlanes(void* base, void* planes[kMaxCount]) const;
|
|
|
|
};
|
|
|
|
#endif // SkYUVASizeInfo_DEFINED
|