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