| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "platform/graphics/skia/SkiaUtils.h" | 28 #include "platform/graphics/skia/SkiaUtils.h" |
| 29 #include "third_party/skia/include/core/SkPaint.h" | 29 #include "third_party/skia/include/core/SkPaint.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 SVGPaintServer::SVGPaintServer(Color color) | 33 SVGPaintServer::SVGPaintServer(Color color) |
| 34 : m_color(color) | 34 : m_color(color) |
| 35 { | 35 { |
| 36 } | 36 } |
| 37 | 37 |
| 38 SVGPaintServer::SVGPaintServer(PassRefPtr<Gradient> gradient) | 38 SVGPaintServer::SVGPaintServer(PassRefPtr<Gradient> gradient, const AffineTransf
orm& transform) |
| 39 : m_gradient(gradient) | 39 : m_gradient(gradient) |
| 40 , m_transform(transform) |
| 40 , m_color(Color::black) | 41 , m_color(Color::black) |
| 41 { | 42 { |
| 42 } | 43 } |
| 43 | 44 |
| 44 SVGPaintServer::SVGPaintServer(PassRefPtr<Pattern> pattern) | 45 SVGPaintServer::SVGPaintServer(PassRefPtr<Pattern> pattern, const AffineTransfor
m& transform) |
| 45 : m_pattern(pattern) | 46 : m_pattern(pattern) |
| 47 , m_transform(transform) |
| 46 , m_color(Color::black) | 48 , m_color(Color::black) |
| 47 { | 49 { |
| 48 } | 50 } |
| 49 | 51 |
| 50 void SVGPaintServer::applyToSkPaint(SkPaint& paint, float paintAlpha) | 52 void SVGPaintServer::applyToSkPaint(SkPaint& paint, float paintAlpha) |
| 51 { | 53 { |
| 52 SkColor baseColor = m_gradient || m_pattern ? SK_ColorBLACK : m_color.rgb(); | 54 SkColor baseColor = m_gradient || m_pattern ? SK_ColorBLACK : m_color.rgb(); |
| 53 paint.setColor(scaleAlpha(baseColor, paintAlpha)); | 55 paint.setColor(scaleAlpha(baseColor, paintAlpha)); |
| 54 if (m_pattern) { | 56 if (m_pattern) { |
| 55 m_pattern->applyToPaint(paint); | 57 m_pattern->applyToPaint(paint, affineTransformToSkMatrix(m_transform)); |
| 56 } else if (m_gradient) { | 58 } else if (m_gradient) { |
| 57 m_gradient->applyToPaint(paint); | 59 m_gradient->applyToPaint(paint, affineTransformToSkMatrix(m_transform)); |
| 58 } else { | 60 } else { |
| 59 paint.setShader(nullptr); | 61 paint.setShader(nullptr); |
| 60 } | 62 } |
| 61 } | 63 } |
| 62 | 64 |
| 63 void SVGPaintServer::prependTransform(const AffineTransform& transform) | 65 void SVGPaintServer::prependTransform(const AffineTransform& transform) |
| 64 { | 66 { |
| 65 ASSERT(m_gradient || m_pattern); | 67 ASSERT(m_gradient || m_pattern); |
| 66 if (m_pattern) | 68 m_transform = transform * m_transform; |
| 67 m_pattern->setPatternSpaceTransform(transform * m_pattern->patternSpaceT
ransform()); | |
| 68 else | |
| 69 m_gradient->setGradientSpaceTransform(transform * m_gradient->gradientSp
aceTransform()); | |
| 70 } | 69 } |
| 71 | 70 |
| 72 static SVGPaintDescription requestPaint(const LayoutObject& object, const Comput
edStyle& style, LayoutSVGResourceMode mode) | 71 static SVGPaintDescription requestPaint(const LayoutObject& object, const Comput
edStyle& style, LayoutSVGResourceMode mode) |
| 73 { | 72 { |
| 74 // If we have no style at all, ignore it. | 73 // If we have no style at all, ignore it. |
| 75 const SVGComputedStyle& svgStyle = style.svgStyle(); | 74 const SVGComputedStyle& svgStyle = style.svgStyle(); |
| 76 | 75 |
| 77 // If we have no fill/stroke, return 0. | 76 // If we have no fill/stroke, return 0. |
| 78 if (mode == ApplyToFillMode) { | 77 if (mode == ApplyToFillMode) { |
| 79 if (!svgStyle.hasFill()) | 78 if (!svgStyle.hasFill()) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() | 174 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() |
| 176 { | 175 { |
| 177 } | 176 } |
| 178 | 177 |
| 179 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription(const
LayoutObject& layoutObject, const ComputedStyle& style, LayoutSVGResourceMode re
sourceMode) | 178 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription(const
LayoutObject& layoutObject, const ComputedStyle& style, LayoutSVGResourceMode re
sourceMode) |
| 180 { | 179 { |
| 181 return requestPaint(layoutObject, style, resourceMode); | 180 return requestPaint(layoutObject, style, resourceMode); |
| 182 } | 181 } |
| 183 | 182 |
| 184 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |