| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 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) 2008 Torch Mobile, Inc. | 4 * Copyright (C) 2008 Torch Mobile, Inc. |
| 5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #ifndef Gradient_h | 29 #ifndef Gradient_h |
| 30 #define Gradient_h | 30 #define Gradient_h |
| 31 | 31 |
| 32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
| 33 #include "platform/geometry/FloatPoint.h" | 33 #include "platform/geometry/FloatPoint.h" |
| 34 #include "platform/graphics/Color.h" | 34 #include "platform/graphics/Color.h" |
| 35 #include "platform/graphics/GraphicsTypes.h" | 35 #include "platform/graphics/GraphicsTypes.h" |
| 36 #include "platform/transforms/AffineTransform.h" | |
| 37 #include "third_party/skia/include/core/SkRefCnt.h" | 36 #include "third_party/skia/include/core/SkRefCnt.h" |
| 38 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
| 39 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 40 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
| 41 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 42 | 41 |
| 42 class SkMatrix; |
| 43 class SkPaint; | 43 class SkPaint; |
| 44 class SkShader; | 44 class SkShader; |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 class PLATFORM_EXPORT Gradient : public RefCounted<Gradient> { | 48 class PLATFORM_EXPORT Gradient : public RefCounted<Gradient> { |
| 49 WTF_MAKE_NONCOPYABLE(Gradient); | 49 WTF_MAKE_NONCOPYABLE(Gradient); |
| 50 public: | 50 public: |
| 51 static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p
1) | 51 static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p
1) |
| 52 { | 52 { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 void setEndRadius(float r) | 104 void setEndRadius(float r) |
| 105 { | 105 { |
| 106 if (m_r1 == r) | 106 if (m_r1 == r) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 m_r1 = r; | 109 m_r1 = r; |
| 110 } | 110 } |
| 111 | 111 |
| 112 float aspectRatio() const { return m_aspectRatio; } | 112 void applyToPaint(SkPaint&, const SkMatrix& localMatrix); |
| 113 | |
| 114 void applyToPaint(SkPaint&); | |
| 115 | 113 |
| 116 void setDrawsInPMColorSpace(bool drawInPMColorSpace); | 114 void setDrawsInPMColorSpace(bool drawInPMColorSpace); |
| 117 | 115 |
| 118 void setSpreadMethod(GradientSpreadMethod); | 116 void setSpreadMethod(GradientSpreadMethod); |
| 119 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; } | 117 GradientSpreadMethod spreadMethod() const { return m_spreadMethod; } |
| 120 void setGradientSpaceTransform(const AffineTransform& gradientSpaceTransform
ation); | |
| 121 AffineTransform gradientSpaceTransform() { return m_gradientSpaceTransformat
ion; } | |
| 122 | 118 |
| 123 private: | 119 private: |
| 124 Gradient(const FloatPoint& p0, const FloatPoint& p1); | 120 Gradient(const FloatPoint& p0, const FloatPoint& p1); |
| 125 Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1, flo
at aspectRatio); | 121 Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1, flo
at aspectRatio); |
| 126 | 122 |
| 127 sk_sp<SkShader> createShader(); | 123 sk_sp<SkShader> createShader(const SkMatrix& localMatrix); |
| 128 | 124 |
| 129 void sortStopsIfNecessary(); | 125 void sortStopsIfNecessary(); |
| 130 | 126 |
| 131 FloatPoint m_p0; | 127 FloatPoint m_p0; |
| 132 FloatPoint m_p1; | 128 FloatPoint m_p1; |
| 133 float m_r0; | 129 float m_r0; |
| 134 float m_r1; | 130 float m_r1; |
| 135 float m_aspectRatio; // For elliptical gradient, width / height. | 131 float m_aspectRatio; // For elliptical gradient, width / height. |
| 136 Vector<ColorStop, 2> m_stops; | 132 Vector<ColorStop, 2> m_stops; |
| 137 bool m_radial; | 133 bool m_radial; |
| 138 bool m_stopsSorted; | 134 bool m_stopsSorted; |
| 139 bool m_drawInPMColorSpace; | 135 bool m_drawInPMColorSpace; |
| 140 GradientSpreadMethod m_spreadMethod; | 136 GradientSpreadMethod m_spreadMethod; |
| 141 AffineTransform m_gradientSpaceTransformation; | |
| 142 | 137 |
| 143 sk_sp<SkShader> m_gradient; | 138 mutable sk_sp<SkShader> m_cachedShader; |
| 144 }; | 139 }; |
| 145 | 140 |
| 146 } // namespace blink | 141 } // namespace blink |
| 147 | 142 |
| 148 #endif | 143 #endif |
| OLD | NEW |