Create video_frame_convert_rgba_to_bgr
This commit is contained in:
parent
55bc1ccd78
commit
9465a00d4b
|
@ -3142,16 +3142,13 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
unsigned x, y;
|
unsigned y;
|
||||||
|
|
||||||
for (y = 0; y < gl->vp.height; y++)
|
for (y = 0; y < gl->vp.height; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < gl->vp.width; x++, buffer += 3, ptr += 4)
|
video_frame_convert_rgba_to_bgr(
|
||||||
{
|
(const void*)ptr,
|
||||||
buffer[0] = ptr[2]; /* RGBA -> BGR. */
|
buffer,
|
||||||
buffer[1] = ptr[1];
|
gl->vp.width);
|
||||||
buffer[2] = ptr[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3176,10 +3173,6 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
|
||||||
as we don't really care about performance in this case. */
|
as we don't really care about performance in this case. */
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
unsigned i;
|
|
||||||
uint8_t *dst = NULL;
|
|
||||||
const uint8_t *src = NULL;
|
|
||||||
|
|
||||||
/* GLES2 only guarantees GL_RGBA/GL_UNSIGNED_BYTE
|
/* GLES2 only guarantees GL_RGBA/GL_UNSIGNED_BYTE
|
||||||
* readbacks so do just that.
|
* readbacks so do just that.
|
||||||
* GLES2 also doesn't support reading back data
|
* GLES2 also doesn't support reading back data
|
||||||
|
@ -3201,15 +3194,10 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
|
||||||
|
|
||||||
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
|
|
||||||
dst = buffer;
|
video_frame_convert_rgba_to_bgr(
|
||||||
src = (const uint8_t*)gl->readback_buffer_screenshot;
|
(const void*)gl->readback_buffer_screenshot,
|
||||||
|
buffer,
|
||||||
for (i = 0; i < num_pixels; i++, dst += 3, src += 4)
|
num_pixels);
|
||||||
{
|
|
||||||
dst[0] = src[2]; /* RGBA -> BGR. */
|
|
||||||
dst[1] = src[1];
|
|
||||||
dst[2] = src[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
free(gl->readback_buffer_screenshot);
|
free(gl->readback_buffer_screenshot);
|
||||||
gl->readback_buffer_screenshot = NULL;
|
gl->readback_buffer_screenshot = NULL;
|
||||||
|
|
|
@ -161,4 +161,21 @@ static INLINE void video_frame_convert_to_bgr24(
|
||||||
scaler_ctx_scale(scaler, output, input);
|
scaler_ctx_scale(scaler, output, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INLINE void video_frame_convert_rgba_to_bgr(
|
||||||
|
const void *src_data,
|
||||||
|
void *dst_data,
|
||||||
|
unsigned width)
|
||||||
|
{
|
||||||
|
unsigned x;
|
||||||
|
uint8_t *dst = (uint8_t*)dst_data;
|
||||||
|
const uint8_t *src = (const uint8_t*)src_data;
|
||||||
|
|
||||||
|
for (x = 0; x < width; x++, dst += 3, src += 4)
|
||||||
|
{
|
||||||
|
dst[0] = src[2];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue