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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
6 #include "sky/engine/platform/graphics/GraphicsContextState.h" | 6 #include "sky/engine/platform/graphics/GraphicsContextState.h" |
7 | 7 |
8 #include "sky/engine/platform/graphics/skia/SkiaUtils.h" | 8 #include "sky/engine/platform/graphics/skia/SkiaUtils.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 GraphicsContextState::GraphicsContextState() | 12 GraphicsContextState::GraphicsContextState() |
13 : m_fillColor(Color::black) | 13 : m_fillColor(Color::black) |
14 , m_fillRule(RULE_NONZERO) | 14 , m_fillRule(RULE_NONZERO) |
15 , m_textDrawingMode(TextModeFill) | 15 , m_textDrawingMode(TextModeFill) |
16 , m_alpha(256) | 16 , m_alpha(256) |
17 , m_compositeOperator(CompositeSourceOver) | 17 , m_compositeOperator(CompositeSourceOver) |
18 , m_blendMode(WebBlendModeNormal) | 18 , m_blendMode(WebBlendModeNormal) |
19 , m_interpolationQuality(InterpolationDefault) | 19 , m_interpolationQuality(InterpolationDefault) |
20 , m_saveCount(0) | 20 , m_saveCount(0) |
21 , m_shouldAntialias(true) | 21 , m_shouldAntialias(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.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_in
terpolationQuality)); | 30 m_strokePaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(
m_interpolationQuality)); |
31 m_strokePaint.setAntiAlias(m_shouldAntialias); | 31 m_strokePaint.setAntiAlias(m_shouldAntialias); |
32 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 32 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
33 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_inte
rpolationQuality)); | 33 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(m_
interpolationQuality)); |
34 m_fillPaint.setAntiAlias(m_shouldAntialias); | 34 m_fillPaint.setAntiAlias(m_shouldAntialias); |
35 } | 35 } |
36 | 36 |
37 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) | 37 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) |
38 : m_strokePaint(other.m_strokePaint) | 38 : m_strokePaint(other.m_strokePaint) |
39 , m_fillPaint(other.m_fillPaint) | 39 , m_fillPaint(other.m_fillPaint) |
40 , m_strokeData(other.m_strokeData) | 40 , m_strokeData(other.m_strokeData) |
41 , m_fillColor(other.m_fillColor) | 41 , m_fillColor(other.m_fillColor) |
42 , m_fillRule(other.m_fillRule) | 42 , m_fillRule(other.m_fillRule) |
43 , m_fillGradient(other.m_fillGradient) | 43 , m_fillGradient(other.m_fillGradient) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 m_compositeOperator = compositeOperation; | 230 m_compositeOperator = compositeOperation; |
231 m_blendMode = blendMode; | 231 m_blendMode = blendMode; |
232 SkXfermode::Mode xferMode = WebCoreCompositeToSkiaComposite(compositeOperati
on, blendMode); | 232 SkXfermode::Mode xferMode = WebCoreCompositeToSkiaComposite(compositeOperati
on, blendMode); |
233 m_strokePaint.setXfermodeMode(xferMode); | 233 m_strokePaint.setXfermodeMode(xferMode); |
234 m_fillPaint.setXfermodeMode(xferMode); | 234 m_fillPaint.setXfermodeMode(xferMode); |
235 } | 235 } |
236 | 236 |
237 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) | 237 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) |
238 { | 238 { |
239 m_interpolationQuality = quality; | 239 m_interpolationQuality = quality; |
240 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qual
ity)); | 240 m_strokePaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(
quality)); |
241 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
y)); | 241 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(qu
ality)); |
242 } | 242 } |
243 | 243 |
244 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 244 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
245 { | 245 { |
246 m_shouldAntialias = shouldAntialias; | 246 m_shouldAntialias = shouldAntialias; |
247 m_strokePaint.setAntiAlias(shouldAntialias); | 247 m_strokePaint.setAntiAlias(shouldAntialias); |
248 m_fillPaint.setAntiAlias(shouldAntialias); | 248 m_fillPaint.setAntiAlias(shouldAntialias); |
249 } | 249 } |
250 | 250 |
251 | 251 |
252 } // namespace blink | 252 } // namespace blink |
OLD | NEW |