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 reserv
ed. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
| 6 * reserved. |
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
7 * | 8 * |
8 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
12 * | 13 * |
13 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
(...skipping 11 matching lines...) Expand all Loading... |
27 | 28 |
28 #include "core/css/StyleColor.h" | 29 #include "core/css/StyleColor.h" |
29 #include "platform/geometry/FloatPoint.h" | 30 #include "platform/geometry/FloatPoint.h" |
30 #include "platform/geometry/FloatRectOutsets.h" | 31 #include "platform/geometry/FloatRectOutsets.h" |
31 #include "platform/graphics/skia/SkiaUtils.h" | 32 #include "platform/graphics/skia/SkiaUtils.h" |
32 | 33 |
33 namespace blink { | 34 namespace blink { |
34 | 35 |
35 enum ShadowStyle { Normal, Inset }; | 36 enum ShadowStyle { Normal, Inset }; |
36 | 37 |
37 // This class holds information about shadows for the text-shadow and box-shadow
properties. | 38 // This class holds information about shadows for the text-shadow and box-shadow |
| 39 // properties. |
38 class ShadowData { | 40 class ShadowData { |
39 USING_FAST_MALLOC(ShadowData); | 41 USING_FAST_MALLOC(ShadowData); |
40 | 42 |
41 public: | 43 public: |
42 ShadowData(const FloatPoint& location, | 44 ShadowData(const FloatPoint& location, |
43 float blur, | 45 float blur, |
44 float spread, | 46 float spread, |
45 ShadowStyle style, | 47 ShadowStyle style, |
46 StyleColor color) | 48 StyleColor color) |
47 : m_location(location), | 49 : m_location(location), |
(...skipping 13 matching lines...) Expand all Loading... |
61 float y() const { return m_location.y(); } | 63 float y() const { return m_location.y(); } |
62 FloatPoint location() const { return m_location; } | 64 FloatPoint location() const { return m_location; } |
63 float blur() const { return m_blur; } | 65 float blur() const { return m_blur; } |
64 float spread() const { return m_spread; } | 66 float spread() const { return m_spread; } |
65 ShadowStyle style() const { return m_style; } | 67 ShadowStyle style() const { return m_style; } |
66 StyleColor color() const { return m_color; } | 68 StyleColor color() const { return m_color; } |
67 | 69 |
68 // Outsets needed to adjust a source rectangle to the one cast by this | 70 // Outsets needed to adjust a source rectangle to the one cast by this |
69 // shadow. | 71 // shadow. |
70 FloatRectOutsets rectOutsets() const { | 72 FloatRectOutsets rectOutsets() const { |
71 // 3 * skBlurRadiusToSigma(blur()) is how Skia implements the radius of a bl
ur. See also | 73 // 3 * skBlurRadiusToSigma(blur()) is how Skia implements the radius of a |
72 // https://crbug.com/624175. | 74 // blur. See also https://crbug.com/624175. |
73 float blurAndSpread = ceil(3 * skBlurRadiusToSigma(blur())) + spread(); | 75 float blurAndSpread = ceil(3 * skBlurRadiusToSigma(blur())) + spread(); |
74 return FloatRectOutsets( | 76 return FloatRectOutsets( |
75 blurAndSpread - y() /* top */, blurAndSpread + x() /* right */, | 77 blurAndSpread - y() /* top */, blurAndSpread + x() /* right */, |
76 blurAndSpread + y() /* bottom */, blurAndSpread - x() /* left */); | 78 blurAndSpread + y() /* bottom */, blurAndSpread - x() /* left */); |
77 } | 79 } |
78 | 80 |
79 private: | 81 private: |
80 FloatPoint m_location; | 82 FloatPoint m_location; |
81 float m_blur; | 83 float m_blur; |
82 float m_spread; | 84 float m_spread; |
83 StyleColor m_color; | 85 StyleColor m_color; |
84 ShadowStyle m_style; | 86 ShadowStyle m_style; |
85 }; | 87 }; |
86 | 88 |
87 } // namespace blink | 89 } // namespace blink |
88 | 90 |
89 #endif // ShadowData_h | 91 #endif // ShadowData_h |
OLD | NEW |