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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return FloatRect(); | 102 return FloatRect(); |
103 | 103 |
104 FloatRect destRect = | 104 FloatRect destRect = |
105 getFilter()->mapLocalRectToAbsoluteRect(filterPrimitiveSubregion()); | 105 getFilter()->mapLocalRectToAbsoluteRect(filterPrimitiveSubregion()); |
106 FloatRect srcRect; | 106 FloatRect srcRect; |
107 if (layoutObject) { | 107 if (layoutObject) { |
108 srcRect = getLayoutObjectRepaintRect(layoutObject); | 108 srcRect = getLayoutObjectRepaintRect(layoutObject); |
109 SVGElement* contextNode = toSVGElement(layoutObject->node()); | 109 SVGElement* contextNode = toSVGElement(layoutObject->node()); |
110 | 110 |
111 if (contextNode->hasRelativeLengths()) { | 111 if (contextNode->hasRelativeLengths()) { |
112 // FIXME: This fixes relative lengths but breaks non-relative ones (see cr
bug/260709). | 112 // FIXME: This fixes relative lengths but breaks non-relative ones (see |
| 113 // crbug/260709). |
113 SVGLengthContext lengthContext(contextNode); | 114 SVGLengthContext lengthContext(contextNode); |
114 FloatSize viewportSize; | 115 FloatSize viewportSize; |
115 if (lengthContext.determineViewport(viewportSize)) { | 116 if (lengthContext.determineViewport(viewportSize)) { |
116 srcRect = | 117 srcRect = |
117 makeMapBetweenRects(FloatRect(FloatPoint(), viewportSize), destRect) | 118 makeMapBetweenRects(FloatRect(FloatPoint(), viewportSize), destRect) |
118 .mapRect(srcRect); | 119 .mapRect(srcRect); |
119 } | 120 } |
120 } else { | 121 } else { |
121 srcRect = getFilter()->mapLocalRectToAbsoluteRect(srcRect); | 122 srcRect = getFilter()->mapLocalRectToAbsoluteRect(srcRect); |
122 srcRect.move(destRect.x(), destRect.y()); | 123 srcRect.move(destRect.x(), destRect.y()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 const LayoutObject& layoutObject) { | 160 const LayoutObject& layoutObject) { |
160 FloatRect dstRect = filterPrimitiveSubregion(); | 161 FloatRect dstRect = filterPrimitiveSubregion(); |
161 | 162 |
162 AffineTransform transform; | 163 AffineTransform transform; |
163 SVGElement* contextNode = toSVGElement(layoutObject.node()); | 164 SVGElement* contextNode = toSVGElement(layoutObject.node()); |
164 | 165 |
165 if (contextNode->hasRelativeLengths()) { | 166 if (contextNode->hasRelativeLengths()) { |
166 SVGLengthContext lengthContext(contextNode); | 167 SVGLengthContext lengthContext(contextNode); |
167 FloatSize viewportSize; | 168 FloatSize viewportSize; |
168 | 169 |
169 // If we're referencing an element with percentage units, eg. <rect with="30
%"> those values were resolved against the viewport. | 170 // If we're referencing an element with percentage units, eg. <rect |
170 // Build up a transformation that maps from the viewport space to the filter
primitive subregion. | 171 // with="30%"> those values were resolved against the viewport. Build up a |
| 172 // transformation that maps from the viewport space to the filter primitive |
| 173 // subregion. |
171 if (lengthContext.determineViewport(viewportSize)) | 174 if (lengthContext.determineViewport(viewportSize)) |
172 transform = | 175 transform = |
173 makeMapBetweenRects(FloatRect(FloatPoint(), viewportSize), dstRect); | 176 makeMapBetweenRects(FloatRect(FloatPoint(), viewportSize), dstRect); |
174 } else { | 177 } else { |
175 transform.translate(dstRect.x(), dstRect.y()); | 178 transform.translate(dstRect.x(), dstRect.y()); |
176 } | 179 } |
177 | 180 |
178 SkPictureBuilder filterPicture(dstRect); | 181 SkPictureBuilder filterPicture(dstRect); |
179 { | 182 { |
180 TransformRecorder transformRecorder(filterPicture.context(), layoutObject, | 183 TransformRecorder transformRecorder(filterPicture.context(), layoutObject, |
181 transform); | 184 transform); |
182 SVGPaintContext::paintSubtree(filterPicture.context(), &layoutObject); | 185 SVGPaintContext::paintSubtree(filterPicture.context(), &layoutObject); |
183 } | 186 } |
184 | 187 |
185 return SkPictureImageFilter::Make(filterPicture.endRecording(), dstRect); | 188 return SkPictureImageFilter::Make(filterPicture.endRecording(), dstRect); |
186 } | 189 } |
187 | 190 |
188 sk_sp<SkImageFilter> FEImage::createImageFilter() { | 191 sk_sp<SkImageFilter> FEImage::createImageFilter() { |
189 if (auto* layoutObject = referencedLayoutObject()) | 192 if (auto* layoutObject = referencedLayoutObject()) |
190 return createImageFilterForLayoutObject(*layoutObject); | 193 return createImageFilterForLayoutObject(*layoutObject); |
191 | 194 |
192 sk_sp<SkImage> image = m_image ? m_image->imageForCurrentFrame() : nullptr; | 195 sk_sp<SkImage> image = m_image ? m_image->imageForCurrentFrame() : nullptr; |
193 if (!image) { | 196 if (!image) { |
194 // "A href reference that is an empty image (zero width or zero height), tha
t fails | 197 // "A href reference that is an empty image (zero width or zero height), |
195 // to download, is non-existent, or that cannot be displayed (e.g. because i
t is | 198 // that fails to download, is non-existent, or that cannot be displayed |
196 // not in a supported image format) fills the filter primitive subregion wit
h | 199 // (e.g. because it is not in a supported image format) fills the filter |
197 // transparent black." | 200 // primitive subregion with transparent black." |
198 return createTransparentBlack(); | 201 return createTransparentBlack(); |
199 } | 202 } |
200 | 203 |
201 FloatRect srcRect = FloatRect(FloatPoint(), FloatSize(m_image->size())); | 204 FloatRect srcRect = FloatRect(FloatPoint(), FloatSize(m_image->size())); |
202 FloatRect dstRect = filterPrimitiveSubregion(); | 205 FloatRect dstRect = filterPrimitiveSubregion(); |
203 | 206 |
204 m_preserveAspectRatio->transformRect(dstRect, srcRect); | 207 m_preserveAspectRatio->transformRect(dstRect, srcRect); |
205 | 208 |
206 return SkImageSource::Make(std::move(image), srcRect, dstRect, | 209 return SkImageSource::Make(std::move(image), srcRect, dstRect, |
207 kHigh_SkFilterQuality); | 210 kHigh_SkFilterQuality); |
208 } | 211 } |
209 | 212 |
210 } // namespace blink | 213 } // namespace blink |
OLD | NEW |