Chromium Code Reviews| 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_libbmp.h" | 8 #include "SkCodec_libbmp.h" |
| 9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 return true; | 489 return true; |
| 490 } | 490 } |
| 491 | 491 |
| 492 /* | 492 /* |
| 493 * | 493 * |
| 494 * Creates a bmp decoder | 494 * Creates a bmp decoder |
| 495 * Reads enough of the stream to determine the image format | 495 * Reads enough of the stream to determine the image format |
| 496 * | 496 * |
| 497 */ | 497 */ |
| 498 SkCodec* SkBmpCodec::NewFromStream(SkStream* stream, bool isIco) { | 498 SkCodec* SkBmpCodec::NewFromStream(SkStream* stream, bool isIco) { |
| 499 SkAutoTDelete<SkStream> streamDeleter(stream); | |
| 499 SkCodec* codec = NULL; | 500 SkCodec* codec = NULL; |
| 500 if (ReadHeader(stream, isIco, &codec)) { | 501 if (ReadHeader(stream, isIco, &codec)) { |
|
mtklein
2015/04/03 13:13:05
Might be less error prone to have ReadHeader take
scroggo
2015/04/03 13:59:53
Yeah, I was not sure the best way to handle this.
| |
| 502 // codec has taken ownership of stream, so we do not need to | |
| 503 // delete it. | |
| 504 SkASSERT(codec); | |
| 505 streamDeleter.detach(); | |
| 501 return codec; | 506 return codec; |
| 502 } | 507 } |
| 503 return NULL; | 508 return NULL; |
| 504 } | 509 } |
| 505 | 510 |
| 506 /* | 511 /* |
| 507 * | 512 * |
| 508 * Creates an instance of the decoder | 513 * Creates an instance of the decoder |
| 509 * Called only by NewFromStream | 514 * Called only by NewFromStream |
| 510 * | 515 * |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 uint32_t alphaBit = | 1131 uint32_t alphaBit = |
| 1127 (srcBuffer.get()[quotient] >> shift) & 0x1; | 1132 (srcBuffer.get()[quotient] >> shift) & 0x1; |
| 1128 dstRow[x] &= alphaBit - 1; | 1133 dstRow[x] &= alphaBit - 1; |
| 1129 } | 1134 } |
| 1130 } | 1135 } |
| 1131 } | 1136 } |
| 1132 | 1137 |
| 1133 // Finished decoding the entire image | 1138 // Finished decoding the entire image |
| 1134 return kSuccess; | 1139 return kSuccess; |
| 1135 } | 1140 } |
| OLD | NEW |