Index: include/codec/SkCodecPriv.h |
diff --git a/include/codec/SkCodecPriv.h b/include/codec/SkCodecPriv.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ae30a825ff5dc959850d6639a1df61fe0f9d7803 |
--- /dev/null |
+++ b/include/codec/SkCodecPriv.h |
@@ -0,0 +1,62 @@ |
+/* |
+ * Copyright 2015 The Android Open Source Project |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+ |
+#include "SkCodec.h" |
+#include "SkImageInfo.h" |
+#include "SkTypes.h" |
+ |
+/* |
+ * |
+ * Checks if alpha types are premul and unpremul |
+ * |
+ */ |
+static inline bool premul_and_unpremul(SkAlphaType dst, SkAlphaType src) { |
+ return kPremul_SkAlphaType == dst && kUnpremul_SkAlphaType == src; |
+} |
+ |
+/* |
+ * |
+ * Get a byte from a buffer |
+ * This method is unsafe, the caller is responsible for performing a check |
+ * |
+ */ |
+static inline uint8_t get_byte(uint8_t* buffer, uint32_t i) { |
+ return buffer[i]; |
+} |
+ |
+/* |
+ * |
+ * Get a short from a buffer |
+ * This method is unsafe, the caller is responsible for performing a check |
+ * |
+ */ |
+static inline uint16_t get_short(uint8_t* buffer, uint32_t i) { |
+ uint16_t result; |
+ memcpy(&result, &(buffer[i]), 2); |
+#ifdef SK_CPU_BENDIAN |
+ return SkEndianSwap16(result); |
+#else |
+ return result; |
+#endif |
+} |
+ |
+/* |
+ * |
+ * Get an int from a buffer |
+ * This method is unsafe, the caller is responsible for performing a check |
+ * |
+ */ |
+static inline uint32_t get_int(uint8_t* buffer, uint32_t i) { |
+ uint32_t result; |
+ memcpy(&result, &(buffer[i]), 4); |
+#ifdef SK_CPU_BENDIAN |
+ return SkEndianSwap32(result); |
+#else |
+ return result; |
+#endif |
+} |