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

Unified Diff: Source/WebCore/rendering/FilterEffectRenderer.cpp

Issue 13984002: Extracting the SVG Filter Reference implementation out of the FilterEffectRenderer into its own typ… Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Removed the changes in SkiaImageFilterBuilder.cpp Created 7 years, 8 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
Index: Source/WebCore/rendering/FilterEffectRenderer.cpp
diff --git a/Source/WebCore/rendering/FilterEffectRenderer.cpp b/Source/WebCore/rendering/FilterEffectRenderer.cpp
index 2de91c4fb1e4cd88d91f8b6a1c54505879539cc1..dfe3615b58f0a61429792bcbee1ae6ca42a26641 100644
--- a/Source/WebCore/rendering/FilterEffectRenderer.cpp
+++ b/Source/WebCore/rendering/FilterEffectRenderer.cpp
@@ -55,6 +55,7 @@
#if ENABLE(SVG)
#include "CachedSVGDocument.h"
#include "CachedSVGDocumentReference.h"
+#include "ReferenceFilterBuilder.h"
#include "SVGElement.h"
#include "SVGFilterPrimitiveStandardAttributes.h"
#include "SourceAlpha.h"
@@ -121,70 +122,6 @@ GraphicsContext* FilterEffectRenderer::inputContext()
return sourceImage() ? sourceImage()->context() : 0;
}
-PassRefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(RenderObject* renderer, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation* filterOperation)
-{
-#if ENABLE(SVG)
- if (!renderer)
- return 0;
-
- Document* document = renderer->document();
- ASSERT(document);
-
- CachedSVGDocumentReference* cachedSVGDocumentReference = filterOperation->cachedSVGDocumentReference();
- CachedSVGDocument* cachedSVGDocument = cachedSVGDocumentReference ? cachedSVGDocumentReference->document() : 0;
-
- // If we have an SVG document, this is an external reference. Otherwise
- // we look up the referenced node in the current document.
- if (cachedSVGDocument)
- document = cachedSVGDocument->document();
-
- if (!document)
- return 0;
-
- Element* filter = document->getElementById(filterOperation->fragment());
- if (!filter) {
- // Although we did not find the referenced filter, it might exist later
- // in the document
- document->accessSVGExtensions()->addPendingResource(filterOperation->fragment(), toElement(renderer->node()));
- return 0;
- }
-
- RefPtr<FilterEffect> effect;
-
- // FIXME: Figure out what to do with SourceAlpha. Right now, we're
- // using the alpha of the original input layer, which is obviously
- // wrong. We should probably be extracting the alpha from the
- // previousEffect, but this requires some more processing.
- // This may need a spec clarification.
- RefPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(previousEffect, SourceAlpha::create(this));
-
- for (Node* node = filter->firstChild(); node; node = node->nextSibling()) {
- if (!node->isSVGElement())
- continue;
-
- SVGElement* element = toSVGElement(node);
- if (!element->isFilterEffect())
- continue;
-
- SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFilterPrimitiveStandardAttributes*>(element);
-
- effect = effectElement->build(builder.get(), this);
- if (!effect)
- continue;
-
- effectElement->setStandardAttributes(effect.get());
- builder->add(effectElement->result(), effect);
- m_effects.append(effect);
- }
- return effect;
-#else
- UNUSED_PARAM(renderer);
- UNUSED_PARAM(previousEffect);
- UNUSED_PARAM(filterOperation);
- return 0;
-#endif
-}
-
bool FilterEffectRenderer::build(RenderObject* renderer, const FilterOperations& operations)
{
#if ENABLE(CSS_SHADERS)
@@ -206,8 +143,7 @@ bool FilterEffectRenderer::build(RenderObject* renderer, const FilterOperations&
switch (filterOperation->getOperationType()) {
case FilterOperation::REFERENCE: {
ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
- effect = buildReferenceFilter(renderer, previousEffect, referenceOperation);
- referenceOperation->setFilterEffect(effect);
+ effect = ReferenceFilterBuilder::build(this, renderer, previousEffect.get(), referenceOperation, m_effects);
break;
}
case FilterOperation::GRAYSCALE: {

Powered by Google App Engine
This is Rietveld 408576698