Skip to content

Commit

Permalink
Add additional fast-fail non-op to Image.copyPixels
Browse files Browse the repository at this point in the history
  • Loading branch information
jgranick committed Aug 30, 2024
1 parent 0d267b4 commit cbb7482
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/lime/graphics/Image.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
}
Expand Down Expand Up @@ -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?
Expand Down

0 comments on commit cbb7482

Please sign in to comment.