Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: third_party/ktx/ktx.h

Issue 312353003: Initial KTX encoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Code review changes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/ktx/ktx.h
diff --git a/third_party/ktx/ktx.h b/third_party/ktx/ktx.h
index 0e4ed9b9900721b3c9700ee8af2b9e57b15b9097..2f445a817a0e6a9fcf0fe10ffc2560370e8f65e7 100644
--- a/third_party/ktx/ktx.h
+++ b/third_party/ktx/ktx.h
@@ -16,7 +16,9 @@
#include "SkString.h"
#include "SkRefCnt.h"
+class SkBitmap;
class SkStreamRewindable;
+class SkWStream;
// KTX Image File
// ---
@@ -49,6 +51,11 @@ public:
return this->valid() ? fPixelData[mipmap].data() : NULL;
}
+ // If the decoded KTX file has the following key, then it will
+ // return the associated value. If not found, the empty string
+ // is returned.
+ SkString getValueForKey(const SkString& key) const;
+
int numMipmaps() const { return static_cast<int>(fHeader.fNumberOfMipmapLevels); }
bool isETC1() const;
@@ -58,6 +65,9 @@ public:
static bool is_ktx(const uint8_t *data);
static bool is_ktx(SkStreamRewindable* stream);
+ static bool WriteETC1ToKTX(SkWStream* stream, const uint8_t *etc1Data,
+ uint32_t width, uint32_t height);
+ static bool WriteBitmapToKTX(SkWStream* stream, const SkBitmap& bitmap);
private:
// The blob holding the file data.
@@ -88,13 +98,18 @@ private:
public:
KeyValue(size_t size) : fDataSz(size) { }
bool readKeyAndValue(const uint8_t *data);
-
+ size_t size() const { return fDataSz; }
+ const SkString& key() const { return fKey; }
+ const SkString& value() const { return fValue; }
+ bool writeKeyAndValueForKTX(SkWStream* strm);
private:
const size_t fDataSz;
- SkString fKey;
- SkString fValue;
+ SkString fKey;
+ SkString fValue;
};
+ static KeyValue CreateKeyValue(const char *key, const char *value);
+
// The pixel data for a single mipmap level in an image. Based on how
// the rest of the data is stored, this may be compressed, a cubemap, etc.
// The header will describe the format of this data.

Powered by Google App Engine
This is Rietveld 408576698