Flutter Engine
The Flutter Engine
Classes | Functions | Variables
SkTiff Namespace Reference

Classes

class  ImageFileDirectory
 

Functions

static const uint8_t * get_entry_address (const SkData *data, uint32_t ifdOffset, uint16_t entryIndex)
 
static bool validate_ifd (const SkData *data, bool littleEndian, uint32_t ifdOffset, bool allowTruncated, uint16_t *outNumEntries, uint32_t *outNextIfdOffset)
 

Variables

constexpr size_t kSizeEntry = 12
 
constexpr size_t kSizeShort = 2
 
constexpr size_t kSizeLong = 4
 
constexpr size_t kEndianSize = 4
 
constexpr uint8_t kEndianBig [kEndianSize] = {'M', 'M', 0, 42}
 
constexpr uint8_t kEndianLittle [kEndianSize] = {'I', 'I', 42, 0}
 
constexpr uint16_t kTypeUnsignedByte = 1
 
constexpr uint16_t kTypeAsciiString = 2
 
constexpr uint16_t kTypeUnsignedShort = 3
 
constexpr uint16_t kTypeUnsignedLong = 4
 
constexpr uint16_t kTypeUnsignedRational = 5
 
constexpr uint16_t kTypeSignedByte = 6
 
constexpr uint16_t kTypeUndefined = 7
 
constexpr uint16_t kTypeSignedShort = 8
 
constexpr uint16_t kTypeSignedLong = 9
 
constexpr uint16_t kTypeSignedRational = 10
 
constexpr uint16_t kTypeSingleFloat = 11
 
constexpr uint16_t kTypeDoubleFloat = 12
 

Function Documentation

◆ get_entry_address()

static const uint8_t * SkTiff::get_entry_address ( const SkData data,
uint32_t  ifdOffset,
uint16_t  entryIndex 
)
static

Definition at line 55 of file SkTiffUtility.cpp.

57 {
58 return data->bytes() + // Base address
59 ifdOffset + // IFD offset
60 kSizeShort + // IFD number of entries
61 kSizeEntry * entryIndex; // Entries
62}
constexpr size_t kSizeEntry
constexpr size_t kSizeShort
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ validate_ifd()

static bool SkTiff::validate_ifd ( const SkData data,
bool  littleEndian,
uint32_t  ifdOffset,
bool  allowTruncated,
uint16_t *  outNumEntries,
uint32_t *  outNextIfdOffset 
)
static

Definition at line 66 of file SkTiffUtility.cpp.

71 {
72 const uint8_t* dataCurrent = data->bytes();
73 size_t dataSize = data->size();
74
75 // Seek to the IFD offset.
76 if (dataSize < ifdOffset) {
77 SkCodecPrintf("IFD offset is too large.\n");
78 return false;
79 }
80 dataCurrent += ifdOffset;
81 dataSize -= ifdOffset;
82
83 // Read the number of entries.
84 if (dataSize < kSizeShort) {
85 SkCodecPrintf("Insufficient space to store number of entries.\n");
86 return false;
87 }
88 uint16_t numEntries = get_endian_short(dataCurrent, littleEndian);
89 dataCurrent += kSizeShort;
90 dataSize -= kSizeShort;
91
92 // Check that there is enough space for all entries.
93 if (dataSize < kSizeEntry * numEntries) {
94 SkCodecPrintf("Insufficient space (%u) to store all %u entries.\n",
95 static_cast<uint32_t>(data->size()),
96 numEntries);
97 if (allowTruncated) {
98 // Set the number of entries to the number of entries that can be fully read, and set
99 // the next IFD offset to 0 (indicating that there is no next IFD).
100 *outNumEntries = dataSize / kSizeEntry;
101 *outNextIfdOffset = 0;
102 return true;
103 }
104 return false;
105 }
106
107 // Save the number of entries.
108 *outNumEntries = numEntries;
109
110 // Seek past the entries.
111 dataCurrent += kSizeEntry * numEntries;
112 dataSize -= kSizeEntry * numEntries;
113
114 // Read the next IFD offset.
115 if (dataSize < kSizeLong) {
116 SkCodecPrintf("Insufficient space to store next IFD offset.\n");
117 if (allowTruncated) {
118 // Set the next IFD offset to 0 (indicating that there is no next IFD).
119 *outNextIfdOffset = 0;
120 return true;
121 }
122 return false;
123 }
124
125 // Save the next IFD offset.
126 *outNextIfdOffset = get_endian_int(dataCurrent, littleEndian);
127 return true;
128}
static uint32_t get_endian_int(const uint8_t *data, bool littleEndian)
Definition: SkCodecPriv.h:202
static uint16_t get_endian_short(const uint8_t *data, bool littleEndian)
Definition: SkCodecPriv.h:194
#define SkCodecPrintf(...)
Definition: SkCodecPriv.h:23
constexpr size_t kSizeLong

Variable Documentation

◆ kEndianBig

constexpr uint8_t SkTiff::kEndianBig[kEndianSize] = {'M', 'M', 0, 42}
inlineconstexpr

Definition at line 22 of file SkTiffUtility.h.

◆ kEndianLittle

constexpr uint8_t SkTiff::kEndianLittle[kEndianSize] = {'I', 'I', 42, 0}
inlineconstexpr

Definition at line 23 of file SkTiffUtility.h.

◆ kEndianSize

constexpr size_t SkTiff::kEndianSize = 4
inlineconstexpr

Definition at line 21 of file SkTiffUtility.h.

◆ kSizeEntry

constexpr size_t SkTiff::kSizeEntry = 12
constexpr

Definition at line 18 of file SkTiffUtility.cpp.

◆ kSizeLong

constexpr size_t SkTiff::kSizeLong = 4
constexpr

Definition at line 20 of file SkTiffUtility.cpp.

◆ kSizeShort

constexpr size_t SkTiff::kSizeShort = 2
constexpr

Definition at line 19 of file SkTiffUtility.cpp.

◆ kTypeAsciiString

constexpr uint16_t SkTiff::kTypeAsciiString = 2
inlineconstexpr

Definition at line 27 of file SkTiffUtility.h.

◆ kTypeDoubleFloat

constexpr uint16_t SkTiff::kTypeDoubleFloat = 12
inlineconstexpr

Definition at line 37 of file SkTiffUtility.h.

◆ kTypeSignedByte

constexpr uint16_t SkTiff::kTypeSignedByte = 6
inlineconstexpr

Definition at line 31 of file SkTiffUtility.h.

◆ kTypeSignedLong

constexpr uint16_t SkTiff::kTypeSignedLong = 9
inlineconstexpr

Definition at line 34 of file SkTiffUtility.h.

◆ kTypeSignedRational

constexpr uint16_t SkTiff::kTypeSignedRational = 10
inlineconstexpr

Definition at line 35 of file SkTiffUtility.h.

◆ kTypeSignedShort

constexpr uint16_t SkTiff::kTypeSignedShort = 8
inlineconstexpr

Definition at line 33 of file SkTiffUtility.h.

◆ kTypeSingleFloat

constexpr uint16_t SkTiff::kTypeSingleFloat = 11
inlineconstexpr

Definition at line 36 of file SkTiffUtility.h.

◆ kTypeUndefined

constexpr uint16_t SkTiff::kTypeUndefined = 7
inlineconstexpr

Definition at line 32 of file SkTiffUtility.h.

◆ kTypeUnsignedByte

constexpr uint16_t SkTiff::kTypeUnsignedByte = 1
inlineconstexpr

Definition at line 26 of file SkTiffUtility.h.

◆ kTypeUnsignedLong

constexpr uint16_t SkTiff::kTypeUnsignedLong = 4
inlineconstexpr

Definition at line 29 of file SkTiffUtility.h.

◆ kTypeUnsignedRational

constexpr uint16_t SkTiff::kTypeUnsignedRational = 5
inlineconstexpr

Definition at line 30 of file SkTiffUtility.h.

◆ kTypeUnsignedShort

constexpr uint16_t SkTiff::kTypeUnsignedShort = 3
inlineconstexpr

Definition at line 28 of file SkTiffUtility.h.