ScrollRect error [OpenFL 8.5.1 Lime 7.1.1 HTML5]

This code

class Main extends Sprite {
	
	var bg:openfl.display.Sprite;
	
	public function new () {
		super ();
		
		bg = new Sprite ();
		bg.graphics.beginFill (0xffff);
		bg.graphics.drawRect (0, 0, 100, 100);
		addChild (bg);
		
		var s = new Sprite ();
		s.graphics.beginFill (0xff);
		s.graphics.drawRect (0, 0, 100, 100);
		addChild (s);
		
		s.scrollRect = new Rectangle( -50, -50, 55, 55);
		
		addEventListener(MouseEvent.CLICK, onClick);
	}
	
	private function onClick(e:MouseEvent):Void {
		removeChild(bg);
	}

}

Before click i see correct rectangles:
1539000660008
but after click i see wrong picture:
1539000712702

But if i test it at OpenFL 8.3.0 / Lime 6.4.0 all correct:
1539000674703

Thanks! The -Dcanvas and -Dcairo renders appear okay, so it looks like a regression in the OpenGL renderer. We’ll take a look soon

I just found a fix for it, committed to the dev version of OpenFL, thanks again :slight_smile:

Thanks for quick fix, but i found another problem:
scrollRect doesn’t work correct for tilemaps:

this code

package;


import openfl.display.Sprite;
import openfl.display.Tile;
import openfl.display.Tilemap;
import openfl.display.Tileset;
import openfl.Assets;
import openfl.geom.Rectangle;


class Main extends Sprite {
	
	var bitmapData:openfl.display.BitmapData;
	var tileset:openfl.display.Tileset;
	
	public function new () {
		
		super ();
		
		bitmapData = Assets.getBitmapData ("assets/wabbit_alpha.png");
		tileset = new Tileset (bitmapData);
		tileset.addRect (bitmapData.rect);
		
		var ss = new Sprite();
		var dd = new Sprite();
		addChild(ss);
		addChild(dd);
		
		var s = new Sprite ();
		s.graphics.beginFill (0xff);
		s.graphics.drawRect (0, 0, 100, 100);
		s.addChild(tt());
		s.x = 0;
		s.y = 0;
		ss.addChild (s);
		
		var d = new Sprite ();
		d.graphics.beginFill (0xffff);
		d.graphics.drawRect (0, 0, 100, 100);
		d.addChild(tt());
		d.x = 100;
		d.y = 100;
		dd.addChild (d);
		
		ss.scrollRect = new Rectangle( 0, 0, 100, 100);
		dd.scrollRect = new Rectangle( 0, 0, 100, 100);
		
	}
	
	function tt():Tilemap {
		var tilemap = new Tilemap (bitmapData.width, bitmapData.height, tileset);
		tilemap.addTile(new Tile());
		return tilemap;
	}

}

show two rabbits:
1539069778401

but it must show one as in OpenFL 8.3.0 / Lime 6.4.0:
1539069701486

Thanks again, I’ll look soon

Thanks again! Fixed on dev :smile:

Very well :slight_smile: but i see another problem:
If tilemap have fractional coordinates, not all image hidden by scrollRect
try this code

class Main extends Sprite {
	
	var bitmapData:openfl.display.BitmapData;
	var tileset:openfl.display.Tileset;
	
	public function new () {
		
		super ();
		
		bitmapData = Assets.getBitmapData ("assets/wabbit_alpha.png");
		tileset = new Tileset (bitmapData);
		tileset.addRect (bitmapData.rect);
		
		var ss = new Sprite();
		var dd = new Sprite();
		addChild(ss);
		addChild(dd);
		
		var s = new Sprite ();
		s.graphics.beginFill (0xff);
		s.graphics.drawRect (0, 0, 100, 100);
		s.addChild(tt());
		s.x = 0;
		s.y = 0;
		ss.addChild (s);
		
		var d = new Sprite ();
		d.graphics.beginFill (0xffff);
		d.graphics.drawRect (0, 0, 100, 100);
		d.addChild(tt());
		d.x = 100;
		d.y = 102.5;
		dd.addChild (d);
		
		ss.scrollRect = new Rectangle( 0, 0, 200, 100);
		dd.scrollRect = new Rectangle( 0, 0, 200, 100);
		
	}
	
	function tt():Tilemap {
		var tilemap = new Tilemap (bitmapData.width, bitmapData.height, tileset);
		tilemap.addTile(new Tile());
		return tilemap;
	}

}

i see 1-pixel line from rabbit-image:
1539159173212

Okay, fixed in latest. I’ve implemented PixelSnapping support, initially, for OpenGL, which resolves that little bit of bleed through the scissor

After apply this commit, test example fixed, but if I change this line

		d.y = 102.5;

to

		d.y = 102.1;

Bug still exist:
1539238744180

for the best testing try this animated example:

package;


import haxe.Timer;
import openfl.display.Sprite;
import openfl.display.Tile;
import openfl.display.Tilemap;
import openfl.display.Tileset;
import openfl.Assets;
import openfl.events.Event;
import openfl.geom.Rectangle;


class Main extends Sprite {
	
	var bitmapData:openfl.display.BitmapData;
	var tileset:openfl.display.Tileset;
	var d:openfl.display.Sprite;
	
	public function new () {
		
		super ();
		
		bitmapData = Assets.getBitmapData ("assets/wabbit_alpha.png");
		tileset = new Tileset (bitmapData);
		tileset.addRect (bitmapData.rect);
		
		var ss = new Sprite();
		var dd = new Sprite();
		addChild(ss);
		addChild(dd);
		
		var s = new Sprite ();
		s.graphics.beginFill (0xff);
		s.graphics.drawRect (0, 0, 100, 100);
		s.addChild(tt());
		s.x = 0;
		s.y = 0;
		ss.addChild (s);
		
		d = new Sprite ();
		d.graphics.beginFill (0xffff);
		d.graphics.drawRect (0, 0, 100, 100);
		d.addChild(tt());
		d.x = 100;
		//d.y = 102.1;
		d.scaleX = 1.01;
		d.scaleY = 1.01;
		dd.addChild (d);
		
		ss.scrollRect = new Rectangle( 0, 0, 200, 100);
		dd.scrollRect = new Rectangle( 0, 0, 200, 100);
		
		addEventListener(Event.ENTER_FRAME, oef);
	}
	
	function oef(e:Event):Void 
	{
		d.y = 100 + Math.sin(Timer.stamp() * 2) * 50;
	}
	
	function tt():Tilemap {
		var tilemap = new Tilemap (bitmapData.width, bitmapData.height, tileset);
		tilemap.addTile(new Tile());
		return tilemap;
	}

}

1539240883975

IMHO i found reason:
in openfl.display.OpenGLRenderer.hx function
__scissorRect (clipRect:Rectangle = null):Void
if clipRect.height == 0 this code genereate height 1 instead 0

			var x = Math.floor (clipRect.x);
			var y = Math.floor (clipRect.y);
			var width = Math.ceil (clipRect.right) - x;
			var height = Math.ceil (clipRect.bottom) - y;
			
			if (width < 0) width = 0;
			if (height < 0) height = 0;

may be change last two lines to next lines
(it was helpfull in my case)

			if (clipRect.width <= 0) width = 0;
			if (clipRect.height <= 0) height = 0;

Awesome! Thank you. Sorry for the issues, but thank you so much for the samples and help in figuring this out :slight_smile:

EDIT: Fix committed to OpenFL