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

Unified Diff: include/codec/SkCodecPriv.h

Issue 947283002: Bmp Image Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@decode-leon-3
Patch Set: Improved efficiency of ResultAlpha and code sharing Created 5 years, 9 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: 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
+}

Powered by Google App Engine
This is Rietveld 408576698