| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 #include "platform/graphics/Gradient.h" | 29 #include "platform/graphics/Gradient.h" |
| 30 | 30 |
| 31 #include "platform/geometry/FloatRect.h" | 31 #include "platform/geometry/FloatRect.h" |
| 32 #include "platform/graphics/GraphicsContext.h" | 32 #include "platform/graphics/GraphicsContext.h" |
| 33 #include "platform/graphics/skia/SkiaUtils.h" | 33 #include "platform/graphics/skia/SkiaUtils.h" |
| 34 #include "third_party/skia/include/core/SkColor.h" | 34 #include "third_party/skia/include/core/SkColor.h" |
| 35 #include "third_party/skia/include/core/SkColorShader.h" | |
| 36 #include "third_party/skia/include/core/SkShader.h" | 35 #include "third_party/skia/include/core/SkShader.h" |
| 37 #include "third_party/skia/include/effects/SkGradientShader.h" | 36 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 38 | 37 |
| 39 typedef Vector<SkScalar, 8> ColorStopOffsetVector; | 38 typedef Vector<SkScalar, 8> ColorStopOffsetVector; |
| 40 typedef Vector<SkColor, 8> ColorStopColorVector; | 39 typedef Vector<SkColor, 8> ColorStopColorVector; |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 Gradient::Gradient(const FloatPoint& p0, const FloatPoint& p1) | 43 Gradient::Gradient(const FloatPoint& p0, const FloatPoint& p1) |
| 45 : m_p0(p0) | 44 : m_p0(p0) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 m_gradient = adoptRef(SkGradientShader::CreateTwoPointConical(m_p0.d
ata(), radius0, m_p1.data(), radius1, colors.data(), pos.data(), static_cast<int
>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix)); | 252 m_gradient = adoptRef(SkGradientShader::CreateTwoPointConical(m_p0.d
ata(), radius0, m_p1.data(), radius1, colors.data(), pos.data(), static_cast<int
>(countUsed), tile, shouldDrawInPMColorSpace, &localMatrix)); |
| 254 } | 253 } |
| 255 } else { | 254 } else { |
| 256 SkPoint pts[2] = { m_p0.data(), m_p1.data() }; | 255 SkPoint pts[2] = { m_p0.data(), m_p1.data() }; |
| 257 SkMatrix localMatrix = affineTransformToSkMatrix(m_gradientSpaceTransfor
mation); | 256 SkMatrix localMatrix = affineTransformToSkMatrix(m_gradientSpaceTransfor
mation); |
| 258 m_gradient = adoptRef(SkGradientShader::CreateLinear(pts, colors.data(),
pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &local
Matrix)); | 257 m_gradient = adoptRef(SkGradientShader::CreateLinear(pts, colors.data(),
pos.data(), static_cast<int>(countUsed), tile, shouldDrawInPMColorSpace, &local
Matrix)); |
| 259 } | 258 } |
| 260 | 259 |
| 261 if (!m_gradient) { | 260 if (!m_gradient) { |
| 262 // use last color, since our "geometry" was degenerate (e.g. radius==0) | 261 // use last color, since our "geometry" was degenerate (e.g. radius==0) |
| 263 m_gradient = adoptRef(new SkColorShader(colors[countUsed - 1])); | 262 m_gradient = adoptRef(SkShader::CreateColorShader(colors[countUsed - 1])
); |
| 264 } | 263 } |
| 265 return m_gradient.get(); | 264 return m_gradient.get(); |
| 266 } | 265 } |
| 267 | 266 |
| 268 } // namespace blink | 267 } // namespace blink |
| OLD | NEW |