OLD | NEW |
---|---|
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/GraphicsContextState.h" | 6 #include "platform/graphics/GraphicsContextState.h" |
7 | 7 |
8 namespace WebCore { | 8 namespace WebCore { |
9 | 9 |
10 GraphicsContextState::GraphicsContextState() | 10 GraphicsContextState::GraphicsContextState() |
11 : m_fillColor(Color::black) | 11 : m_fillColor(Color::black) |
12 , m_fillRule(RULE_NONZERO) | 12 , m_fillRule(RULE_NONZERO) |
13 , m_textDrawingMode(TextModeFill) | 13 , m_textDrawingMode(TextModeFill) |
14 , m_alpha(256) | 14 , m_alpha(256) |
15 , m_xferMode(nullptr) | 15 , m_xferMode(nullptr) |
16 , m_compositeOperator(CompositeSourceOver) | 16 , m_compositeOperator(CompositeSourceOver) |
17 , m_blendMode(blink::WebBlendModeNormal) | 17 , m_blendMode(blink::WebBlendModeNormal) |
18 , m_interpolationQuality(InterpolationDefault) | 18 , m_interpolationQuality(InterpolationDefault) |
19 , m_saveCount(0) | 19 , m_saveCount(0) |
20 , m_shouldAntialias(true) | 20 , m_shouldAntialias(true) |
21 , m_shouldSmoothFonts(true) | 21 , m_shouldSmoothFonts(true) |
22 , m_shouldClampToSourceRect(true) | 22 , m_shouldClampToSourceRect(true) |
23 { | 23 { |
24 m_strokePaint.setStyle(SkPaint::kStroke_Style); | 24 m_strokePaint.setStyle(SkPaint::kStroke_Style); |
25 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); | 25 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); |
26 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); | 26 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); |
27 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 27 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |
28 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); | 28 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); |
29 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); | 29 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); |
30 m_strokePaint.setFilterBitmap(m_interpolationQuality != InterpolationNone); | 30 m_strokePaint.setFilterLevel(m_interpolationQuality != InterpolationNone |
31 ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel); | |
31 m_strokePaint.setAntiAlias(m_shouldAntialias); | 32 m_strokePaint.setAntiAlias(m_shouldAntialias); |
32 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 33 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
33 m_fillPaint.setFilterBitmap(m_interpolationQuality != InterpolationNone); | 34 m_fillPaint.setFilterLevel(m_interpolationQuality != InterpolationNone |
Stephen White
2014/05/07 16:40:47
Nit: maybe we should have an inline function to do
f(malita)
2014/05/07 17:53:26
Done.
| |
35 ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel); | |
34 m_fillPaint.setAntiAlias(m_shouldAntialias); | 36 m_fillPaint.setAntiAlias(m_shouldAntialias); |
35 } | 37 } |
36 | 38 |
37 void GraphicsContextState::copy(GraphicsContextState* source) | 39 void GraphicsContextState::copy(GraphicsContextState* source) |
38 { | 40 { |
39 m_strokePaint = source->m_strokePaint; | 41 m_strokePaint = source->m_strokePaint; |
40 m_fillPaint = source->m_fillPaint; | 42 m_fillPaint = source->m_fillPaint; |
41 m_strokeData = source->m_strokeData; | 43 m_strokeData = source->m_strokeData; |
42 m_fillColor = source->m_fillColor; | 44 m_fillColor = source->m_fillColor; |
43 m_fillRule = source->m_fillRule; | 45 m_fillRule = source->m_fillRule; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 m_compositeOperator = compositeOperation; | 230 m_compositeOperator = compositeOperation; |
229 m_blendMode = blendMode; | 231 m_blendMode = blendMode; |
230 m_xferMode = WebCoreCompositeToSkiaComposite(compositeOperation, blendMode); | 232 m_xferMode = WebCoreCompositeToSkiaComposite(compositeOperation, blendMode); |
231 m_strokePaint.setXfermode(m_xferMode.get()); | 233 m_strokePaint.setXfermode(m_xferMode.get()); |
232 m_fillPaint.setXfermode(m_xferMode.get()); | 234 m_fillPaint.setXfermode(m_xferMode.get()); |
233 } | 235 } |
234 | 236 |
235 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) | 237 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) |
236 { | 238 { |
237 m_interpolationQuality = quality; | 239 m_interpolationQuality = quality; |
238 m_strokePaint.setFilterBitmap(quality != InterpolationNone); | 240 SkPaint::FilterLevel filterLevel = quality != InterpolationNone ? |
239 m_fillPaint.setFilterBitmap(quality != InterpolationNone); | 241 SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel; |
242 m_strokePaint.setFilterLevel(filterLevel); | |
243 m_fillPaint.setFilterLevel(filterLevel); | |
240 } | 244 } |
241 | 245 |
242 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 246 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
243 { | 247 { |
244 m_shouldAntialias = shouldAntialias; | 248 m_shouldAntialias = shouldAntialias; |
245 m_strokePaint.setAntiAlias(shouldAntialias); | 249 m_strokePaint.setAntiAlias(shouldAntialias); |
246 m_fillPaint.setAntiAlias(shouldAntialias); | 250 m_fillPaint.setAntiAlias(shouldAntialias); |
247 } | 251 } |
248 | 252 |
249 | 253 |
250 } // namespace WebCore | 254 } // namespace WebCore |
OLD | NEW |