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