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

Side by Side Diff: Source/core/svg/SVGGradientElement.cpp

Issue 201503002: Simplify Gradient by holding a Color instead of four floats. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use SkColorSetARGB Created 6 years, 9 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
« no previous file with comments | « no previous file | Source/platform/graphics/Gradient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (RenderObject* object = renderer()) 118 if (RenderObject* object = renderer())
119 object->setNeedsLayout(); 119 object->setNeedsLayout();
120 } 120 }
121 121
122 Vector<Gradient::ColorStop> SVGGradientElement::buildStops() 122 Vector<Gradient::ColorStop> SVGGradientElement::buildStops()
123 { 123 {
124 Vector<Gradient::ColorStop> stops; 124 Vector<Gradient::ColorStop> stops;
125 125
126 float previousOffset = 0.0f; 126 float previousOffset = 0.0f;
127 for (SVGStopElement* stop = Traversal<SVGStopElement>::firstChild(*this); st op; stop = Traversal<SVGStopElement>::nextSibling(*stop)) { 127 for (SVGStopElement* stop = Traversal<SVGStopElement>::firstChild(*this); st op; stop = Traversal<SVGStopElement>::nextSibling(*stop)) {
128 Color color = stop->stopColorIncludingOpacity();
129
130 // Figure out right monotonic offset 128 // Figure out right monotonic offset
131 float offset = stop->offset()->currentValue()->value(); 129 float offset = stop->offset()->currentValue()->value();
132 offset = std::min(std::max(previousOffset, offset), 1.0f); 130 offset = std::min(std::max(previousOffset, offset), 1.0f);
133 previousOffset = offset; 131 previousOffset = offset;
134 132
135 // Extract individual channel values 133 stops.append(Gradient::ColorStop(offset, stop->stopColorIncludingOpacity ()));
136 // FIXME: Why doesn't ColorStop take a Color and an offset??
137 float r, g, b, a;
138 color.getRGBA(r, g, b, a);
139
140 stops.append(Gradient::ColorStop(offset, r, g, b, a));
141 } 134 }
142 135
143 return stops; 136 return stops;
144 } 137 }
145 138
146 } 139 }
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/Gradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698