| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> |
| 6 * Copyright (C) 2013 Google Inc. All rights reserved. | 6 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 AffineTransform makeMapBetweenRects(const FloatRect& source, const FloatRect& de
st) | 85 AffineTransform makeMapBetweenRects(const FloatRect& source, const FloatRect& de
st) |
| 86 { | 86 { |
| 87 AffineTransform transform; | 87 AffineTransform transform; |
| 88 transform.translate(dest.x() - source.x(), dest.y() - source.y()); | 88 transform.translate(dest.x() - source.x(), dest.y() - source.y()); |
| 89 transform.scale(dest.width() / source.width(), dest.height() / source.height
()); | 89 transform.scale(dest.width() / source.width(), dest.height() / source.height
()); |
| 90 return transform; | 90 return transform; |
| 91 } | 91 } |
| 92 | 92 |
| 93 FloatRect FEImage::determineAbsolutePaintRect(const FloatRect& originalRequested
Rect) const | 93 FloatRect FEImage::mapInputs(const FloatRect&) const |
| 94 { | 94 { |
| 95 LayoutObject* layoutObject = referencedLayoutObject(); | 95 LayoutObject* layoutObject = referencedLayoutObject(); |
| 96 if (!m_image && !layoutObject) | 96 if (!m_image && !layoutObject) |
| 97 return FloatRect(); | 97 return FloatRect(); |
| 98 | 98 |
| 99 FloatRect requestedRect = originalRequestedRect; | |
| 100 if (clipsToBounds()) | |
| 101 requestedRect.intersect(absoluteBounds()); | |
| 102 | |
| 103 FloatRect destRect = getFilter()->mapLocalRectToAbsoluteRect(filterPrimitive
Subregion()); | 99 FloatRect destRect = getFilter()->mapLocalRectToAbsoluteRect(filterPrimitive
Subregion()); |
| 104 FloatRect srcRect; | 100 FloatRect srcRect; |
| 105 if (layoutObject) { | 101 if (layoutObject) { |
| 106 srcRect = getLayoutObjectRepaintRect(layoutObject); | 102 srcRect = getLayoutObjectRepaintRect(layoutObject); |
| 107 SVGElement* contextNode = toSVGElement(layoutObject->node()); | 103 SVGElement* contextNode = toSVGElement(layoutObject->node()); |
| 108 | 104 |
| 109 if (contextNode->hasRelativeLengths()) { | 105 if (contextNode->hasRelativeLengths()) { |
| 110 // FIXME: This fixes relative lengths but breaks non-relative ones (
see crbug/260709). | 106 // FIXME: This fixes relative lengths but breaks non-relative ones (
see crbug/260709). |
| 111 SVGLengthContext lengthContext(contextNode); | 107 SVGLengthContext lengthContext(contextNode); |
| 112 FloatSize viewportSize; | 108 FloatSize viewportSize; |
| 113 if (lengthContext.determineViewport(viewportSize)) { | 109 if (lengthContext.determineViewport(viewportSize)) { |
| 114 srcRect = makeMapBetweenRects(FloatRect(FloatPoint(), viewportSi
ze), destRect).mapRect(srcRect); | 110 srcRect = makeMapBetweenRects(FloatRect(FloatPoint(), viewportSi
ze), destRect).mapRect(srcRect); |
| 115 } | 111 } |
| 116 } else { | 112 } else { |
| 117 srcRect = getFilter()->mapLocalRectToAbsoluteRect(srcRect); | 113 srcRect = getFilter()->mapLocalRectToAbsoluteRect(srcRect); |
| 118 srcRect.move(destRect.x(), destRect.y()); | 114 srcRect.move(destRect.x(), destRect.y()); |
| 119 } | 115 } |
| 120 destRect.intersect(srcRect); | 116 destRect.intersect(srcRect); |
| 121 } else { | 117 } else { |
| 122 srcRect = FloatRect(FloatPoint(), FloatSize(m_image->size())); | 118 srcRect = FloatRect(FloatPoint(), FloatSize(m_image->size())); |
| 123 m_preserveAspectRatio->transformRect(destRect, srcRect); | 119 m_preserveAspectRatio->transformRect(destRect, srcRect); |
| 124 } | 120 } |
| 125 | |
| 126 destRect.intersect(requestedRect); | |
| 127 return destRect; | 121 return destRect; |
| 128 } | 122 } |
| 129 | 123 |
| 130 LayoutObject* FEImage::referencedLayoutObject() const | 124 LayoutObject* FEImage::referencedLayoutObject() const |
| 131 { | 125 { |
| 132 if (!m_treeScope) | 126 if (!m_treeScope) |
| 133 return nullptr; | 127 return nullptr; |
| 134 Element* hrefElement = SVGURIReference::targetElementFromIRIString(m_href, *
m_treeScope); | 128 Element* hrefElement = SVGURIReference::targetElementFromIRIString(m_href, *
m_treeScope); |
| 135 if (!hrefElement || !hrefElement->isSVGElement()) | 129 if (!hrefElement || !hrefElement->isSVGElement()) |
| 136 return nullptr; | 130 return nullptr; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 190 |
| 197 FloatRect srcRect = FloatRect(FloatPoint(), FloatSize(m_image->size())); | 191 FloatRect srcRect = FloatRect(FloatPoint(), FloatSize(m_image->size())); |
| 198 FloatRect dstRect = filterPrimitiveSubregion(); | 192 FloatRect dstRect = filterPrimitiveSubregion(); |
| 199 | 193 |
| 200 m_preserveAspectRatio->transformRect(dstRect, srcRect); | 194 m_preserveAspectRatio->transformRect(dstRect, srcRect); |
| 201 | 195 |
| 202 return SkImageSource::Make(std::move(image), srcRect, dstRect, kHigh_SkFilte
rQuality); | 196 return SkImageSource::Make(std::move(image), srcRect, dstRect, kHigh_SkFilte
rQuality); |
| 203 } | 197 } |
| 204 | 198 |
| 205 } // namespace blink | 199 } // namespace blink |
| OLD | NEW |