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 blink { | 8 namespace blink { |
9 | 9 |
10 GraphicsContextState::GraphicsContextState() | 10 GraphicsContextState::GraphicsContextState() |
11 : m_strokeColor(Color::black) | 11 : m_strokeColor(Color::black) |
12 , m_fillColor(Color::black) | 12 , m_fillColor(Color::black) |
13 , m_fillRule(RULE_NONZERO) | |
14 , m_textDrawingMode(TextModeFill) | 13 , m_textDrawingMode(TextModeFill) |
15 , m_alpha(256) | 14 , m_alpha(256) |
16 , m_compositeOperation(SkXfermode::kSrcOver_Mode) | 15 , m_compositeOperation(SkXfermode::kSrcOver_Mode) |
17 , m_interpolationQuality(InterpolationDefault) | 16 , m_interpolationQuality(InterpolationDefault) |
18 , m_saveCount(0) | 17 , m_saveCount(0) |
19 , m_shouldAntialias(true) | 18 , m_shouldAntialias(true) |
20 , m_shouldClampToSourceRect(true) | 19 , m_shouldClampToSourceRect(true) |
21 { | 20 { |
22 m_strokePaint.setStyle(SkPaint::kStroke_Style); | 21 m_strokePaint.setStyle(SkPaint::kStroke_Style); |
23 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); | 22 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); |
24 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | 23 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); |
25 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 24 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |
26 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); | 25 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); |
27 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); | 26 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); |
28 m_strokePaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(
m_interpolationQuality)); | 27 m_strokePaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(
m_interpolationQuality)); |
29 m_strokePaint.setAntiAlias(m_shouldAntialias); | 28 m_strokePaint.setAntiAlias(m_shouldAntialias); |
30 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 29 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
31 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(m_
interpolationQuality)); | 30 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(m_
interpolationQuality)); |
32 m_fillPaint.setAntiAlias(m_shouldAntialias); | 31 m_fillPaint.setAntiAlias(m_shouldAntialias); |
33 } | 32 } |
34 | 33 |
35 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) | 34 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) |
36 : m_strokePaint(other.m_strokePaint) | 35 : m_strokePaint(other.m_strokePaint) |
37 , m_fillPaint(other.m_fillPaint) | 36 , m_fillPaint(other.m_fillPaint) |
38 , m_strokeData(other.m_strokeData) | 37 , m_strokeData(other.m_strokeData) |
39 , m_strokeColor(other.m_strokeColor) | 38 , m_strokeColor(other.m_strokeColor) |
40 , m_strokeGradient(other.m_strokeGradient) | 39 , m_strokeGradient(other.m_strokeGradient) |
41 , m_strokePattern(other.m_strokePattern) | 40 , m_strokePattern(other.m_strokePattern) |
42 , m_fillColor(other.m_fillColor) | 41 , m_fillColor(other.m_fillColor) |
43 , m_fillRule(other.m_fillRule) | |
44 , m_fillGradient(other.m_fillGradient) | 42 , m_fillGradient(other.m_fillGradient) |
45 , m_fillPattern(other.m_fillPattern) | 43 , m_fillPattern(other.m_fillPattern) |
46 , m_looper(other.m_looper) | 44 , m_looper(other.m_looper) |
47 , m_dropShadowImageFilter(other.m_dropShadowImageFilter) | 45 , m_dropShadowImageFilter(other.m_dropShadowImageFilter) |
48 , m_textDrawingMode(other.m_textDrawingMode) | 46 , m_textDrawingMode(other.m_textDrawingMode) |
49 , m_alpha(other.m_alpha) | 47 , m_alpha(other.m_alpha) |
50 , m_colorFilter(other.m_colorFilter) | 48 , m_colorFilter(other.m_colorFilter) |
51 , m_compositeOperation(other.m_compositeOperation) | 49 , m_compositeOperation(other.m_compositeOperation) |
52 , m_interpolationQuality(other.m_interpolationQuality) | 50 , m_interpolationQuality(other.m_interpolationQuality) |
53 , m_saveCount(0) | 51 , m_saveCount(0) |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 215 } |
218 | 216 |
219 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 217 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
220 { | 218 { |
221 m_shouldAntialias = shouldAntialias; | 219 m_shouldAntialias = shouldAntialias; |
222 m_strokePaint.setAntiAlias(shouldAntialias); | 220 m_strokePaint.setAntiAlias(shouldAntialias); |
223 m_fillPaint.setAntiAlias(shouldAntialias); | 221 m_fillPaint.setAntiAlias(shouldAntialias); |
224 } | 222 } |
225 | 223 |
226 } // namespace blink | 224 } // namespace blink |
OLD | NEW |