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

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

Issue 1011343003: Enabling ico decoding with use of png and bmp decoders (Closed) Base URL: https://skia.googlesource.com/skia.git@swizzle
Patch Set: Removed additional blacklist items 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 unified diff | Download patch
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libbmp.cpp » ('j') | no next file with comments »
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 7
8 #include "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkColorTable.h" 9 #include "SkColorTable.h"
10 #include "SkEncodedFormat.h"
11 #include "SkImageInfo.h" 10 #include "SkImageInfo.h"
12 #include "SkMaskSwizzler.h" 11 #include "SkMaskSwizzler.h"
13 #include "SkStream.h" 12 #include "SkStream.h"
14 #include "SkSwizzler.h" 13 #include "SkSwizzler.h"
15 #include "SkTypes.h" 14 #include "SkTypes.h"
16 15
17 // TODO: rename SkCodec_libbmp files to SkBmpCodec 16 // TODO: rename SkCodec_libbmp files to SkBmpCodec
18 // TODO: define a wrapper for SkDebugf that doesn't always print 17 // TODO: define a wrapper for SkDebugf that doesn't always print
19 /* 18 /*
20 * 19 *
21 * This class implements the decoding for bmp images 20 * This class implements the decoding for bmp images
22 * 21 *
23 */ 22 */
24 class SkBmpCodec : public SkCodec { 23 class SkBmpCodec : public SkCodec {
25 public: 24 public:
26 25
27 /* 26 /*
28 * 27 *
29 * Describes if rows of the input start at the top or bottom of the image 28 * Describes if rows of the input start at the top or bottom of the image
30 * 29 *
31 */ 30 */
32 enum RowOrder { 31 enum RowOrder {
33 kTopDown_RowOrder, 32 kTopDown_RowOrder,
34 kBottomUp_RowOrder 33 kBottomUp_RowOrder
35 }; 34 };
36 35
37 /* 36 /*
38 * 37 *
39 * Checks the start of the stream to see if the image is a bitmap 38 * Checks the start of the stream to see if the image is a bmp
40 * 39 *
41 */ 40 */
42 static bool IsBmp(SkStream*); 41 static bool IsBmp(SkStream*);
43 42
44 /* 43 /*
45 * 44 *
46 * Assumes IsBmp was called and returned true 45 * Assumes IsBmp was called and returned true
47 * Creates a bitmap decoder 46 * Creates a bmp decoder
48 * Reads enough of the stream to determine the image format 47 * Reads enough of the stream to determine the image format
49 * 48 *
50 */ 49 */
51 static SkCodec* NewFromStream(SkStream*); 50 static SkCodec* NewFromStream(SkStream*);
52 51
52 /*
53 *
54 * Creates a bmp decoder for a bmp embedded in ico
55 * Reads enough of the stream to determine the image format
56 *
57 */
58 static SkCodec* NewFromIco(SkStream*);
59
53 protected: 60 protected:
54 61
55 /* 62 /*
56 * 63 *
57 * Initiates the bitmap decode 64 * Initiates the bmp decode
58 * 65 *
59 */ 66 */
60 virtual Result onGetPixels(const SkImageInfo& dstInfo, void* dst, 67 virtual Result onGetPixels(const SkImageInfo& dstInfo, void* dst,
61 size_t dstRowBytes, const Options&, SkPMColor*, 68 size_t dstRowBytes, const Options&, SkPMColor*,
62 int*) SK_OVERRIDE; 69 int*) SK_OVERRIDE;
63 70
64 SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kBMP_SkEncod edFormat; } 71 SkEncodedFormat onGetEncodedFormat() const SK_OVERRIDE { return kBMP_SkEncod edFormat; }
72
65 private: 73 private:
66 74
67 /* 75 /*
68 * 76 *
69 * Used to define the input format of the bitmap 77 * Used to define the input format of the bmp
70 * 78 *
71 */ 79 */
72 enum BitmapInputFormat { 80 enum BitmapInputFormat {
73 kStandard_BitmapInputFormat, 81 kStandard_BitmapInputFormat,
74 kRLE_BitmapInputFormat, 82 kRLE_BitmapInputFormat,
75 kBitMask_BitmapInputFormat, 83 kBitMask_BitmapInputFormat,
76 kUnknown_BitmapInputFormat 84 kUnknown_BitmapInputFormat
77 }; 85 };
78 86
79 /* 87 /*
80 * 88 *
81 * Creates the color table 89 * Creates the color table
82 * 90 *
83 */ 91 */
84 bool createColorTable(SkAlphaType alphaType); 92 bool createColorTable(SkAlphaType alphaType);
85 93
86 /* 94 /*
87 * 95 *
96 * Creates a bmp decoder
97 * Reads enough of the stream to determine the image format
98 *
99 */
100 static SkCodec* NewFromStream(SkStream*, bool isIco);
101
102 /*
103 *
88 * Performs the bitmap decoding for bit masks input format 104 * Performs the bitmap decoding for bit masks input format
89 * 105 *
90 */ 106 */
91 Result decodeMask(const SkImageInfo& dstInfo, void* dst, 107 Result decodeMask(const SkImageInfo& dstInfo, void* dst,
92 size_t dstRowBytes); 108 size_t dstRowBytes);
93 109
94 /* 110 /*
95 * 111 *
96 * Set an RLE pixel using the color table 112 * Set an RLE pixel using the color table
97 * 113 *
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 * @param rowOrder indicates whether rows are ordered top-down or bottom-up 158 * @param rowOrder indicates whether rows are ordered top-down or bottom-up
143 * @param RLEBytes used only for RLE decodes, as we must decode all 159 * @param RLEBytes used only for RLE decodes, as we must decode all
144 * of the data at once rather than row by row 160 * of the data at once rather than row by row
145 * it indicates the amount of data left in the stream 161 * it indicates the amount of data left in the stream
146 * after decoding the headers 162 * after decoding the headers
147 * 163 *
148 */ 164 */
149 SkBmpCodec(const SkImageInfo& srcInfo, SkStream* stream, 165 SkBmpCodec(const SkImageInfo& srcInfo, SkStream* stream,
150 uint16_t bitsPerPixel, BitmapInputFormat format, 166 uint16_t bitsPerPixel, BitmapInputFormat format,
151 SkMasks* masks, uint32_t numColors, uint32_t bytesPerColor, 167 SkMasks* masks, uint32_t numColors, uint32_t bytesPerColor,
152 uint32_t offset, RowOrder rowOrder, size_t RLEByes); 168 uint32_t offset, RowOrder rowOrder, size_t RLEBytes,
169 bool isIco);
153 170
154 // Fields 171 // Fields
155 const uint16_t fBitsPerPixel; 172 const uint16_t fBitsPerPixel;
156 const BitmapInputFormat fInputFormat; 173 const BitmapInputFormat fInputFormat;
157 SkAutoTDelete<SkMasks> fMasks; // owned 174 SkAutoTDelete<SkMasks> fMasks; // owned
158 SkAutoTDelete<SkColorTable> fColorTable; // owned 175 SkAutoTDelete<SkColorTable> fColorTable; // owned
159 uint32_t fNumColors; 176 uint32_t fNumColors;
160 const uint32_t fBytesPerColor; 177 const uint32_t fBytesPerColor;
161 const uint32_t fOffset; 178 const uint32_t fOffset;
162 const RowOrder fRowOrder; 179 const RowOrder fRowOrder;
163 const size_t fRLEBytes; 180 const size_t fRLEBytes;
181 const bool fIsIco;
164 182
165 typedef SkCodec INHERITED; 183 typedef SkCodec INHERITED;
166 }; 184 };
OLDNEW
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698