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) | 13 , m_fillRule(RULE_NONZERO) |
14 , m_textDrawingMode(TextModeFill) | 14 , m_textDrawingMode(TextModeFill) |
15 , m_alpha(256) | 15 , m_alpha(256) |
16 , m_compositeOperation(SkXfermode::kSrcOver_Mode) | 16 , m_compositeOperation(SkXfermode::kSrcOver_Mode) |
17 , m_interpolationQuality(InterpolationDefault) | 17 , m_interpolationQuality(InterpolationDefault) |
18 , m_saveCount(0) | 18 , m_saveCount(0) |
19 , m_shouldAntialias(true) | 19 , m_shouldAntialias(true) |
20 , m_shouldClampToSourceRect(true) | 20 , m_shouldClampToSourceRect(true) |
21 , m_hasComplexClip(false) | |
22 { | 21 { |
23 m_strokePaint.setStyle(SkPaint::kStroke_Style); | 22 m_strokePaint.setStyle(SkPaint::kStroke_Style); |
24 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); | 23 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); |
25 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | 24 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); |
26 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 25 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |
27 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); | 26 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); |
28 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); | 27 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); |
29 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_in
terpolationQuality)); | 28 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_in
terpolationQuality)); |
30 m_strokePaint.setAntiAlias(m_shouldAntialias); | 29 m_strokePaint.setAntiAlias(m_shouldAntialias); |
31 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 30 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
(...skipping 14 matching lines...) Expand all Loading... |
46 , m_fillPattern(other.m_fillPattern) | 45 , m_fillPattern(other.m_fillPattern) |
47 , m_looper(other.m_looper) | 46 , m_looper(other.m_looper) |
48 , m_dropShadowImageFilter(other.m_dropShadowImageFilter) | 47 , m_dropShadowImageFilter(other.m_dropShadowImageFilter) |
49 , m_textDrawingMode(other.m_textDrawingMode) | 48 , m_textDrawingMode(other.m_textDrawingMode) |
50 , m_alpha(other.m_alpha) | 49 , m_alpha(other.m_alpha) |
51 , m_colorFilter(other.m_colorFilter) | 50 , m_colorFilter(other.m_colorFilter) |
52 , m_compositeOperation(other.m_compositeOperation) | 51 , m_compositeOperation(other.m_compositeOperation) |
53 , m_interpolationQuality(other.m_interpolationQuality) | 52 , m_interpolationQuality(other.m_interpolationQuality) |
54 , m_saveCount(0) | 53 , m_saveCount(0) |
55 , m_shouldAntialias(other.m_shouldAntialias) | 54 , m_shouldAntialias(other.m_shouldAntialias) |
56 , m_shouldClampToSourceRect(other.m_shouldClampToSourceRect) | 55 , m_shouldClampToSourceRect(other.m_shouldClampToSourceRect) { } |
57 , m_hasComplexClip(other.m_hasComplexClip) { } | |
58 | 56 |
59 void GraphicsContextState::copy(const GraphicsContextState& source) | 57 void GraphicsContextState::copy(const GraphicsContextState& source) |
60 { | 58 { |
61 this->~GraphicsContextState(); | 59 this->~GraphicsContextState(); |
62 new (this) GraphicsContextState(source); | 60 new (this) GraphicsContextState(source); |
63 } | 61 } |
64 | 62 |
65 const SkPaint& GraphicsContextState::strokePaint(int strokedPathLength) const | 63 const SkPaint& GraphicsContextState::strokePaint(int strokedPathLength) const |
66 { | 64 { |
67 if (m_strokeGradient && m_strokeGradient->shaderChanged()) | 65 if (m_strokeGradient && m_strokeGradient->shaderChanged()) |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
y)); | 244 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
y)); |
247 } | 245 } |
248 | 246 |
249 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 247 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
250 { | 248 { |
251 m_shouldAntialias = shouldAntialias; | 249 m_shouldAntialias = shouldAntialias; |
252 m_strokePaint.setAntiAlias(shouldAntialias); | 250 m_strokePaint.setAntiAlias(shouldAntialias); |
253 m_fillPaint.setAntiAlias(shouldAntialias); | 251 m_fillPaint.setAntiAlias(shouldAntialias); |
254 } | 252 } |
255 | 253 |
256 bool GraphicsContextState::hasComplexClip() const | |
257 { | |
258 return m_hasComplexClip; | |
259 } | |
260 | |
261 void GraphicsContextState::setHasComplexClip() | |
262 { | |
263 m_hasComplexClip = true; | |
264 } | |
265 | |
266 | |
267 } // namespace blink | 254 } // namespace blink |
OLD | NEW |