| 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 WebCore { | 10 namespace WebCore { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 29 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |
| 30 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); | 30 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); |
| 31 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); | 31 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); |
| 32 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_in
terpolationQuality)); | 32 m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_in
terpolationQuality)); |
| 33 m_strokePaint.setAntiAlias(m_shouldAntialias); | 33 m_strokePaint.setAntiAlias(m_shouldAntialias); |
| 34 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 34 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
| 35 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_inte
rpolationQuality)); | 35 m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(m_inte
rpolationQuality)); |
| 36 m_fillPaint.setAntiAlias(m_shouldAntialias); | 36 m_fillPaint.setAntiAlias(m_shouldAntialias); |
| 37 } | 37 } |
| 38 | 38 |
| 39 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) | 39 void GraphicsContextState::copy(GraphicsContextState* source) |
| 40 : m_strokePaint(other.m_strokePaint) | |
| 41 , m_fillPaint(other.m_fillPaint) | |
| 42 , m_strokeData(other.m_strokeData) | |
| 43 , m_fillColor(other.m_fillColor) | |
| 44 , m_fillRule(other.m_fillRule) | |
| 45 , m_fillGradient(other.m_fillGradient) | |
| 46 , m_fillPattern(other.m_fillPattern) | |
| 47 , m_looper(other.m_looper) | |
| 48 , m_textDrawingMode(other.m_textDrawingMode) | |
| 49 , m_alpha(other.m_alpha) | |
| 50 , m_xferMode(other.m_xferMode) | |
| 51 , m_colorFilter(other.m_colorFilter) | |
| 52 , m_compositeOperator(other.m_compositeOperator) | |
| 53 , m_blendMode(other.m_blendMode) | |
| 54 , m_interpolationQuality(other.m_interpolationQuality) | |
| 55 , m_saveCount(0) | |
| 56 , m_shouldAntialias(other.m_shouldAntialias) | |
| 57 , m_shouldSmoothFonts(other.m_shouldSmoothFonts) | |
| 58 , m_shouldClampToSourceRect(other.m_shouldClampToSourceRect) { } | |
| 59 | |
| 60 void GraphicsContextState::copy(const GraphicsContextState& source) | |
| 61 { | 40 { |
| 62 new (this) GraphicsContextState(source); | 41 m_strokePaint = source->m_strokePaint; |
| 42 m_fillPaint = source->m_fillPaint; |
| 43 m_strokeData = source->m_strokeData; |
| 44 m_fillColor = source->m_fillColor; |
| 45 m_fillRule = source->m_fillRule; |
| 46 m_fillGradient = source->m_fillGradient; |
| 47 m_fillPattern = source->m_fillPattern; |
| 48 m_looper = source->m_looper; |
| 49 m_textDrawingMode = source->m_textDrawingMode; |
| 50 m_alpha = source->m_alpha; |
| 51 m_xferMode = source->m_xferMode; |
| 52 m_colorFilter = source->m_colorFilter; |
| 53 m_compositeOperator = source->m_compositeOperator; |
| 54 m_blendMode = source->m_blendMode; |
| 55 m_interpolationQuality = source->m_interpolationQuality; |
| 56 m_saveCount = 0; |
| 57 m_shouldAntialias = source->m_shouldAntialias; |
| 58 m_shouldSmoothFonts = source->m_shouldSmoothFonts; |
| 59 m_shouldClampToSourceRect = source->m_shouldClampToSourceRect; |
| 63 } | 60 } |
| 64 | 61 |
| 65 const SkPaint& GraphicsContextState::strokePaint(int strokedPathLength) const | 62 const SkPaint& GraphicsContextState::strokePaint(int strokedPathLength) const |
| 66 { | 63 { |
| 67 if (m_strokeData.gradient() && m_strokeData.gradient()->shaderChanged()) | 64 if (m_strokeData.gradient() && m_strokeData.gradient()->shaderChanged()) |
| 68 m_strokePaint.setShader(m_strokeData.gradient()->shader()); | 65 m_strokePaint.setShader(m_strokeData.gradient()->shader()); |
| 69 m_strokeData.setupPaintDashPathEffect(&m_strokePaint, strokedPathLength); | 66 m_strokeData.setupPaintDashPathEffect(&m_strokePaint, strokedPathLength); |
| 70 return m_strokePaint; | 67 return m_strokePaint; |
| 71 } | 68 } |
| 72 | 69 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 243 |
| 247 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 244 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
| 248 { | 245 { |
| 249 m_shouldAntialias = shouldAntialias; | 246 m_shouldAntialias = shouldAntialias; |
| 250 m_strokePaint.setAntiAlias(shouldAntialias); | 247 m_strokePaint.setAntiAlias(shouldAntialias); |
| 251 m_fillPaint.setAntiAlias(shouldAntialias); | 248 m_fillPaint.setAntiAlias(shouldAntialias); |
| 252 } | 249 } |
| 253 | 250 |
| 254 | 251 |
| 255 } // namespace WebCore | 252 } // namespace WebCore |
| OLD | NEW |