| 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_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_xferMode(nullptr) |   17     , m_xferMode(nullptr) | 
|   18     , m_compositeOperator(CompositeSourceOver) |   18     , m_compositeOperator(CompositeSourceOver) | 
|   19     , m_blendMode(blink::WebBlendModeNormal) |   19     , m_blendMode(WebBlendModeNormal) | 
|   20     , m_interpolationQuality(InterpolationDefault) |   20     , m_interpolationQuality(InterpolationDefault) | 
|   21     , m_saveCount(0) |   21     , m_saveCount(0) | 
|   22     , m_shouldAntialias(true) |   22     , m_shouldAntialias(true) | 
|   23     , m_shouldSmoothFonts(true) |   23     , m_shouldSmoothFonts(true) | 
|   24     , m_shouldClampToSourceRect(true) |   24     , m_shouldClampToSourceRect(true) | 
|   25 { |   25 { | 
|   26     m_strokePaint.setStyle(SkPaint::kStroke_Style); |   26     m_strokePaint.setStyle(SkPaint::kStroke_Style); | 
|   27     m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); |   27     m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); | 
|   28     m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); |   28     m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); | 
|   29     m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |   29     m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  222     m_strokeData.setLineDash(dashes, dashOffset); |  222     m_strokeData.setLineDash(dashes, dashOffset); | 
|  223 } |  223 } | 
|  224  |  224  | 
|  225 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) |  225 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) | 
|  226 { |  226 { | 
|  227     m_colorFilter = colorFilter; |  227     m_colorFilter = colorFilter; | 
|  228     m_strokePaint.setColorFilter(m_colorFilter.get()); |  228     m_strokePaint.setColorFilter(m_colorFilter.get()); | 
|  229     m_fillPaint.setColorFilter(m_colorFilter.get()); |  229     m_fillPaint.setColorFilter(m_colorFilter.get()); | 
|  230 } |  230 } | 
|  231  |  231  | 
|  232 void GraphicsContextState::setCompositeOperation(CompositeOperator compositeOper
     ation, blink::WebBlendMode blendMode) |  232 void GraphicsContextState::setCompositeOperation(CompositeOperator compositeOper
     ation, WebBlendMode blendMode) | 
|  233 { |  233 { | 
|  234     m_compositeOperator = compositeOperation; |  234     m_compositeOperator = compositeOperation; | 
|  235     m_blendMode = blendMode; |  235     m_blendMode = blendMode; | 
|  236     m_xferMode = WebCoreCompositeToSkiaComposite(compositeOperation, blendMode); |  236     m_xferMode = WebCoreCompositeToSkiaComposite(compositeOperation, blendMode); | 
|  237     m_strokePaint.setXfermode(m_xferMode.get()); |  237     m_strokePaint.setXfermode(m_xferMode.get()); | 
|  238     m_fillPaint.setXfermode(m_xferMode.get()); |  238     m_fillPaint.setXfermode(m_xferMode.get()); | 
|  239 } |  239 } | 
|  240  |  240  | 
|  241 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) |  241 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) | 
|  242 { |  242 { | 
|  243     m_interpolationQuality = quality; |  243     m_interpolationQuality = quality; | 
|  244     m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qual
     ity)); |  244     m_strokePaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qual
     ity)); | 
|  245     m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
     y)); |  245     m_fillPaint.setFilterLevel(WebCoreInterpolationQualityToSkFilterLevel(qualit
     y)); | 
|  246 } |  246 } | 
|  247  |  247  | 
|  248 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |  248 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 
|  249 { |  249 { | 
|  250     m_shouldAntialias = shouldAntialias; |  250     m_shouldAntialias = shouldAntialias; | 
|  251     m_strokePaint.setAntiAlias(shouldAntialias); |  251     m_strokePaint.setAntiAlias(shouldAntialias); | 
|  252     m_fillPaint.setAntiAlias(shouldAntialias); |  252     m_fillPaint.setAntiAlias(shouldAntialias); | 
|  253 } |  253 } | 
|  254  |  254  | 
|  255  |  255  | 
|  256 } // namespace blink |  256 } // namespace blink | 
| OLD | NEW |