Chromium Code Reviews| 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 static inline SkFilterQuality filterQualityForPaint(InterpolationQuality quality ) | |
| 11 { | |
| 12 // The filter quality "selected" here will primarily be used when paintinga | |
|
f(malita)
2015/07/16 15:33:27
nit: paintinga spacing
fs
2015/07/17 07:20:21
Done.
| |
| 13 // primitive using one of the SkPaints below. For the most part this will | |
| 14 // not affect things that are part of the Image class hierarchy (which use | |
| 15 // the unmodified m_interpolationQuality.) | |
| 16 return quality != InterpolationNone ? kLow_SkFilterQuality : kNone_SkFilterQ uality; | |
| 17 } | |
| 18 | |
| 10 GraphicsContextState::GraphicsContextState() | 19 GraphicsContextState::GraphicsContextState() |
| 11 : m_strokeColor(Color::black) | 20 : m_strokeColor(Color::black) |
| 12 , m_fillColor(Color::black) | 21 , m_fillColor(Color::black) |
| 13 , m_textDrawingMode(TextModeFill) | 22 , m_textDrawingMode(TextModeFill) |
| 14 , m_interpolationQuality(InterpolationDefault) | 23 , m_interpolationQuality(InterpolationDefault) |
| 15 , m_saveCount(0) | 24 , m_saveCount(0) |
| 16 , m_shouldAntialias(true) | 25 , m_shouldAntialias(true) |
| 17 { | 26 { |
| 18 m_strokePaint.setStyle(SkPaint::kStroke_Style); | 27 m_strokePaint.setStyle(SkPaint::kStroke_Style); |
| 19 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); | 28 m_strokePaint.setStrokeWidth(SkFloatToScalar(m_strokeData.thickness())); |
| 20 m_strokePaint.setColor(m_strokeColor.rgb()); | 29 m_strokePaint.setColor(m_strokeColor.rgb()); |
| 21 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); | 30 m_strokePaint.setStrokeCap(SkPaint::kDefault_Cap); |
| 22 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); | 31 m_strokePaint.setStrokeJoin(SkPaint::kDefault_Join); |
| 23 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); | 32 m_strokePaint.setStrokeMiter(SkFloatToScalar(m_strokeData.miterLimit())); |
| 24 m_strokePaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality( m_interpolationQuality)); | 33 m_strokePaint.setFilterQuality(filterQualityForPaint(m_interpolationQuality) ); |
| 25 m_strokePaint.setAntiAlias(m_shouldAntialias); | 34 m_strokePaint.setAntiAlias(m_shouldAntialias); |
| 26 m_fillPaint.setColor(m_fillColor.rgb()); | 35 m_fillPaint.setColor(m_fillColor.rgb()); |
| 27 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(m_ interpolationQuality)); | 36 m_fillPaint.setFilterQuality(filterQualityForPaint(m_interpolationQuality)); |
| 28 m_fillPaint.setAntiAlias(m_shouldAntialias); | 37 m_fillPaint.setAntiAlias(m_shouldAntialias); |
| 29 } | 38 } |
| 30 | 39 |
| 31 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) | 40 GraphicsContextState::GraphicsContextState(const GraphicsContextState& other) |
| 32 : m_strokePaint(other.m_strokePaint) | 41 : m_strokePaint(other.m_strokePaint) |
| 33 , m_fillPaint(other.m_fillPaint) | 42 , m_fillPaint(other.m_fillPaint) |
| 34 , m_strokeData(other.m_strokeData) | 43 , m_strokeData(other.m_strokeData) |
| 35 , m_strokeColor(other.m_strokeColor) | 44 , m_strokeColor(other.m_strokeColor) |
| 36 , m_strokeGradient(other.m_strokeGradient) | 45 , m_strokeGradient(other.m_strokeGradient) |
| 37 , m_fillColor(other.m_fillColor) | 46 , m_fillColor(other.m_fillColor) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) | 157 void GraphicsContextState::setColorFilter(PassRefPtr<SkColorFilter> colorFilter) |
| 149 { | 158 { |
| 150 m_colorFilter = colorFilter; | 159 m_colorFilter = colorFilter; |
| 151 m_strokePaint.setColorFilter(m_colorFilter.get()); | 160 m_strokePaint.setColorFilter(m_colorFilter.get()); |
| 152 m_fillPaint.setColorFilter(m_colorFilter.get()); | 161 m_fillPaint.setColorFilter(m_colorFilter.get()); |
| 153 } | 162 } |
| 154 | 163 |
| 155 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) | 164 void GraphicsContextState::setInterpolationQuality(InterpolationQuality quality) |
| 156 { | 165 { |
| 157 m_interpolationQuality = quality; | 166 m_interpolationQuality = quality; |
| 158 m_strokePaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality( quality)); | 167 m_strokePaint.setFilterQuality(filterQualityForPaint(quality)); |
| 159 m_fillPaint.setFilterQuality(WebCoreInterpolationQualityToSkFilterQuality(qu ality)); | 168 m_fillPaint.setFilterQuality(filterQualityForPaint(quality)); |
| 160 } | 169 } |
| 161 | 170 |
| 162 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 171 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
| 163 { | 172 { |
| 164 m_shouldAntialias = shouldAntialias; | 173 m_shouldAntialias = shouldAntialias; |
| 165 m_strokePaint.setAntiAlias(shouldAntialias); | 174 m_strokePaint.setAntiAlias(shouldAntialias); |
| 166 m_fillPaint.setAntiAlias(shouldAntialias); | 175 m_fillPaint.setAntiAlias(shouldAntialias); |
| 167 } | 176 } |
| 168 | 177 |
| 169 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |