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

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

Issue 1365313002: Merge SkCodec with SkScanlineDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Skip ICO in SkScaledCodec for now Created 5 years, 2 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 | « resources/plane_interlaced.png ('k') | src/codec/SkBmpCodec.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 #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"
15 #include "SkStream.h" 14 #include "SkStream.h"
16 #include "SkSwizzler.h" 15 #include "SkSwizzler.h"
17 #include "SkTypes.h" 16 #include "SkTypes.h"
18 17
19 /* 18 /*
20 * This class enables code sharing between its bmp codec subclasses. The 19 * This class enables code sharing between its bmp codec subclasses. The
21 * subclasses actually do the work. 20 * subclasses actually do the work.
22 */ 21 */
23 class SkBmpCodec : public SkCodec { 22 class SkBmpCodec : public SkCodec {
24 public: 23 public:
25 24
26 /* 25 /*
27 * Checks the start of the stream to see if the image is a bmp 26 * Checks the start of the stream to see if the image is a bmp
28 */ 27 */
29 static bool IsBmp(SkStream*); 28 static bool IsBmp(SkStream*);
30 29
31 /* 30 /*
32 * Assumes IsBmp was called and returned true 31 * Assumes IsBmp was called and returned true
33 * Creates a bmp decoder 32 * Creates a bmp decoder
34 * Reads enough of the stream to determine the image format 33 * Reads enough of the stream to determine the image format
35 */ 34 */
36 static SkCodec* NewFromStream(SkStream*); 35 static SkCodec* NewFromStream(SkStream*);
37 36
38 /* 37 /*
39 * Creates a bmp decoder for a bmp embedded in ico 38 * Creates a bmp decoder for a bmp embedded in ico
40 * Reads enough of the stream to determine the image format 39 * Reads enough of the stream to determine the image format
41 */ 40 */
42 static SkCodec* NewFromIco(SkStream*); 41 static SkCodec* NewFromIco(SkStream*);
43 42
44 /*
45 * Assumes IsBmp was called and returned true
46 * Creates a bmp scanline decoder
47 * Takes ownership of the stream
48 */
49 static SkScanlineDecoder* NewSDFromStream(SkStream* stream);
50
51 protected: 43 protected:
52 44
53 SkBmpCodec(const SkImageInfo& info, SkStream* stream, uint16_t bitsPerPixel, 45 SkBmpCodec(const SkImageInfo& info, SkStream* stream, uint16_t bitsPerPixel,
54 SkScanlineDecoder::SkScanlineOrder rowOrder); 46 SkCodec::SkScanlineOrder rowOrder);
55 47
56 SkEncodedFormat onGetEncodedFormat() const override { return kBMP_SkEncodedF ormat; } 48 SkEncodedFormat onGetEncodedFormat() const override { return kBMP_SkEncodedF ormat; }
57 49
58 /* 50 /*
59 * Read enough of the stream to initialize the SkBmpCodec. Returns a bool 51 * Read enough of the stream to initialize the SkBmpCodec. Returns a bool
60 * representing success or failure. If it returned true, and codecOut was 52 * representing success or failure. If it returned true, and codecOut was
61 * not nullptr, it will be set to a new SkBmpCodec. 53 * not nullptr, it will be set to a new SkBmpCodec.
62 * Does *not* take ownership of the passed in SkStream. 54 * Does *not* take ownership of the passed in SkStream.
63 */ 55 */
64 static bool ReadHeader(SkStream*, bool inIco, SkCodec** codecOut); 56 static bool ReadHeader(SkStream*, bool inIco, SkCodec** codecOut);
(...skipping 15 matching lines...) Expand all
80 * Get the destination row number corresponding to the encoded row number. 72 * Get the destination row number corresponding to the encoded row number.
81 * For kTopDown, we simply return y, but for kBottomUp, the rows will be 73 * For kTopDown, we simply return y, but for kBottomUp, the rows will be
82 * decoded in reverse order. 74 * decoded in reverse order.
83 * 75 *
84 * @param y Iterates from 0 to height, indicating the current row. 76 * @param y Iterates from 0 to height, indicating the current row.
85 * @param height The height of the current subset of the image that we are 77 * @param height The height of the current subset of the image that we are
86 * decoding. This is generally equal to the full height 78 * decoding. This is generally equal to the full height
87 * when we want to decode the full or one when we are 79 * when we want to decode the full or one when we are
88 * sampling. 80 * sampling.
89 */ 81 */
90 int32_t getDstRow(int32_t y, int32_t height); 82 int32_t getDstRow(int32_t y, int32_t height) const;
91 83
92 /* 84 /*
93 * Get the destination row to start filling from 85 * Get the destination row to start filling from
94 * Used to fill the remainder of the image on incomplete input for bmps 86 * Used to fill the remainder of the image on incomplete input for bmps
95 * This is tricky since bmps may be kTopDown or kBottomUp. For kTopDown, 87 * This is tricky since bmps may be kTopDown or kBottomUp. For kTopDown,
96 * we start filling from where we left off, but for kBottomUp we start 88 * we start filling from where we left off, but for kBottomUp we start
97 * filling at the top of the image. 89 * filling at the top of the image.
98 */ 90 */
99 void* getDstStartRow(void* dst, size_t dstRowBytes, int32_t y) const; 91 void* getDstStartRow(void* dst, size_t dstRowBytes, int32_t y) const;
100 92
101 /* 93 /*
102 * Compute the number of colors in the color table 94 * Compute the number of colors in the color table
103 */ 95 */
104 uint32_t computeNumColors(uint32_t numColors); 96 uint32_t computeNumColors(uint32_t numColors);
105 97
106 /* 98 /*
107 * Accessors used by subclasses 99 * Accessors used by subclasses
108 */ 100 */
109 uint16_t bitsPerPixel() const { return fBitsPerPixel; } 101 uint16_t bitsPerPixel() const { return fBitsPerPixel; }
110 SkScanlineDecoder::SkScanlineOrder rowOrder() const { return fRowOrder; } 102 SkScanlineOrder onGetScanlineOrder() const override { return fRowOrder; }
111 103
112 /* 104 /*
113 * To be overriden by bmp subclasses, which provide unique implementations. 105 * To be overriden by bmp subclasses, which provide unique implementations.
114 * Performs subclass specific setup. 106 * Performs subclass specific setup.
115 * 107 *
116 * @param dstInfo Contains output information. Height specifies 108 * @param dstInfo Contains output information. Height specifies
117 * the total number of rows that will be decoded. 109 * the total number of rows that will be decoded.
118 * @param options Additonal options to pass to the decoder. 110 * @param options Additonal options to pass to the decoder.
119 * @param inputColorPtr Client-provided memory for a color table. Must 111 * @param inputColorPtr Client-provided memory for a color table. Must
120 * be enough for 256 colors. This will be 112 * be enough for 256 colors. This will be
(...skipping 25 matching lines...) Expand all
146 * lines in the image. 138 * lines in the image.
147 * 139 *
148 * @param dstInfo Contains output information. Height specifies the 140 * @param dstInfo Contains output information. Height specifies the
149 * number of rows to decode at this time. 141 * number of rows to decode at this time.
150 * @param dst Memory location to store output pixels 142 * @param dst Memory location to store output pixels
151 * @param dstRowBytes Bytes in a row of the destination 143 * @param dstRowBytes Bytes in a row of the destination
152 */ 144 */
153 virtual Result decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstR owBytes, 145 virtual Result decodeRows(const SkImageInfo& dstInfo, void* dst, size_t dstR owBytes,
154 const Options& opts) = 0; 146 const Options& opts) = 0;
155 147
156 const uint16_t fBitsPerPixel; 148 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const SkCodec::Opti ons&,
157 const SkScanlineDecoder::SkScanlineOrder fRowOrder; 149 SkPMColor inputColorPtr[], int* inputColorCount) override;
158 150
159 friend class SkBmpScanlineDecoder; 151 Result onGetScanlines(void* dst, int count, size_t rowBytes) override;
152
153 int onNextScanline() const override;
154
155 // TODO(msarett): Override default skipping with something more clever.
156
157 const uint16_t fBitsPerPixel;
158 const SkScanlineOrder fRowOrder;
160 159
161 typedef SkCodec INHERITED; 160 typedef SkCodec INHERITED;
162 }; 161 };
163 162
164 #endif 163 #endif
OLDNEW
« no previous file with comments | « resources/plane_interlaced.png ('k') | src/codec/SkBmpCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698