You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2018/09/02 08:57:33 UTC
[royale-asjs] 03/14: Filter elements should not be treated as beads
as they are not unique.
This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch feature/Merge_MXRoyale_To_Develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 3383bd7832f42bed89568a86034d3aaed17d659e
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Wed Jul 11 16:11:04 2018 +0300
Filter elements should not be treated as beads as they are not
unique.
---
.../Graphics/src/main/resources/defaults.css | 8 ---
.../org/apache/royale/svg/BlendFilterElement.as | 37 ++++------
.../org/apache/royale/svg/BlurFilterElement.as | 10 ++-
.../apache/royale/svg/ColorMatrixFilterElement.as | 12 ++--
.../apache/royale/svg/CompositeFilterElement.as | 12 ++--
.../main/royale/org/apache/royale/svg/Filter.as | 16 ++---
.../royale/org/apache/royale/svg/FilterElement.as | 65 ++++++++---------
.../org/apache/royale/svg/InvertFilterElement.as | 16 ++---
.../org/apache/royale/svg/MergeFilterElement.as | 84 ----------------------
.../org/apache/royale/svg/OffsetFilterElement.as | 12 ++--
.../org/apache/royale/svg/SpreadFilterElement.as | 14 ++--
11 files changed, 78 insertions(+), 208 deletions(-)
diff --git a/frameworks/projects/Graphics/src/main/resources/defaults.css b/frameworks/projects/Graphics/src/main/resources/defaults.css
index 99d45ee..6bc0b1b 100644
--- a/frameworks/projects/Graphics/src/main/resources/defaults.css
+++ b/frameworks/projects/Graphics/src/main/resources/defaults.css
@@ -38,12 +38,4 @@ svg|BinaryImage
svg|DropShadowFilter
{
Filter: ClassReference("org.apache.royale.svg.Filter");
- BlendFilterElement: ClassReference("org.apache.royale.svg.BlendFilterElement");
- OffsetFilterElement: ClassReference("org.apache.royale.svg.OffsetFilterElement");
- ColorMatrixFilterElement: ClassReference("org.apache.royale.svg.ColorMatrixFilterElement");
- BlurFilterElement: ClassReference("org.apache.royale.svg.BlurFilterElement");
- BlendFilterElement: ClassReference("org.apache.royale.svg.BlendFilterElement");
- SpreadFilterElement: ClassReference("org.apache.royale.svg.SpreadFilterElement");
- CompositeFilterElement: ClassReference("org.apache.royale.svg.CompositeFilterElement");
- InvertFilterElement: ClassReference("org.apache.royale.svg.InvertFilterElement");
}
\ No newline at end of file
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
index bca53eb..ecbac1d 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
@@ -36,7 +36,7 @@ package org.apache.royale.svg
* @playerversion AIR 2.6
* @productversion Royale 0.9.3
*/
- public class BlendFilterElement implements IBead
+ public class BlendFilterElement extends FilterElement
{
private var _strand:IStrand;
private var _in2:String;
@@ -47,32 +47,15 @@ package org.apache.royale.svg
}
/**
- * @copy org.apache.royale.core.IBead#strand
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.3
- */
- public function set strand(value:IStrand):void
- {
- _strand = value;
- (_strand as IEventDispatcher).addEventListener('beadsAdded', onInitComplete);
- }
-
- /**
* @royaleignorecoercion Element
*/
- protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ override protected function build():void
{
- COMPILE::JS
- {
- var filter:Element = (_strand.getBeadByType(Filter) as Filter).filterElementWrapper;
- var blend:Element = addSvgElementToElement(filter, "feBlend") as Element;
- blend.setAttribute("in", in);
- blend.setAttribute("in2", in2);
- blend.setAttribute("mode", "normal");
- }
+ super.build();
+ filterElement.setAttribute("in", in);
+ filterElement.setAttribute("in2", in2);
+ filterElement.setAttribute("mode", "normal");
}
/**
@@ -102,6 +85,12 @@ package org.apache.royale.svg
{
_in = value;
}
+
+ COMPILE::JS
+ override protected function get filterElementType():String
+ {
+ return "feBlend";
+ }
}
}
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlurFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlurFilterElement.as
index 14ba372..fdfe358 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlurFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlurFilterElement.as
@@ -45,13 +45,11 @@ package org.apache.royale.svg
/**
* @royaleignorecoercion Element
*/
- override protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ override protected function build():void
{
- super.onInitComplete(e);
- COMPILE::JS
- {
- filterElement.setAttribute("stdDeviation", stdDeviation);
- }
+ super.build();
+ filterElement.setAttribute("stdDeviation", stdDeviation);
}
/**
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/ColorMatrixFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/ColorMatrixFilterElement.as
index 924edb7..89b460b 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/ColorMatrixFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/ColorMatrixFilterElement.as
@@ -49,14 +49,12 @@ package org.apache.royale.svg
/**
* @royaleignorecoercion Element
*/
- override protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ override protected function build():void
{
- super.onInitComplete(e);
- COMPILE::JS
- {
- var matrixValues:String = "0 0 0 0 " + red + " 0 0 0 0 " + green + " 0 0 0 0 " + blue + " 0 0 0 " + opacity + " 0";
- filterElement.setAttribute("values", matrixValues);
- }
+ super.build();
+ var matrixValues:String = "0 0 0 0 " + red + " 0 0 0 0 " + green + " 0 0 0 0 " + blue + " 0 0 0 " + opacity + " 0";
+ filterElement.setAttribute("values", matrixValues);
}
/**
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/CompositeFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/CompositeFilterElement.as
index 94dd7d1..fa84244 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/CompositeFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/CompositeFilterElement.as
@@ -46,14 +46,12 @@ package org.apache.royale.svg
/**
* @royaleignorecoercion Element
*/
- override protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ override protected function build():void
{
- super.onInitComplete(e);
- COMPILE::JS
- {
- filterElement.setAttribute("in2", in2);
- filterElement.setAttribute("operator", operator);
- }
+ super.build();
+ filterElement.setAttribute("in2", in2);
+ filterElement.setAttribute("operator", operator);
}
public function get in2():String
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/Filter.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/Filter.as
index b349e20..e58bc70 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/Filter.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/Filter.as
@@ -108,20 +108,12 @@ package org.apache.royale.svg
filterElementWrapper.setAttribute("width", _width);
filterElementWrapper.setAttribute("height", _height);
// clean up existing filter
- if (filterElementWrapper.hasChildNodes())
+ host.element.style["filter"] = "url(#" + filterElementWrapper.id + ")";
+ for (var i:int = 0; i < children.length; i++)
{
- var childNodes:Object = filterElementWrapper.childNodes;
- for (var i:int = 0; i < childNodes.length; i++)
- {
- filterElementWrapper.removeChild(childNodes[i]);
- }
+ var filterElement:FilterElement = children[i] as FilterElement;
+ filterElement.buildOn(filterElementWrapper);
}
-// var flood:Element = addSvgElementToWrapper(filterElementWrapper, "feFlood") as Element;
-// flood.setAttribute("flood-color", floodColor);
-// flood.setAttribute("flood-alpha", floodAlpha);
- // create blend
- // apply filter
- host.element.style["filter"] = "url(#" + filterElementWrapper.id + ")";
}
COMPILE::JS
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/FilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/FilterElement.as
index b286a2e..6afb656 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/FilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/FilterElement.as
@@ -19,8 +19,6 @@
package org.apache.royale.svg
{
- import org.apache.royale.core.IBead;
- import org.apache.royale.core.IStrand;
import org.apache.royale.events.IEventDispatcher;
import org.apache.royale.events.Event;
COMPILE::JS
@@ -36,59 +34,36 @@ package org.apache.royale.svg
* @playerversion AIR 2.6
* @productversion Royale 0.9.3
*/
- public class FilterElement implements IBead
+ public class FilterElement
{
- private var _strand:IStrand;
- private var _result:String;
+ COMPILE::JS
+ {
+ private var _filterElementWrapper:Element;
+ }
COMPILE::JS
{
private var _filterElement:Element;
}
+ private var _result:String;
public function FilterElement()
{
}
/**
- * @copy org.apache.royale.core.IBead#strand
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.3
- */
- public function set strand(value:IStrand):void
- {
- _strand = value;
- (_strand as IEventDispatcher).addEventListener('beadsAdded', onInitComplete);
- }
-
- /**
* @royaleignorecoercion Element
*/
- protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ protected function build():void
{
- COMPILE::JS
+ _filterElement = addSvgElementToElement(filterElementWrapper, filterElementType) as Element;
+ if (result)
{
- var filter:Element = getFilterElementWrapper();
- _filterElement = addSvgElementToElement(filter, filterElementType) as Element;
- if (result)
- {
- filterElement.setAttribute("result", result);
- }
+ filterElement.setAttribute("result", result);
}
}
/**
- * @royaleignorecoercion Element
- */
- COMPILE::JS
- protected function getFilterElementWrapper():Element
- {
- return (_strand.getBeadByType(Filter) as Filter).filterElementWrapper;
- }
-
- /**
* Reference to the filter element result. This can later be used as input for a subsequent filter element.
*
* @langversion 3.0
@@ -121,6 +96,24 @@ package org.apache.royale.svg
{
return _filterElement;
}
+
+ /**
+ * @royaleignorecoercion Element
+ */
+ COMPIE::JS
+ public function get filterElementWrapper():Element
+ {
+ return _filterElementWrapper;
+ }
+
+ /**
+ * @royaleignorecoercion Element
+ */
+ COMPIE::JS
+ public function set filterElementWrapper(value:Element):void
+ {
+ _filterElementWrapper = value;
+ }
}
}
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/InvertFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/InvertFilterElement.as
index ae37052..3ba808a 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/InvertFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/InvertFilterElement.as
@@ -45,16 +45,14 @@ package org.apache.royale.svg
/*
* @royaleignorecoercion Element
*/
- override protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ override protected function build():void
{
- super.onInitComplete(e);
- COMPILE::JS
- {
- filterElement.setAttribute("in", "SourceAlpha");
- var funcA:Element = addSvgElementToElement(filterElement, "feFuncA") as Element;
- funcA.setAttribute("type", "table");
- funcA.setAttribute("tableValues", "1 0");
- }
+ super.build();
+ filterElement.setAttribute("in", "SourceAlpha");
+ var funcA:Element = addSvgElementToElement(filterElement, "feFuncA") as Element;
+ funcA.setAttribute("type", "table");
+ funcA.setAttribute("tableValues", "1 0");
}
COMPILE::JS
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MergeFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MergeFilterElement.as
deleted file mode 100644
index 1be51fa..0000000
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MergeFilterElement.as
+++ /dev/null
@@ -1,84 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You under the Apache License, Version 2.0
-// (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package org.apache.royale.svg
-{
-
- import org.apache.royale.events.Event;
- COMPILE::JS
- {
- import org.apache.royale.graphics.utils.addSvgElementToElement;
- }
-
- /**
- * The BlendFilterElement filterElements several filter elements
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.3
- */
- public class BlendFilterElement extends FilterElement
- {
- private var _in2:String;
-
- public function BlendFilterElement()
- {
- }
-
-
- /**
- * @royaleignorecoercion Element
- */
- override protected function onInitComplete(e:Event):void
- {
- super.onInitComplete(e);
- COMPILE::JS
- {
- filterElement.setAttribute("in", "SourceGraphic");
- filterElement.setAttribute("in2", in2);
- filterElement.setAttribute("mode", "normal");
- }
- }
-
- /**
- * The filter element result which is filterElemented with the source graphic.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.3
- */
- public function get in2():String
- {
- return _in2;
- }
-
- public function set in2(value:String):void
- {
- _in2 = value;
- }
-
- COMPILE::JS
- override protected function get filterElementType():String
- {
- return "feBlend";
- }
- }
-}
-
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as
index 56ed0bc..1ace625 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as
@@ -46,14 +46,12 @@ package org.apache.royale.svg
/**
* @royaleignorecoercion Element
*/
- override protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ override protected function build():void
{
- super.onInitComplete(e);
- COMPILE::JS
- {
- filterElement.setAttribute("dx", dx);
- filterElement.setAttribute("dy", dy);
- }
+ super.build();
+ filterElement.setAttribute("dx", dx);
+ filterElement.setAttribute("dy", dy);
}
/**
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/SpreadFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/SpreadFilterElement.as
index edc414b..44786ec 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/SpreadFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/SpreadFilterElement.as
@@ -45,15 +45,13 @@ package org.apache.royale.svg
/**
* @royaleignorecoercion Element
*/
- override protected function onInitComplete(e:Event):void
+ COMPILE::JS
+ override protected function build():void
{
- super.onInitComplete(e);
- COMPILE::JS
- {
- var funcA:Element = addSvgElementToElement(filterElement, "feFuncA") as Element;
- funcA.setAttribute("type", "linear");
- funcA.setAttribute("slope", spread);
- }
+ super.build();
+ var funcA:Element = addSvgElementToElement(filterElement, "feFuncA") as Element;
+ funcA.setAttribute("type", "linear");
+ funcA.setAttribute("slope", spread);
}
/**