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" | 8 #include "platform/graphics/skia/SkiaUtils.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 GraphicsContextState::GraphicsContextState() | 12 GraphicsContextState::GraphicsContextState() |
13 : m_strokeColor(Color::black) | 13 : m_strokeColor(Color::black) |
14 , m_fillColor(Color::black) | 14 , m_fillColor(Color::black) |
15 , m_fillRule(RULE_NONZERO) | 15 , m_fillRule(RULE_NONZERO) |
16 , m_textDrawingMode(TextModeFill) | 16 , m_textDrawingMode(TextModeFill) |
17 , m_alpha(256) | 17 , m_alpha(256) |
18 , m_compositeOperator(CompositeSourceOver) | 18 , m_compositeOperation(SkXfermode::kSrcOver_Mode) |
19 , m_blendMode(WebBlendModeNormal) | |
20 , m_interpolationQuality(InterpolationDefault) | 19 , m_interpolationQuality(InterpolationDefault) |
21 , m_saveCount(0) | 20 , m_saveCount(0) |
22 , m_shouldAntialias(true) | 21 , m_shouldAntialias(true) |
23 , m_shouldClampToSourceRect(true) | 22 , m_shouldClampToSourceRect(true) |
24 { | 23 { |
25 m_strokePaint.setStyle(SkPaint::kStroke_Style); | 24 m_strokePaint.setStyle(SkPaint::kStroke_Style); |
26 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); | 25 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); |
27 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); | 26 m_strokePaint.setColor(applyAlpha(m_strokeColor.rgb())); |
28 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 27 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |
29 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); | 28 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); |
(...skipping 14 matching lines...) Expand all Loading... |
44 , m_strokePattern(other.m_strokePattern) | 43 , m_strokePattern(other.m_strokePattern) |
45 , m_fillColor(other.m_fillColor) | 44 , m_fillColor(other.m_fillColor) |
46 , m_fillRule(other.m_fillRule) | 45 , m_fillRule(other.m_fillRule) |
47 , m_fillGradient(other.m_fillGradient) | 46 , m_fillGradient(other.m_fillGradient) |
48 , m_fillPattern(other.m_fillPattern) | 47 , m_fillPattern(other.m_fillPattern) |
49 , m_looper(other.m_looper) | 48 , m_looper(other.m_looper) |
50 , m_dropShadowImageFilter(other.m_dropShadowImageFilter) | 49 , m_dropShadowImageFilter(other.m_dropShadowImageFilter) |
51 , m_textDrawingMode(other.m_textDrawingMode) | 50 , m_textDrawingMode(other.m_textDrawingMode) |
52 , m_alpha(other.m_alpha) | 51 , m_alpha(other.m_alpha) |
53 , m_colorFilter(other.m_colorFilter) | 52 , m_colorFilter(other.m_colorFilter) |
54 , m_compositeOperator(other.m_compositeOperator) | 53 , m_compositeOperation(other.m_compositeOperation) |
55 , m_blendMode(other.m_blendMode) | |
56 , m_interpolationQuality(other.m_interpolationQuality) | 54 , m_interpolationQuality(other.m_interpolationQuality) |
57 , m_saveCount(0) | 55 , m_saveCount(0) |
58 , m_shouldAntialias(other.m_shouldAntialias) | 56 , m_shouldAntialias(other.m_shouldAntialias) |
59 , m_shouldClampToSourceRect(other.m_shouldClampToSourceRect) { } | 57 , m_shouldClampToSourceRect(other.m_shouldClampToSourceRect) { } |
60 | 58 |
61 void GraphicsContextState::copy(const GraphicsContextState& source) | 59 void GraphicsContextState::copy(const GraphicsContextState& source) |
62 { | 60 { |
63 this->~GraphicsContextState(); | 61 this->~GraphicsContextState(); |
64 new (this) GraphicsContextState(source); | 62 new (this) GraphicsContextState(source); |
65 } | 63 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 m_strokeData.setLineDash(dashes, dashOffset); | 231 m_strokeData.setLineDash(dashes, dashOffset); |
234 } | 232 } |
235 | 233 |
236 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) | 234 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) |
237 { | 235 { |
238 m_colorFilter = colorFilter; | 236 m_colorFilter = colorFilter; |
239 m_strokePaint.setColorFilter(m_colorFilter.get()); | 237 m_strokePaint.setColorFilter(m_colorFilter.get()); |
240 m_fillPaint.setColorFilter(m_colorFilter.get()); | 238 m_fillPaint.setColorFilter(m_colorFilter.get()); |
241 } | 239 } |
242 | 240 |
243 void GraphicsContextState::setCompositeOperation(CompositeOperator compositeOper
ation, WebBlendMode blendMode) | 241 void GraphicsContextState::setCompositeOperation(SkXfermode::Mode xferMode) |
244 { | 242 { |
245 m_compositeOperator = compositeOperation; | 243 m_compositeOperation = xferMode; |
246 m_blendMode = blendMode; | |
247 SkXfermode::Mode xferMode = WebCoreCompositeToSkiaComposite(compositeOperati
on, blendMode); | |
248 m_strokePaint.setXfermodeMode(xferMode); | 244 m_strokePaint.setXfermodeMode(xferMode); |
249 m_fillPaint.setXfermodeMode(xferMode); | 245 m_fillPaint.setXfermodeMode(xferMode); |
250 } | 246 } |
251 | 247 |
252 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) | 248 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) |
253 { | 249 { |
254 m_interpolationQuality = quality; | 250 m_interpolationQuality = quality; |
255 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qual
ity)); | 251 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qual
ity)); |
256 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
y)); | 252 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
y)); |
257 } | 253 } |
258 | 254 |
259 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 255 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
260 { | 256 { |
261 m_shouldAntialias = shouldAntialias; | 257 m_shouldAntialias = shouldAntialias; |
262 m_strokePaint.setAntiAlias(shouldAntialias); | 258 m_strokePaint.setAntiAlias(shouldAntialias); |
263 m_fillPaint.setAntiAlias(shouldAntialias); | 259 m_fillPaint.setAntiAlias(shouldAntialias); |
264 } | 260 } |
265 | 261 |
266 | 262 |
267 } // namespace blink | 263 } // namespace blink |
OLD | NEW |