| 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 "SkBmpMaskCodec.h" | 8 #include "SkBmpMaskCodec.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (dstInfo.dimensions() != this->getInfo().dimensions()) { | 39 if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
| 40 SkCodecPrintf("Error: scaling not supported.\n"); | 40 SkCodecPrintf("Error: scaling not supported.\n"); |
| 41 return kInvalidScale; | 41 return kInvalidScale; |
| 42 } | 42 } |
| 43 | 43 |
| 44 if (!conversion_possible(dstInfo, this->getInfo())) { | 44 if (!conversion_possible(dstInfo, this->getInfo())) { |
| 45 SkCodecPrintf("Error: cannot convert input type to output type.\n"); | 45 SkCodecPrintf("Error: cannot convert input type to output type.\n"); |
| 46 return kInvalidConversion; | 46 return kInvalidConversion; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Initialize a the mask swizzler | 49 Result result = this->prepareToDecode(dstInfo, opts, inputColorPtr, inputCol
orCount); |
| 50 if (!this->initializeSwizzler(dstInfo)) { | 50 if (kSuccess != result) { |
| 51 SkCodecPrintf("Error: cannot initialize swizzler.\n"); | 51 return result; |
| 52 return kInvalidConversion; | |
| 53 } | 52 } |
| 54 | 53 |
| 55 return this->decode(dstInfo, dst, dstRowBytes, opts); | 54 return this->decode(dstInfo, dst, dstRowBytes, opts); |
| 56 } | 55 } |
| 57 | 56 |
| 58 bool SkBmpMaskCodec::initializeSwizzler(const SkImageInfo& dstInfo) { | 57 bool SkBmpMaskCodec::initializeSwizzler(const SkImageInfo& dstInfo) { |
| 59 // Allocate space for a row buffer | 58 // Allocate space for a row buffer |
| 60 const size_t rowBytes = SkAlign4(compute_row_bytes(dstInfo.width(), this->bi
tsPerPixel())); | 59 const size_t rowBytes = SkAlign4(compute_row_bytes(dstInfo.width(), this->bi
tsPerPixel())); |
| 61 fSrcBuffer.reset(SkNEW_ARRAY(uint8_t, rowBytes)); | 60 fSrcBuffer.reset(SkNEW_ARRAY(uint8_t, rowBytes)); |
| 62 | 61 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 93 SK_ColorBLACK : SK_ColorTRANSPARENT; | 92 SK_ColorBLACK : SK_ColorTRANSPARENT; |
| 94 if (kNo_ZeroInitialized == opts.fZeroInitialized || 0 != fillColor)
{ | 93 if (kNo_ZeroInitialized == opts.fZeroInitialized || 0 != fillColor)
{ |
| 95 void* dstStart = this->getDstStartRow(dst, dstRowBytes, y); | 94 void* dstStart = this->getDstStartRow(dst, dstRowBytes, y); |
| 96 SkSwizzler::Fill(dstStart, dstInfo, dstRowBytes, dstInfo.height(
) - y, fillColor, | 95 SkSwizzler::Fill(dstStart, dstInfo, dstRowBytes, dstInfo.height(
) - y, fillColor, |
| 97 NULL); | 96 NULL); |
| 98 } | 97 } |
| 99 return kIncompleteInput; | 98 return kIncompleteInput; |
| 100 } | 99 } |
| 101 | 100 |
| 102 // Decode the row in destination format | 101 // Decode the row in destination format |
| 103 int row = SkBmpCodec::kBottomUp_RowOrder == this->rowOrder() ? height -
1 - y : y; | 102 uint32_t row = this->getDstRow(y); |
| 104 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); | 103 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); |
| 105 fMaskSwizzler->swizzle(dstRow, srcRow); | 104 fMaskSwizzler->swizzle(dstRow, srcRow); |
| 106 } | 105 } |
| 107 | 106 |
| 108 // Finished decoding the entire image | 107 // Finished decoding the entire image |
| 109 return kSuccess; | 108 return kSuccess; |
| 110 } | 109 } |
| 110 |
| 111 SkCodec::Result SkBmpMaskCodec::prepareToDecode(const SkImageInfo& dstInfo, |
| 112 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo
lorCount) { |
| 113 // Initialize a the mask swizzler |
| 114 if (!this->initializeSwizzler(dstInfo)) { |
| 115 SkCodecPrintf("Error: cannot initialize swizzler.\n"); |
| 116 return SkCodec::kInvalidConversion; |
| 117 } |
| 118 |
| 119 return SkCodec::kSuccess; |
| 120 } |
| OLD | NEW |