From aa741087a56173ce85d16d29a3d8bca1f67ca735 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Mon, 7 Jan 2019 16:39:35 -0600 Subject: [PATCH] GTK+: Clean up gtk_display files a little. --- gtk/src/gtk_display.cpp | 1337 +++++++++++++++++---------------------- gtk/src/gtk_display.h | 9 +- 2 files changed, 584 insertions(+), 762 deletions(-) diff --git a/gtk/src/gtk_display.cpp b/gtk/src/gtk_display.cpp index 8615da9f..a581db63 100644 --- a/gtk/src/gtk_display.cpp +++ b/gtk/src/gtk_display.cpp @@ -21,27 +21,6 @@ #include "gtk_display_driver_opengl.h" #endif -static const char kern[224][2] = -{ - { 2, 2 },{ 2, 3 },{ 1, 2 },{ 0, 1 },{ 0, 1 },{ 0, 2 },{ 0, 2 },{ 0, 3 },{ 1, 3 },{ 1, 3 },{ 0, 3 },{ 0, 1 },{ 0, 3 },{ 0, 2 },{ 1, 3 },{ 0, 2 }, - { 0, 3 },{ 0, 3 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 1, 3 },{ 0, 3 },{ 0, 3 },{ 0, 2 },{ 0, 3 },{ 0, 3 }, - { 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 3 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 1 },{ 0, 1 },{ 0, 2 }, - { 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 3 },{ 0, 1 },{ 0, 1 },{ 0, 1 },{ 0, 2 },{ 0, 3 },{ 0, 2 },{ 0, 3 },{ 0, 2 },{ 0, 3 },{ 0, 3 },{ 0, 2 }, - { 0, 3 },{ 0, 2 },{ 0, 2 },{ 0, 3 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 2 },{ 0, 3 },{ 0, 3 },{ 0, 2 },{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 0, 1 },{ 0, 2 },{ 0, 3 }, - { 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 }, - { 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 },{ 2, 2 } -}; - -static const int font_width = 8; -static const int font_height = 9; - static S9xDisplayDriver *driver; static snes_ntsc_t snes_ntsc; static thread_job_t job[8]; @@ -50,7 +29,7 @@ static uint8 *y_table, *u_table, *v_table; static int endianess = ENDIAN_NORMAL; /* Scanline constants for the NTSC filter */ -static unsigned int scanline_offsets[] = +static const unsigned int scanline_offsets[] = { 0, /* 0% */ 3, /* 12.5% */ @@ -59,7 +38,7 @@ static unsigned int scanline_offsets[] = 0, /* 100% */ }; -static unsigned short scanline_masks[] = +static const unsigned short scanline_masks[] = { 0x0000, /* 0% */ 0x18E3, /* 12.5% */ @@ -69,7 +48,7 @@ static unsigned short scanline_masks[] = }; /* Scanline constants for standard scanline filter */ -static uint8 scanline_shifts[] = +static const uint8 scanline_shifts[] = { 3, 2, @@ -77,42 +56,39 @@ static uint8 scanline_shifts[] = 0 }; -void -S9xSetEndianess (int type) +void S9xSetEndianess (int type) { endianess = type; } -double -S9xGetAspect () +double S9xGetAspect () { double native_aspect = 256.0 / (gui_config->overscan ? 239.0 : 224.0); double aspect; switch (gui_config->aspect_ratio / 2) { - case 0: /* Square pixels */ - aspect = native_aspect; - break; + case 0: /* Square pixels */ + aspect = native_aspect; + break; - case 1: /* 4:3 */ - aspect = native_aspect * 7 / 6; - break; + case 1: /* 4:3 */ + aspect = native_aspect * 7 / 6; + break; - case 2: - default: /* Correct */ - aspect = native_aspect * 8 / 7; - break; + case 2: + default: /* Correct */ + aspect = native_aspect * 8 / 7; + break; } return aspect; } -void -S9xApplyAspect (int &s_width, /* Output: x */ - int &s_height, /* Output: y */ - int &d_width, /* Output: width */ - int &d_height) /* Output: height */ +void S9xApplyAspect (int &s_width, /* Output: x */ + int &s_height, /* Output: y */ + int &d_width, /* Output: width */ + int &d_height) /* Output: height */ { double screen_aspect = (double) d_width / (double) d_height; double snes_aspect = S9xGetAspect (); @@ -189,8 +165,7 @@ S9xApplyAspect (int &s_width, /* Output: x */ d_height = h; } -void -S9xRegisterYUVTables (uint8 *y, uint8 *u, uint8 *v) +void S9xRegisterYUVTables (uint8 *y, uint8 *u, uint8 *v) { y_table = y; u_table = u; @@ -198,13 +173,12 @@ S9xRegisterYUVTables (uint8 *y, uint8 *u, uint8 *v) } /* YUY2 in LSB first format */ -static void -internal_convert_16_yuv (void *src_buffer, - void *dst_buffer, - int src_pitch, - int dst_pitch, - int width, - int height) +static void internal_convert_16_yuv (void *src_buffer, + void *dst_buffer, + int src_pitch, + int dst_pitch, + int width, + int height) { int x, y; uint16 *src; @@ -251,17 +225,16 @@ internal_convert_16_yuv (void *src_buffer, } } -static void -internal_convert_mask (void *src_buffer, - void *dst_buffer, - int src_pitch, - int dst_pitch, - int width, - int height, - unsigned int inv_rshift, - unsigned int inv_gshift, - unsigned int inv_bshift, - unsigned int bpp) +static void internal_convert_mask (void *src_buffer, + void *dst_buffer, + int src_pitch, + int dst_pitch, + int width, + int height, + unsigned int inv_rshift, + unsigned int inv_gshift, + unsigned int inv_bshift, + unsigned int bpp) { #ifdef __BIG_ENDIAN__ if (endianess == ENDIAN_SWAPPED) @@ -271,98 +244,80 @@ internal_convert_mask (void *src_buffer, { switch (bpp) { - case 15: - case 16: + case 15: + case 16: + for (int y = 0; y < height; y++) + { + uint16 *data = (uint16 *) ((uint8 *) dst_buffer + y * dst_pitch); + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) { - uint16 *data = - (uint16 *) ((uint8 *) dst_buffer + y * dst_pitch); + uint32 pixel = *snes++; - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - - for (int x = 0; x < width; x++) - { - uint32 pixel = *snes++; - - *data++ = ((pixel & 0xf800) << 0) >> inv_rshift - | ((pixel & 0x07e0) << 5) >> inv_gshift - | ((pixel & 0x001f) << 11) >> inv_bshift; - } + *data++ = ((pixel & 0xf800) << 0) >> inv_rshift + | ((pixel & 0x07e0) << 5) >> inv_gshift + | ((pixel & 0x001f) << 11) >> inv_bshift; } + } + break; - break; - - case 24: - + case 24: #ifdef __BIG_ENDIAN__ - if (inv_rshift > 8) + if (inv_rshift > 8) #else - if (!(inv_rshift > 8)) + if (!(inv_rshift > 8)) #endif - { - for (int y = 0; y < height; y++) - { - uint8 *data = - (uint8 *) dst_buffer + y * dst_pitch; - - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - - for (int x = 0; x < width; x++) - { - uint32 pixel = *snes++; - *data++ = ((pixel & 0x001f) << 3); - *data++ = ((pixel & 0x07e0) >> 3); - *data++ = ((pixel & 0xf800) >> 8); - } - } - } - - else - { - for (int y = 0; y < height; y++) - { - uint8 *data = - (uint8 *) dst_buffer + y * dst_pitch; - - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - - for (int x = 0; x < width; x++) - { - uint32 pixel = *snes++; - *data++ = ((pixel & 0xf800) >> 8); - *data++ = ((pixel & 0x07e0) >> 3); - *data++ = ((pixel & 0x001f) << 3); - } - } - } - - break; - - case 32: - + { for (int y = 0; y < height; y++) { - uint32 *data = - (uint32 *) ((uint8 *) dst_buffer + y * dst_pitch); - - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); + uint8 *data = (uint8 *) dst_buffer + y * dst_pitch; + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); for (int x = 0; x < width; x++) { uint32 pixel = *snes++; - - *data++ = ((uint32) (pixel & 0xf800) << 16) >> inv_rshift - | ((uint32) (pixel & 0x07e0) << 21) >> inv_gshift - | ((uint32) (pixel & 0x001f) << 27) >> inv_bshift; + *data++ = ((pixel & 0x001f) << 3); + *data++ = ((pixel & 0x07e0) >> 3); + *data++ = ((pixel & 0xf800) >> 8); } } + } + else + { + for (int y = 0; y < height; y++) + { + uint8 *data = (uint8 *) dst_buffer + y * dst_pitch; - break; + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); + + for (int x = 0; x < width; x++) + { + uint32 pixel = *snes++; + *data++ = ((pixel & 0xf800) >> 8); + *data++ = ((pixel & 0x07e0) >> 3); + *data++ = ((pixel & 0x001f) << 3); + } + } + } + break; + + case 32: + for (int y = 0; y < height; y++) + { + uint32 *data = (uint32 *) ((uint8 *) dst_buffer + y * dst_pitch); + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); + + for (int x = 0; x < width; x++) + { + uint32 pixel = *snes++; + + *data++ = ((uint32) (pixel & 0xf800) << 16) >> inv_rshift + | ((uint32) (pixel & 0x07e0) << 21) >> inv_gshift + | ((uint32) (pixel & 0x001f) << 27) >> inv_bshift; + } + } + break; } } @@ -370,120 +325,100 @@ internal_convert_mask (void *src_buffer, { switch (bpp) { - case 15: - case 16: + case 15: + case 16: + for (int y = 0; y < height; y++) + { + uint16 *data = (uint16 *) ((uint8 *) dst_buffer + y * dst_pitch); + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) { - uint16 *data = - (uint16 *) ((uint8 *) dst_buffer + y * dst_pitch); + uint32 pixel = *snes++; + uint16 value; - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); + value = ((pixel & 0xf800) << 0) >> inv_rshift + | ((pixel & 0x07e0) << 5) >> inv_gshift + | ((pixel & 0x001f) << 11) >> inv_bshift; - for (int x = 0; x < width; x++) - { - uint32 pixel = *snes++; - uint16 value; - - value = ((pixel & 0xf800) << 0) >> inv_rshift - | ((pixel & 0x07e0) << 5) >> inv_gshift - | ((pixel & 0x001f) << 11) >> inv_bshift; - - *data++ = ((value & 0xff) << 8) - | ((value & 0xff00) >> 8); - } + *data++ = ((value & 0xff) << 8) + | ((value & 0xff00) >> 8); } + } + break; - break; - - case 24: - + case 24: #ifdef __BIG_ENDIAN__ - if (inv_rshift > 8) + if (inv_rshift > 8) #else - if (!(inv_rshift > 8)) + if (!(inv_rshift > 8)) #endif - { - for (int y = 0; y < height; y++) - { - uint8 *data = - (uint8 *) dst_buffer + y * dst_pitch; - - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - - for (int x = 0; x < width; x++) - { - uint32 pixel = *snes++; - *data++ = ((pixel & 0xf800) >> 8); - *data++ = ((pixel & 0x07e0) >> 3); - *data++ = ((pixel & 0x001f) << 3); - } - } - } - - else - { - for (int y = 0; y < height; y++) - { - uint8 *data = - (uint8 *) dst_buffer + y * dst_pitch; - - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - - for (int x = 0; x < width; x++) - { - uint32 pixel = *snes++; - *data++ = ((pixel & 0x001f) << 3); - *data++ = ((pixel & 0x07e0) >> 3); - *data++ = ((pixel & 0xf800) >> 8); - } - } - } - - break; - - case 32: - + { for (int y = 0; y < height; y++) { - uint32 *data = - (uint32 *) ((uint8 *) dst_buffer + y * dst_pitch); - - uint16 *snes = - (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); + uint8 *data = (uint8 *) dst_buffer + y * dst_pitch; + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); for (int x = 0; x < width; x++) { uint32 pixel = *snes++; - uint32 value; - - value = ((uint32) (pixel & 0xf800) << 16) >> inv_rshift - | ((uint32) (pixel & 0x07e0) << 21) >> inv_gshift - | ((uint32) (pixel & 0x001f) << 27) >> inv_bshift; - - *data++ = ((value & 0x000000ff) << 24) - | ((value & 0x0000ff00) << 8) - | ((value & 0x00ff0000) >> 8) - | ((value & 0xff000000) >> 24); + *data++ = ((pixel & 0xf800) >> 8); + *data++ = ((pixel & 0x07e0) >> 3); + *data++ = ((pixel & 0x001f) << 3); } } + } + else + { + for (int y = 0; y < height; y++) + { + uint8 *data = (uint8 *) dst_buffer + y * dst_pitch; + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); - break; + for (int x = 0; x < width; x++) + { + uint32 pixel = *snes++; + *data++ = ((pixel & 0x001f) << 3); + *data++ = ((pixel & 0x07e0) >> 3); + *data++ = ((pixel & 0xf800) >> 8); + } + } + } + break; + + case 32: + for (int y = 0; y < height; y++) + { + uint32 *data = (uint32 *) ((uint8 *) dst_buffer + y * dst_pitch); + uint16 *snes = (uint16 *) (((uint8 *) src_buffer) + y * src_pitch); + + for (int x = 0; x < width; x++) + { + uint32 pixel = *snes++; + uint32 value; + + value = ((uint32) (pixel & 0xf800) << 16) >> inv_rshift + | ((uint32) (pixel & 0x07e0) << 21) >> inv_gshift + | ((uint32) (pixel & 0x001f) << 27) >> inv_bshift; + + *data++ = ((value & 0x000000ff) << 24) + | ((value & 0x0000ff00) << 8) + | ((value & 0x00ff0000) >> 8) + | ((value & 0xff000000) >> 24); + } + } + break; } } } -static void -internal_convert (void *src_buffer, - void *dst_buffer, - int src_pitch, - int dst_pitch, - int width, - int height, - int bpp) +static void internal_convert (void *src_buffer, + void *dst_buffer, + int src_pitch, + int dst_pitch, + int width, + int height, + int bpp) { if (endianess == ENDIAN_SWAPPED) { @@ -572,11 +507,10 @@ internal_convert (void *src_buffer, } } -static void -S9xForceHires (void *buffer, - int pitch, - int &width, - int &height) +static void S9xForceHires (void *buffer, + int pitch, + int &width, + int &height) { int double_width = 0, double_height = 0; @@ -630,13 +564,15 @@ S9xForceHires (void *buffer, } } -#undef AVERAGE_565 -#define AVERAGE_565(el0, el1) (((el0) & (el1)) + ((((el0) ^ (el1)) & 0xF7DE) >> 1)) -static void -S9xMergeHires (void *buffer, - int pitch, - int &width, - int &height) +static inline uint16 average_565(uint16 colora, uint16 colorb) +{ + return (((colora) & (colorb)) + ((((colora) ^ (colorb)) & 0xF7DE) >> 1)); +} + +static void S9xMergeHires (void *buffer, + int pitch, + int &width, + int &height) { if (width < 512) { @@ -650,7 +586,7 @@ S9xMergeHires (void *buffer, for (int x = 0; x < (width >> 1); x++) { - *output++ = AVERAGE_565 (input[0], input[1]); + *output++ = average_565 (input[0], input[1]); input += 2; } } @@ -658,47 +594,12 @@ S9xMergeHires (void *buffer, width >>= 1; } -#if 0 -static void -S9xBlendHires (void *buffer, int pitch, int &width, int &height) -{ - uint16 tmp[512]; - - if (width < 512) - { - width <<= 1; - - for (int y = 0; y < height; y++) - { - uint16 *input = (uint16 *) ((uint8 *) buffer + y * pitch); - - tmp[0] = input[0]; - for (int x = 1; x < width; x++) - tmp[x] = AVERAGE_1555 (input[(x - 1) >> 1], input[(x >> 1)]); - - memcpy (input, tmp, width << 1); - } - } - else for (int y = 0; y < height; y++) - { - uint16 *input = (uint16 *) ((uint8 *) buffer + y * pitch); - - tmp[0] = input[0]; - for (int x = 1; x < width; x++) - tmp[x] = AVERAGE_1555 (input[x - 1], input[x]); - - memcpy (input, tmp, pitch); - } -} -#endif - -void -filter_2x (void *src, - int src_pitch, - void *dst, - int dst_pitch, - int width, - int height) +void filter_2x (void *src, + int src_pitch, + void *dst, + int dst_pitch, + int width, + int height) { int x, y; @@ -721,13 +622,12 @@ filter_2x (void *src, } } -void -filter_3x (void *src, - int src_pitch, - void *dst, - int dst_pitch, - int width, - int height) +void filter_3x (void *src, + int src_pitch, + void *dst, + int dst_pitch, + int width, + int height) { int x, y, z; @@ -754,13 +654,12 @@ filter_3x (void *src, } } -void -filter_4x (void *src, - int src_pitch, - void *dst, - int dst_pitch, - int width, - int height) +void filter_4x (void *src, + int src_pitch, + void *dst, + int dst_pitch, + int width, + int height) { int x, y, z; @@ -788,13 +687,12 @@ filter_4x (void *src, } } -void -filter_scanlines (void *src_buffer, - int src_pitch, - void *dst_buffer, - int dst_pitch, - int width, - int height) +void filter_scanlines (void *src_buffer, + int src_pitch, + void *dst_buffer, + int dst_pitch, + int width, + int height) { int x, y; uint16 *src, *dst_a, *dst_b; @@ -820,388 +718,362 @@ filter_scanlines (void *src_buffer, } } -void -get_filter_scale (int &width, int &height) +void get_filter_scale (int &width, int &height) { switch (gui_config->scale_method) { - case FILTER_SUPEREAGLE: - width *= 2; - height *= 2; - break; + case FILTER_SUPEREAGLE: + width *= 2; + height *= 2; + break; - case FILTER_2XSAI: - width *= 2; - height *= 2; - break; + case FILTER_2XSAI: + width *= 2; + height *= 2; + break; - case FILTER_SUPER2XSAI: - width *= 2; - height *= 2; - break; + case FILTER_SUPER2XSAI: + width *= 2; + height *= 2; + break; #ifdef USE_HQ2X - case FILTER_HQ4X: - if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && + case FILTER_HQ4X: + if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && ((height * 4) <= S9xDisplayDriver::scaled_max_height)) - { - width *= 4; - height *= 4; - break; - } - // Fall through - case FILTER_HQ3X: - if (width * 3 <= S9xDisplayDriver::scaled_max_width && - height * 3 <= S9xDisplayDriver::scaled_max_height) - { - width *= 3; - height *= 3; - break; - } - // Fall through - case FILTER_HQ2X: - width *= 2; - height *= 2; + { + width *= 4; + height *= 4; break; + } + // Fall through + case FILTER_HQ3X: + if (width * 3 <= S9xDisplayDriver::scaled_max_width && + height * 3 <= S9xDisplayDriver::scaled_max_height) + { + width *= 3; + height *= 3; + break; + } + // Fall through + case FILTER_HQ2X: + width *= 2; + height *= 2; + break; #endif /* USE_HQ2X */ #ifdef USE_XBRZ - case FILTER_4XBRZ: - if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && - ((height * 4) <= S9xDisplayDriver::scaled_max_height)) - { - width *= 4; - height *= 4; - break; - } - // Fall through - case FILTER_3XBRZ: - if (width * 3 <= S9xDisplayDriver::scaled_max_width && - height * 3 <= S9xDisplayDriver::scaled_max_height) - { - width *= 3; - height *= 3; - break; - } - // Fall through - case FILTER_2XBRZ: - width *= 2; - height *= 2; + case FILTER_4XBRZ: + if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && + ((height * 4) <= S9xDisplayDriver::scaled_max_height)) + { + width *= 4; + height *= 4; break; + } + // Fall through + case FILTER_3XBRZ: + if (width * 3 <= S9xDisplayDriver::scaled_max_width && + height * 3 <= S9xDisplayDriver::scaled_max_height) + { + width *= 3; + height *= 3; + break; + } + // Fall through + case FILTER_2XBRZ: + width *= 2; + height *= 2; + break; #endif /* USE_XBRZ */ - case FILTER_SIMPLE4X: - if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && - ((height * 4) <= S9xDisplayDriver::scaled_max_height)) - { - width *= 4; - height *= 4; - break; - } - // Fall through - case FILTER_SIMPLE3X: - if (width * 3 <= S9xDisplayDriver::scaled_max_width && - height * 3 <= S9xDisplayDriver::scaled_max_height) - { - width *= 3; - height *= 3; - break; - } - // Fall through - case FILTER_SIMPLE2X: - width *= 2; - height *= 2; + case FILTER_SIMPLE4X: + if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && + ((height * 4) <= S9xDisplayDriver::scaled_max_height)) + { + width *= 4; + height *= 4; break; + } + // Fall through + case FILTER_SIMPLE3X: + if (width * 3 <= S9xDisplayDriver::scaled_max_width && + height * 3 <= S9xDisplayDriver::scaled_max_height) + { + width *= 3; + height *= 3; + break; + } + // Fall through + case FILTER_SIMPLE2X: + width *= 2; + height *= 2; + break; - case FILTER_EPX: - width *= 2; - height *= 2; - break; + case FILTER_EPX: + width *= 2; + height *= 2; + break; - case FILTER_NTSC: - if (width > 256) - width = SNES_NTSC_OUT_WIDTH (width / 2); - else - width = SNES_NTSC_OUT_WIDTH (width); - height *= 2; - break; + case FILTER_NTSC: + if (width > 256) + width = SNES_NTSC_OUT_WIDTH (width / 2); + else + width = SNES_NTSC_OUT_WIDTH (width); + height *= 2; + break; - case FILTER_SCANLINES: - height *= 2; - break; + case FILTER_SCANLINES: + height *= 2; + break; - case FILTER_EPX_SMOOTH: - width *= 2; - height *= 2; - break; + case FILTER_EPX_SMOOTH: + width *= 2; + height *= 2; + break; } } -static void -internal_filter (uint8 *src_buffer, - int src_pitch, - uint8 *dst_buffer, - int dst_pitch, - int &width, - int &height) +static void internal_filter (uint8 *src_buffer, + int src_pitch, + uint8 *dst_buffer, + int dst_pitch, + int &width, + int &height) { switch (gui_config->scale_method) { - case FILTER_SUPEREAGLE: - SuperEagle (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - - break; - - case FILTER_2XSAI: - _2xSaI (src_buffer, + case FILTER_SUPEREAGLE: + SuperEagle (src_buffer, src_pitch, dst_buffer, dst_pitch, width, height); + break; - break; + case FILTER_2XSAI: + _2xSaI (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; - case FILTER_SUPER2XSAI: - Super2xSaI (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - - break; + case FILTER_SUPER2XSAI: + Super2xSaI (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; #ifdef USE_HQ2X - case FILTER_HQ4X: - - if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && - ((height * 4) <= S9xDisplayDriver::scaled_max_height)) - { - HQ4X_16 (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - - break; - } - // Fall through - case FILTER_HQ3X: - - if (width * 3 <= S9xDisplayDriver::scaled_max_width && - height * 3 <= S9xDisplayDriver::scaled_max_height) - { - HQ3X_16 (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - - break; - } - // Fall through - case FILTER_HQ2X: - - HQ2X_16 (src_buffer, + case FILTER_HQ4X: + if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && + ((height * 4) <= S9xDisplayDriver::scaled_max_height)) + { + HQ4X_16 (src_buffer, src_pitch, dst_buffer, dst_pitch, width, height); - break; -#endif /* USE_HQ2X */ - -#ifdef USE_XBRZ - case FILTER_4XBRZ: - - filter_4xBRZ (src_buffer, + } + // Fall through + case FILTER_HQ3X: + if (width * 3 <= S9xDisplayDriver::scaled_max_width && + height * 3 <= S9xDisplayDriver::scaled_max_height) + { + HQ3X_16 (src_buffer, src_pitch, dst_buffer, dst_pitch, width, height); - break; - // Fall through - case FILTER_3XBRZ: - - filter_3xBRZ (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - - break; - // Fall through - case FILTER_2XBRZ: - - filter_2xBRZ (src_buffer, + } + // Fall through + case FILTER_HQ2X: + HQ2X_16 (src_buffer, src_pitch, dst_buffer, dst_pitch, width, height); + break; +#endif /* USE_HQ2X */ - break; +#ifdef USE_XBRZ + case FILTER_4XBRZ: + filter_4xBRZ (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; + // Fall through + case FILTER_3XBRZ: + filter_3xBRZ (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; + // Fall through + case FILTER_2XBRZ: + filter_2xBRZ (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; #endif /* USE_XBRZ */ - - case FILTER_SIMPLE4X: - - if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && - ((height * 4) <= S9xDisplayDriver::scaled_max_height)) - { - filter_4x (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - - break; - } - // Fall through - case FILTER_SIMPLE3X: - - if (width * 3 <= S9xDisplayDriver::scaled_max_width && - height * 3 <= S9xDisplayDriver::scaled_max_height) - { - filter_3x (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - - break; - } - // Fall through - case FILTER_SIMPLE2X: - - filter_2x (src_buffer, + case FILTER_SIMPLE4X: + if (((width * 4) <= S9xDisplayDriver::scaled_max_width) && + ((height * 4) <= S9xDisplayDriver::scaled_max_height)) + { + filter_4x (src_buffer, src_pitch, dst_buffer, dst_pitch, width, height); - break; + } + // Fall through + case FILTER_SIMPLE3X: - case FILTER_EPX: - - EPX_16_unsafe (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); - + if (width * 3 <= S9xDisplayDriver::scaled_max_width && + height * 3 <= S9xDisplayDriver::scaled_max_height) + { + filter_3x (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); break; + } + // Fall through + case FILTER_SIMPLE2X: + filter_2x (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; - case FILTER_EPX_SMOOTH: + case FILTER_EPX: + EPX_16_unsafe (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; - EPX_16_smooth_unsafe (src_buffer, - src_pitch, - dst_buffer, - dst_pitch, - width, - height); + case FILTER_EPX_SMOOTH: - break; - - case FILTER_NTSC: - if (width > 256) - snes_ntsc_blit_hires_scanlines (&snes_ntsc, - (SNES_NTSC_IN_T *) src_buffer, - src_pitch >> 1, - 0, /* Burst_phase */ - width, - height, - (void *) dst_buffer, - dst_pitch); - else - snes_ntsc_blit_scanlines (&snes_ntsc, - (SNES_NTSC_IN_T *) src_buffer, - src_pitch >> 1, - 0, /* Burst_phase */ - width, - height, - (void *) dst_buffer, - dst_pitch); - break; - - case FILTER_SCANLINES: - filter_scanlines (src_buffer, + EPX_16_smooth_unsafe (src_buffer, src_pitch, dst_buffer, dst_pitch, width, height); - break; + + break; + + case FILTER_NTSC: + if (width > 256) + snes_ntsc_blit_hires_scanlines (&snes_ntsc, + (SNES_NTSC_IN_T *) src_buffer, + src_pitch >> 1, + 0, /* Burst_phase */ + width, + height, + (void *) dst_buffer, + dst_pitch); + else + snes_ntsc_blit_scanlines (&snes_ntsc, + (SNES_NTSC_IN_T *) src_buffer, + src_pitch >> 1, + 0, /* Burst_phase */ + width, + height, + (void *) dst_buffer, + dst_pitch); + break; + + case FILTER_SCANLINES: + filter_scanlines (src_buffer, + src_pitch, + dst_buffer, + dst_pitch, + width, + height); + break; } get_filter_scale (width, height); } -static void -thread_worker (gpointer data, - gpointer user_data) +static void thread_worker (gpointer data, + gpointer user_data) { thread_job_t *job = ((thread_job_t *) data); switch (job->operation_type) { - case JOB_FILTER: - internal_filter (job->src_buffer, - job->src_pitch, - job->dst_buffer, - job->dst_pitch, - job->width, - job->height); - break; + case JOB_FILTER: + internal_filter (job->src_buffer, + job->src_pitch, + job->dst_buffer, + job->dst_pitch, + job->width, + job->height); + break; - case JOB_CONVERT: - internal_convert (job->src_buffer, - job->dst_buffer, - job->src_pitch, - job->dst_pitch, - job->width, - job->height, - job->bpp); - break; + case JOB_CONVERT: + internal_convert (job->src_buffer, + job->dst_buffer, + job->src_pitch, + job->dst_pitch, + job->width, + job->height, + job->bpp); + break; - case JOB_CONVERT_YUV: - internal_convert_16_yuv (job->src_buffer, - job->dst_buffer, - job->src_pitch, - job->dst_pitch, - job->width, - job->height); - break; + case JOB_CONVERT_YUV: + internal_convert_16_yuv (job->src_buffer, + job->dst_buffer, + job->src_pitch, + job->dst_pitch, + job->width, + job->height); + break; - case JOB_CONVERT_MASK: - internal_convert_mask (job->src_buffer, - job->dst_buffer, - job->src_pitch, - job->dst_pitch, - job->width, - job->height, - job->inv_rmask, - job->inv_bmask, - job->inv_gmask, - job->bpp); - break; + case JOB_CONVERT_MASK: + internal_convert_mask (job->src_buffer, + job->dst_buffer, + job->src_pitch, + job->dst_pitch, + job->width, + job->height, + job->inv_rmask, + job->inv_bmask, + job->inv_gmask, + job->bpp); + break; } job->complete = true; @@ -1229,11 +1101,9 @@ internal_threaded_convert (void *src_buffer, int height, int bpp) { - int i, flag; - create_thread_pool (); - for (i = 0; i < gui_config->num_threads - 1; i++) + for (int i = 0; i < gui_config->num_threads; i++) { job[i].operation_type = (bpp == -1 ? JOB_CONVERT_YUV : JOB_CONVERT); job[i].src_buffer = @@ -1247,52 +1117,39 @@ internal_threaded_convert (void *src_buffer, job[i].bpp = bpp; job[i].complete = false; + if (i == gui_config->num_threads - 1) + job[i].height = height - ((gui_config->num_threads - 1) * (height / gui_config->num_threads)); + g_thread_pool_push (pool, (gpointer) &(job[i]), NULL); } - job[i].operation_type = (bpp == -1 ? JOB_CONVERT_YUV : JOB_CONVERT); - job[i].src_buffer = - ((uint8 *) src_buffer) + (src_pitch * i * (height / gui_config->num_threads)); - job[i].src_pitch = src_pitch; - job[i].dst_buffer = - ((uint8 *) dst_buffer) + (dst_pitch * i * (height / gui_config->num_threads)); - job[i].dst_pitch = dst_pitch; - job[i].width = width; - job[i].height = height - ((gui_config->num_threads - 1) * (height / gui_config->num_threads)); - job[i].bpp = bpp; - - thread_worker ((gpointer) &(job[i]), NULL); - while (1) { - flag = 1; - for (i = 0; i < gui_config->num_threads - 1; i++) - flag = flag && job[i].complete; + int complete = 1; + for (int i = 0; i < gui_config->num_threads; i++) + complete = complete && job[i].complete; - if (flag) + if (complete) break; sched_yield (); } } -static void -internal_threaded_convert_mask (void *src_buffer, - void *dst_buffer, - int src_pitch, - int dst_pitch, - int width, - int height, - int inv_rmask, - int inv_gmask, - int inv_bmask, - int bpp) +static void internal_threaded_convert_mask (void *src_buffer, + void *dst_buffer, + int src_pitch, + int dst_pitch, + int width, + int height, + int inv_rmask, + int inv_gmask, + int inv_bmask, + int bpp) { - int i, flag; - create_thread_pool (); - for (i = 0; i < gui_config->num_threads - 1; i++) + for (int i = 0; i < gui_config->num_threads; i++) { job[i].operation_type = (bpp == -1 ? JOB_CONVERT_YUV : JOB_CONVERT); job[i].src_buffer = @@ -1309,58 +1166,41 @@ internal_threaded_convert_mask (void *src_buffer, job[i].inv_bmask = inv_bmask; job[i].complete = false; + if (i == gui_config->num_threads - 1) + job[i].height = height - ((gui_config->num_threads - 1) * (height / gui_config->num_threads)); + g_thread_pool_push (pool, (gpointer) &(job[i]), NULL); } - job[i].operation_type = (bpp == -1 ? JOB_CONVERT_YUV : JOB_CONVERT); - job[i].src_buffer = - ((uint8 *) src_buffer) + (src_pitch * i * (height / gui_config->num_threads)); - job[i].src_pitch = src_pitch; - job[i].dst_buffer = - ((uint8 *) dst_buffer) + (dst_pitch * i * (height / gui_config->num_threads)); - job[i].dst_pitch = dst_pitch; - job[i].width = width; - job[i].height = height - ((gui_config->num_threads - 1) * (height / gui_config->num_threads)); - job[i].bpp = bpp; - job[i].inv_rmask = inv_rmask; - job[i].inv_gmask = inv_gmask; - job[i].inv_bmask = inv_bmask; - - thread_worker ((gpointer) &(job[i]), NULL); - while (1) { - flag = 1; - for (i = 0; i < gui_config->num_threads - 1; i++) - flag = flag && job[i].complete; + int complete = 1; + for (int i = 0; i < gui_config->num_threads; i++) + complete = complete && job[i].complete; - if (flag) + if (complete) break; sched_yield (); } } -static void -internal_threaded_filter (uint8 *src_buffer, - int src_pitch, - uint8 *dst_buffer, - int dst_pitch, - int &width, - int &height) +static void internal_threaded_filter (uint8 *src_buffer, + int src_pitch, + uint8 *dst_buffer, + int dst_pitch, + int &width, + int &height) { - int i, flag; - int dwidth = width, dheight = height; int src_coverage = 0, dst_coverage = 0; - int height_scale; + int xscale = 1, yscale = 1; - get_filter_scale (dwidth, dheight); - height_scale = dheight / height; + get_filter_scale (xscale, yscale); /* If the threadpool doesn't exist, create it */ create_thread_pool (); - for (i = 0; i < gui_config->num_threads - 1; i++) + for (int i = 0; i < gui_config->num_threads; i++) { job[i].operation_type = JOB_FILTER; job[i].complete = false; @@ -1369,33 +1209,22 @@ internal_threaded_filter (uint8 *src_buffer, job[i].dst_pitch = dst_pitch; job[i].src_buffer = src_buffer + (src_pitch * src_coverage); job[i].dst_buffer = dst_buffer + (dst_pitch * dst_coverage); - job[i].height = (height / gui_config->num_threads) & ~3; /* Cut to multiple of 4 */ + if (i == gui_config->num_threads - 1) + job[i].height = height - src_coverage; src_coverage += job[i].height; - dst_coverage += job[i].height * height_scale; - + dst_coverage += job[i].height * yscale; g_thread_pool_push (pool, (gpointer) &(job[i]), NULL); } - job[i].operation_type = JOB_FILTER; - job[i].width = width; - job[i].src_pitch = src_pitch; - job[i].dst_pitch = dst_pitch; - job[i].src_buffer = src_buffer + (src_pitch * src_coverage); - job[i].dst_buffer = dst_buffer + (dst_pitch * dst_coverage); - - job[i].height = height - src_coverage; - - thread_worker ((gpointer) &(job[i]), NULL); - while (1) { - flag = 1; - for (i = 0; i < gui_config->num_threads - 1; i++) - flag = flag && job[i].complete; + int complete = 1; + for (int i = 0; i < gui_config->num_threads; i++) + complete = complete && job[i].complete; - if (flag) + if (complete) break; sched_yield (); @@ -1404,13 +1233,12 @@ internal_threaded_filter (uint8 *src_buffer, get_filter_scale (width, height); } -void -S9xFilter (uint8 *src_buffer, - int src_pitch, - uint8 *dst_buffer, - int dst_pitch, - int &width, - int &height) +void S9xFilter (uint8 *src_buffer, + int src_pitch, + uint8 *dst_buffer, + int dst_pitch, + int &width, + int &height) { if (gui_config->multithreading) @@ -1429,13 +1257,12 @@ S9xFilter (uint8 *src_buffer, height); } -void -S9xConvertYUV (void *src_buffer, - void *dst_buffer, - int src_pitch, - int dst_pitch, - int width, - int height) +void S9xConvertYUV (void *src_buffer, + void *dst_buffer, + int src_pitch, + int dst_pitch, + int width, + int height) { if (gui_config->multithreading) internal_threaded_convert (src_buffer, @@ -1454,14 +1281,13 @@ S9xConvertYUV (void *src_buffer, height); } -void -S9xConvert (void *src, - void *dst, - int src_pitch, - int dst_pitch, - int width, - int height, - int bpp) +void S9xConvert (void *src, + void *dst, + int src_pitch, + int dst_pitch, + int width, + int height, + int bpp) { if (gui_config->multithreading) internal_threaded_convert (src, @@ -1481,17 +1307,16 @@ S9xConvert (void *src, bpp); } -void -S9xConvertMask (void *src, - void *dst, - int src_pitch, - int dst_pitch, - int width, - int height, - int rshift, - int gshift, - int bshift, - int bpp) +void S9xConvertMask (void *src, + void *dst, + int src_pitch, + int dst_pitch, + int width, + int height, + int rshift, + int gshift, + int bshift, + int bpp) { if (gui_config->multithreading) internal_threaded_convert_mask (src, @@ -1517,14 +1342,12 @@ S9xConvertMask (void *src, bpp); } -void -S9xDisplayRefresh (int width, int height) +void S9xDisplayRefresh (int width, int height) { driver->refresh (width, height); } -static void -ntsc_filter_init () +static void ntsc_filter_init () { snes_ntsc_scanline_offset = scanline_offsets [gui_config->ntsc_scanline_intensity]; snes_ntsc_scanline_mask = scanline_masks [gui_config->ntsc_scanline_intensity]; @@ -1532,8 +1355,7 @@ ntsc_filter_init () snes_ntsc_init (&snes_ntsc, &gui_config->ntsc_setup); } -void -S9xDisplayReconfigure () +void S9xDisplayReconfigure () { ntsc_filter_init (); @@ -1543,8 +1365,7 @@ S9xDisplayReconfigure () } } -void -S9xQueryDrivers () +void S9xQueryDrivers () { GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (top_level->get_window())); @@ -1576,8 +1397,7 @@ S9xQueryDrivers () #endif } -bool8 -S9xDeinitUpdate (int width, int height) +bool8 S9xDeinitUpdate (int width, int height) { int yoffset = 0; @@ -1649,8 +1469,7 @@ S9xDeinitUpdate (int width, int height) return true; } -static void -S9xInitDriver () +static void S9xInitDriver () { #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) @@ -1700,20 +1519,17 @@ S9xInitDriver () pool = NULL; } -S9xDisplayDriver * -S9xDisplayGetDriver () +S9xDisplayDriver *S9xDisplayGetDriver () { return driver; } -void -S9xDisplayClearBuffers () +void S9xDisplayClearBuffers () { driver->clear_buffers (); } -void -S9xDeinitDisplay () +void S9xDeinitDisplay () { driver->deinit (); delete driver; @@ -1725,8 +1541,7 @@ S9xDeinitDisplay () g_thread_pool_free (pool, false, true); } -void -S9xReinitDisplay () +void S9xReinitDisplay () { uint16 *buffer = NULL; int width, height; @@ -1751,34 +1566,50 @@ S9xReinitDisplay () free (buffer); } -bool8 -S9xContinueUpdate (int width, int height) +bool8 S9xContinueUpdate (int width, int height) { S9xDeinitUpdate (width, height); return true; } -bool8 -S9xInitUpdate () +bool8 S9xInitUpdate () { return true; } -void -S9xSetPalette () +void S9xSetPalette () { } -void -S9xTextMode () +void S9xTextMode () { } -void -S9xGraphicsMode () +void S9xGraphicsMode () { } +static const char kern[224][2] = +{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int font_height = 9; + static inline int CharWidth (uint8 c) { return font_width - kern[c - 32][0] - kern[c - 32][1]; @@ -1891,8 +1722,7 @@ static void S9xGTKDisplayString (const char *string, int linesFromBottom, } } -void -S9xInitDisplay (int argc, char **argv) +void S9xInitDisplay (int argc, char **argv) { Settings.SupportHiRes = true; S9xBlit2xSaIFilterInit (); @@ -1906,8 +1736,7 @@ S9xInitDisplay (int argc, char **argv) S9xCustomDisplayString = S9xGTKDisplayString; } -bool -S9xDisplayDriverIsReady () +bool S9xDisplayDriverIsReady () { if (!driver) return false; diff --git a/gtk/src/gtk_display.h b/gtk/src/gtk_display.h index bdea978d..42ef3579 100644 --- a/gtk/src/gtk_display.h +++ b/gtk/src/gtk_display.h @@ -83,21 +83,18 @@ typedef struct thread_job_t int line_end; volatile bool complete; -} -thread_job_t; +} thread_job_t; void S9xRegisterYUVTables (uint8 *y, uint8 *u, uint8 *v); void S9xSetEndianess (int type); double S9xGetAspect (); void S9xApplyAspect (int&, int&, int&, int&); - void S9xConvertYUV (void *src_buffer, void *dst_buffer, int src_pitch, int dst_pitch, int width, int height); - void S9xConvert (void *src, void *dst, int src_pitch, @@ -105,7 +102,6 @@ void S9xConvert (void *src, int width, int height, int bpp); - void S9xConvertMask (void *src, void *dst, int src_pitch, @@ -116,7 +112,6 @@ void S9xConvertMask (void *src, int gshift, int bshift, int bpp); - void S9xFilter (uint8 *src_buffer, int src_pitch, uint8 *dst_buffer, @@ -124,13 +119,11 @@ void S9xFilter (uint8 *src_buffer, int& width, int& height); void get_filter_scale (int& width, int& height); - void S9xDisplayRefresh (int width, int height); void S9xDisplayClearBuffers (); void S9xReinitDisplay (); void S9xDisplayReconfigure (); void S9xQueryDrivers (); - S9xDisplayDriver *S9xDisplayGetDriver (); bool S9xDisplayDriverIsReady ();