Skip to content

Commit e587b1b

Browse files
committed
no need to load pixels if not in source image
1 parent 6a5a1f4 commit e587b1b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5790,15 +5790,17 @@ protected void setImpl(PImage sourceImage,
57905790
int targetX, int targetY) {
57915791
updatePixelSize();
57925792

5793-
// Copies the pixels
5794-
loadPixels();
5795-
if(sourceImage.pixels==null) sourceImage.loadPixels();
5796-
int sourceOffset = sourceY * sourceImage.pixelWidth + sourceX;
5797-
int targetOffset = targetY * pixelWidth + targetX;
5798-
for (int y = sourceY; y < sourceY + sourceHeight; y++) {
5799-
System.arraycopy(sourceImage.pixels, sourceOffset, pixels, targetOffset, sourceWidth);
5800-
sourceOffset += sourceImage.pixelWidth;
5801-
targetOffset += pixelWidth;
5793+
if (sourceImage.pixels == null) {
5794+
// Copies the pixels
5795+
loadPixels();
5796+
sourceImage.loadPixels();
5797+
int sourceOffset = sourceY * sourceImage.pixelWidth + sourceX;
5798+
int targetOffset = targetY * pixelWidth + targetX;
5799+
for (int y = sourceY; y < sourceY + sourceHeight; y++) {
5800+
System.arraycopy(sourceImage.pixels, sourceOffset, pixels, targetOffset, sourceWidth);
5801+
sourceOffset += sourceImage.pixelWidth;
5802+
targetOffset += pixelWidth;
5803+
}
58025804
}
58035805

58045806
// Draws the texture, copy() is very efficient because it simply renders

0 commit comments

Comments
 (0)