Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: Source/WebCore/svg/graphics/filters/SVGFEImage.cpp

Issue 9117045: Merge 105612 - <feImage> has problems referencing local elements (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/svg/graphics/filters/SVGFEImage.h ('k') | Source/WebCore/svg/graphics/filters/SVGFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/svg/graphics/filters/SVGFEImage.cpp
===================================================================
--- Source/WebCore/svg/graphics/filters/SVGFEImage.cpp (revision 105779)
+++ Source/WebCore/svg/graphics/filters/SVGFEImage.cpp (working copy)
@@ -28,8 +28,12 @@
#include "AffineTransform.h"
#include "Filter.h"
#include "GraphicsContext.h"
+#include "RenderObject.h"
#include "RenderTreeAsText.h"
+#include "SVGFilter.h"
+#include "SVGImageBufferTools.h"
#include "SVGPreserveAspectRatio.h"
+#include "SVGURIReference.h"
#include "TextStream.h"
namespace WebCore {
@@ -37,34 +41,74 @@
FEImage::FEImage(Filter* filter, PassRefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio)
: FilterEffect(filter)
, m_image(image)
+ , m_document(0)
, m_preserveAspectRatio(preserveAspectRatio)
{
}
-PassRefPtr<FEImage> FEImage::create(Filter* filter, PassRefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio)
+FEImage::FEImage(Filter* filter, Document* document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
+ : FilterEffect(filter)
+ , m_document(document)
+ , m_href(href)
+ , m_preserveAspectRatio(preserveAspectRatio)
{
+}
+
+PassRefPtr<FEImage> FEImage::createWithImage(Filter* filter, PassRefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio)
+{
return adoptRef(new FEImage(filter, image, preserveAspectRatio));
}
+PassRefPtr<FEImage> FEImage::createWithIRIReference(Filter* filter, Document* document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
+{
+ return adoptRef(new FEImage(filter, document, href, preserveAspectRatio));
+}
+
void FEImage::determineAbsolutePaintRect()
{
- ASSERT(m_image);
- FloatRect srcRect(FloatPoint(), m_image->size());
+ FloatRect srcRect;
+ if (m_image)
+ srcRect.setSize(m_image->size());
+ else if (RenderObject* renderer = referencedRenderer())
+ srcRect = static_cast<SVGFilter*>(filter())->absoluteTransform().mapRect(renderer->repaintRectInLocalCoordinates());
+
FloatRect paintRect(m_absoluteSubregion);
m_preserveAspectRatio.transformRect(paintRect, srcRect);
paintRect.intersect(maxEffectRect());
setAbsolutePaintRect(enclosingIntRect(paintRect));
}
+RenderObject* FEImage::referencedRenderer() const
+{
+ if (!m_document)
+ return 0;
+ Element* hrefElement = SVGURIReference::targetElementFromIRIString(m_href, m_document);
+ if (!hrefElement || !hrefElement->isSVGElement())
+ return 0;
+ return hrefElement->renderer();
+}
+
void FEImage::platformApplySoftware()
{
- if (!m_image.get())
+ RenderObject* renderer = referencedRenderer();
+ if (!m_image && !renderer)
return;
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
+ if (renderer) {
+ const AffineTransform& absoluteTransform = static_cast<SVGFilter*>(filter())->absoluteTransform();
+ resultImage->context()->concatCTM(absoluteTransform);
+
+ AffineTransform contentTransformation;
+ SVGImageBufferTools::renderSubtreeToImageBuffer(resultImage, renderer, contentTransformation);
+
+ resultImage->context()->concatCTM(absoluteTransform.inverse());
+ return;
+ }
+
FloatRect srcRect(FloatPoint(), m_image->size());
FloatRect destRect(m_absoluteSubregion);
m_preserveAspectRatio.transformRect(destRect, srcRect);
@@ -81,8 +125,11 @@
TextStream& FEImage::externalRepresentation(TextStream& ts, int indent) const
{
- ASSERT(m_image);
- IntSize imageSize = m_image->size();
+ IntSize imageSize;
+ if (m_image)
+ imageSize = m_image->size();
+ else if (RenderObject* renderer = referencedRenderer())
+ imageSize = enclosingIntRect(renderer->repaintRectInLocalCoordinates()).size();
writeIndent(ts, indent);
ts << "[feImage";
FilterEffect::externalRepresentation(ts);
« no previous file with comments | « Source/WebCore/svg/graphics/filters/SVGFEImage.h ('k') | Source/WebCore/svg/graphics/filters/SVGFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698