| 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 "platform/graphics/GraphicsContextState.h" | 5 #include "platform/graphics/GraphicsContextState.h" |
| 6 | 6 |
| 7 #include "platform/graphics/skia/SkiaUtils.h" | 7 #include "platform/graphics/skia/SkiaUtils.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 void GraphicsContextState::setStrokeThickness(float thickness) | 82 void GraphicsContextState::setStrokeThickness(float thickness) |
| 83 { | 83 { |
| 84 m_strokeData.setThickness(thickness); | 84 m_strokeData.setThickness(thickness); |
| 85 m_strokePaint.setStrokeWidth(SkFloatToScalar(thickness)); | 85 m_strokePaint.setStrokeWidth(SkFloatToScalar(thickness)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void GraphicsContextState::setStrokeColor(const Color& color) | 88 void GraphicsContextState::setStrokeColor(const Color& color) |
| 89 { | 89 { |
| 90 m_strokeColor = color; |
| 91 m_strokePaint.setColor(Color::toDeviceColor(color).rgb()); |
| 90 m_strokeGradient.clear(); | 92 m_strokeGradient.clear(); |
| 91 m_strokeColor = color; | |
| 92 m_strokePaint.setColor(color.rgb()); | |
| 93 m_strokePaint.setShader(0); | 93 m_strokePaint.setShader(0); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient
, float alpha) | 96 void GraphicsContextState::setStrokeGradient(const PassRefPtr<Gradient> gradient
, float alpha) |
| 97 { | 97 { |
| 98 m_strokeColor = Color::black; | 98 m_strokeColor = Color::black; |
| 99 m_strokeGradient = gradient; | 99 m_strokeGradient = gradient; |
| 100 m_strokePaint.setColor(scaleAlpha(SK_ColorBLACK, alpha)); | 100 SkColor strokeColor = scaleAlpha(Color::black, alpha); |
| 101 m_strokePaint.setColor(Color::toDeviceColor(strokeColor).rgb()); |
| 101 m_strokeGradient->applyToPaint(m_strokePaint); | 102 m_strokeGradient->applyToPaint(m_strokePaint); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void GraphicsContextState::setLineCap(LineCap cap) | 105 void GraphicsContextState::setLineCap(LineCap cap) |
| 105 { | 106 { |
| 106 m_strokeData.setLineCap(cap); | 107 m_strokeData.setLineCap(cap); |
| 107 m_strokePaint.setStrokeCap((SkPaint::Cap)cap); | 108 m_strokePaint.setStrokeCap((SkPaint::Cap)cap); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void GraphicsContextState::setLineJoin(LineJoin join) | 111 void GraphicsContextState::setLineJoin(LineJoin join) |
| 111 { | 112 { |
| 112 m_strokeData.setLineJoin(join); | 113 m_strokeData.setLineJoin(join); |
| 113 m_strokePaint.setStrokeJoin((SkPaint::Join)join); | 114 m_strokePaint.setStrokeJoin((SkPaint::Join)join); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void GraphicsContextState::setMiterLimit(float miterLimit) | 117 void GraphicsContextState::setMiterLimit(float miterLimit) |
| 117 { | 118 { |
| 118 m_strokeData.setMiterLimit(miterLimit); | 119 m_strokeData.setMiterLimit(miterLimit); |
| 119 m_strokePaint.setStrokeMiter(SkFloatToScalar(miterLimit)); | 120 m_strokePaint.setStrokeMiter(SkFloatToScalar(miterLimit)); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void GraphicsContextState::setFillColor(const Color& color) | 123 void GraphicsContextState::setFillColor(const Color& color) |
| 123 { | 124 { |
| 124 m_fillColor = color; | 125 m_fillColor = color; |
| 126 m_fillPaint.setColor(Color::toDeviceColor(color).rgb()); |
| 125 m_fillGradient.clear(); | 127 m_fillGradient.clear(); |
| 126 m_fillPaint.setColor(color.rgb()); | |
| 127 m_fillPaint.setShader(0); | 128 m_fillPaint.setShader(0); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient,
float alpha) | 131 void GraphicsContextState::setFillGradient(const PassRefPtr<Gradient> gradient,
float alpha) |
| 131 { | 132 { |
| 132 m_fillColor = Color::black; | 133 m_fillColor = Color::black; |
| 133 m_fillGradient = gradient; | 134 m_fillGradient = gradient; |
| 134 m_fillPaint.setColor(scaleAlpha(SK_ColorBLACK, alpha)); | 135 SkColor fillColor = scaleAlpha(Color::black, alpha); |
| 136 m_fillPaint.setColor(Color::toDeviceColor(fillColor).rgb()); |
| 135 m_fillGradient->applyToPaint(m_fillPaint); | 137 m_fillGradient->applyToPaint(m_fillPaint); |
| 136 } | 138 } |
| 137 | 139 |
| 138 // Shadow. (This will need tweaking if we use draw loopers for other things.) | 140 // Shadow. (This will need tweaking if we use draw loopers for other things.) |
| 139 void GraphicsContextState::setDrawLooper(PassRefPtr<SkDrawLooper> drawLooper) | 141 void GraphicsContextState::setDrawLooper(PassRefPtr<SkDrawLooper> drawLooper) |
| 140 { | 142 { |
| 141 m_looper = drawLooper; | 143 m_looper = drawLooper; |
| 142 m_strokePaint.setLooper(m_looper.get()); | 144 m_strokePaint.setLooper(m_looper.get()); |
| 143 m_fillPaint.setLooper(m_looper.get()); | 145 m_fillPaint.setLooper(m_looper.get()); |
| 144 } | 146 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 170 } | 172 } |
| 171 | 173 |
| 172 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) | 174 void GraphicsContextState::setShouldAntialias(bool shouldAntialias) |
| 173 { | 175 { |
| 174 m_shouldAntialias = shouldAntialias; | 176 m_shouldAntialias = shouldAntialias; |
| 175 m_strokePaint.setAntiAlias(shouldAntialias); | 177 m_strokePaint.setAntiAlias(shouldAntialias); |
| 176 m_fillPaint.setAntiAlias(shouldAntialias); | 178 m_fillPaint.setAntiAlias(shouldAntialias); |
| 177 } | 179 } |
| 178 | 180 |
| 179 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |