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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const RGBA32 Color::gray; | 43 const RGBA32 Color::gray; |
44 const RGBA32 Color::lightGray; | 44 const RGBA32 Color::lightGray; |
45 const RGBA32 Color::transparent; | 45 const RGBA32 Color::transparent; |
46 #endif | 46 #endif |
47 | 47 |
48 static const RGBA32 lightenedBlack = 0xFF545454; | 48 static const RGBA32 lightenedBlack = 0xFF545454; |
49 static const RGBA32 darkenedWhite = 0xFFABABAB; | 49 static const RGBA32 darkenedWhite = 0xFFABABAB; |
50 | 50 |
51 RGBA32 makeRGB(int r, int g, int b) | 51 RGBA32 makeRGB(int r, int g, int b) |
52 { | 52 { |
53 return 0xFF000000 | std::max(0, std::min(r, 255)) << 16 | std::max(0, std::m
in(g, 255)) << 8 | std::max(0, std::min(b, 255)); | 53 return 0xFF000000 | clampTo(r, 0, 255) << 16 | clampTo(g, 0, 255) << 8 | cla
mpTo(b, 0, 255); |
54 } | 54 } |
55 | 55 |
56 RGBA32 makeRGBA(int r, int g, int b, int a) | 56 RGBA32 makeRGBA(int r, int g, int b, int a) |
57 { | 57 { |
58 return std::max(0, std::min(a, 255)) << 24 | std::max(0, std::min(r, 255)) <
< 16 | std::max(0, std::min(g, 255)) << 8 | std::max(0, std::min(b, 255)); | 58 return clampTo(a, 0, 255) << 24 | clampTo(r, 0, 255) << 16 | clampTo(g, 0, 2
55) << 8 | clampTo(b, 0, 255); |
59 } | 59 } |
60 | 60 |
61 static int colorFloatToRGBAByte(float f) | 61 static int colorFloatToRGBAByte(float f) |
62 { | 62 { |
63 return std::max(0, std::min(static_cast<int>(lroundf(255.0f * f)), 255)); | 63 return clampTo(static_cast<int>(lroundf(255.0f * f)), 0, 255); |
64 } | 64 } |
65 | 65 |
66 RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a) | 66 RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a) |
67 { | 67 { |
68 return colorFloatToRGBAByte(a) << 24 | colorFloatToRGBAByte(r) << 16 | color
FloatToRGBAByte(g) << 8 | colorFloatToRGBAByte(b); | 68 return colorFloatToRGBAByte(a) << 24 | colorFloatToRGBAByte(r) << 16 | color
FloatToRGBAByte(g) << 8 | colorFloatToRGBAByte(b); |
69 } | 69 } |
70 | 70 |
71 static double calcHue(double temp1, double temp2, double hueVal) | 71 static double calcHue(double temp1, double temp2, double hueVal) |
72 { | 72 { |
73 if (hueVal < 0.0) | 73 if (hueVal < 0.0) |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 (color.green() * alpha + 254) / 255, | 448 (color.green() * alpha + 254) / 255, |
449 (color.blue() * alpha + 254) / 255, | 449 (color.blue() * alpha + 254) / 255, |
450 alpha).rgb(); | 450 alpha).rgb(); |
451 } else | 451 } else |
452 pixelColor = color.rgb(); | 452 pixelColor = color.rgb(); |
453 | 453 |
454 return pixelColor; | 454 return pixelColor; |
455 } | 455 } |
456 | 456 |
457 } // namespace blink | 457 } // namespace blink |
OLD | NEW |