| 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 { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 m_strokePaint.setShader(m_strokeData.gradient()->shader()); | 107 m_strokePaint.setShader(m_strokeData.gradient()->shader()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void GraphicsContextState::clearStrokeGradient() | 110 void GraphicsContextState::clearStrokeGradient() |
| 111 { | 111 { |
| 112 m_strokeData.clearGradient(); | 112 m_strokeData.clearGradient(); |
| 113 ASSERT(!m_strokeData.pattern()); | 113 ASSERT(!m_strokeData.pattern()); |
| 114 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); | 114 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern) | 117 void GraphicsContextState::setStrokePattern(const PassRefPtr<Pattern> pattern, S
kShader::ShaderLocation preferredLocation) |
| 118 { | 118 { |
| 119 m_strokeData.setColor(Color::black); | 119 m_strokeData.setColor(Color::black); |
| 120 m_strokeData.clearGradient(); | 120 m_strokeData.clearGradient(); |
| 121 m_strokeData.setPattern(pattern); | 121 m_strokeData.setPattern(pattern); |
| 122 m_strokePaint.setColor(applyAlpha(SK_ColorBLACK)); | 122 m_strokePaint.setColor(applyAlpha(SK_ColorBLACK)); |
| 123 m_strokePaint.setShader(m_strokeData.pattern()->shader()); | 123 m_strokePaint.setShader(m_strokeData.pattern()->shader(preferredLocation)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void GraphicsContextState::clearStrokePattern() | 126 void GraphicsContextState::clearStrokePattern() |
| 127 { | 127 { |
| 128 m_strokeData.clearPattern(); | 128 m_strokeData.clearPattern(); |
| 129 ASSERT(!m_strokeData.gradient()); | 129 ASSERT(!m_strokeData.gradient()); |
| 130 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); | 130 m_strokePaint.setColor(applyAlpha(m_strokeData.color().rgb())); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void GraphicsContextState::setLineCap(LineCap cap) | 133 void GraphicsContextState::setLineCap(LineCap cap) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 m_fillPaint.setShader(m_fillGradient->shader()); | 166 m_fillPaint.setShader(m_fillGradient->shader()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void GraphicsContextState::clearFillGradient() | 169 void GraphicsContextState::clearFillGradient() |
| 170 { | 170 { |
| 171 m_fillGradient.clear(); | 171 m_fillGradient.clear(); |
| 172 ASSERT(!m_fillPattern); | 172 ASSERT(!m_fillPattern); |
| 173 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 173 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern) | 176 void GraphicsContextState::setFillPattern(const PassRefPtr<Pattern> pattern, SkS
hader::ShaderLocation preferredLocation) |
| 177 { | 177 { |
| 178 m_fillColor = Color::black; | 178 m_fillColor = Color::black; |
| 179 m_fillGradient.clear(); | 179 m_fillGradient.clear(); |
| 180 m_fillPattern = pattern; | 180 m_fillPattern = pattern; |
| 181 m_fillPaint.setColor(applyAlpha(SK_ColorBLACK)); | 181 m_fillPaint.setColor(applyAlpha(SK_ColorBLACK)); |
| 182 m_fillPaint.setShader(m_fillPattern->shader()); | 182 m_fillPaint.setShader(m_fillPattern->shader(preferredLocation)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void GraphicsContextState::clearFillPattern() | 185 void GraphicsContextState::clearFillPattern() |
| 186 { | 186 { |
| 187 m_fillPattern.clear(); | 187 m_fillPattern.clear(); |
| 188 ASSERT(!m_fillGradient); | 188 ASSERT(!m_fillGradient); |
| 189 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); | 189 m_fillPaint.setColor(applyAlpha(m_fillColor.rgb())); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Shadow. (This will need tweaking if we use draw loopers for other things.) | 192 // Shadow. (This will need tweaking if we use draw loopers for other things.) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |