OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkKTXFile_DEFINED | 10 #ifndef SkKTXFile_DEFINED |
11 #define SkKTXFile_DEFINED | 11 #define SkKTXFile_DEFINED |
12 | 12 |
13 #include "SkData.h" | 13 #include "SkData.h" |
| 14 #include "SkTextureCompressor.h" |
14 #include "SkTypes.h" | 15 #include "SkTypes.h" |
15 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
16 #include "SkString.h" | 17 #include "SkString.h" |
17 #include "SkRefCnt.h" | 18 #include "SkRefCnt.h" |
18 | 19 |
19 class SkBitmap; | 20 class SkBitmap; |
20 class SkStreamRewindable; | 21 class SkStreamRewindable; |
21 class SkWStream; | 22 class SkWStream; |
22 | 23 |
23 // KTX Image File | 24 // KTX Image File |
(...skipping 27 matching lines...) Expand all Loading... |
51 return this->valid() ? fPixelData[mipmap].data() : NULL; | 52 return this->valid() ? fPixelData[mipmap].data() : NULL; |
52 } | 53 } |
53 | 54 |
54 // If the decoded KTX file has the following key, then it will | 55 // If the decoded KTX file has the following key, then it will |
55 // return the associated value. If not found, the empty string | 56 // return the associated value. If not found, the empty string |
56 // is returned. | 57 // is returned. |
57 SkString getValueForKey(const SkString& key) const; | 58 SkString getValueForKey(const SkString& key) const; |
58 | 59 |
59 int numMipmaps() const { return static_cast<int>(fHeader.fNumberOfMipmapLeve
ls); } | 60 int numMipmaps() const { return static_cast<int>(fHeader.fNumberOfMipmapLeve
ls); } |
60 | 61 |
61 bool isETC1() const; | 62 bool isCompressedFormat(SkTextureCompressor::Format fmt) const; |
62 bool isRGBA8() const; | 63 bool isRGBA8() const; |
63 bool isRGB8() const; | 64 bool isRGB8() const; |
64 | 65 |
65 static bool is_ktx(const uint8_t *data); | 66 static bool is_ktx(const uint8_t *data); |
66 static bool is_ktx(SkStreamRewindable* stream); | 67 static bool is_ktx(SkStreamRewindable* stream); |
67 | 68 |
68 static bool WriteETC1ToKTX(SkWStream* stream, const uint8_t *etc1Data, | 69 static bool WriteETC1ToKTX(SkWStream* stream, const uint8_t *etc1Data, |
69 uint32_t width, uint32_t height); | 70 uint32_t width, uint32_t height); |
70 static bool WriteBitmapToKTX(SkWStream* stream, const SkBitmap& bitmap); | 71 static bool WriteBitmapToKTX(SkWStream* stream, const SkBitmap& bitmap); |
71 private: | 72 private: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // If the endianness of the platform is different than the file, | 136 // If the endianness of the platform is different than the file, |
136 // then we need to do proper byte swapping. | 137 // then we need to do proper byte swapping. |
137 bool fSwapBytes; | 138 bool fSwapBytes; |
138 | 139 |
139 // Read an integer from a buffer, advance the buffer, and swap | 140 // Read an integer from a buffer, advance the buffer, and swap |
140 // bytes if fSwapBytes is set | 141 // bytes if fSwapBytes is set |
141 uint32_t readInt(const uint8_t** buf, size_t* bytesLeft) const; | 142 uint32_t readInt(const uint8_t** buf, size_t* bytesLeft) const; |
142 }; | 143 }; |
143 | 144 |
144 #endif // SkKTXFile_DEFINED | 145 #endif // SkKTXFile_DEFINED |
OLD | NEW |