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 DCHECK(IsAlphaSupported()); |
246 return bit_masks_[3] ? GetComponent(pixel, 3) : 0xff; | 248 return GetComponent(pixel, 3); |
247 } | 249 } |
248 | 250 |
249 // Sets the current pixel to the color given by |color_index|. This also | 251 // Sets the current pixel to the color given by |color_index|. This also |
250 // increments the relevant local variables to move the current pixel | 252 // increments the relevant local variables to move the current pixel |
251 // right by one. | 253 // right by one. |
252 inline void SetI(size_t color_index) { | 254 inline void SetI(size_t color_index) { |
253 SetRGBA(color_table_[color_index].rgb_red, | 255 SetRGBA(color_table_[color_index].rgb_red, |
254 color_table_[color_index].rgb_green, | 256 color_table_[color_index].rgb_green, |
255 color_table_[color_index].rgb_blue, 0xff); | 257 color_table_[color_index].rgb_blue, 0xff); |
256 } | 258 } |
(...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 | 363 // 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 | 364 // (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 | 365 // header, thus doubling it). If |is_in_ico_| is true, this variable tracks |
364 // whether we've begun decoding this mask yet. | 366 // whether we've begun decoding this mask yet. |
365 bool decoding_and_mask_; | 367 bool decoding_and_mask_; |
366 }; | 368 }; |
367 | 369 |
368 } // namespace blink | 370 } // namespace blink |
369 | 371 |
370 #endif | 372 #endif |
OLD | NEW |