Add SkEncodedFormat, used by SkCodec.
Needed by Android to determine the format.
Review URL: https://codereview.chromium.org/1018953003
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 3550bb1..ec4b3e1 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -8,6 +8,7 @@
#ifndef SkCodec_DEFINED
#define SkCodec_DEFINED
+#include "SkEncodedFormat.h"
#include "SkImageGenerator.h"
#include "SkImageInfo.h"
#include "SkSize.h"
@@ -50,6 +51,11 @@
return this->onGetScaledDimensions(desiredScale);
}
+ /**
+ * Format of the encoded data.
+ */
+ SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
+
protected:
SkCodec(const SkImageInfo&, SkStream*);
@@ -73,6 +79,8 @@
return fInfo.dimensions();
}
+ virtual SkEncodedFormat onGetEncodedFormat() const = 0;
+
/**
* If the stream was previously read, attempt to rewind.
* @returns:
diff --git a/include/codec/SkEncodedFormat.h b/include/codec/SkEncodedFormat.h
new file mode 100644
index 0000000..003159a
--- /dev/null
+++ b/include/codec/SkEncodedFormat.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkEncodedFormat_DEFINED
+#define SkEncodedFormat_DEFINED
+
+/**
+ * Enum describing format of encoded data.
+ */
+enum SkEncodedFormat {
+ kUnknown_SkEncodedFormat,
+ kBMP_SkEncodedFormat,
+ kGIF_SkEncodedFormat,
+ kICO_SkEncodedFormat,
+ kJPEG_SkEncodedFormat,
+ kPNG_SkEncodedFormat,
+ kWBMP_SkEncodedFormat,
+ kWEBP_SkEncodedFormat,
+ kPKM_SkEncodedFormat,
+ kKTX_SkEncodedFormat,
+ kASTC_SkEncodedFormat,
+};
+#endif // SkEncodedFormat_DEFINED
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h
index 4dfd3c2..f4ae78a 100644
--- a/include/core/SkImageDecoder.h
+++ b/include/core/SkImageDecoder.h
@@ -26,6 +26,7 @@
public:
virtual ~SkImageDecoder();
+ // TODO (scroggo): Merge with SkEncodedFormat
enum Format {
kUnknown_Format,
kBMP_Format,
diff --git a/include/core/SkImageEncoder.h b/include/core/SkImageEncoder.h
index 6ee173c..a9eecc4 100644
--- a/include/core/SkImageEncoder.h
+++ b/include/core/SkImageEncoder.h
@@ -17,6 +17,7 @@
class SkImageEncoder {
public:
+ // TODO (scroggo): Merge with SkEncodedFormat.
enum Type {
kUnknown_Type,
kBMP_Type,
diff --git a/src/codec/SkCodec_libbmp.h b/src/codec/SkCodec_libbmp.h
index e6620d2..fb23716 100644
--- a/src/codec/SkCodec_libbmp.h
+++ b/src/codec/SkCodec_libbmp.h
@@ -7,6 +7,7 @@
#include "SkCodec.h"
#include "SkColorTable.h"
+#include "SkEncodedFormat.h"
#include "SkImageInfo.h"
#include "SkMaskSwizzler.h"
#include "SkStream.h"
@@ -60,6 +61,7 @@
size_t dstRowBytes, const Options&, SkPMColor*,
int*) SK_OVERRIDE;
+ SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kBMP_SkEncodedFormat; }
private:
/*
diff --git a/src/codec/SkCodec_libpng.h b/src/codec/SkCodec_libpng.h
index b255449..debb14b 100644
--- a/src/codec/SkCodec_libpng.h
+++ b/src/codec/SkCodec_libpng.h
@@ -6,6 +6,7 @@
*/
#include "SkCodec.h"
+#include "SkEncodedFormat.h"
#include "SkImageInfo.h"
extern "C" {
@@ -24,6 +25,7 @@
protected:
Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*)
SK_OVERRIDE;
+ SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kPNG_SkEncodedFormat; }
private:
png_structp fPng_ptr;
png_infop fInfo_ptr;