Skip to content

Commit 2453977

Browse files
committed
Merge branch 'master' of https://github.com/raysan5/raylib
2 parents d5e8ee7 + e2233ac commit 2453977

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/rlgl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ void rlPushMatrix(void)
12521252
RLGL.State.stackCounter++;
12531253
}
12541254

1255-
// Pop lattest inserted matrix from RLGL.State.stack
1255+
// Pop latest inserted matrix from RLGL.State.stack
12561256
void rlPopMatrix(void)
12571257
{
12581258
if (RLGL.State.stackCounter > 0)

src/rtextures.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,11 +3341,14 @@ void ImageClearBackground(Image *dst, Color color)
33413341

33423342
unsigned char *pSrcPixel = (unsigned char *)dst->data;
33433343
int bytesPerPixel = GetPixelDataSize(1, 1, dst->format);
3344+
int totalPixels = dst->width * dst->height;
33443345

3345-
// Repeat the first pixel data throughout the image
3346-
for (int i = 1; i < dst->width*dst->height; i++)
3346+
// Repeat the first pixel data throughout the image,
3347+
// doubling the pixels copied on each iteration
3348+
for (int i = 1; i < totalPixels; i *= 2)
33473349
{
3348-
memcpy(pSrcPixel + i*bytesPerPixel, pSrcPixel, bytesPerPixel);
3350+
int pixelsToCopy = MIN(i, totalPixels - i);
3351+
memcpy(pSrcPixel + i * bytesPerPixel, pSrcPixel, pixelsToCopy * bytesPerPixel);
33493352
}
33503353
}
33513354

@@ -3724,9 +3727,10 @@ void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
37243727
unsigned char *pSrcPixel = (unsigned char *)dst->data + bytesOffset;
37253728

37263729
// Repeat the first pixel data throughout the row
3727-
for (int x = 1; x < (int)rec.width; x++)
3730+
for (int x = 1; x < (int)rec.width; x *= 2)
37283731
{
3729-
memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, bytesPerPixel);
3732+
int pixelsToCopy = MIN(x, (int)rec.width - x);
3733+
memcpy(pSrcPixel + x*bytesPerPixel, pSrcPixel, pixelsToCopy * bytesPerPixel);
37303734
}
37313735

37323736
// Repeat the first row data for all other rows

0 commit comments

Comments
 (0)