OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 float v = max(r, max(g, b)); | 323 float v = max(r, max(g, b)); |
324 float multiplier = max(0.0f, (v - 0.33f) / v); | 324 float multiplier = max(0.0f, (v - 0.33f) / v); |
325 | 325 |
326 return Color(static_cast<int>(multiplier * r * scaleFactor), | 326 return Color(static_cast<int>(multiplier * r * scaleFactor), |
327 static_cast<int>(multiplier * g * scaleFactor), | 327 static_cast<int>(multiplier * g * scaleFactor), |
328 static_cast<int>(multiplier * b * scaleFactor), | 328 static_cast<int>(multiplier * b * scaleFactor), |
329 alpha()); | 329 alpha()); |
330 } | 330 } |
331 | 331 |
| 332 Color Color::combineWithAlpha(float otherAlpha) const |
| 333 { |
| 334 return colorWithOverrideAlpha(rgb(), (alpha() / 255.f) * otherAlpha); |
| 335 } |
| 336 |
332 static int blendComponent(int c, int a) | 337 static int blendComponent(int c, int a) |
333 { | 338 { |
334 // We use white. | 339 // We use white. |
335 float alpha = a / 255.0f; | 340 float alpha = a / 255.0f; |
336 int whiteBlend = 255 - a; | 341 int whiteBlend = 255 - a; |
337 c -= whiteBlend; | 342 c -= whiteBlend; |
338 return static_cast<int>(c / alpha); | 343 return static_cast<int>(c / alpha); |
339 } | 344 } |
340 | 345 |
341 const int cStartAlpha = 153; // 60% | 346 const int cStartAlpha = 153; // 60% |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 (color.green() * alpha + 254) / 255, | 460 (color.green() * alpha + 254) / 255, |
456 (color.blue() * alpha + 254) / 255, | 461 (color.blue() * alpha + 254) / 255, |
457 alpha).rgb(); | 462 alpha).rgb(); |
458 } else | 463 } else |
459 pixelColor = color.rgb(); | 464 pixelColor = color.rgb(); |
460 | 465 |
461 return pixelColor; | 466 return pixelColor; |
462 } | 467 } |
463 | 468 |
464 } // namespace WebCore | 469 } // namespace WebCore |
OLD | NEW |