Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/config.h" | |
| 6 #include "sky/engine/core/painting/CanvasGradient.h" | |
| 7 | |
| 8 #include "base/logging.h" | |
| 9 #include "sky/engine/core/painting/Picture.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 PassRefPtr<CanvasGradient> CanvasGradient::create(int type, | |
| 14 Vector<Point> end_points, | |
|
eseidel
2015/06/08 17:26:57
These are going to cause the vector to get copied
Matt Perry
2015/06/08 17:43:53
Oops - I made them pass by const ref.
| |
| 15 Vector<SkColor> colors, | |
| 16 Vector<float> color_stops) { | |
| 17 ASSERT(type == 0); // Only 1 supported type so far. | |
| 18 ASSERT(end_points.size() == 2); | |
| 19 ASSERT(colors.size() == color_stops.size() || color_stops.data() == nullptr); | |
| 20 SkPoint sk_end_points[2]; | |
| 21 for (int i = 0; i < 2; ++i) | |
| 22 sk_end_points[i] = end_points[i].sk_point; | |
| 23 | |
| 24 SkShader* shader = SkGradientShader::CreateLinear( | |
| 25 sk_end_points, colors.data(), color_stops.data(), colors.size(), | |
| 26 SkShader::kClamp_TileMode); | |
| 27 return adoptRef(new CanvasGradient(adoptRef(shader))); | |
| 28 } | |
| 29 | |
| 30 CanvasGradient::CanvasGradient(PassRefPtr<SkShader> shader) | |
| 31 : Shader(shader) | |
| 32 { | |
| 33 } | |
| 34 | |
| 35 CanvasGradient::~CanvasGradient() | |
| 36 { | |
| 37 } | |
| 38 | |
| 39 } // namespace blink | |
| OLD | NEW |