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 19 matching lines...) Expand all Loading... |
30 #include "wtf/Assertions.h" | 30 #include "wtf/Assertions.h" |
31 #include "wtf/HexNumber.h" | 31 #include "wtf/HexNumber.h" |
32 #include "wtf/MathExtras.h" | 32 #include "wtf/MathExtras.h" |
33 #include "wtf/dtoa.h" | 33 #include "wtf/dtoa.h" |
34 #include "wtf/text/StringBuilder.h" | 34 #include "wtf/text/StringBuilder.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 // VS 2015 and above allow these definitions and in this case require them | 38 // VS 2015 and above allow these definitions and in this case require them |
39 #if !COMPILER(MSVC) || _MSC_VER >= 1900 | 39 #if !COMPILER(MSVC) || _MSC_VER >= 1900 |
40 // FIXME: Use C++11 strong enums to avoid static data member with initializer de
finition problems. | 40 // FIXME: Use C++11 enum classes to avoid static data member initializer |
| 41 // definition problems. |
41 const RGBA32 Color::black; | 42 const RGBA32 Color::black; |
42 const RGBA32 Color::white; | 43 const RGBA32 Color::white; |
43 const RGBA32 Color::darkGray; | 44 const RGBA32 Color::darkGray; |
44 const RGBA32 Color::gray; | 45 const RGBA32 Color::gray; |
45 const RGBA32 Color::lightGray; | 46 const RGBA32 Color::lightGray; |
46 const RGBA32 Color::transparent; | 47 const RGBA32 Color::transparent; |
47 #endif | 48 #endif |
48 | 49 |
49 static const RGBA32 lightenedBlack = 0xFF545454; | 50 static const RGBA32 lightenedBlack = 0xFF545454; |
50 static const RGBA32 darkenedWhite = 0xFFABABAB; | 51 static const RGBA32 darkenedWhite = 0xFFABABAB; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 return Color(r, g, b, a); | 356 return Color(r, g, b, a); |
356 } | 357 } |
357 | 358 |
358 Color Color::blendWithWhite() const { | 359 Color Color::blendWithWhite() const { |
359 // If the color contains alpha already, we leave it alone. | 360 // If the color contains alpha already, we leave it alone. |
360 if (hasAlpha()) | 361 if (hasAlpha()) |
361 return *this; | 362 return *this; |
362 | 363 |
363 Color newColor; | 364 Color newColor; |
364 for (int alpha = cStartAlpha; alpha <= cEndAlpha; alpha += cAlphaIncrement) { | 365 for (int alpha = cStartAlpha; alpha <= cEndAlpha; alpha += cAlphaIncrement) { |
365 // We have a solid color. Convert to an equivalent color that looks the sam
e when blended with white | 366 // We have a solid color. Convert to an equivalent color that looks the |
366 // at the current alpha. Try using less transparency if the numbers end up
being negative. | 367 // same when blended with white at the current alpha. Try using less |
| 368 // transparency if the numbers end up being negative. |
367 int r = blendComponent(red(), alpha); | 369 int r = blendComponent(red(), alpha); |
368 int g = blendComponent(green(), alpha); | 370 int g = blendComponent(green(), alpha); |
369 int b = blendComponent(blue(), alpha); | 371 int b = blendComponent(blue(), alpha); |
370 | 372 |
371 newColor = Color(r, g, b, alpha); | 373 newColor = Color(r, g, b, alpha); |
372 | 374 |
373 if (r >= 0 && g >= 0 && b >= 0) | 375 if (r >= 0 && g >= 0 && b >= 0) |
374 break; | 376 break; |
375 } | 377 } |
376 return newColor; | 378 return newColor; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 (color.green() * alpha + 254) / 255, | 446 (color.green() * alpha + 254) / 255, |
445 (color.blue() * alpha + 254) / 255, alpha) | 447 (color.blue() * alpha + 254) / 255, alpha) |
446 .rgb(); | 448 .rgb(); |
447 } else | 449 } else |
448 pixelColor = color.rgb(); | 450 pixelColor = color.rgb(); |
449 | 451 |
450 return pixelColor; | 452 return pixelColor; |
451 } | 453 } |
452 | 454 |
453 } // namespace blink | 455 } // namespace blink |
OLD | NEW |