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

Side by Side Diff: src/codec/SkBmpCodec.h

Issue 1287423002: Scanline decoding for bmp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Scanline decoding for bmp without reordering 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/codec/SkBmpCodec.cpp » ('j') | src/codec/SkBmpCodec.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #ifndef SkBmpCodec_DEFINED 7 #ifndef SkBmpCodec_DEFINED
8 #define SkBmpCodec_DEFINED 8 #define SkBmpCodec_DEFINED
9 9
10 #include "SkCodec.h" 10 #include "SkCodec.h"
11 #include "SkColorTable.h" 11 #include "SkColorTable.h"
12 #include "SkImageInfo.h" 12 #include "SkImageInfo.h"
13 #include "SkMaskSwizzler.h" 13 #include "SkMaskSwizzler.h"
14 #include "SkScanlineDecoder.h"
14 #include "SkStream.h" 15 #include "SkStream.h"
15 #include "SkSwizzler.h" 16 #include "SkSwizzler.h"
16 #include "SkTypes.h" 17 #include "SkTypes.h"
17 18
18 /* 19 /*
19 * This class enables code sharing between its bmp codec subclasses. The 20 * This class enables code sharing between its bmp codec subclasses. The
20 * subclasses actually do the work. 21 * subclasses actually do the work.
21 */ 22 */
22 class SkBmpCodec : public SkCodec { 23 class SkBmpCodec : public SkCodec {
23 public: 24 public:
24 25
25 /* 26 /*
26 * Describes if rows of the input start at the top or bottom of the image 27 * Describes if rows of the input start at the top or bottom of the image
27 */ 28 */
28 enum RowOrder { 29 enum RowOrder {
29 kTopDown_RowOrder, 30 kTopDown_RowOrder,
30 kBottomUp_RowOrder 31 kBottomUp_RowOrder
31 }; 32 };
32 33
33 /* 34 /*
35 * Used to define the input format of the bmp
36 */
37 enum BmpInputFormat {
38 kStandard_BmpInputFormat,
39 kRLE_BmpInputFormat,
40 kBitMask_BmpInputFormat,
41 kUnknown_BmpInputFormat
42 };
43
44 /*
34 * Checks the start of the stream to see if the image is a bmp 45 * Checks the start of the stream to see if the image is a bmp
35 */ 46 */
36 static bool IsBmp(SkStream*); 47 static bool IsBmp(SkStream*);
37 48
38 /* 49 /*
39 * Assumes IsBmp was called and returned true 50 * Assumes IsBmp was called and returned true
40 * Creates a bmp decoder 51 * Creates a bmp decoder
41 * Reads enough of the stream to determine the image format 52 * Reads enough of the stream to determine the image format
42 */ 53 */
43 static SkCodec* NewFromStream(SkStream*); 54 static SkCodec* NewFromStream(SkStream*);
44 55
45 /* 56 /*
46 * Creates a bmp decoder for a bmp embedded in ico 57 * Creates a bmp decoder for a bmp embedded in ico
47 * Reads enough of the stream to determine the image format 58 * Reads enough of the stream to determine the image format
48 */ 59 */
49 static SkCodec* NewFromIco(SkStream*); 60 static SkCodec* NewFromIco(SkStream*);
50 61
62 /*
63 * Assumes IsBmp was called and returned true
64 * Creates a bmp scanline decoder
65 * Takes ownership of the stream
66 */
67 static SkScanlineDecoder* NewSDFromStream(SkStream* stream);
68
51 protected: 69 protected:
52 70
53 SkBmpCodec(const SkImageInfo& info, SkStream* stream, uint16_t bitsPerPixel, 71 SkBmpCodec(const SkImageInfo& info, SkStream* stream, BmpInputFormat inputFo rmat,
54 RowOrder rowOrder); 72 uint16_t bitsPerPixel, RowOrder rowOrder);
55 73
56 SkEncodedFormat onGetEncodedFormat() const override { return kBMP_SkEncodedF ormat; } 74 SkEncodedFormat onGetEncodedFormat() const override { return kBMP_SkEncodedF ormat; }
57 75
58 /* 76 /*
59 * Read enough of the stream to initialize the SkBmpCodec. Returns a bool 77 * Read enough of the stream to initialize the SkBmpCodec. Returns a bool
60 * representing success or failure. If it returned true, and codecOut was 78 * representing success or failure. If it returned true, and codecOut was
61 * not NULL, it will be set to a new SkBmpCodec. 79 * not NULL, it will be set to a new SkBmpCodec.
62 * Does *not* take ownership of the passed in SkStream. 80 * Does *not* take ownership of the passed in SkStream.
63 */ 81 */
64 static bool ReadHeader(SkStream*, bool inIco, SkCodec** codecOut); 82 static bool ReadHeader(SkStream*, bool inIco, SkCodec** codecOut);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 RowOrder rowOrder() const { return fRowOrder; } 115 RowOrder rowOrder() const { return fRowOrder; }
98 116
99 private: 117 private:
100 118
101 /* 119 /*
102 * Creates a bmp decoder 120 * Creates a bmp decoder
103 * Reads enough of the stream to determine the image format 121 * Reads enough of the stream to determine the image format
104 */ 122 */
105 static SkCodec* NewFromStream(SkStream*, bool inIco); 123 static SkCodec* NewFromStream(SkStream*, bool inIco);
106 124
107 const uint16_t fBitsPerPixel; 125 const BmpInputFormat fInputFormat;
108 const RowOrder fRowOrder; 126 const uint16_t fBitsPerPixel;
127 const RowOrder fRowOrder;
109 128
110 typedef SkCodec INHERITED; 129 typedef SkCodec INHERITED;
111 }; 130 };
112 131
113 #endif 132 #endif
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkBmpCodec.cpp » ('j') | src/codec/SkBmpCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698