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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Gradient.cpp

Issue 2792163002: Add support for repeating-conic-gradient() (Closed)
Patch Set: baselines Created 3 years, 8 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 | « third_party/WebKit/Source/platform/graphics/Gradient.h ('k') | no next file » | 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) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2013 Google Inc. All rights reserved. 4 * Copyright (C) 2013 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 const FloatPoint m_p1; 252 const FloatPoint m_p1;
253 const float m_r0; 253 const float m_r0;
254 const float m_r1; 254 const float m_r1;
255 const float m_aspectRatio; // For elliptical gradient, width / height. 255 const float m_aspectRatio; // For elliptical gradient, width / height.
256 }; 256 };
257 257
258 class ConicGradient final : public Gradient { 258 class ConicGradient final : public Gradient {
259 public: 259 public:
260 ConicGradient(const FloatPoint& position, 260 ConicGradient(const FloatPoint& position,
261 float angle, 261 float angle,
262 GradientSpreadMethod spreadMethod,
263 ColorInterpolation interpolation) 262 ColorInterpolation interpolation)
264 : Gradient(Type::Conic, spreadMethod, interpolation), 263 : Gradient(Type::Conic, SpreadMethodPad, interpolation),
265 m_position(position), 264 m_position(position),
266 m_angle(angle) {} 265 m_angle(angle) {}
267 266
268 protected: 267 protected:
269 sk_sp<SkShader> createShader(const ColorBuffer& colors, 268 sk_sp<SkShader> createShader(const ColorBuffer& colors,
270 const OffsetBuffer& pos, 269 const OffsetBuffer& pos,
271 SkShader::TileMode tileMode, 270 SkShader::TileMode tileMode,
272 uint32_t flags, 271 uint32_t flags,
273 const SkMatrix& localMatrix) const override { 272 const SkMatrix& localMatrix) const override {
274 if (tileMode != SkShader::kClamp_TileMode) { 273 DCHECK_NE(tileMode, SkShader::kMirror_TileMode);
275 // TODO(fmalita): kRepeat support
276 return nullptr;
277 }
278 274
279 // Skia's sweep gradient angles are relative to the x-axis, not the y-axis. 275 // Skia's sweep gradient angles are relative to the x-axis, not the y-axis.
280 const float skiaAngle = m_angle - 90; 276 const float skiaAngle = m_angle - 90;
281 SkTCopyOnFirstWrite<SkMatrix> adjustedLocalMatrix(localMatrix); 277 SkTCopyOnFirstWrite<SkMatrix> adjustedLocalMatrix(localMatrix);
282 if (skiaAngle) { 278 if (skiaAngle) {
283 adjustedLocalMatrix.writable()->preRotate(skiaAngle, m_position.x(), 279 adjustedLocalMatrix.writable()->preRotate(skiaAngle, m_position.x(),
284 m_position.y()); 280 m_position.y());
285 } 281 }
286 282
287 return SkGradientShader::MakeSweep( 283 return SkGradientShader::MakeSweep(
(...skipping 21 matching lines...) Expand all
309 float r1, 305 float r1,
310 float aspectRatio, 306 float aspectRatio,
311 GradientSpreadMethod spreadMethod, 307 GradientSpreadMethod spreadMethod,
312 ColorInterpolation interpolation) { 308 ColorInterpolation interpolation) {
313 return adoptRef(new RadialGradient(p0, r0, p1, r1, aspectRatio, spreadMethod, 309 return adoptRef(new RadialGradient(p0, r0, p1, r1, aspectRatio, spreadMethod,
314 interpolation)); 310 interpolation));
315 } 311 }
316 312
317 PassRefPtr<Gradient> Gradient::createConic(const FloatPoint& position, 313 PassRefPtr<Gradient> Gradient::createConic(const FloatPoint& position,
318 float angle, 314 float angle,
319 GradientSpreadMethod spreadMethod,
320 ColorInterpolation interpolation) { 315 ColorInterpolation interpolation) {
321 return adoptRef( 316 return adoptRef(new ConicGradient(position, angle, interpolation));
322 new ConicGradient(position, angle, spreadMethod, interpolation));
323 } 317 }
324 318
325 } // namespace blink 319 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Gradient.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698