22bool ImageFileDirectory::IsValidType(uint16_t
type) {
return type >= 1 &&
type <= 12; }
24size_t ImageFileDirectory::BytesForType(uint16_t
type) {
57 uint16_t entryIndex) {
58 return data->bytes() +
70 uint16_t* outNumEntries,
71 uint32_t* outNextIfdOffset) {
72 const uint8_t* dataCurrent =
data->bytes();
73 size_t dataSize =
data->size();
76 if (dataSize < ifdOffset) {
80 dataCurrent += ifdOffset;
81 dataSize -= ifdOffset;
85 SkCodecPrintf(
"Insufficient space to store number of entries.\n");
94 SkCodecPrintf(
"Insufficient space (%u) to store all %u entries.\n",
95 static_cast<uint32_t
>(
data->size()),
101 *outNextIfdOffset = 0;
108 *outNumEntries = numEntries;
116 SkCodecPrintf(
"Insufficient space to store next IFD offset.\n");
117 if (allowTruncated) {
119 *outNextIfdOffset = 0;
131 bool* outLittleEndian,
132 uint32_t* outIfdOffset) {
134 if (
data->size() < 8) {
139 SkCodecPrintf(
"Tiff header had invalid endian marker 0x%x,0x%x,0x%x,0x%x.\n",
153 bool allowTruncated) {
154 uint16_t numEntries = 0;
155 uint32_t nextOffset = 0;
157 data.get(), littleEndian, ifdOffset, allowTruncated, &numEntries, &nextOffset)) {
162 std::move(
data), littleEndian, ifdOffset, numEntries, nextOffset));
169 uint32_t nextIfdOffset)
171 , fLittleEndian(littleEndian)
173 , fNumEntries(numEntries)
174 , fNextIfdOffset(nextIfdOffset) {}
181bool ImageFileDirectory::getEntryRawData(uint16_t entryIndex,
185 const uint8_t** outData,
186 size_t* outDataSize)
const {
196 if (!IsValidType(
type)) {
205 const size_t entryDataBytes = BytesForType(
type) *
count;
206 const uint8_t* entryData =
nullptr;
211 const uint32_t entryDataOffset =
get_endian_int(entry, fLittleEndian);
212 if (fData->
size() < entryDataOffset || fData->
size() - entryDataOffset < entryDataBytes) {
215 entryData = fData->
bytes() + entryDataOffset;
218 if (outTag) *outTag = tag;
219 if (outType) *outType =
type;
220 if (outCount) *outCount =
count;
221 if (outData) *outData = entryData;
222 if (outDataSize) *outDataSize = entryDataBytes;
229 const uint8_t*
data =
nullptr;
240bool ImageFileDirectory::getEntryValuesGeneric(uint16_t entryIndex,
244 uint16_t entryType = 0;
245 uint32_t entryCount = 0;
246 const uint8_t* entryData =
nullptr;
247 if (!getEntryRawData(entryIndex,
nullptr, &entryType, &entryCount, &entryData,
nullptr)) {
250 if (
type != entryType) {
253 if (
count != entryCount) {
256 for (uint32_t
i = 0;
i <
count; ++
i) {
268 if (denominator == 0) {
272 reinterpret_cast<float*
>(
values)[
i] = 0;
274 reinterpret_cast<float*
>(
values)[
i] =
275 numerator /
static_cast<float>(denominator);
282 if (denominator == 0) {
284 reinterpret_cast<float*
>(
values)[
i] = 0.f;
286 reinterpret_cast<float*
>(
values)[
i] =
287 numerator /
static_cast<float>(denominator);
static uint32_t get_endian_int(const uint8_t *data, bool littleEndian)
static uint16_t get_endian_short(const uint8_t *data, bool littleEndian)
#define SkCodecPrintf(...)
static bool is_valid_endian_marker(const uint8_t *data, bool *isLittleEndian)
const uint8_t * bytes() const
static sk_sp< SkData > MakeSubset(const SkData *src, size_t offset, size_t length)
sk_sp< SkData > getEntryUndefinedData(uint16_t entryIndex) const
static bool ParseHeader(const SkData *data, bool *outLittleEndian, uint32_t *outIfdOffset)
static std::unique_ptr< ImageFileDirectory > MakeFromOffset(sk_sp< SkData > data, bool littleEndian, uint32_t ifdOffset, bool allowTruncated=false)
uint16_t getEntryTag(uint16_t entryIndex) const
constexpr size_t kSizeEntry
constexpr size_t kSizeLong
constexpr uint16_t kTypeDoubleFloat
constexpr uint16_t kTypeUnsignedLong
constexpr size_t kSizeShort
constexpr uint16_t kTypeSignedLong
constexpr uint16_t kTypeUnsignedShort
constexpr uint16_t kTypeSignedByte
static bool validate_ifd(const SkData *data, bool littleEndian, uint32_t ifdOffset, bool allowTruncated, uint16_t *outNumEntries, uint32_t *outNextIfdOffset)
constexpr uint16_t kTypeUndefined
constexpr uint16_t kTypeUnsignedByte
constexpr uint16_t kTypeAsciiString
constexpr uint16_t kTypeSignedShort
static const uint8_t * get_entry_address(const SkData *data, uint32_t ifdOffset, uint16_t entryIndex)
constexpr uint16_t kTypeSingleFloat
constexpr uint16_t kTypeSignedRational
constexpr uint16_t kTypeUnsignedRational
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::shared_ptr< const fml::Mapping > data