| 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 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 * @param dstInfo Describes the destination. | 123 * @param dstInfo Describes the destination. |
| 124 * @param ZeroInitialized Whether dst is zero-initialized. The | 124 * @param ZeroInitialized Whether dst is zero-initialized. The |
| 125 * implementation may choose to skip writing zeroes | 125 * implementation may choose to skip writing zeroes |
| 126 * if set to kYes_ZeroInitialized. | 126 * if set to kYes_ZeroInitialized. |
| 127 * @return A new SkSwizzler or nullptr on failure. | 127 * @return A new SkSwizzler or nullptr on failure. |
| 128 */ | 128 */ |
| 129 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, | 129 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, |
| 130 const SkImageInfo& dstInfo, SkCodec::ZeroI
nitialized); | 130 const SkImageInfo& dstInfo, SkCodec::ZeroI
nitialized); |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * Fill the remainder of the destination with a single color | |
| 134 * | |
| 135 * @param dstStartRow | |
| 136 * The destination row to fill from. | |
| 137 * | |
| 138 * @param numRows | |
| 139 * The number of rows to fill. | |
| 140 * | |
| 141 * @param colorOrIndex | |
| 142 * @param colorTable | |
| 143 * If dstInfo.colorType() is kIndex8, colorOrIndex is assumed to be a uint8_
t | |
| 144 * index, and colorTable is ignored. Each 8-bit pixel will be set to (uint8_
t) | |
| 145 * index. | |
| 146 * | |
| 147 * If dstInfo.colorType() is kN32, colorOrIndex is treated differently depen
ding on | |
| 148 * whether colorTable is nullptr: | |
| 149 * | |
| 150 * A nullptr colorTable means colorOrIndex is treated as an SkPMColor (premu
l or | |
| 151 * unpremul, depending on dstInfo.alphaType()). Each 4-byte pixel will be se
t to | |
| 152 * colorOrIndex. | |
| 153 | |
| 154 * A non-nullptr colorTable means colorOrIndex is treated as a uint8_t index
into | |
| 155 * the colorTable. i.e. each 4-byte pixel will be set to | |
| 156 * colorTable[(uint8_t) colorOrIndex]. | |
| 157 * | |
| 158 * If dstInfo.colorType() is kGray, colorOrIndex is always treated as an 8-b
it color. | |
| 159 * | |
| 160 * Other SkColorTypes are not supported. | |
| 161 * | |
| 162 * @param zeroInit | |
| 163 * Indicates whether memory is already zero initialized. | |
| 164 * | |
| 165 */ | |
| 166 static void Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstRo
wBytes, | |
| 167 uint32_t numRows, uint32_t colorOrIndex, const SkPMColor* colorTable
, | |
| 168 SkCodec::ZeroInitialized zeroInit); | |
| 169 | |
| 170 /** | |
| 171 * Swizzle a line. Generally this will be called height times, once | 133 * Swizzle a line. Generally this will be called height times, once |
| 172 * for each row of source. | 134 * for each row of source. |
| 173 * By allowing the caller to pass in the dst pointer, we give the caller | 135 * By allowing the caller to pass in the dst pointer, we give the caller |
| 174 * flexibility to use the swizzler even when the encoded data does not | 136 * flexibility to use the swizzler even when the encoded data does not |
| 175 * store the rows in order. This also improves usability for scaled and | 137 * store the rows in order. This also improves usability for scaled and |
| 176 * subset decodes. | 138 * subset decodes. |
| 177 * @param dst Where we write the output. | 139 * @param dst Where we write the output. |
| 178 * @param src The next row of the source data. | 140 * @param src The next row of the source data. |
| 179 * @return A result code describing if the row was fully opaque, fully | 141 * @return A result code describing if the row was fully opaque, fully |
| 180 * transparent, or neither | 142 * transparent, or neither |
| 181 */ | 143 */ |
| 182 ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); | 144 ResultAlpha swizzle(void* dst, const uint8_t* SK_RESTRICT src); |
| 183 | 145 |
| 146 /** |
| 147 * Implement fill using a custom width. |
| 148 */ |
| 149 void fill(const SkImageInfo& info, void* dst, size_t rowBytes, uint32_t colo
rOrIndex, |
| 150 SkCodec::ZeroInitialized zeroInit) override { |
| 151 const SkImageInfo fillInfo = info.makeWH(fDstWidth, info.height()); |
| 152 SkSampler::Fill(fillInfo, dst, rowBytes, colorOrIndex, zeroInit); |
| 153 } |
| 154 |
| 184 private: | 155 private: |
| 185 | 156 |
| 186 /** | 157 /** |
| 187 * Method for converting raw data to Skia pixels. | 158 * Method for converting raw data to Skia pixels. |
| 188 * @param dstRow Row in which to write the resulting pixels. | 159 * @param dstRow Row in which to write the resulting pixels. |
| 189 * @param src Row of src data, in format specified by SrcConfig | 160 * @param src Row of src data, in format specified by SrcConfig |
| 190 * @param dstWidth Width in pixels of the destination | 161 * @param dstWidth Width in pixels of the destination |
| 191 * @param bpp if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel | 162 * @param bpp if bitsPerPixel % 8 == 0, deltaSrc is bytesPerPixel |
| 192 * else, deltaSrc is bitsPerPixel | 163 * else, deltaSrc is bitsPerPixel |
| 193 * @param deltaSrc bpp * sampleX | 164 * @param deltaSrc bpp * sampleX |
| (...skipping 13 matching lines...) Expand all Loading... |
| 207 // else | 178 // else |
| 208 // deltaSrc is bitsPerPixel | 179 // deltaSrc is bitsPerPixel |
| 209 const int fSrcWidth; // Width of the source - i.e. before a
ny sampling. | 180 const int fSrcWidth; // Width of the source - i.e. before a
ny sampling. |
| 210 int fDstWidth; // Width of dst, which may differ with
sampling. | 181 int fDstWidth; // Width of dst, which may differ with
sampling. |
| 211 int fX0; // first X coord to sample | 182 int fX0; // first X coord to sample |
| 212 int fSampleX; // step between X samples | 183 int fSampleX; // step between X samples |
| 213 | 184 |
| 214 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, int srcWidth
); | 185 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, int srcWidth
); |
| 215 | 186 |
| 216 int onSetSampleX(int) override; | 187 int onSetSampleX(int) override; |
| 188 |
| 217 }; | 189 }; |
| 218 #endif // SkSwizzler_DEFINED | 190 #endif // SkSwizzler_DEFINED |
| OLD | NEW |