Chromium Code Reviews| 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 "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 int reserved = read2Bytes(buf, 0); // 0 | 87 int reserved = read2Bytes(buf, 0); // 0 |
| 88 int type = read2Bytes(buf, 2); // 1 | 88 int type = read2Bytes(buf, 2); // 1 |
| 89 if (reserved != 0 || type != 1) | 89 if (reserved != 0 || type != 1) |
| 90 return false; | 90 return false; |
| 91 int count = read2Bytes(buf, 4); | 91 int count = read2Bytes(buf, 4); |
| 92 | 92 |
| 93 //need to at least have enough space to hold the initial table of info | 93 //need to at least have enough space to hold the initial table of info |
| 94 if (length < (size_t)(6 + count*16)) | 94 if (length < (size_t)(6 + count*16)) |
| 95 return false; | 95 return false; |
| 96 | 96 |
| 97 #ifdef SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER | |
| 97 int choice; | 98 int choice; |
| 98 Chooser* chooser = this->getChooser(); | 99 Chooser* chooser = this->getChooser(); |
|
scroggo
2014/06/11 17:11:23
ICO is the prime example where the choice actually
| |
| 99 //FIXME:if no chooser, consider providing the largest color image | 100 //FIXME:if no chooser, consider providing the largest color image |
| 100 //what are the odds that the largest image would be monochrome? | 101 //what are the odds that the largest image would be monochrome? |
| 101 if (NULL == chooser) { | 102 if (NULL == chooser) { |
| 102 choice = 0; | 103 choice = 0; |
| 103 } else { | 104 } else { |
| 104 chooser->begin(count); | 105 chooser->begin(count); |
| 105 for (int i = 0; i < count; i++) | 106 for (int i = 0; i < count; i++) |
| 106 { | 107 { |
| 107 //need to find out the config, width, and height from the stream | 108 //need to find out the config, width, and height from the stream |
| 108 int width = readByte(buf, 6 + i*16); | 109 int width = readByte(buf, 6 + i*16); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 131 continue; | 132 continue; |
| 132 } | 133 } |
| 133 chooser->inspect(i, c, width, height); | 134 chooser->inspect(i, c, width, height); |
| 134 } | 135 } |
| 135 choice = chooser->choose(); | 136 choice = chooser->choose(); |
| 136 } | 137 } |
| 137 | 138 |
| 138 //you never know what the chooser is going to supply | 139 //you never know what the chooser is going to supply |
| 139 if (choice >= count || choice < 0) | 140 if (choice >= count || choice < 0) |
| 140 return false; | 141 return false; |
| 142 #else | |
| 143 const int choice = 0; // TODO: fold this value into the expressions below | |
| 144 #endif | |
| 141 | 145 |
| 142 //skip ahead to the correct header | 146 //skip ahead to the correct header |
| 143 //commented out lines are not used, but if i switch to other read method, ne ed to know how many to skip | 147 //commented out lines are not used, but if i switch to other read method, ne ed to know how many to skip |
| 144 //otherwise, they could be used for error checking | 148 //otherwise, they could be used for error checking |
| 145 int w = readByte(buf, 6 + choice*16); | 149 int w = readByte(buf, 6 + choice*16); |
| 146 int h = readByte(buf, 7 + choice*16); | 150 int h = readByte(buf, 7 + choice*16); |
| 147 int colorCount = readByte(buf, 8 + choice*16); | 151 int colorCount = readByte(buf, 8 + choice*16); |
| 148 //int reservedToo = readByte(buf, 9 + choice*16); //0 | 152 //int reservedToo = readByte(buf, 9 + choice*16); //0 |
| 149 //int planes = read2Bytes(buf, 10 + choice*16); //1 - but often 0 | 153 //int planes = read2Bytes(buf, 10 + choice*16); //1 - but often 0 |
| 150 //int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usu ally 0 | 154 //int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usu ally 0 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); | 412 static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); |
| 409 | 413 |
| 410 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { | 414 static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { |
| 411 if (is_ico(stream)) { | 415 if (is_ico(stream)) { |
| 412 return SkImageDecoder::kICO_Format; | 416 return SkImageDecoder::kICO_Format; |
| 413 } | 417 } |
| 414 return SkImageDecoder::kUnknown_Format; | 418 return SkImageDecoder::kUnknown_Format; |
| 415 } | 419 } |
| 416 | 420 |
| 417 static SkImageDecoder_FormatReg gFormatReg(get_format_ico); | 421 static SkImageDecoder_FormatReg gFormatReg(get_format_ico); |
| OLD | NEW |