2018-10-18 18:36:59 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2018-11-30 15:39:32 +00:00
|
|
|
#include "SkEncodedOrigin.h"
|
2018-10-29 20:26:02 +00:00
|
|
|
#include "SkImageInfo.h"
|
|
|
|
#include "SkSize.h"
|
2018-10-18 18:36:59 +00:00
|
|
|
|
2018-11-02 19:31:58 +00:00
|
|
|
struct SK_API SkYUVASizeInfo {
|
2018-10-29 20:26:02 +00:00
|
|
|
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];
|
|
|
|
|
2018-11-30 15:39:32 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2018-10-29 20:26:02 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
};
|
2018-10-18 18:36:59 +00:00
|
|
|
|
|
|
|
#endif // SkYUVASizeInfo_DEFINED
|