Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ There are three primary code paths within the library:

This library can be called automatically by the OpenFL/Lime command-line tools to process `<library />` tags, or it can be used on the command-line to process SWF files into Animate ZIP files.

Compact Animate timelines
=========================

Projects with large Animate libraries may define
`swf_compact_animate_timelines` to keep serialized timeline events in compact
numeric buffers. The default parser creates one `AnimateFrame` and
`AnimateFrameObject` graph for every frame and event, including separate
matrix, color-transform and filter objects. The compact mode decodes these
values directly during playback, reducing retained managed memory and the
amount of graph traversal performed by full garbage collections.

The exported Animate asset format does not change, and standard timeline
playback remains compatible. This mode is opt-in because code that accesses
`AnimateSpriteSymbol.frames` directly will not receive the eagerly expanded
legacy metadata.


Usage
=====
Expand Down
5 changes: 5 additions & 0 deletions src/swf/exporters/animate/AnimateLibrary.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import openfl.filters.GlowFilter;
@:noDebug
#end
@:access(swf.exporters.animate.AnimateSpriteSymbol)
@:access(swf.exporters.animate.AnimateTimelineData)
@:access(swf.exporters.animate)
@SuppressWarnings("checkstyle:FieldDocComment")
@:keep class AnimateLibrary extends AssetLibrary
Expand Down Expand Up @@ -743,6 +744,9 @@ import openfl.filters.GlowFilter;
symbol.scale9Grid = data.scale9Grid != null ? new Rectangle(__pixel(data.scale9Grid[0]), __pixel(data.scale9Grid[1]), __pixel(data.scale9Grid[2]),
__pixel(data.scale9Grid[3])) : null;
var frames:Array<Dynamic> = data.frames;
#if swf_compact_animate_timelines
symbol.__setCompactTimeline(frames);
#else
var frame:AnimateFrame,
objects:Array<Dynamic>,
object:AnimateFrameObject;
Expand Down Expand Up @@ -790,6 +794,7 @@ import openfl.filters.GlowFilter;
}
symbol.frames.push(frame);
}
#end
return symbol;
}

Expand Down
6 changes: 6 additions & 0 deletions src/swf/exporters/animate/AnimateSpriteSymbol.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AnimateSpriteSymbol extends AnimateSymbol
public var frames:Array<AnimateFrame>;
public var scale9Grid:Rectangle;

private var compactTimeline:AnimateTimelineData;
private var library:AnimateLibrary;

public function new()
Expand Down Expand Up @@ -128,4 +129,9 @@ class AnimateSpriteSymbol extends AnimateSymbol
this.library = library;
__constructor(cast instance);
}

private function __setCompactTimeline(frames:Array<Dynamic>):Void
{
compactTimeline = new AnimateTimelineData(frames);
}
}
Loading
Loading