forked from openfl/lime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openfl#367 from leshido/master
FIX: HTML5 canvas masks not working (closes openfl#366)
- Loading branch information
Showing
4 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,62 @@ | ||
package openfl._internal.renderer.canvas; | ||
|
||
import openfl.display.*; | ||
import openfl.geom.*; | ||
|
||
class MaskManager { | ||
|
||
|
||
private var renderSession:RenderSession; | ||
|
||
|
||
public function new (renderSession:RenderSession) { | ||
|
||
this.renderSession = renderSession; | ||
|
||
} | ||
|
||
|
||
public function pushMask (mask:IBitmapDrawable):Void { | ||
|
||
var context = renderSession.context; | ||
|
||
context.save (); | ||
|
||
//var cacheAlpha = mask.__worldAlpha; | ||
var transform = mask.__worldTransform; | ||
if (transform == null) transform = new Matrix (); | ||
|
||
context.setTransform (transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); | ||
|
||
context.beginPath (); | ||
mask.__renderMask (renderSession); | ||
|
||
context.clip (); | ||
|
||
//mask.worldAlpha = cacheAlpha; | ||
|
||
} | ||
|
||
|
||
public function pushRect (rect:Rectangle, transform:Matrix):Void { | ||
|
||
var context = renderSession.context; | ||
context.save (); | ||
|
||
context.setTransform (transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); | ||
|
||
context.beginPath (); | ||
context.rect (rect.x, rect.y, rect.width, rect.height); | ||
context.clip (); | ||
|
||
} | ||
|
||
|
||
public function popMask ():Void { | ||
|
||
renderSession.context.restore (); | ||
|
||
} | ||
|
||
|
||
} |