mirror of https://github.com/libsdl-org/SDL.git
Added a fast path for converting the same format and pitch
This commit is contained in:
parent
f24f9d3bed
commit
9267930fea
|
|
@ -2298,13 +2298,17 @@ bool SDL_ConvertPixelsAndColorspace(int width, int height,
|
||||||
|
|
||||||
// Fast path for same format copy
|
// Fast path for same format copy
|
||||||
if (src_format == dst_format && src_colorspace == dst_colorspace) {
|
if (src_format == dst_format && src_colorspace == dst_colorspace) {
|
||||||
int i;
|
if (src_pitch == dst_pitch) {
|
||||||
const int bpp = SDL_BYTESPERPIXEL(src_format);
|
SDL_memcpy(dst, src, height * src_pitch);
|
||||||
width *= bpp;
|
} else {
|
||||||
for (i = height; i--;) {
|
int i;
|
||||||
SDL_memcpy(dst, src, width);
|
const int bpp = SDL_BYTESPERPIXEL(src_format);
|
||||||
src = (const Uint8 *)src + src_pitch;
|
width *= bpp;
|
||||||
dst = (Uint8 *)dst + dst_pitch;
|
for (i = height; i--;) {
|
||||||
|
SDL_memcpy(dst, src, width);
|
||||||
|
src = (const Uint8 *)src + src_pitch;
|
||||||
|
dst = (Uint8 *)dst + dst_pitch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue