From cbb7482066e6eb230faa7203f85b8fe9d74d1624 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Fri, 30 Aug 2024 11:30:08 -0700 Subject: [PATCH] Add additional fast-fail non-op to Image.copyPixels --- src/lime/graphics/Image.hx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lime/graphics/Image.hx b/src/lime/graphics/Image.hx index c825d9d84d..9b9f9b9737 100644 --- a/src/lime/graphics/Image.hx +++ b/src/lime/graphics/Image.hx @@ -59,7 +59,6 @@ import format.tools.Deflate; import sys.io.File; #end #end - /** `Image` is a convenience class for working with bitmap images in Lime. @@ -395,8 +394,7 @@ class Image sourceRect.offset(sourceImage.offsetX, sourceImage.offsetY); destPoint.offset(offsetX, offsetY); - buffer.__srcBitmapData.copyChannel(sourceImage.buffer.src, sourceRect.__toFlashRectangle(), destPoint.__toFlashPoint(), srcChannel, - dstChannel); + buffer.__srcBitmapData.copyChannel(sourceImage.buffer.src, sourceRect.__toFlashRectangle(), destPoint.__toFlashPoint(), srcChannel, dstChannel); default: } @@ -450,6 +448,18 @@ class Image destPoint.y = 0; } + if (sourceImage == this + && (alphaImage == null || (alphaImage == this && ((alphaPoint == null) || (alphaPoint.x == 0 && alphaPoint.y == 0)))) + && destPoint.x == 0 + && destPoint.y == 0 + && sourceRect.x == 0 + && sourceRect.y == 0 + && sourceRect.width == width + && sourceRect.height == height) + { + return; + } + if (sourceImage == this && destPoint.x < sourceRect.right && destPoint.y < sourceRect.bottom) { // TODO: Optimize further?