OLD | NEW |
1 // Copyright (C) 2013 Google Inc. All rights reserved. | 1 // Copyright (C) 2013 Google Inc. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
(...skipping 19 matching lines...) Expand all Loading... |
30 #define GraphicsContextState_h | 30 #define GraphicsContextState_h |
31 | 31 |
32 #include "platform/graphics/DrawLooperBuilder.h" | 32 #include "platform/graphics/DrawLooperBuilder.h" |
33 #include "platform/graphics/Gradient.h" | 33 #include "platform/graphics/Gradient.h" |
34 #include "platform/graphics/GraphicsTypes.h" | 34 #include "platform/graphics/GraphicsTypes.h" |
35 #include "platform/graphics/Path.h" | 35 #include "platform/graphics/Path.h" |
36 #include "platform/graphics/Pattern.h" | 36 #include "platform/graphics/Pattern.h" |
37 #include "platform/graphics/StrokeData.h" | 37 #include "platform/graphics/StrokeData.h" |
38 #include "platform/graphics/skia/SkiaUtils.h" | 38 #include "platform/graphics/skia/SkiaUtils.h" |
39 #include "third_party/skia/include/core/SkColorFilter.h" | 39 #include "third_party/skia/include/core/SkColorFilter.h" |
40 #include "third_party/skia/include/core/SkImageFilter.h" | |
41 #include "third_party/skia/include/core/SkPaint.h" | 40 #include "third_party/skia/include/core/SkPaint.h" |
42 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
43 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
44 | 43 |
45 namespace blink { | 44 namespace blink { |
46 | 45 |
47 // Encapsulates the state information we store for each pushed graphics state. | 46 // Encapsulates the state information we store for each pushed graphics state. |
48 // Only GraphicsContext can use this class. | 47 // Only GraphicsContext can use this class. |
49 class PLATFORM_EXPORT GraphicsContextState final { | 48 class PLATFORM_EXPORT GraphicsContextState final { |
50 public: | 49 public: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 // Path fill rule | 101 // Path fill rule |
103 WindRule fillRule() const { return m_fillRule; } | 102 WindRule fillRule() const { return m_fillRule; } |
104 void setFillRule(WindRule rule) { m_fillRule = rule; } | 103 void setFillRule(WindRule rule) { m_fillRule = rule; } |
105 | 104 |
106 // Shadow. (This will need tweaking if we use draw loopers for other things.
) | 105 // Shadow. (This will need tweaking if we use draw loopers for other things.
) |
107 SkDrawLooper* drawLooper() const { return m_looper.get(); } | 106 SkDrawLooper* drawLooper() const { return m_looper.get(); } |
108 void setDrawLooper(PassRefPtr<SkDrawLooper>); | 107 void setDrawLooper(PassRefPtr<SkDrawLooper>); |
109 void clearDrawLooper(); | 108 void clearDrawLooper(); |
110 | 109 |
111 SkImageFilter* dropShadowImageFilter() const { return m_dropShadowImageFilte
r.get(); } | |
112 void setDropShadowImageFilter(PassRefPtr<SkImageFilter>); | |
113 void clearDropShadowImageFilter(); | |
114 | |
115 // Text. (See TextModeFill & friends.) | 110 // Text. (See TextModeFill & friends.) |
116 TextDrawingModeFlags textDrawingMode() const { return m_textDrawingMode; } | 111 TextDrawingModeFlags textDrawingMode() const { return m_textDrawingMode; } |
117 void setTextDrawingMode(TextDrawingModeFlags mode) { m_textDrawingMode = mod
e; } | 112 void setTextDrawingMode(TextDrawingModeFlags mode) { m_textDrawingMode = mod
e; } |
118 | 113 |
119 // Common shader state. | 114 // Common shader state. |
120 int alpha() const { return m_alpha; } | 115 int alpha() const { return m_alpha; } |
121 void setAlphaAsFloat(float); | |
122 | 116 |
123 SkColorFilter* colorFilter() const { return m_colorFilter.get(); } | 117 SkColorFilter* colorFilter() const { return m_colorFilter.get(); } |
124 void setColorFilter(PassRefPtr<SkColorFilter>); | 118 void setColorFilter(PassRefPtr<SkColorFilter>); |
125 | 119 |
126 // Compositing control, for the CSS and Canvas compositing spec. | 120 // Compositing control, for the CSS spec. |
127 void setCompositeOperation(SkXfermode::Mode); | 121 void setCompositeOperation(SkXfermode::Mode); |
128 SkXfermode::Mode compositeOperation() const { return m_compositeOperation; } | 122 SkXfermode::Mode compositeOperation() const { return m_compositeOperation; } |
129 | 123 |
130 // Image interpolation control. | 124 // Image interpolation control. |
131 InterpolationQuality interpolationQuality() const { return m_interpolationQu
ality; } | 125 InterpolationQuality interpolationQuality() const { return m_interpolationQu
ality; } |
132 void setInterpolationQuality(InterpolationQuality); | 126 void setInterpolationQuality(InterpolationQuality); |
133 | 127 |
134 bool shouldAntialias() const { return m_shouldAntialias; } | 128 bool shouldAntialias() const { return m_shouldAntialias; } |
135 void setShouldAntialias(bool); | 129 void setShouldAntialias(bool); |
136 | 130 |
137 bool shouldClampToSourceRect() const { return m_shouldClampToSourceRect; } | |
138 void setShouldClampToSourceRect(bool shouldClampToSourceRect) { m_shouldClam
pToSourceRect = shouldClampToSourceRect; } | |
139 | |
140 private: | 131 private: |
141 GraphicsContextState(); | 132 GraphicsContextState(); |
142 explicit GraphicsContextState(const GraphicsContextState&); | 133 explicit GraphicsContextState(const GraphicsContextState&); |
143 GraphicsContextState& operator=(const GraphicsContextState&); | 134 GraphicsContextState& operator=(const GraphicsContextState&); |
144 | 135 |
145 // Helper function for applying the state's alpha value to the given input | 136 // Helper function for applying the state's alpha value to the given input |
146 // color to produce a new output color. | 137 // color to produce a new output color. |
147 SkColor applyAlpha(SkColor color) const | 138 SkColor applyAlpha(SkColor color) const |
148 { | 139 { |
149 return scaleAlpha(color, m_alpha); | 140 return scaleAlpha(color, m_alpha); |
150 } | 141 } |
151 | 142 |
152 // These are mutbale to enable gradient updates when the paints are fetched
for use. | 143 // These are mutbale to enable gradient updates when the paints are fetched
for use. |
153 mutable SkPaint m_strokePaint; | 144 mutable SkPaint m_strokePaint; |
154 mutable SkPaint m_fillPaint; | 145 mutable SkPaint m_fillPaint; |
155 | 146 |
156 StrokeData m_strokeData; | 147 StrokeData m_strokeData; |
157 | 148 |
158 Color m_strokeColor; | 149 Color m_strokeColor; |
159 RefPtr<Gradient> m_strokeGradient; | 150 RefPtr<Gradient> m_strokeGradient; |
160 RefPtr<Pattern> m_strokePattern; | 151 RefPtr<Pattern> m_strokePattern; |
161 | 152 |
162 Color m_fillColor; | 153 Color m_fillColor; |
163 WindRule m_fillRule; | 154 WindRule m_fillRule; |
164 RefPtr<Gradient> m_fillGradient; | 155 RefPtr<Gradient> m_fillGradient; |
165 RefPtr<Pattern> m_fillPattern; | 156 RefPtr<Pattern> m_fillPattern; |
166 | 157 |
167 RefPtr<SkDrawLooper> m_looper; | 158 RefPtr<SkDrawLooper> m_looper; |
168 RefPtr<SkImageFilter> m_dropShadowImageFilter; | |
169 | 159 |
170 TextDrawingModeFlags m_textDrawingMode; | 160 TextDrawingModeFlags m_textDrawingMode; |
171 | 161 |
172 int m_alpha; | 162 int m_alpha; |
173 RefPtr<SkColorFilter> m_colorFilter; | 163 RefPtr<SkColorFilter> m_colorFilter; |
174 | 164 |
175 SkXfermode::Mode m_compositeOperation; | 165 SkXfermode::Mode m_compositeOperation; |
176 | 166 |
177 InterpolationQuality m_interpolationQuality; | 167 InterpolationQuality m_interpolationQuality; |
178 | 168 |
179 uint16_t m_saveCount; | 169 uint16_t m_saveCount; |
180 | 170 |
181 bool m_shouldAntialias : 1; | 171 bool m_shouldAntialias : 1; |
182 bool m_shouldClampToSourceRect : 1; | |
183 }; | 172 }; |
184 | 173 |
185 } // namespace blink | 174 } // namespace blink |
186 | 175 |
187 #endif // GraphicsContextState_h | 176 #endif // GraphicsContextState_h |
OLD | NEW |