Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 // Returns the value of the desired component (0, 1, 2, 3 == R, G, B, A) | 234 // Returns the value of the desired component (0, 1, 2, 3 == R, G, B, A) |
| 235 // in the given pixel data. | 235 // in the given pixel data. |
| 236 inline unsigned GetComponent(uint32_t pixel, int component) const { | 236 inline unsigned GetComponent(uint32_t pixel, int component) const { |
| 237 uint8_t value = | 237 uint8_t value = |
| 238 (pixel & bit_masks_[component]) >> bit_shifts_right_[component]; | 238 (pixel & bit_masks_[component]) >> bit_shifts_right_[component]; |
| 239 return lookup_table_addresses_[component] | 239 return lookup_table_addresses_[component] |
| 240 ? lookup_table_addresses_[component][value] | 240 ? lookup_table_addresses_[component][value] |
| 241 : value; | 241 : value; |
| 242 } | 242 } |
| 243 | 243 |
| 244 inline bool IsAlphaSupported() const { return bit_masks_[3]; } | |
| 245 | |
| 244 inline unsigned GetAlpha(uint32_t pixel) const { | 246 inline unsigned GetAlpha(uint32_t pixel) const { |
| 245 // For images without alpha, return alpha of 0xff. | 247 return GetComponent(pixel, 3); |
|
scroggo_chromium
2017/05/30 19:45:17
Should this
DCHECK(IsAlphaSupported());
?
cblume
2017/05/30 23:45:14
Good idea.
| |
| 246 return bit_masks_[3] ? GetComponent(pixel, 3) : 0xff; | |
| 247 } | 248 } |
| 248 | 249 |
| 249 // Sets the current pixel to the color given by |color_index|. This also | 250 // Sets the current pixel to the color given by |color_index|. This also |
| 250 // increments the relevant local variables to move the current pixel | 251 // increments the relevant local variables to move the current pixel |
| 251 // right by one. | 252 // right by one. |
| 252 inline void SetI(size_t color_index) { | 253 inline void SetI(size_t color_index) { |
| 253 SetRGBA(color_table_[color_index].rgb_red, | 254 SetRGBA(color_table_[color_index].rgb_red, |
| 254 color_table_[color_index].rgb_green, | 255 color_table_[color_index].rgb_green, |
| 255 color_table_[color_index].rgb_blue, 0xff); | 256 color_table_[color_index].rgb_blue, 0xff); |
| 256 } | 257 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 // ICOs store a 1bpp "mask" immediately after the main bitmap image data | 362 // ICOs store a 1bpp "mask" immediately after the main bitmap image data |
| 362 // (and, confusingly, add its height to the biHeight value in the info | 363 // (and, confusingly, add its height to the biHeight value in the info |
| 363 // header, thus doubling it). If |is_in_ico_| is true, this variable tracks | 364 // header, thus doubling it). If |is_in_ico_| is true, this variable tracks |
| 364 // whether we've begun decoding this mask yet. | 365 // whether we've begun decoding this mask yet. |
| 365 bool decoding_and_mask_; | 366 bool decoding_and_mask_; |
| 366 }; | 367 }; |
| 367 | 368 |
| 368 } // namespace blink | 369 } // namespace blink |
| 369 | 370 |
| 370 #endif | 371 #endif |
| OLD | NEW |