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

Unified Diff: src/codec/SkMaskSwizzler.h

Issue 947283002: Bmp Image Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@decode-leon-3
Patch Set: separate swizzler for masks 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: src/codec/SkMaskSwizzler.h
diff --git a/src/codec/SkMaskSwizzler.h b/src/codec/SkMaskSwizzler.h
new file mode 100644
index 0000000000000000000000000000000000000000..19e0d00c650c3e4dd0e738280295aa8132b782be
--- /dev/null
+++ b/src/codec/SkMaskSwizzler.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkSwizzler.h"
+#include "SkTemplates.h"
+
+/*
+ *
+ * Used to swizzle images whose pixel components are extracted by bit masks
+ * Currently only used by bmp
+ *
+ */
+class SkMaskSwizzler {
+public:
+
+ /*
+ *
+ * Input bit masks format
+ *
+ */
+ struct InputMasks {
+ uint32_t red;
+ uint32_t green;
+ uint32_t blue;
+ uint32_t alpha;
+ };
+
+ /*
+ *
+ * Contains all of the information for a single mask
+ *
+ */
+ struct MaskInfo {
+ uint32_t mask;
+ uint32_t shift;
+ uint32_t size;
+ };
+
+ /*
+ *
+ * The bit masks used in the decode
+ *
+ */
+ struct Masks {
+ const MaskInfo red;
+ const MaskInfo green;
+ const MaskInfo blue;
+ const MaskInfo alpha;
+ };
+
+ /*
+ *
+ * Process an input mask to obtain the necessary information
+ *
+ */
+ static const MaskInfo& ProcessMask(uint32_t mask, uint32_t bpp);
+
+ /*
+ *
+ * Create a new swizzler
+ *
+ */
+ static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& imageInfo,
+ InputMasks masks,
+ uint32_t bitsPerPixel);
+
+ /*
+ *
+ * Swizzle the next row
+ *
+ */
+ SkSwizzler::ResultAlpha next(void* dst, const uint8_t* src);
+
+private:
+
+ /*
+ *
+ * Row procedure used for swizzle
+ *
+ */
+ typedef SkSwizzler::ResultAlpha (*RowProc)(
+ void* dstRow, const uint8_t* srcRow, int width, const Masks& masks);
+
+ /*
+ *
+ * Constructor for mask swizzler
+ *
+ */
+ SkMaskSwizzler(const SkImageInfo& info, const Masks& masks, RowProc proc);
+
+ // Fields
+ const SkImageInfo& fImageInfo;
+ const Masks fMasks;
+ const RowProc fRowProc;
+};

Powered by Google App Engine
This is Rietveld 408576698