OLD | NEW |
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 #ifndef SkSwizzler_DEFINED | 8 #ifndef SkSwizzler_DEFINED |
9 #define SkSwizzler_DEFINED | 9 #define SkSwizzler_DEFINED |
10 | 10 |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkImageInfo.h" | 13 #include "SkImageInfo.h" |
14 #include "SkSampler.h" | 14 #include "SkSampler.h" |
15 | 15 |
16 class SkSwizzler : public SkSampler { | 16 class SkSwizzler : public SkSampler { |
17 public: | 17 public: |
18 /** | 18 /** |
19 * Create a new SkSwizzler. | 19 * Create a new SkSwizzler. |
20 * @param encodedInfo Description of the format of the encoded data. | 20 * @param encodedInfo Description of the format of the encoded data. |
21 * @param ctable Unowned pointer to an array of up to 256 colors for an | 21 * @param ctable Unowned pointer to an array of up to 256 colors for an |
22 * index source. | 22 * index source. |
23 * @param dstInfo Describes the destination. | 23 * @param dstInfo Describes the destination. |
24 * @param options Indicates if dst is zero-initialized. The | 24 * @param options Indicates if dst is zero-initialized. The |
25 * implementation may choose to skip writing zeroes | 25 * implementation may choose to skip writing zeroes |
26 * if set to kYes_ZeroInitialized. | 26 * if set to kYes_ZeroInitialized. |
27 * Contains partial scanline information. | 27 * Contains partial scanline information. |
28 * @param frame Is non-NULL if the source pixels are part of an image | 28 * @param frame Is non-NULL if the source pixels are part of an image |
29 * frame that is a subset of the full image. | 29 * frame that is a subset of the full image. |
| 30 * @param preSwizzled Indicates that the codec has already swizzled to the |
| 31 * destination format. The swizzler only needs to sampl
e |
| 32 * and/or subset. |
30 * | 33 * |
31 * Note that a deeper discussion of partial scanline subsets and image fram
e | 34 * Note that a deeper discussion of partial scanline subsets and image fram
e |
32 * subsets is below. Currently, we do not support both simultaneously. If | 35 * subsets is below. Currently, we do not support both simultaneously. If |
33 * options->fSubset is non-NULL, frame must be NULL. | 36 * options->fSubset is non-NULL, frame must be NULL. |
34 * | 37 * |
35 * @return A new SkSwizzler or nullptr on failure. | 38 * @return A new SkSwizzler or nullptr on failure. |
36 */ | 39 */ |
37 static SkSwizzler* CreateSwizzler(const SkEncodedInfo& encodedInfo, const Sk
PMColor* ctable, | 40 static SkSwizzler* CreateSwizzler(const SkEncodedInfo& encodedInfo, const Sk
PMColor* ctable, |
38 const SkImageInfo& dstInfo, const SkCodec:
:Options&, | 41 const SkImageInfo& dstInfo, const SkCodec:
:Options&, |
39 const SkIRect* frame = nullptr); | 42 const SkIRect* frame = nullptr, bool preSw
izzled = false); |
40 | 43 |
41 /** | 44 /** |
42 * Swizzle a line. Generally this will be called height times, once | 45 * Swizzle a line. Generally this will be called height times, once |
43 * for each row of source. | 46 * for each row of source. |
44 * By allowing the caller to pass in the dst pointer, we give the caller | 47 * By allowing the caller to pass in the dst pointer, we give the caller |
45 * flexibility to use the swizzler even when the encoded data does not | 48 * flexibility to use the swizzler even when the encoded data does not |
46 * store the rows in order. This also improves usability for scaled and | 49 * store the rows in order. This also improves usability for scaled and |
47 * subset decodes. | 50 * subset decodes. |
48 * @param dst Where we write the output. | 51 * @param dst Where we write the output. |
49 * @param src The next row of the source data. | 52 * @param src The next row of the source data. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // fBPP is bitsPerPixel | 195 // fBPP is bitsPerPixel |
193 const int fDstBPP; // Bytes per pixel for the destination
color type | 196 const int fDstBPP; // Bytes per pixel for the destination
color type |
194 | 197 |
195 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO
ffset, | 198 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO
ffset, |
196 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP); | 199 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP); |
197 | 200 |
198 int onSetSampleX(int) override; | 201 int onSetSampleX(int) override; |
199 | 202 |
200 }; | 203 }; |
201 #endif // SkSwizzler_DEFINED | 204 #endif // SkSwizzler_DEFINED |
OLD | NEW |