| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef CanvasStyle_h | 27 #ifndef CanvasStyle_h |
| 28 #define CanvasStyle_h | 28 #define CanvasStyle_h |
| 29 | 29 |
| 30 #include "platform/graphics/Color.h" | 30 #include "platform/graphics/Color.h" |
| 31 #include "platform/graphics/paint/PaintFlags.h" |
| 31 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
| 32 #include "wtf/Assertions.h" | 33 #include "wtf/Assertions.h" |
| 33 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 34 | 35 |
| 35 class SkPaint; | |
| 36 | |
| 37 namespace blink { | 36 namespace blink { |
| 38 | 37 |
| 39 class CanvasGradient; | 38 class CanvasGradient; |
| 40 class CanvasPattern; | 39 class CanvasPattern; |
| 41 class HTMLCanvasElement; | 40 class HTMLCanvasElement; |
| 42 | 41 |
| 43 class CanvasStyle final : public GarbageCollected<CanvasStyle> { | 42 class CanvasStyle final : public GarbageCollected<CanvasStyle> { |
| 44 public: | 43 public: |
| 45 static CanvasStyle* createFromRGBA(RGBA32 rgba) { | 44 static CanvasStyle* createFromRGBA(RGBA32 rgba) { |
| 46 return new CanvasStyle(rgba); | 45 return new CanvasStyle(rgba); |
| 47 } | 46 } |
| 48 static CanvasStyle* createFromGradient(CanvasGradient*); | 47 static CanvasStyle* createFromGradient(CanvasGradient*); |
| 49 static CanvasStyle* createFromPattern(CanvasPattern*); | 48 static CanvasStyle* createFromPattern(CanvasPattern*); |
| 50 | 49 |
| 51 String color() const { | 50 String color() const { |
| 52 ASSERT(m_type == ColorRGBA); | 51 ASSERT(m_type == ColorRGBA); |
| 53 return Color(m_rgba).serialized(); | 52 return Color(m_rgba).serialized(); |
| 54 } | 53 } |
| 55 CanvasGradient* getCanvasGradient() const { return m_gradient.get(); } | 54 CanvasGradient* getCanvasGradient() const { return m_gradient.get(); } |
| 56 CanvasPattern* getCanvasPattern() const { return m_pattern; } | 55 CanvasPattern* getCanvasPattern() const { return m_pattern; } |
| 57 | 56 |
| 58 void applyToPaint(SkPaint&) const; | 57 void applyToPaint(PaintFlags&) const; |
| 59 RGBA32 paintColor() const; | 58 RGBA32 paintColor() const; |
| 60 | 59 |
| 61 bool isEquivalentRGBA(RGBA32 rgba) const { | 60 bool isEquivalentRGBA(RGBA32 rgba) const { |
| 62 return m_type == ColorRGBA && m_rgba == rgba; | 61 return m_type == ColorRGBA && m_rgba == rgba; |
| 63 } | 62 } |
| 64 | 63 |
| 65 DECLARE_TRACE(); | 64 DECLARE_TRACE(); |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 enum Type { ColorRGBA, Gradient, ImagePattern }; | 67 enum Type { ColorRGBA, Gradient, ImagePattern }; |
| 69 | 68 |
| 70 CanvasStyle(RGBA32); | 69 CanvasStyle(RGBA32); |
| 71 CanvasStyle(CanvasGradient*); | 70 CanvasStyle(CanvasGradient*); |
| 72 CanvasStyle(CanvasPattern*); | 71 CanvasStyle(CanvasPattern*); |
| 73 | 72 |
| 74 Type m_type; | 73 Type m_type; |
| 75 RGBA32 m_rgba; | 74 RGBA32 m_rgba; |
| 76 | 75 |
| 77 Member<CanvasGradient> m_gradient; | 76 Member<CanvasGradient> m_gradient; |
| 78 Member<CanvasPattern> m_pattern; | 77 Member<CanvasPattern> m_pattern; |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 bool parseColorOrCurrentColor(Color& parsedColor, | 80 bool parseColorOrCurrentColor(Color& parsedColor, |
| 82 const String& colorString, | 81 const String& colorString, |
| 83 HTMLCanvasElement*); | 82 HTMLCanvasElement*); |
| 84 | 83 |
| 85 } // namespace blink | 84 } // namespace blink |
| 86 | 85 |
| 87 #endif | 86 #endif |
| OLD | NEW |