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 #include "SkBmpRLECodec.h" | 8 #include "SkBmpRLECodec.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 fRLEBytes = remainingBytes + additionalBytes; | 191 fRLEBytes = remainingBytes + additionalBytes; |
192 return fRLEBytes; | 192 return fRLEBytes; |
193 } | 193 } |
194 | 194 |
195 /* | 195 /* |
196 * Set an RLE pixel using the color table | 196 * Set an RLE pixel using the color table |
197 */ | 197 */ |
198 void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes, | 198 void SkBmpRLECodec::setPixel(void* dst, size_t dstRowBytes, |
199 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, | 199 const SkImageInfo& dstInfo, uint32_t x, uint32_t y, |
200 uint8_t index) { | 200 uint8_t index) { |
201 if (is_coord_necessary(x, fSampleX, dstInfo.width())) { | 201 if (is_coord_necessary(x, fSampleX, dstInfo.width(), 0)) { |
202 // Set the row | 202 // Set the row |
203 uint32_t row = this->getDstRow(y, dstInfo.height()); | 203 uint32_t row = this->getDstRow(y, dstInfo.height()); |
204 | 204 |
205 // Set the pixel based on destination color type | 205 // Set the pixel based on destination color type |
206 const int dstX = get_dst_coord(x, fSampleX); | 206 const int dstX = get_dst_coord(x, fSampleX); |
207 switch (dstInfo.colorType()) { | 207 switch (dstInfo.colorType()) { |
208 case kN32_SkColorType: { | 208 case kN32_SkColorType: { |
209 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst
RowBytes); | 209 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst
RowBytes); |
210 dstRow[dstX] = fColorTable->operator[](index); | 210 dstRow[dstX] = fColorTable->operator[](index); |
211 break; | 211 break; |
(...skipping 12 matching lines...) Expand all Loading... |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 /* | 227 /* |
228 * Set an RLE pixel from R, G, B values | 228 * Set an RLE pixel from R, G, B values |
229 */ | 229 */ |
230 void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes, | 230 void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes, |
231 const SkImageInfo& dstInfo, uint32_t x, | 231 const SkImageInfo& dstInfo, uint32_t x, |
232 uint32_t y, uint8_t red, uint8_t green, | 232 uint32_t y, uint8_t red, uint8_t green, |
233 uint8_t blue) { | 233 uint8_t blue) { |
234 if (is_coord_necessary(x, fSampleX, dstInfo.width())) { | 234 if (is_coord_necessary(x, fSampleX, dstInfo.width(), 0)) { |
235 // Set the row | 235 // Set the row |
236 uint32_t row = this->getDstRow(y, dstInfo.height()); | 236 uint32_t row = this->getDstRow(y, dstInfo.height()); |
237 | 237 |
238 // Set the pixel based on destination color type | 238 // Set the pixel based on destination color type |
239 const int dstX = get_dst_coord(x, fSampleX); | 239 const int dstX = get_dst_coord(x, fSampleX); |
240 switch (dstInfo.colorType()) { | 240 switch (dstInfo.colorType()) { |
241 case kN32_SkColorType: { | 241 case kN32_SkColorType: { |
242 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst
RowBytes); | 242 SkPMColor* dstRow = SkTAddOffset<SkPMColor>(dst, row * (int) dst
RowBytes); |
243 dstRow[dstX] = SkPackARGB32NoCheck(0xFF, red, green, blue); | 243 dstRow[dstX] = SkPackARGB32NoCheck(0xFF, red, green, blue); |
244 break; | 244 break; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 fSampler.reset(new SkBmpRLESampler(this)); | 506 fSampler.reset(new SkBmpRLESampler(this)); |
507 } | 507 } |
508 | 508 |
509 return fSampler; | 509 return fSampler; |
510 } | 510 } |
511 | 511 |
512 int SkBmpRLECodec::setSampleX(int sampleX){ | 512 int SkBmpRLECodec::setSampleX(int sampleX){ |
513 fSampleX = sampleX; | 513 fSampleX = sampleX; |
514 return get_scaled_dimension(this->getInfo().width(), sampleX); | 514 return get_scaled_dimension(this->getInfo().width(), sampleX); |
515 } | 515 } |
OLD | NEW |