Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: Source/platform/graphics/Color.cpp

Issue 126033003: Support colors w/ alpha in SVG 'stop' elements and 'feFlood' (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 float v = max(r, max(g, b)); 306 float v = max(r, max(g, b));
307 float multiplier = max(0.0f, (v - 0.33f) / v); 307 float multiplier = max(0.0f, (v - 0.33f) / v);
308 308
309 return Color(static_cast<int>(multiplier * r * scaleFactor), 309 return Color(static_cast<int>(multiplier * r * scaleFactor),
310 static_cast<int>(multiplier * g * scaleFactor), 310 static_cast<int>(multiplier * g * scaleFactor),
311 static_cast<int>(multiplier * b * scaleFactor), 311 static_cast<int>(multiplier * b * scaleFactor),
312 alpha()); 312 alpha());
313 } 313 }
314 314
315 Color Color::modulate(float factor) const
316 {
317 return colorWithOverrideAlpha(rgb(), (alpha() / 255.f) * factor);
318 }
319
315 static int blendComponent(int c, int a) 320 static int blendComponent(int c, int a)
316 { 321 {
317 // We use white. 322 // We use white.
318 float alpha = a / 255.0f; 323 float alpha = a / 255.0f;
319 int whiteBlend = 255 - a; 324 int whiteBlend = 255 - a;
320 c -= whiteBlend; 325 c -= whiteBlend;
321 return static_cast<int>(c / alpha); 326 return static_cast<int>(c / alpha);
322 } 327 }
323 328
324 const int cStartAlpha = 153; // 60% 329 const int cStartAlpha = 153; // 60%
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 (color.green() * alpha + 254) / 255, 443 (color.green() * alpha + 254) / 255,
439 (color.blue() * alpha + 254) / 255, 444 (color.blue() * alpha + 254) / 255,
440 alpha).rgb(); 445 alpha).rgb();
441 } else 446 } else
442 pixelColor = color.rgb(); 447 pixelColor = color.rgb();
443 448
444 return pixelColor; 449 return pixelColor;
445 } 450 }
446 451
447 } // namespace WebCore 452 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698