Repository navigation
core: Fix bitmap cache updates for animated masks (jitter fix) #24949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cmdocmd
wants to merge
3
commits into
ruffle-rs:master
Choose a base branch
from
cmdocmd:fix-filter-mask-jitter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+298
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
tests/tests/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/Test.as
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| package { | ||
| import flash.display.Bitmap; | ||
| import flash.display.BlendMode; | ||
| import flash.display.MovieClip; | ||
| import flash.display.Shape; | ||
| import flash.display.Sprite; | ||
| import flash.display.StageAlign; | ||
| import flash.display.StageScaleMode; | ||
| import flash.events.Event; | ||
| import flash.filters.ColorMatrixFilter; | ||
| import flash.geom.Rectangle; | ||
| import flash.system.fscommand; | ||
|
|
||
| [SWF(width="480", height="300", frameRate="30", backgroundColor="#A0A0A0")] | ||
| public class Test extends MovieClip { | ||
| [Embed(source="maskee.png")] | ||
| private var Maskee:Class; | ||
|
|
||
| private var containers:Array = []; | ||
| private var bitmaps:Array = []; | ||
| private var masks:Array = []; | ||
| private var frame:int = 0; | ||
|
|
||
| public function Test() { | ||
| stage.scaleMode = StageScaleMode.NO_SCALE; | ||
| stage.align = StageAlign.TOP_LEFT; | ||
|
|
||
| trace("Animated mask / filter bounds"); | ||
| trace("Top row, left to right: ColorMatrix+HardLight, ColorMatrix, HardLight"); | ||
| trace("Bottom row: no effects, ColorMatrix+moving clipping edge, ColorMatrix+moving bitmap"); | ||
|
|
||
| for (var i:int = 0; i < 6; i++) { | ||
| var container:Sprite = new Sprite(); | ||
| container.x = 40 + (i % 3) * 160; | ||
| container.y = 35 + int(i / 3) * 150; | ||
| addChild(container); | ||
|
|
||
| var bitmap:Bitmap = new Maskee(); | ||
| bitmap.scaleX = bitmap.scaleY = 4; | ||
| container.addChild(bitmap); | ||
|
|
||
| var maskShape:Shape = new Shape(); | ||
| container.addChild(maskShape); | ||
| if (i == 4) { | ||
| drawMask(maskShape, 0, 0, 40, 80); | ||
| } else { | ||
| drawMask(maskShape, -12, -12, 104, 104); | ||
| } | ||
| bitmap.mask = maskShape; | ||
|
|
||
| if (i == 0 || i == 1 || i == 4 || i == 5) { | ||
| container.filters = [new ColorMatrixFilter([ | ||
| 0.8, 0, 0, 0, 12, | ||
| 0, 0.9, 0, 0, 6, | ||
| 0, 0, 0.7, 0, 18, | ||
| 0, 0, 0, 1, 0 | ||
| ])]; | ||
| } | ||
|
|
||
| if (i == 0 || i == 2) { | ||
| container.blendMode = BlendMode.HARDLIGHT; | ||
| } | ||
|
|
||
|
|
||
| containers.push(container); | ||
| bitmaps.push(bitmap); | ||
| masks.push(maskShape); | ||
| } | ||
|
|
||
| addEventListener(Event.ENTER_FRAME, onFrame); | ||
| } | ||
|
|
||
| private function drawMask( | ||
| maskShape:Shape, | ||
| x:Number, | ||
| y:Number, | ||
| width:Number, | ||
| height:Number | ||
| ):void { | ||
| maskShape.graphics.clear(); | ||
| maskShape.graphics.beginFill(0x000000); | ||
| maskShape.graphics.drawRect(x, y, width, height); | ||
| maskShape.graphics.endFill(); | ||
| } | ||
|
|
||
| private function bounds(rect:Rectangle):String { | ||
| return rect.x.toFixed(2) + "," + | ||
| rect.y.toFixed(2) + "," + | ||
| rect.width.toFixed(2) + "," + | ||
| rect.height.toFixed(2); | ||
| } | ||
|
|
||
| private function onFrame(event:Event):void { | ||
| frame++; | ||
|
|
||
| var phase:int = (frame - 1) % 40; | ||
| var controlPhase:int = int((frame - 1) / 2) % 4; | ||
| var delta:Number = phase * 0.05; | ||
|
|
||
| for (var i:int = 0; i < 6; i++) { | ||
| var maskShape:Shape = masks[i]; | ||
| var bitmap:Bitmap = bitmaps[i]; | ||
|
|
||
| if (i == 4) { | ||
| // Intentional visible clipping motion. | ||
| maskShape.x = controlPhase * 10; | ||
| } else { | ||
| // Move the mask while it still fully covers the bitmap. | ||
| maskShape.x = -delta; | ||
| maskShape.y = -delta; | ||
| } | ||
|
|
||
| if (i == 5) { | ||
| // Intentional bitmap motion. | ||
| bitmap.x = controlPhase * 2; | ||
| } | ||
| } | ||
|
|
||
| if ( | ||
| frame == 1 || frame == 11 || frame == 19 || | ||
| frame == 35 || frame == 40 || frame == 60 || | ||
| frame == 123 | ||
| ) { | ||
| trace("frame=" + frame + " delta=" + delta.toFixed(2)); | ||
|
|
||
| for (i = 0; i < 6; i++) { | ||
| trace( | ||
| "case=" + i + | ||
| " bitmap=" + | ||
| bounds(Bitmap(bitmaps[i]).getBounds(this)) + | ||
| " mask=" + | ||
| bounds(Shape(masks[i]).getBounds(this)) + | ||
| " container=" + | ||
| bounds(Sprite(containers[i]).getBounds(this)) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| if (frame == 11 || frame == 19 || frame == 35) { | ||
| fscommand("captureImage", "frame" + frame); | ||
| } | ||
| if (frame == 123) { | ||
| trace("DONE"); | ||
| removeEventListener(Event.ENTER_FRAME, onFrame); | ||
| } | ||
| } | ||
| } | ||
| } |
Binary file added
BIN
+1.48 KB
...ts/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/frame11.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.48 KB
...ts/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/frame19.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.48 KB
...ts/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/frame35.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+224 Bytes
tests/tests/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/maskee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.48 KB
...sts/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/output.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions
53
tests/tests/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| Animated mask / filter bounds | ||
| Top row, left to right: ColorMatrix+HardLight, ColorMatrix, HardLight | ||
| Bottom row: no effects, ColorMatrix+moving clipping edge, ColorMatrix+moving bitmap | ||
| frame=1 delta=0.00 | ||
| case=0 bitmap=40.00,35.00,80.00,80.00 mask=28.00,23.00,104.00,104.00 container=28.00,23.00,104.00,104.00 | ||
| case=1 bitmap=200.00,35.00,80.00,80.00 mask=188.00,23.00,104.00,104.00 container=188.00,23.00,104.00,104.00 | ||
| case=2 bitmap=360.00,35.00,80.00,80.00 mask=348.00,23.00,104.00,104.00 container=348.00,23.00,104.00,104.00 | ||
| case=3 bitmap=40.00,185.00,80.00,80.00 mask=28.00,173.00,104.00,104.00 container=28.00,173.00,104.00,104.00 | ||
| case=4 bitmap=200.00,185.00,80.00,80.00 mask=200.00,185.00,40.00,80.00 container=200.00,185.00,80.00,80.00 | ||
| case=5 bitmap=360.00,185.00,80.00,80.00 mask=348.00,173.00,104.00,104.00 container=348.00,173.00,104.00,104.00 | ||
| frame=11 delta=0.50 | ||
| case=0 bitmap=40.00,35.00,80.00,80.00 mask=27.50,22.50,104.00,104.00 container=27.50,22.50,104.00,104.00 | ||
| case=1 bitmap=200.00,35.00,80.00,80.00 mask=187.50,22.50,104.00,104.00 container=187.50,22.50,104.00,104.00 | ||
| case=2 bitmap=360.00,35.00,80.00,80.00 mask=347.50,22.50,104.00,104.00 container=347.50,22.50,104.00,104.00 | ||
| case=3 bitmap=40.00,185.00,80.00,80.00 mask=27.50,172.50,104.00,104.00 container=27.50,172.50,104.00,104.00 | ||
| case=4 bitmap=200.00,185.00,80.00,80.00 mask=210.00,185.00,40.00,80.00 container=200.00,185.00,80.00,80.00 | ||
| case=5 bitmap=362.00,185.00,80.00,80.00 mask=347.50,172.50,104.00,104.00 container=347.50,172.50,104.00,104.00 | ||
| frame=19 delta=0.90 | ||
| case=0 bitmap=40.00,35.00,80.00,80.00 mask=27.10,22.10,104.00,104.00 container=27.10,22.10,104.00,104.00 | ||
| case=1 bitmap=200.00,35.00,80.00,80.00 mask=187.10,22.10,104.00,104.00 container=187.10,22.10,104.00,104.00 | ||
| case=2 bitmap=360.00,35.00,80.00,80.00 mask=347.10,22.10,104.00,104.00 container=347.10,22.10,104.00,104.00 | ||
| case=3 bitmap=40.00,185.00,80.00,80.00 mask=27.10,172.10,104.00,104.00 container=27.10,172.10,104.00,104.00 | ||
| case=4 bitmap=200.00,185.00,80.00,80.00 mask=210.00,185.00,40.00,80.00 container=200.00,185.00,80.00,80.00 | ||
| case=5 bitmap=362.00,185.00,80.00,80.00 mask=347.10,172.10,104.00,104.00 container=347.10,172.10,104.00,104.00 | ||
| frame=35 delta=1.70 | ||
| case=0 bitmap=40.00,35.00,80.00,80.00 mask=26.30,21.30,104.00,104.00 container=26.30,21.30,104.00,104.00 | ||
| case=1 bitmap=200.00,35.00,80.00,80.00 mask=186.30,21.30,104.00,104.00 container=186.30,21.30,104.00,104.00 | ||
| case=2 bitmap=360.00,35.00,80.00,80.00 mask=346.30,21.30,104.00,104.00 container=346.30,21.30,104.00,104.00 | ||
| case=3 bitmap=40.00,185.00,80.00,80.00 mask=26.30,171.30,104.00,104.00 container=26.30,171.30,104.00,104.00 | ||
| case=4 bitmap=200.00,185.00,80.00,80.00 mask=210.00,185.00,40.00,80.00 container=200.00,185.00,80.00,80.00 | ||
| case=5 bitmap=362.00,185.00,80.00,80.00 mask=346.30,171.30,104.00,104.00 container=346.30,171.30,104.00,104.00 | ||
| frame=40 delta=1.95 | ||
| case=0 bitmap=40.00,35.00,80.00,80.00 mask=26.05,21.05,104.00,104.00 container=26.05,21.05,104.00,104.00 | ||
| case=1 bitmap=200.00,35.00,80.00,80.00 mask=186.05,21.05,104.00,104.00 container=186.05,21.05,104.00,104.00 | ||
| case=2 bitmap=360.00,35.00,80.00,80.00 mask=346.05,21.05,104.00,104.00 container=346.05,21.05,104.00,104.00 | ||
| case=3 bitmap=40.00,185.00,80.00,80.00 mask=26.05,171.05,104.00,104.00 container=26.05,171.05,104.00,104.00 | ||
| case=4 bitmap=200.00,185.00,80.00,80.00 mask=230.00,185.00,40.00,80.00 container=200.00,185.00,80.00,80.00 | ||
| case=5 bitmap=366.00,185.00,80.00,80.00 mask=346.05,171.05,104.00,104.00 container=346.05,171.05,104.00,104.00 | ||
| frame=60 delta=0.95 | ||
| case=0 bitmap=40.00,35.00,80.00,80.00 mask=27.05,22.05,104.00,104.00 container=27.05,22.05,104.00,104.00 | ||
| case=1 bitmap=200.00,35.00,80.00,80.00 mask=187.05,22.05,104.00,104.00 container=187.05,22.05,104.00,104.00 | ||
| case=2 bitmap=360.00,35.00,80.00,80.00 mask=347.05,22.05,104.00,104.00 container=347.05,22.05,104.00,104.00 | ||
| case=3 bitmap=40.00,185.00,80.00,80.00 mask=27.05,172.05,104.00,104.00 container=27.05,172.05,104.00,104.00 | ||
| case=4 bitmap=200.00,185.00,80.00,80.00 mask=210.00,185.00,40.00,80.00 container=200.00,185.00,80.00,80.00 | ||
| case=5 bitmap=362.00,185.00,80.00,80.00 mask=347.05,172.05,104.00,104.00 container=347.05,172.05,104.00,104.00 | ||
| frame=123 delta=0.10 | ||
| case=0 bitmap=40.00,35.00,80.00,80.00 mask=27.90,22.90,104.00,104.00 container=27.90,22.90,104.00,104.00 | ||
| case=1 bitmap=200.00,35.00,80.00,80.00 mask=187.90,22.90,104.00,104.00 container=187.90,22.90,104.00,104.00 | ||
| case=2 bitmap=360.00,35.00,80.00,80.00 mask=347.90,22.90,104.00,104.00 container=347.90,22.90,104.00,104.00 | ||
| case=3 bitmap=40.00,185.00,80.00,80.00 mask=27.90,172.90,104.00,104.00 container=27.90,172.90,104.00,104.00 | ||
| case=4 bitmap=200.00,185.00,80.00,80.00 mask=210.00,185.00,40.00,80.00 container=200.00,185.00,80.00,80.00 | ||
| case=5 bitmap=362.00,185.00,80.00,80.00 mask=347.90,172.90,104.00,104.00 container=347.90,172.90,104.00,104.00 | ||
| DONE |
Binary file added
BIN
+11.1 KB
tests/tests/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/test.swf
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
tests/tests/swfs/visual/cache_as_bitmap/animated_mask_filter_bounds/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| num_frames = 124 | ||
|
|
||
| [image_comparisons.frame11] | ||
| trigger = "fs_command" | ||
| tolerance = 1 | ||
|
|
||
| [image_comparisons.frame19] | ||
| trigger = "fs_command" | ||
| tolerance = 1 | ||
|
|
||
| [image_comparisons.frame35] | ||
| trigger = "fs_command" | ||
| tolerance = 1 | ||
|
|
||
| [image_comparisons.output] | ||
| tolerance = 1 | ||
|
|
||
| [player_options] | ||
| with_renderer = { optional = false, quality = "high" } |
47 changes: 47 additions & 0 deletions
47
tests/tests/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/Test.as
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package { | ||
| import flash.display.MovieClip; | ||
| import flash.display.StageAlign; | ||
| import flash.display.StageQuality; | ||
| import flash.display.StageScaleMode; | ||
| import flash.events.Event; | ||
| import flash.system.fscommand; | ||
|
|
||
| [SWF(width="160", height="160", frameRate="24", backgroundColor="#A0A0A0")] | ||
| public class Test extends MovieClip { | ||
| private var scene:MovieClip; | ||
| private var sampleFrame:int = 1; | ||
| private var holdFrames:int = 0; | ||
|
|
||
| public function Test() { | ||
| stage.scaleMode = StageScaleMode.NO_SCALE; | ||
| stage.align = StageAlign.TOP_LEFT; | ||
| stage.quality = StageQuality.HIGH; | ||
|
|
||
| addEventListener(Event.ENTER_FRAME, onFrame); | ||
| } | ||
|
|
||
| private function onFrame(event:Event):void { | ||
| if (scene == null) { | ||
| // The build script adds the native timeline to the root frame. | ||
| if (numChildren == 0) { | ||
| return; | ||
| } | ||
| scene = MovieClip(getChildAt(0)); | ||
| trace("Timeline mask cache bounds"); | ||
| } | ||
| if (holdFrames > 0) { | ||
| holdFrames--; | ||
| return; | ||
| } | ||
| scene.gotoAndStop(sampleFrame); | ||
| holdFrames = 71; | ||
| trace("frame=" + scene.currentFrame); | ||
| fscommand("captureImage", "frame0" + sampleFrame); | ||
| if (sampleFrame == scene.totalFrames) { | ||
| removeEventListener(Event.ENTER_FRAME, onFrame); | ||
| trace("DONE"); | ||
| } | ||
| sampleFrame++; | ||
| } | ||
| } | ||
| } |
Binary file added
BIN
+530 Bytes
...sts/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/frame01.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+530 Bytes
...sts/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/frame02.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+530 Bytes
...sts/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/frame03.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+530 Bytes
...sts/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/frame04.expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
tests/tests/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Timeline mask cache bounds | ||
| frame=1 | ||
| frame=2 | ||
| frame=3 | ||
| frame=4 | ||
| DONE |
Binary file added
BIN
+2.21 KB
tests/tests/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/test.swf
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
tests/tests/swfs/visual/cache_as_bitmap/timeline_mask_cache_bounds/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| num_frames = 240 | ||
|
|
||
| [player_options] | ||
| with_renderer = { optional = false, quality = "high" } | ||
|
|
||
| [image_comparisons.frame01] | ||
| trigger = "fs_command" | ||
| tolerance = 54 | ||
|
|
||
| [image_comparisons.frame02] | ||
| trigger = "fs_command" | ||
| tolerance = 54 | ||
|
|
||
| [image_comparisons.frame03] | ||
| trigger = "fs_command" | ||
| tolerance = 54 | ||
|
|
||
| [image_comparisons.frame04] | ||
| trigger = "fs_command" | ||
| tolerance = 54 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.