| 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 "SkCodec.h" | 8 #include "SkCodec.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) { | 155 SkCodec* SkWbmpCodec::NewFromStream(SkStream* stream) { |
| 156 SkAutoTDelete<SkStream> streamDeleter(stream); | 156 SkAutoTDelete<SkStream> streamDeleter(stream); |
| 157 SkISize size; | 157 SkISize size; |
| 158 if (!read_header(stream, &size)) { | 158 if (!read_header(stream, &size)) { |
| 159 return NULL; | 159 return NULL; |
| 160 } | 160 } |
| 161 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), | 161 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), |
| 162 kGray_8_SkColorType, kOpaque_SkAlphaType); | 162 kGray_8_SkColorType, kOpaque_SkAlphaType); |
| 163 return SkNEW_ARGS(SkWbmpCodec, (info, streamDeleter.detach())); | 163 return new SkWbmpCodec(info, streamDeleter.detach()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 class SkWbmpScanlineDecoder : public SkScanlineDecoder { | 166 class SkWbmpScanlineDecoder : public SkScanlineDecoder { |
| 167 public: | 167 public: |
| 168 /* | 168 /* |
| 169 * Takes ownership of all pointer paramters. | 169 * Takes ownership of all pointer paramters. |
| 170 */ | 170 */ |
| 171 SkWbmpScanlineDecoder(SkWbmpCodec* codec) | 171 SkWbmpScanlineDecoder(SkWbmpCodec* codec) |
| 172 : INHERITED(codec->getInfo()) | 172 : INHERITED(codec->getInfo()) |
| 173 , fCodec(codec) | 173 , fCodec(codec) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 if (!valid_alpha(dstInfo.alphaType(), this->getInfo().alphaType())) { | 208 if (!valid_alpha(dstInfo.alphaType(), this->getInfo().alphaType())) { |
| 209 return SkCodec::kInvalidConversion; | 209 return SkCodec::kInvalidConversion; |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Fill in the color table | 212 // Fill in the color table |
| 213 setup_color_table(dstInfo.colorType(), inputColorTable, inputColorCount)
; | 213 setup_color_table(dstInfo.colorType(), inputColorTable, inputColorCount)
; |
| 214 | 214 |
| 215 // Copy the color table to a pointer that can be owned by the scanline d
ecoder | 215 // Copy the color table to a pointer that can be owned by the scanline d
ecoder |
| 216 if (kIndex_8_SkColorType == dstInfo.colorType()) { | 216 if (kIndex_8_SkColorType == dstInfo.colorType()) { |
| 217 fColorTable.reset(SkNEW_ARGS(SkColorTable, (inputColorTable, 2))); | 217 fColorTable.reset(new SkColorTable(inputColorTable, 2)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 // Initialize the swizzler | 220 // Initialize the swizzler |
| 221 fSwizzler.reset(fCodec->initializeSwizzler(dstInfo, | 221 fSwizzler.reset(fCodec->initializeSwizzler(dstInfo, |
| 222 get_color_ptr(fColorTable.get()), options)); | 222 get_color_ptr(fColorTable.get()), options)); |
| 223 if (NULL == fSwizzler.get()) { | 223 if (NULL == fSwizzler.get()) { |
| 224 return SkCodec::kInvalidConversion; | 224 return SkCodec::kInvalidConversion; |
| 225 } | 225 } |
| 226 | 226 |
| 227 return SkCodec::kSuccess; | 227 return SkCodec::kSuccess; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 241 }; | 241 }; |
| 242 | 242 |
| 243 SkScanlineDecoder* SkWbmpCodec::NewSDFromStream(SkStream* stream) { | 243 SkScanlineDecoder* SkWbmpCodec::NewSDFromStream(SkStream* stream) { |
| 244 SkAutoTDelete<SkWbmpCodec> codec(static_cast<SkWbmpCodec*>( | 244 SkAutoTDelete<SkWbmpCodec> codec(static_cast<SkWbmpCodec*>( |
| 245 SkWbmpCodec::NewFromStream(stream))); | 245 SkWbmpCodec::NewFromStream(stream))); |
| 246 if (!codec) { | 246 if (!codec) { |
| 247 return NULL; | 247 return NULL; |
| 248 } | 248 } |
| 249 | 249 |
| 250 // Return the new scanline decoder | 250 // Return the new scanline decoder |
| 251 return SkNEW_ARGS(SkWbmpScanlineDecoder, (codec.detach())); | 251 return new SkWbmpScanlineDecoder(codec.detach()); |
| 252 } | 252 } |
| OLD | NEW |