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

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

Issue 1911613002: Use SkEncodedInfo in place of SkSwizzler::SrcConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bmp bug Created 4 years, 8 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/SkRawCodec.cpp ('k') | src/codec/SkSwizzler.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 #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 * Enum describing the config of the source data.
20 */
21 enum SrcConfig {
22 kUnknown, // Invalid type.
23 kBit, // A single bit to distinguish between white and black.
24 kGray,
25 kGrayAlpha,
26 kIndex1,
27 kIndex2,
28 kIndex4,
29 kIndex,
30 kRGB,
31 kBGR,
32 kBGRX, // The alpha channel can be anything, but the image is opaque .
33 kRGBA,
34 kBGRA,
35 kCMYK,
36 kNoOp8, // kNoOp modes are used exclusively for sampling, subsetting, and
37 kNoOp16, // copying. The pixels themselves do not need to be modified .
38 kNoOp32,
39 };
40
41 /*
42 *
43 * Returns bits per pixel for source config
44 *
45 */
46 static int BitsPerPixel(SrcConfig sc) {
47 switch (sc) {
48 case kBit:
49 case kIndex1:
50 return 1;
51 case kIndex2:
52 return 2;
53 case kIndex4:
54 return 4;
55 case kGray:
56 case kIndex:
57 case kNoOp8:
58 return 8;
59 case kGrayAlpha:
60 case kNoOp16:
61 return 16;
62 case kRGB:
63 case kBGR:
64 return 24;
65 case kRGBA:
66 case kBGRX:
67 case kBGRA:
68 case kCMYK:
69 case kNoOp32:
70 return 32;
71 default:
72 SkASSERT(false);
73 return 0;
74 }
75 }
76
77 /*
78 *
79 * Returns bytes per pixel for source config
80 * Raises an error if each pixel is not stored in an even number of bytes
81 *
82 */
83 static int BytesPerPixel(SrcConfig sc) {
84 SkASSERT(SkIsAlign8(BitsPerPixel(sc)));
85 return BitsPerPixel(sc) >> 3;
86 }
87
88 /**
89 * Create a new SkSwizzler. 19 * Create a new SkSwizzler.
90 * @param SrcConfig Description of the format of the source. 20 * @param encodedInfo Description of the format of the encoded data.
91 * @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
92 * index source. 22 * index source.
93 * @param dstInfo Describes the destination. 23 * @param dstInfo Describes the destination.
94 * @param options Indicates if dst is zero-initialized. The 24 * @param options Indicates if dst is zero-initialized. The
95 * implementation may choose to skip writing zeroes 25 * implementation may choose to skip writing zeroes
96 * if set to kYes_ZeroInitialized. 26 * if set to kYes_ZeroInitialized.
97 * Contains partial scanline information. 27 * Contains partial scanline information.
98 * @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
99 * frame that is a subset of the full image. 29 * frame that is a subset of the full image.
100 * 30 *
101 * Note that a deeper discussion of partial scanline subsets and image fram e 31 * Note that a deeper discussion of partial scanline subsets and image fram e
102 * subsets is below. Currently, we do not support both simultaneously. If 32 * subsets is below. Currently, we do not support both simultaneously. If
103 * options->fSubset is non-NULL, frame must be NULL. 33 * options->fSubset is non-NULL, frame must be NULL.
104 * 34 *
105 * @return A new SkSwizzler or nullptr on failure. 35 * @return A new SkSwizzler or nullptr on failure.
106 */ 36 */
107 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, 37 static SkSwizzler* CreateSwizzler(const SkEncodedInfo& encodedInfo, const Sk PMColor* ctable,
108 const SkImageInfo& dstInfo, const SkCodec: :Options&, 38 const SkImageInfo& dstInfo, const SkCodec: :Options&,
109 const SkIRect* frame = nullptr); 39 const SkIRect* frame = nullptr);
110 40
111 /** 41 /**
112 * Swizzle a line. Generally this will be called height times, once 42 * Swizzle a line. Generally this will be called height times, once
113 * for each row of source. 43 * for each row of source.
114 * By allowing the caller to pass in the dst pointer, we give the caller 44 * By allowing the caller to pass in the dst pointer, we give the caller
115 * flexibility to use the swizzler even when the encoded data does not 45 * flexibility to use the swizzler even when the encoded data does not
116 * store the rows in order. This also improves usability for scaled and 46 * store the rows in order. This also improves usability for scaled and
117 * subset decodes. 47 * subset decodes.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // fBPP is bitsPerPixel 192 // fBPP is bitsPerPixel
263 const int fDstBPP; // Bytes per pixel for the destination color type 193 const int fDstBPP; // Bytes per pixel for the destination color type
264 194
265 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO ffset, 195 SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcO ffset,
266 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP); 196 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP);
267 197
268 int onSetSampleX(int) override; 198 int onSetSampleX(int) override;
269 199
270 }; 200 };
271 #endif // SkSwizzler_DEFINED 201 #endif // SkSwizzler_DEFINED
OLDNEW
« no previous file with comments | « src/codec/SkRawCodec.cpp ('k') | src/codec/SkSwizzler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698