| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Google, Inc. All rights reserved. | 2 * Copyright (C) 2008 Google, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "Gradient.h" | 27 #include "Gradient.h" |
| 28 | 28 |
| 29 #include "CSSParser.h" | 29 #include "CSSParser.h" |
| 30 #include "GraphicsContext.h" | 30 #include "GraphicsContext.h" |
| 31 #include "NotImplemented.h" | |
| 32 | 31 |
| 33 #include "SkGradientShader.h" | 32 #include "SkGradientShader.h" |
| 34 #include "SkiaUtils.h" | 33 #include "SkiaUtils.h" |
| 35 | 34 |
| 36 namespace WebCore { | 35 namespace WebCore { |
| 37 | 36 |
| 38 void Gradient::platformDestroy() | 37 void Gradient::platformDestroy() |
| 39 { | 38 { |
| 40 if (m_gradient) | 39 if (m_gradient) |
| 41 m_gradient->safeUnref(); | 40 m_gradient->safeUnref(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ASSERT(count_used >= m_stops.size()); | 113 ASSERT(count_used >= m_stops.size()); |
| 115 | 114 |
| 116 // FIXME: Why is all this manual pointer math needed?! | 115 // FIXME: Why is all this manual pointer math needed?! |
| 117 SkAutoMalloc storage(count_used * (sizeof(SkColor) + sizeof(SkScalar))); | 116 SkAutoMalloc storage(count_used * (sizeof(SkColor) + sizeof(SkScalar))); |
| 118 SkColor* colors = (SkColor*)storage.get(); | 117 SkColor* colors = (SkColor*)storage.get(); |
| 119 SkScalar* pos = (SkScalar*)(colors + count_used); | 118 SkScalar* pos = (SkScalar*)(colors + count_used); |
| 120 | 119 |
| 121 fill_stops(m_stops.data(), m_stops.size(), pos, colors); | 120 fill_stops(m_stops.data(), m_stops.size(), pos, colors); |
| 122 | 121 |
| 123 if (m_radial) { | 122 if (m_radial) { |
| 123 // TODO(mmoss) CSS radial Gradients allow an offset focal point (the |
| 124 // "start circle"), but skia doesn't seem to support that, so this just |
| 125 // ignores m_p0/m_r0 and draws the gradient centered in the "end |
| 126 // circle" (m_p1/m_r1). |
| 127 // See http://webkit.org/blog/175/introducing-css-gradients/ for a |
| 128 // description of the expected behavior. |
| 124 m_gradient = SkGradientShader::CreateRadial(m_p1, | 129 m_gradient = SkGradientShader::CreateRadial(m_p1, |
| 125 WebCoreFloatToSkScalar(m_r1), colors, pos, | 130 WebCoreFloatToSkScalar(m_r1), colors, pos, |
| 126 static_cast<int>(count_used), SkShader::kClamp_TileMode); | 131 static_cast<int>(count_used), SkShader::kClamp_TileMode); |
| 127 } else { | 132 } else { |
| 128 SkPoint pts[2] = { m_p0, m_p1 }; | 133 SkPoint pts[2] = { m_p0, m_p1 }; |
| 129 m_gradient = SkGradientShader::CreateLinear(pts, colors, pos, | 134 m_gradient = SkGradientShader::CreateLinear(pts, colors, pos, |
| 130 static_cast<int>(count_used), SkShader::kClamp_TileMode); | 135 static_cast<int>(count_used), SkShader::kClamp_TileMode); |
| 131 } | 136 } |
| 132 | 137 |
| 133 return m_gradient; | 138 return m_gradient; |
| 134 } | 139 } |
| 135 | 140 |
| 136 void Gradient::fill(GraphicsContext* context, const FloatRect& rect) | 141 void Gradient::fill(GraphicsContext* context, const FloatRect& rect) |
| 137 { | 142 { |
| 138 // Until this is filled, we don't support CSSGradients | 143 context->setFillGradient(this); |
| 139 notImplemented(); | 144 context->fillRect(rect); |
| 140 } | 145 } |
| 141 | 146 |
| 142 } // namespace WebCore | 147 } // namespace WebCore |
| OLD | NEW |