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

Unified Diff: src/codec/SkBmpRLECodec.h

Issue 1258863008: Split SkBmpCodec into three separate classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkBmpCodec is a parent class of the bmp codecs Created 5 years, 4 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/SkBmpRLECodec.h
diff --git a/src/codec/SkBmpRLECodec.h b/src/codec/SkBmpRLECodec.h
new file mode 100644
index 0000000000000000000000000000000000000000..e28e5b4a6f1505985be156157d1095ad5a3907c7
--- /dev/null
+++ b/src/codec/SkBmpRLECodec.h
@@ -0,0 +1,86 @@
+/*
+ * 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 "SkBmpCodec.h"
+#include "SkColorTable.h"
+#include "SkImageInfo.h"
+#include "SkTypes.h"
+
+/*
+ * This class implements the decoding for bmp images that use an RLE encoding
+ */
+class SkBmpRLECodec : public SkBmpCodec {
+public:
+
+ /*
+ * Creates an instance of the decoder
+ * Called only by SkBmpCodec::NewFromStream
scroggo 2015/08/04 16:16:46 Interesting that you say that, because it is a pub
msarett 2015/08/04 23:14:45 Yeah I'm pretty happy with the subclasses instead
+ *
+ * @param srcInfo contains the source width and height
+ * @param stream the stream of image data
scroggo 2015/08/04 16:16:46 nit: encoded (image data)
msarett 2015/08/04 23:14:45 Done.
+ * @param bitsPerPixel the number of bits used to store each pixel
+ * @param numColors the number of colors in the color table
+ * @param bytesPerColor the number of bytes in the stream used to represent
+ each color in the color table
+ * @param offset the offset of the image pixel data from the end of the
+ * headers
+ * @param rowOrder indicates whether rows are ordered top-down or bottom-up
+ * @param RLEBytes used only for RLE decodes, as we must decode all
scroggo 2015/08/04 16:16:46 It seems redundant to say this is used only for RL
msarett 2015/08/04 23:14:45 Done.
+ * of the data at once rather than row by row
+ * it indicates the amount of data left in the stream
+ * after decoding the headers
+ */
+ SkBmpRLECodec(const SkImageInfo& srcInfo, SkStream* stream,
+ uint16_t bitsPerPixel, uint32_t numColors,
+ uint32_t bytesPerColor, uint32_t offset,
+ SkBmpCodec::RowOrder rowOrder, size_t RLEBytes);
+
+protected:
+
+ Result onGetPixels(const SkImageInfo& dstInfo, void* dst,
+ size_t dstRowBytes, const Options&, SkPMColor*,
+ int*) override;
+
+private:
+
+ /*
+ * Creates the color table
+ * Sets colorCount to the new color count if it is non-NULL
+ */
+ bool createColorTable(SkAlphaType alphaType, int* colorCount);
msarett 2015/08/03 22:52:36 Used to be in SkBmpCodec. This has been simplifie
+
+ bool initializeStreamBuffer();
msarett 2015/08/03 22:52:36 Factored out of decodeRLE(). Will make scanline d
+
+ /*
+ * Set an RLE pixel using the color table
+ */
+ void setPixel(void* dst, size_t dstRowBytes,
+ const SkImageInfo& dstInfo, uint32_t x, uint32_t y,
+ uint8_t index);
+ /*
+ * Set an RLE24 pixel from R, G, B values
+ */
+ void setRGBPixel(void* dst, size_t dstRowBytes,
+ const SkImageInfo& dstInfo, uint32_t x, uint32_t y,
+ uint8_t red, uint8_t green, uint8_t blue);
+
+ /*
+ * Performs the bitmap decoding for RLE input format
+ */
+ Result decode(const SkImageInfo& dstInfo, void* dst,
msarett 2015/08/03 22:52:36 Used to be decodeRLE() in SkBmpCodec.
+ size_t dstRowBytes, const Options& opts);
+
+ SkAutoTUnref<SkColorTable> fColorTable; // owned
+ uint32_t fNumColors;
+ const uint32_t fBytesPerColor;
+ const uint32_t fOffset;
+ SkAutoTDeleteArray<uint8_t> fStreamBuffer;
+ size_t fRLEBytes;
+ uint32_t fCurrRLEByte;
+
+ typedef SkBmpCodec INHERITED;
+};

Powered by Google App Engine
This is Rietveld 408576698