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

Unified Diff: sky/engine/core/painting/CanvasGradient.cpp

Issue 1166223004: Sky: Allow clients to specify tile mode for gradients (repeating or mirror). (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: sky/engine/core/painting/CanvasGradient.cpp
diff --git a/sky/engine/core/painting/CanvasGradient.cpp b/sky/engine/core/painting/CanvasGradient.cpp
index b1d8cf1f7447177ae99ec6a3a5d253a3b4e1c66d..5ceaae149883336a51b08da8a9d848fff4b6b101 100644
--- a/sky/engine/core/painting/CanvasGradient.cpp
+++ b/sky/engine/core/painting/CanvasGradient.cpp
@@ -13,9 +13,11 @@ PassRefPtr<CanvasGradient> CanvasGradient::create() {
void CanvasGradient::initLinear(const Vector<Point>& end_points,
const Vector<SkColor>& colors,
- const Vector<float>& color_stops) {
+ const Vector<float>& color_stops,
+ unsigned tile_mode) {
ASSERT(end_points.size() == 2);
ASSERT(colors.size() == color_stops.size() || color_stops.data() == nullptr);
+ ASSERT(tile_mode < SkShader::kTileModeCount);
SkPoint sk_end_points[2];
for (int i = 0; i < 2; ++i)
sk_end_points[i] = end_points[i].sk_point;
@@ -23,19 +25,21 @@ void CanvasGradient::initLinear(const Vector<Point>& end_points,
// TODO(mpcomplete): allow setting the TileMode.
SkShader* shader = SkGradientShader::CreateLinear(
sk_end_points, colors.data(), color_stops.data(), colors.size(),
- SkShader::kClamp_TileMode);
+ static_cast<SkShader::TileMode>(tile_mode));
set_shader(adoptRef(shader));
}
void CanvasGradient::initRadial(const Point& center,
double radius,
const Vector<SkColor>& colors,
- const Vector<float>& color_stops) {
+ const Vector<float>& color_stops,
+ unsigned tile_mode) {
ASSERT(colors.size() == color_stops.size() || color_stops.data() == nullptr);
+ ASSERT(tile_mode < SkShader::kTileModeCount);
SkShader* shader = SkGradientShader::CreateRadial(
center.sk_point, radius, colors.data(), color_stops.data(), colors.size(),
- SkShader::kClamp_TileMode);
+ static_cast<SkShader::TileMode>(tile_mode));
set_shader(adoptRef(shader));
}

Powered by Google App Engine
This is Rietveld 408576698