BitmapData.copyPixels mobile performance issue

I’ve reading on muut about android, or mobile device in general, issue related to copyPixels (and/or similar functions) and performance.

I’m using this function heavy during a specific function to put on top some BitmapData(s) on a main BitmapData.
Here the function i’m using:

public static var rect = new openfl.geom.Rectangle(0, 0, 1, 1);
	public static var point = new openfl.geom.Point(0, 0);
public static function drawImageOnImage(source:BitmapData, dest:BitmapData, x:Int, y:Int) {
	if(source != null && dest != null) {
		rect.x = 0;
		rect.y = 0;
		rect.width = source.width;
		rect.height = source.height;
		
		point.x = x;
		point.y = y;
		
		dest.copyPixels(source, rect, point, null, null, true);			
	}
}

Can someone suggest me a path to follow to avoid use of these kind of feature for mobile targets?

About copyPixels similar functions, which functions must I consider can be have similar performance issues?

Thanks in advance, David.

bitmapData operations, like copyPixels, are software-related, so it’s up to the host CPU to determine how fast this runs. On mobile, CPU performance is significantly reduced, so you want to limit the use of APIs like this. Is this something you can run one-time? Can it be done before runtime?

No, it’s a runtime process involve too many possibility. I’m looking for another way to make same thing use different APIs or methods. Any suggestion?

Thanks again.

What is the effect? Can you use the display list? (separate BitmapData and Bitmap objects, positioned as needed?)

If you use BitmapData.copyPixels to create a new BitmapData object and then delete the original bitmapData, will the copy’s remain unaffected? That way the only BitmapData left in memory is what you needed from the original. Just curious.

Do you target html5 on mobile or native application? I use copyPixels to generate puzzle pieces and targeting html5 mobile browser is really useless-it took 20 seconds to create 4 puzzle pieces grid. This is demoe: puzzlegame

I’m working on the way suggested by singmajesty, lot of work but seems the only way to bypass copyPixels. If someone have some other suggestions they are welcome!

@benspyda Not sure about understanding question but I need to print on a main BitmapData many other Bitmapdata in order to build a final image with many differences any time. Any single image remain unaffected.
@gonzos I’m working on native app not html5.

David.

Can’t you just keep all your bitmapdata as single objects and use a parent Sprite to group them all rather than drawing each one on a main bitmapdata with copyPixels?

Thanks for reply. I’m working on this issue in a similar way. During this extra work I ask myself more times about this unusual way chosed some time ago to make things, until found the answer.

Same image composed using this method was used in three different actors type in order to show same image using different dimensions, without any difference: I compose image at max resolution then scale final bitmapdata result at desired dimensions. As I result I have an harmonious result without little boring flaw.

Now I’m not sure about achieving same result. Any suggestion about?

Thanks, David.