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

Unified Diff: Source/core/svg/SVGFEBlendElement.cpp

Issue 419253002: Use WebBlendMode in FEBlend (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WebBlendModeNormal -> "normal" (not "source-over"). Created 6 years, 5 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/core/svg/SVGFEBlendElement.h ('k') | Source/platform/graphics/cpu/arm/filters/FEBlendNEON.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGFEBlendElement.cpp
diff --git a/Source/core/svg/SVGFEBlendElement.cpp b/Source/core/svg/SVGFEBlendElement.cpp
index 7c429c787fba8c73e0c07ab723e55b0a3d46cd40..7075f6e7ebf2befc68cb9c4f09052f65c9db7270 100644
--- a/Source/core/svg/SVGFEBlendElement.cpp
+++ b/Source/core/svg/SVGFEBlendElement.cpp
@@ -23,20 +23,40 @@
#include "core/svg/SVGFEBlendElement.h"
#include "core/SVGNames.h"
+#include "platform/graphics/filters/FEBlend.h"
#include "platform/graphics/filters/FilterEffect.h"
#include "core/svg/graphics/filters/SVGFilterBuilder.h"
namespace blink {
-template<> const SVGEnumerationStringEntries& getStaticStringEntries<BlendModeType>()
+static WebBlendMode toWebBlendMode(SVGFEBlendElement::Mode mode)
+{
+ switch (mode) {
+ case SVGFEBlendElement::ModeNormal:
+ return WebBlendModeNormal;
+ case SVGFEBlendElement::ModeMultiply:
+ return WebBlendModeMultiply;
+ case SVGFEBlendElement::ModeScreen:
+ return WebBlendModeScreen;
+ case SVGFEBlendElement::ModeDarken:
+ return WebBlendModeDarken;
+ case SVGFEBlendElement::ModeLighten:
+ return WebBlendModeLighten;
+ default:
+ ASSERT_NOT_REACHED();
+ return WebBlendModeNormal;
+ }
+}
+
+template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGFEBlendElement::Mode>()
{
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.isEmpty()) {
- entries.append(std::make_pair(FEBLEND_MODE_NORMAL, "normal"));
- entries.append(std::make_pair(FEBLEND_MODE_MULTIPLY, "multiply"));
- entries.append(std::make_pair(FEBLEND_MODE_SCREEN, "screen"));
- entries.append(std::make_pair(FEBLEND_MODE_DARKEN, "darken"));
- entries.append(std::make_pair(FEBLEND_MODE_LIGHTEN, "lighten"));
+ entries.append(std::make_pair(SVGFEBlendElement::ModeNormal, "normal"));
+ entries.append(std::make_pair(SVGFEBlendElement::ModeMultiply, "multiply"));
+ entries.append(std::make_pair(SVGFEBlendElement::ModeScreen, "screen"));
+ entries.append(std::make_pair(SVGFEBlendElement::ModeDarken, "darken"));
+ entries.append(std::make_pair(SVGFEBlendElement::ModeLighten, "lighten"));
}
return entries;
}
@@ -45,7 +65,7 @@ inline SVGFEBlendElement::SVGFEBlendElement(Document& document)
: SVGFilterPrimitiveStandardAttributes(SVGNames::feBlendTag, document)
, m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create()))
, m_in2(SVGAnimatedString::create(this, SVGNames::in2Attr, SVGString::create()))
- , m_mode(SVGAnimatedEnumeration<BlendModeType>::create(this, SVGNames::modeAttr, FEBLEND_MODE_NORMAL))
+ , m_mode(SVGAnimatedEnumeration<Mode>::create(this, SVGNames::modeAttr, SVGFEBlendElement::ModeNormal))
{
ScriptWrappable::init(this);
addToPropertyMap(m_in1);
@@ -91,7 +111,7 @@ bool SVGFEBlendElement::setFilterEffectAttribute(FilterEffect* effect, const Qua
{
FEBlend* blend = static_cast<FEBlend*>(effect);
if (attrName == SVGNames::modeAttr)
- return blend->setBlendMode(m_mode->currentValue()->enumValue());
+ return blend->setBlendMode(toWebBlendMode(m_mode->currentValue()->enumValue()));
ASSERT_NOT_REACHED();
return false;
@@ -127,7 +147,7 @@ PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilde
if (!input1 || !input2)
return nullptr;
- RefPtr<FilterEffect> effect = FEBlend::create(filter, m_mode->currentValue()->enumValue());
+ RefPtr<FilterEffect> effect = FEBlend::create(filter, toWebBlendMode(m_mode->currentValue()->enumValue()));
FilterEffectVector& inputEffects = effect->inputEffects();
inputEffects.reserveCapacity(2);
inputEffects.append(input1);
« no previous file with comments | « Source/core/svg/SVGFEBlendElement.h ('k') | Source/platform/graphics/cpu/arm/filters/FEBlendNEON.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698