Chromium Code Reviews| 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 const SkMatrix localMatrix = affineTransformToSkMatrix(m_transform); |
| 58 m_pattern->applyToPaint(paint, &localMatrix); | |
| 56 } else if (m_gradient) { | 59 } else if (m_gradient) { |
| 57 m_gradient->applyToPaint(paint); | 60 const SkMatrix localMatrix = affineTransformToSkMatrix(m_transform); |
| 61 m_gradient->applyToPaint(paint, &localMatrix); | |
| 58 } else { | 62 } else { |
| 59 paint.setShader(nullptr); | 63 paint.setShader(nullptr); |
| 60 } | 64 } |
| 61 } | 65 } |
| 62 | 66 |
| 63 void SVGPaintServer::prependTransform(const AffineTransform& transform) | 67 void SVGPaintServer::prependTransform(const AffineTransform& transform) |
| 64 { | 68 { |
| 65 ASSERT(m_gradient || m_pattern); | 69 ASSERT(m_gradient || m_pattern); |
| 66 if (m_pattern) | 70 m_transform = transform * m_transform; |
|
Stephen White
2016/05/26 20:36:26
Is there any danger that this function will be cal
fs
2016/05/26 21:35:43
The semantics are unchanged, maybe easier to see i
Stephen White
2016/05/26 21:38:28
You're right; it's the same as before. Ignore my c
| |
| 67 m_pattern->setPatternSpaceTransform(transform * m_pattern->patternSpaceT ransform()); | |
| 68 else | |
| 69 m_gradient->setGradientSpaceTransform(transform * m_gradient->gradientSp aceTransform()); | |
| 70 } | 71 } |
| 71 | 72 |
| 72 static SVGPaintDescription requestPaint(const LayoutObject& object, const Comput edStyle& style, LayoutSVGResourceMode mode) | 73 static SVGPaintDescription requestPaint(const LayoutObject& object, const Comput edStyle& style, LayoutSVGResourceMode mode) |
| 73 { | 74 { |
| 74 // If we have no style at all, ignore it. | 75 // If we have no style at all, ignore it. |
| 75 const SVGComputedStyle& svgStyle = style.svgStyle(); | 76 const SVGComputedStyle& svgStyle = style.svgStyle(); |
| 76 | 77 |
| 77 // If we have no fill/stroke, return 0. | 78 // If we have no fill/stroke, return 0. |
| 78 if (mode == ApplyToFillMode) { | 79 if (mode == ApplyToFillMode) { |
| 79 if (!svgStyle.hasFill()) | 80 if (!svgStyle.hasFill()) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() | 176 LayoutSVGResourcePaintServer::~LayoutSVGResourcePaintServer() |
| 176 { | 177 { |
| 177 } | 178 } |
| 178 | 179 |
| 179 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription(const LayoutObject& layoutObject, const ComputedStyle& style, LayoutSVGResourceMode re sourceMode) | 180 SVGPaintDescription LayoutSVGResourcePaintServer::requestPaintDescription(const LayoutObject& layoutObject, const ComputedStyle& style, LayoutSVGResourceMode re sourceMode) |
| 180 { | 181 { |
| 181 return requestPaint(layoutObject, style, resourceMode); | 182 return requestPaint(layoutObject, style, resourceMode); |
| 182 } | 183 } |
| 183 | 184 |
| 184 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |