diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2015-11-22 18:51:11 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-11-29 10:54:08 +0100 |
commit | 2b7dad60efbbbe0fcbfc699131cbe882b1e94680 (patch) | |
tree | b736373fcaa9aadbc2013430c46f28050d6d9a80 | |
parent | e6db50ab6c184d043dcfda96e323dc8f362d3c60 (diff) |
svg-export: animation sequence was wrong
Animation sequence was wrong due to the priority queue and related
compare functions implementation.
Change-Id: I359abd087e922ffa0aa4f7770fcc0c9bdb029843
Reviewed-on: https://gerrit.libreoffice.org/20236
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 1ed6d1423c7cffa5403dad69a9946ec790a374f2)
-rw-r--r-- | filter/source/svg/presentation_engine.js | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index e4fe52edcad0..f6426dc149ed 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -3776,7 +3776,6 @@ function PriorityQueue( aCompareFunc ) { this.aSequence = new Array(); this.aCompareFunc = aCompareFunc; - this.bSorted = true; } PriorityQueue.prototype.clone = function() @@ -3793,18 +3792,11 @@ PriorityQueue.prototype.clone = function() } } aCopy.aSequence = dest; - aCopy.bSorted = this.bSorted; - return aCopy; }; PriorityQueue.prototype.top = function() { - if( !this.bSorted ) - { - this.aSequence.sort(this.aCompareFunc) - this.bSorted = true; - } return this.aSequence[this.aSequence.length - 1]; }; @@ -3815,28 +3807,23 @@ PriorityQueue.prototype.isEmpty = function() PriorityQueue.prototype.push = function( aValue ) { - this.bSorted = false; - this.aSequence.push( aValue ); + this.aSequence.unshift( aValue ); + this.aSequence.sort(this.aCompareFunc); }; PriorityQueue.prototype.clear = function() { - this.bSorted = true; this.aSequence = new Array(); }; PriorityQueue.prototype.pop = function() { - if( !this.bSorted ) - { - this.aSequence.sort(this.aCompareFunc) - this.bSorted = true; - } - return this.aSequence.pop(); }; + + /********************************************************************************************** * AnimationNode Class Hierarchy **********************************************************************************************/ @@ -10353,17 +10340,30 @@ function PriorityEntry( aValue, nPriority ) * An instance of type PriorityEntry. * @param aRhsEntry * An instance of type PriorityEntry. - * @return {Boolean} - * True if the first entry has higher priority of the second entry, - * false otherwise. + * @return {Integer} + * -1 if the left entry has lower priority of the right entry, + * 1 if the left entry has higher priority of the right entry, + * 0 if the two entry have the same priority */ PriorityEntry.compare = function( aLhsEntry, aRhsEntry ) { - return ( aLhsEntry.nPriority < aRhsEntry.nPriority ); + if ( aLhsEntry.nPriority < aRhsEntry.nPriority ) + { + return -1; + } + else if (aLhsEntry.nPriority > aRhsEntry.nPriority) + { + return 1; + } + else + { + return 0; + } }; + function EventMultiplexer( aTimerEventQueue ) { this.nId = EventMultiplexer.getUniqueId(); @@ -12907,7 +12907,18 @@ function EventEntry( aEvent, nTime ) EventEntry.compare = function( aLhsEventEntry, aRhsEventEntry ) { - return ( aLhsEventEntry.nActivationTime > aRhsEventEntry.nActivationTime ); + if ( aLhsEventEntry.nActivationTime > aRhsEventEntry.nActivationTime ) + { + return -1; + } + else if ( aLhsEventEntry.nActivationTime < aRhsEventEntry.nActivationTime ) + { + return 1; + } + else + { + return 0; + } }; |