Closed Diamanter closed 8 years ago
That shouldn't happen: when you're using Quads, and they are aligned to the stage bounds, you should have the same number of draw calls as with a clipRect
in Starling 1.x.
Could you post some sample code? Or else, set a breakpoint in Painter.drawMask
and enter the method isRectangularMask
. Maybe you can see why it's not recognized as a rectangular one.
This is a change for your "Mask scene" (added 2 images, removed color filter). Active mask2 added 2 draw calls with and without circle mask.
For my game scene in Starling 1.7 I have only 1 draw call, now I have 20+ draw calls.
clipRect for Images (or even better Sprites) will fix the problem and makes similar scenes batchable.
var image:Image = new Image(Game.assets.getTexture("flight_00"));
image.x = (stageWidth - image.width) / 2;
image.y = 80;
_contents.addChild(image);
var image2:Image = new Image(Game.assets.getTexture("flight_00"));
image2.x = (stageWidth - image2.width) / 2;
image2.y = 0;
_contents.addChild(image2);
var mask2:Quad = new Quad(image2.width, image2.height/2);
mask2.x = image2.x;
mask2.y = image2.y;
image2.mask = mask2;
var image3:Image = new Image(Game.assets.getTexture("flight_00"));
image3.x = (stageWidth - image3.width) / 2;
image3.y = 180;
_contents.addChild(image3);
// just to prove it works, use a filter on the image.
//var cm:ColorMatrixFilter = new ColorMatrixFilter();
//cm.adjustHue(-0.5);
//image.filter = cm;
isRectangularMask() returns true for these simple masks, no problem here.
I'm afraid I still don't quite get it, sorry. :wink:
If you make the same in Starling 1.8, (1) you couldn't add a clipRect to image2
at all, because that was only available on Sprites. (2) If you'd wrap it up in a Sprite, you'd still have the same number of draw calls as your sample in Starling 2.
To make this more apparent, I've stripped down the sample, containing just a single mask / clipRect.
Both scenes require exactly 4 draw calls. And that's to be expected, since an axis-aligned Quad
-mask is automatically converted to a clipRect
(scissorRect
) internally.
If you're aware of all that, please try to explain your issue again, so that I can truly understand it. :wink: Thanks!
Ok, I made my own clipRect using Image.setTexCoords, this makes things really faster (and batchable) :)
Thank you for tips!
Yes, that's the fastest route you can go! :+1: This will give you full batching.
Happy to hear this is not a Starling issue per se, then! I'll close this issue. Let me know if you need anything else!
Can we get back clipRect property at least for Image objects?
Even using quad masks I've got 2 more draw calls for every clipped image.