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 #include "platform/graphics/skia/SkiaUtils.h" |
| 9 |
8 namespace WebCore { | 10 namespace WebCore { |
9 | 11 |
10 GraphicsContextState::GraphicsContextState() | 12 GraphicsContextState::GraphicsContextState() |
11 : m_fillColor(Color::black) | 13 : m_fillColor(Color::black) |
12 , m_fillRule(RULE_NONZERO) | 14 , m_fillRule(RULE_NONZERO) |
13 , m_textDrawingMode(TextModeFill) | 15 , m_textDrawingMode(TextModeFill) |
14 , m_alpha(256) | 16 , m_alpha(256) |
15 , m_xferMode(nullptr) | 17 , m_xferMode(nullptr) |
16 , m_compositeOperator(CompositeSourceOver) | 18 , m_compositeOperator(CompositeSourceOver) |
17 , m_blendMode(blink::WebBlendModeNormal) | 19 , m_blendMode(blink::WebBlendModeNormal) |
18 , m_interpolationQuality(InterpolationDefault) | 20 , m_interpolationQuality(InterpolationDefault) |
19 , m_saveCount(0) | 21 , m_saveCount(0) |
20 , m_shouldAntialias(true) | 22 , m_shouldAntialias(true) |
21 , m_shouldSmoothFonts(true) | 23 , m_shouldSmoothFonts(true) |
22 , m_shouldClampToSourceRect(true) | 24 , m_shouldClampToSourceRect(true) |
23 { | 25 { |
24 m_strokePaint.setStyle(SkPaint::kStroke_Style); | 26 m_strokePaint.setStyle(SkPaint::kStroke_Style); |
25 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); | 27 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); |
26 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); | 28 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); |
27 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 29 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |
28 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); | 30 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); |
29 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); | 31 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); |
30 m_strokePaint.setFilterBitmap(m_interpolationQuality != InterpolationNone); | 32 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_in
terpolationQuality)); |
31 m_strokePaint.setAntiAlias(m_shouldAntialias); | 33 m_strokePaint.setAntiAlias(m_shouldAntialias); |
32 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 34 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
33 m_fillPaint.setFilterBitmap(m_interpolationQuality != InterpolationNone); | 35 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_inte
rpolationQuality)); |
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 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qual
ity)); |
239 m_fillPaint.setFilterBitmap(quality != InterpolationNone); | 241 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
y)); |
240 } | 242 } |
241 | 243 |
242 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 244 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
243 { | 245 { |
244 m_shouldAntialias = shouldAntialias; | 246 m_shouldAntialias = shouldAntialias; |
245 m_strokePaint.setAntiAlias(shouldAntialias); | 247 m_strokePaint.setAntiAlias(shouldAntialias); |
246 m_fillPaint.setAntiAlias(shouldAntialias); | 248 m_fillPaint.setAntiAlias(shouldAntialias); |
247 } | 249 } |
248 | 250 |
249 | 251 |
250 } // namespace WebCore | 252 } // namespace WebCore |
OLD | NEW |