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

Side by Side Diff: sky/engine/core/painting/CanvasGradient.cpp

Issue 1170963003: Sky: Add a DartConverterEnum and use that for all our enum needs. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: 360 no scope Created 5 years, 6 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 | « sky/engine/core/painting/CanvasGradient.h ('k') | sky/engine/core/painting/Gradient.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SkShader::TileMode tile_mode) {
18 ASSERT(end_points.size() == 2); 18 ASSERT(end_points.size() == 2);
19 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); 20 ASSERT(tile_mode < SkShader::kTileModeCount);
21 SkPoint sk_end_points[2]; 21 SkPoint sk_end_points[2];
22 for (int i = 0; i < 2; ++i) 22 for (int i = 0; i < 2; ++i)
23 sk_end_points[i] = end_points[i].sk_point; 23 sk_end_points[i] = end_points[i].sk_point;
24 24
25 // TODO(mpcomplete): allow setting the TileMode. 25 // TODO(mpcomplete): allow setting the TileMode.
26 SkShader* shader = SkGradientShader::CreateLinear( 26 SkShader* shader = SkGradientShader::CreateLinear(
27 sk_end_points, colors.data(), color_stops.data(), colors.size(), 27 sk_end_points, colors.data(), color_stops.data(), colors.size(),
28 static_cast<SkShader::TileMode>(tile_mode)); 28 tile_mode);
29 set_shader(adoptRef(shader)); 29 set_shader(adoptRef(shader));
30 } 30 }
31 31
32 void CanvasGradient::initRadial(const Point& center, 32 void CanvasGradient::initRadial(const Point& center,
33 double radius, 33 double radius,
34 const Vector<SkColor>& colors, 34 const Vector<SkColor>& colors,
35 const Vector<float>& color_stops, 35 const Vector<float>& color_stops,
36 unsigned tile_mode) { 36 SkShader::TileMode tile_mode) {
37 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); 38 ASSERT(tile_mode < SkShader::kTileModeCount);
39 39
40 SkShader* shader = SkGradientShader::CreateRadial( 40 SkShader* shader = SkGradientShader::CreateRadial(
41 center.sk_point, radius, colors.data(), color_stops.data(), colors.size(), 41 center.sk_point, radius, colors.data(), color_stops.data(), colors.size(),
42 static_cast<SkShader::TileMode>(tile_mode)); 42 tile_mode);
43 set_shader(adoptRef(shader)); 43 set_shader(adoptRef(shader));
44 } 44 }
45 45
46 CanvasGradient::CanvasGradient() 46 CanvasGradient::CanvasGradient()
47 : Shader(nullptr) 47 : Shader(nullptr)
48 { 48 {
49 } 49 }
50 50
51 CanvasGradient::~CanvasGradient() 51 CanvasGradient::~CanvasGradient()
52 { 52 {
53 } 53 }
54 54
55 } // namespace blink 55 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/painting/CanvasGradient.h ('k') | sky/engine/core/painting/Gradient.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698