| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // In the case of a 4 bit image with an odd width, we need to add some | 66 // In the case of a 4 bit image with an odd width, we need to add some |
| 67 // so we can go off the end of the drawn bitmap. | 67 // so we can go off the end of the drawn bitmap. |
| 68 // Add 4 to ensure that it is still a multiple of 4. | 68 // Add 4 to ensure that it is still a multiple of 4. |
| 69 if (4 == bitCount && (w & 0x1)) { | 69 if (4 == bitCount && (w & 0x1)) { |
| 70 return (w + 1) << 2; | 70 return (w + 1) << 2; |
| 71 } | 71 } |
| 72 // Otherwise return 0, which will allow it to be calculated automatically. | 72 // Otherwise return 0, which will allow it to be calculated automatically. |
| 73 return 0; | 73 return 0; |
| 74 } | 74 } |
| 75 | 75 |
| 76 SkImageDecoder::Result SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) | 76 SkImageDecoder::Result SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* b
m, Mode mode) { |
| 77 { | 77 auto data = SkCopyStreamToData(stream); |
| 78 SkAutoTUnref<SkData> data(SkCopyStreamToData(stream)); | |
| 79 if (!data) { | 78 if (!data) { |
| 80 return kFailure; | 79 return kFailure; |
| 81 } | 80 } |
| 82 | 81 |
| 83 const size_t length = data->size(); | 82 const size_t length = data->size(); |
| 84 // Check that the buffer is large enough to read the directory header | 83 // Check that the buffer is large enough to read the directory header |
| 85 if (length < 6) { | 84 if (length < 6) { |
| 86 return kFailure; | 85 return kFailure; |
| 87 } | 86 } |
| 88 | 87 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); | 447 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); |
| 449 | 448 |
| 450 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { | 449 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { |
| 451 if (is_ico(stream)) { | 450 if (is_ico(stream)) { |
| 452 return SkImageDecoder::kICO_Format; | 451 return SkImageDecoder::kICO_Format; |
| 453 } | 452 } |
| 454 return SkImageDecoder::kUnknown_Format; | 453 return SkImageDecoder::kUnknown_Format; |
| 455 } | 454 } |
| 456 | 455 |
| 457 static SkImageDecoder_FormatReg gFormatReg(get_format_ico); | 456 static SkImageDecoder_FormatReg gFormatReg(get_format_ico); |
| OLD | NEW |