OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
6 * reserved. | 6 * reserved. |
7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "core/css/StyleColor.h" | 29 #include "core/css/StyleColor.h" |
30 #include "platform/geometry/FloatPoint.h" | 30 #include "platform/geometry/FloatPoint.h" |
31 #include "platform/geometry/FloatRectOutsets.h" | 31 #include "platform/geometry/FloatRectOutsets.h" |
32 #include "platform/graphics/skia/SkiaUtils.h" | 32 #include "platform/graphics/skia/SkiaUtils.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 enum ShadowStyle { Normal, Inset }; | 36 enum ShadowStyle { Normal, Inset }; |
37 | 37 |
38 // This class holds information about shadows for the text-shadow and box-shadow | 38 // This class holds information about shadows for the text-shadow and box-shadow |
39 // properties. | 39 // properties, as well as the drop-shadow(...) filter operation. |
40 class ShadowData { | 40 class ShadowData { |
41 USING_FAST_MALLOC(ShadowData); | 41 USING_FAST_MALLOC(ShadowData); |
42 | 42 |
43 public: | 43 public: |
44 ShadowData(const FloatPoint& location, | 44 ShadowData(const FloatPoint& location, |
45 float blur, | 45 float blur, |
46 float spread, | 46 float spread, |
47 ShadowStyle style, | 47 ShadowStyle style, |
48 StyleColor color) | 48 StyleColor color) |
49 : m_location(location), | 49 : m_location(location), |
50 m_blur(blur), | 50 m_blur(blur), |
51 m_spread(spread), | 51 m_spread(spread), |
52 m_color(color), | 52 m_color(color), |
53 m_style(style) {} | 53 m_style(style) {} |
54 | 54 |
55 bool operator==(const ShadowData&) const; | 55 bool operator==(const ShadowData&) const; |
56 bool operator!=(const ShadowData& o) const { return !(*this == o); } | 56 bool operator!=(const ShadowData& o) const { return !(*this == o); } |
57 | 57 |
58 ShadowData blend(const ShadowData& from, | 58 ShadowData blend(const ShadowData& from, |
59 double progress, | 59 double progress, |
60 const Color& currentColor) const; | 60 const Color& currentColor) const; |
| 61 static ShadowData neutralValue(); |
61 | 62 |
62 float x() const { return m_location.x(); } | 63 float x() const { return m_location.x(); } |
63 float y() const { return m_location.y(); } | 64 float y() const { return m_location.y(); } |
64 FloatPoint location() const { return m_location; } | 65 FloatPoint location() const { return m_location; } |
65 float blur() const { return m_blur; } | 66 float blur() const { return m_blur; } |
66 float spread() const { return m_spread; } | 67 float spread() const { return m_spread; } |
67 ShadowStyle style() const { return m_style; } | 68 ShadowStyle style() const { return m_style; } |
68 StyleColor color() const { return m_color; } | 69 StyleColor color() const { return m_color; } |
69 | 70 |
| 71 void overrideColor(Color color) { m_color = StyleColor(color); } |
| 72 |
70 // Outsets needed to adjust a source rectangle to the one cast by this | 73 // Outsets needed to adjust a source rectangle to the one cast by this |
71 // shadow. | 74 // shadow. |
72 FloatRectOutsets rectOutsets() const { | 75 FloatRectOutsets rectOutsets() const { |
73 // 3 * skBlurRadiusToSigma(blur()) is how Skia implements the radius of a | 76 // 3 * skBlurRadiusToSigma(blur()) is how Skia implements the radius of a |
74 // blur. See also https://crbug.com/624175. | 77 // blur. See also https://crbug.com/624175. |
75 float blurAndSpread = ceil(3 * skBlurRadiusToSigma(blur())) + spread(); | 78 float blurAndSpread = ceil(3 * skBlurRadiusToSigma(blur())) + spread(); |
76 return FloatRectOutsets( | 79 return FloatRectOutsets( |
77 blurAndSpread - y() /* top */, blurAndSpread + x() /* right */, | 80 blurAndSpread - y() /* top */, blurAndSpread + x() /* right */, |
78 blurAndSpread + y() /* bottom */, blurAndSpread - x() /* left */); | 81 blurAndSpread + y() /* bottom */, blurAndSpread - x() /* left */); |
79 } | 82 } |
80 | 83 |
81 private: | 84 private: |
82 FloatPoint m_location; | 85 FloatPoint m_location; |
83 float m_blur; | 86 float m_blur; |
84 float m_spread; | 87 float m_spread; |
85 StyleColor m_color; | 88 StyleColor m_color; |
86 ShadowStyle m_style; | 89 ShadowStyle m_style; |
87 }; | 90 }; |
88 | 91 |
89 } // namespace blink | 92 } // namespace blink |
90 | 93 |
91 #endif // ShadowData_h | 94 #endif // ShadowData_h |
OLD | NEW |