| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/painting/CanvasGradient.h" | 6 #include "sky/engine/core/painting/CanvasGradient.h" |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 | 9 |
| 10 PassRefPtr<CanvasGradient> CanvasGradient::create() { | 10 PassRefPtr<CanvasGradient> CanvasGradient::create() { |
| 11 return adoptRef(new CanvasGradient()); | 11 return adoptRef(new CanvasGradient()); |
| 12 } | 12 } |
| 13 | 13 |
| 14 void CanvasGradient::initLinear(const Vector<Point>& end_points, | 14 void CanvasGradient::initLinear(const Vector<Point>& end_points, |
| 15 const Vector<SkColor>& colors, | 15 const Vector<SkColor>& colors, |
| 16 const Vector<float>& color_stops) { | 16 const Vector<float>& color_stops, |
| 17 unsigned tile_mode) { |
| 17 ASSERT(end_points.size() == 2); | 18 ASSERT(end_points.size() == 2); |
| 18 ASSERT(colors.size() == color_stops.size() || color_stops.data() == nullptr); | 19 ASSERT(colors.size() == color_stops.size() || color_stops.data() == nullptr); |
| 20 ASSERT(tile_mode < SkShader::kTileModeCount); |
| 19 SkPoint sk_end_points[2]; | 21 SkPoint sk_end_points[2]; |
| 20 for (int i = 0; i < 2; ++i) | 22 for (int i = 0; i < 2; ++i) |
| 21 sk_end_points[i] = end_points[i].sk_point; | 23 sk_end_points[i] = end_points[i].sk_point; |
| 22 | 24 |
| 23 // TODO(mpcomplete): allow setting the TileMode. | 25 // TODO(mpcomplete): allow setting the TileMode. |
| 24 SkShader* shader = SkGradientShader::CreateLinear( | 26 SkShader* shader = SkGradientShader::CreateLinear( |
| 25 sk_end_points, colors.data(), color_stops.data(), colors.size(), | 27 sk_end_points, colors.data(), color_stops.data(), colors.size(), |
| 26 SkShader::kClamp_TileMode); | 28 static_cast<SkShader::TileMode>(tile_mode)); |
| 27 set_shader(adoptRef(shader)); | 29 set_shader(adoptRef(shader)); |
| 28 } | 30 } |
| 29 | 31 |
| 30 void CanvasGradient::initRadial(const Point& center, | 32 void CanvasGradient::initRadial(const Point& center, |
| 31 double radius, | 33 double radius, |
| 32 const Vector<SkColor>& colors, | 34 const Vector<SkColor>& colors, |
| 33 const Vector<float>& color_stops) { | 35 const Vector<float>& color_stops, |
| 36 unsigned tile_mode) { |
| 34 ASSERT(colors.size() == color_stops.size() || color_stops.data() == nullptr); | 37 ASSERT(colors.size() == color_stops.size() || color_stops.data() == nullptr); |
| 38 ASSERT(tile_mode < SkShader::kTileModeCount); |
| 35 | 39 |
| 36 SkShader* shader = SkGradientShader::CreateRadial( | 40 SkShader* shader = SkGradientShader::CreateRadial( |
| 37 center.sk_point, radius, colors.data(), color_stops.data(), colors.size(), | 41 center.sk_point, radius, colors.data(), color_stops.data(), colors.size(), |
| 38 SkShader::kClamp_TileMode); | 42 static_cast<SkShader::TileMode>(tile_mode)); |
| 39 set_shader(adoptRef(shader)); | 43 set_shader(adoptRef(shader)); |
| 40 } | 44 } |
| 41 | 45 |
| 42 CanvasGradient::CanvasGradient() | 46 CanvasGradient::CanvasGradient() |
| 43 : Shader(nullptr) | 47 : Shader(nullptr) |
| 44 { | 48 { |
| 45 } | 49 } |
| 46 | 50 |
| 47 CanvasGradient::~CanvasGradient() | 51 CanvasGradient::~CanvasGradient() |
| 48 { | 52 { |
| 49 } | 53 } |
| 50 | 54 |
| 51 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |