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 15 matching lines...) Expand all Loading... |
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/heap/Handle.h" | 31 #include "platform/heap/Handle.h" |
32 #include "wtf/Assertions.h" | 32 #include "wtf/Assertions.h" |
33 #include "wtf/RefCounted.h" | 33 #include "wtf/RefCounted.h" |
34 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
35 | 35 |
| 36 class SkShader; |
| 37 |
36 namespace blink { | 38 namespace blink { |
37 | 39 |
38 class CanvasGradient; | 40 class CanvasGradient; |
39 class CanvasPattern; | 41 class CanvasPattern; |
40 class GraphicsContext; | 42 class GraphicsContext; |
41 class HTMLCanvasElement; | 43 class HTMLCanvasElement; |
42 | 44 |
43 class CanvasStyle final : public RefCountedWillBeGarbageCollected<CanvasStyl
e> { | 45 class CanvasStyle final : public RefCountedWillBeGarbageCollected<CanvasStyl
e> { |
44 public: | 46 public: |
45 static PassRefPtrWillBeRawPtr<CanvasStyle> createFromRGBA(RGBA32 rgba) {
return adoptRefWillBeNoop(new CanvasStyle(rgba)); } | 47 static PassRefPtrWillBeRawPtr<CanvasStyle> createFromRGBA(RGBA32 rgba) {
return adoptRefWillBeNoop(new CanvasStyle(rgba)); } |
46 static PassRefPtrWillBeRawPtr<CanvasStyle> createFromGradient(PassRefPtr
WillBeRawPtr<CanvasGradient>); | 48 static PassRefPtrWillBeRawPtr<CanvasStyle> createFromGradient(PassRefPtr
WillBeRawPtr<CanvasGradient>); |
47 static PassRefPtrWillBeRawPtr<CanvasStyle> createFromPattern(PassRefPtrW
illBeRawPtr<CanvasPattern>); | 49 static PassRefPtrWillBeRawPtr<CanvasStyle> createFromPattern(PassRefPtrW
illBeRawPtr<CanvasPattern>); |
48 | 50 |
49 String color() const { ASSERT(m_type == ColorRGBA); return Color(m_rgba)
.serialized(); } | 51 String color() const { ASSERT(m_type == ColorRGBA); return Color(m_rgba)
.serialized(); } |
50 CanvasGradient* canvasGradient() const { return m_gradient.get(); } | 52 CanvasGradient* canvasGradient() const { return m_gradient.get(); } |
51 CanvasPattern* canvasPattern() const { return m_pattern.get(); } | 53 CanvasPattern* canvasPattern() const { return m_pattern.get(); } |
52 | 54 |
53 void applyFillColor(GraphicsContext*); | 55 void applyFillColor(GraphicsContext*); // Deprecated |
54 void applyStrokeColor(GraphicsContext*); | 56 void applyStrokeColor(GraphicsContext*); // Deprecated |
| 57 SkShader* shader() const; |
| 58 RGBA32 paintColor() const; |
55 | 59 |
56 bool isEquivalentRGBA(RGBA32 rgba) const { return m_type == ColorRGBA &&
m_rgba == rgba; } | 60 bool isEquivalentRGBA(RGBA32 rgba) const { return m_type == ColorRGBA &&
m_rgba == rgba; } |
57 | 61 |
58 DECLARE_TRACE(); | 62 DECLARE_TRACE(); |
59 | 63 |
60 private: | 64 private: |
61 enum Type { ColorRGBA, Gradient, ImagePattern }; | 65 enum Type { ColorRGBA, Gradient, ImagePattern }; |
62 | 66 |
63 CanvasStyle(RGBA32 rgba); | 67 CanvasStyle(RGBA32 rgba); |
64 CanvasStyle(PassRefPtrWillBeRawPtr<CanvasGradient>); | 68 CanvasStyle(PassRefPtrWillBeRawPtr<CanvasGradient>); |
65 CanvasStyle(PassRefPtrWillBeRawPtr<CanvasPattern>); | 69 CanvasStyle(PassRefPtrWillBeRawPtr<CanvasPattern>); |
66 | 70 |
67 Type m_type; | 71 Type m_type; |
68 RGBA32 m_rgba; | 72 RGBA32 m_rgba; |
69 | 73 |
70 RefPtrWillBeMember<CanvasGradient> m_gradient; | 74 RefPtrWillBeMember<CanvasGradient> m_gradient; |
71 RefPtrWillBeMember<CanvasPattern> m_pattern; | 75 RefPtrWillBeMember<CanvasPattern> m_pattern; |
72 }; | 76 }; |
73 | 77 |
74 bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString
, HTMLCanvasElement*); | 78 bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString
, HTMLCanvasElement*); |
75 | 79 |
76 } // namespace blink | 80 } // namespace blink |
77 | 81 |
78 #endif | 82 #endif |
OLD | NEW |