Allow bilinear filtering in GTK output driver.

This commit is contained in:
Brandon Wright 2010-11-18 06:31:27 -06:00
parent 6880eacd5e
commit 2ccee69fee
6 changed files with 2308 additions and 2292 deletions

View File

@ -162,6 +162,7 @@ Snes9xConfig::load_defaults (void)
ntsc_setup = snes_ntsc_composite;
ntsc_scanline_intensity = 1;
scanline_filter_intensity = 0;
bilinear_filter = 0;
netplay_activated = FALSE;
netplay_server_up = FALSE;
netplay_is_server = FALSE;
@ -175,7 +176,6 @@ Snes9xConfig::load_defaults (void)
modal_dialogs = 1;
#ifdef USE_OPENGL
bilinear_filter = 0;
sync_to_vblank = 1;
use_pbos = 1;
pbo_format = 0;
@ -323,9 +323,9 @@ Snes9xConfig::save_config_file (void)
xml_out_int (xml, "ntsc_scanline_intensity", ntsc_scanline_intensity);
xml_out_int (xml, "scanline_filter_intensity", scanline_filter_intensity);
xml_out_int (xml, "hw_accel", hw_accel);
xml_out_int (xml, "bilinear_filter", bilinear_filter);
#ifdef USE_OPENGL
xml_out_int (xml, "bilinear_filter", bilinear_filter);
xml_out_int (xml, "sync_to_vblank", sync_to_vblank);
xml_out_int (xml, "sync_every_frame", sync_every_frame);
xml_out_int (xml, "use_pbos", use_pbos);
@ -499,9 +499,7 @@ Snes9xConfig::set_option (const char *name, const char *value)
}
else if (!strcasecmp (name, "bilinear_filter"))
{
#ifdef USE_OPENGL
bilinear_filter = atoi (value);
#endif
}
else if (!strcasecmp (name, "sync_to_vblank"))
{

View File

@ -81,6 +81,7 @@ class Snes9xConfig
float ntsc_merge_fields;
unsigned int ntsc_scanline_intensity;
unsigned int scanline_filter_intensity;
unsigned char bilinear_filter;
unsigned char hw_accel;
unsigned char allow_opengl;
unsigned char allow_xv;
@ -138,7 +139,6 @@ class Snes9xConfig
#ifdef USE_OPENGL
unsigned char bilinear_filter;
unsigned char sync_to_vblank;
unsigned char opengl_activated;
unsigned char use_pbos;

View File

@ -62,6 +62,7 @@ S9xGTKDisplayDriver::update (int width, int height)
x = width; y = height; w = c_width; h = c_height;
S9xApplyAspect (x, y, w, h);
output (final_buffer, final_pitch, x, y, width, height, w, h);
return;
@ -77,7 +78,7 @@ S9xGTKDisplayDriver::output (void *src,
int dst_width,
int dst_height)
{
if (width > gdk_buffer_width || height > gdk_buffer_height)
if (width != gdk_buffer_width || height != gdk_buffer_height)
{
gdk_buffer_width = width;
gdk_buffer_height = height;
@ -97,6 +98,14 @@ S9xGTKDisplayDriver::output (void *src,
NULL);
}
if (last_known_width != dst_width || last_known_height != dst_height)
{
clear ();
last_known_width = dst_width;
last_known_height = dst_height;
}
S9xConvert (src,
padded_buffer[2],
src_pitch,
@ -120,11 +129,15 @@ S9xGTKDisplayDriver::output (void *src,
(double) height / (double) dst_height);
cairo_matrix_translate (&matrix, -x, -y);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
cairo_pattern_set_filter (pattern,
config->bilinear_filter
? CAIRO_FILTER_BILINEAR
: CAIRO_FILTER_NEAREST);
}
cairo_rectangle (cr, x, y, dst_width, dst_height);
cairo_fill (cr);
cairo_destroy (cr);
window->set_mouseable_area (x, y, width, height);

View File

@ -32,6 +32,8 @@ class S9xGTKDisplayDriver : public S9xDisplayDriver
GdkPixbuf *pixbuf;
int gdk_buffer_width;
int gdk_buffer_height;
int last_known_width;
int last_known_height;
};
#endif /* __GTK_DISPLAY_DRIVER_GTK_H */

View File

@ -341,14 +341,17 @@ event_hw_accel_changed (GtkComboBox *widget, gpointer data)
switch (value)
{
case HWA_NONE:
gtk_widget_show (window->get_widget ("bilinear_filter"));
gtk_widget_hide (window->get_widget ("opengl_frame"));
gtk_widget_hide (window->get_widget ("xv_frame"));
break;
case HWA_OPENGL:
gtk_widget_show (window->get_widget ("bilinear_filter"));
gtk_widget_show (window->get_widget ("opengl_frame"));
gtk_widget_hide (window->get_widget ("xv_frame"));
break;
case HWA_XV:
gtk_widget_hide (window->get_widget ("bilinear_filter"));
gtk_widget_show (window->get_widget ("xv_frame"));
gtk_widget_hide (window->get_widget ("opengl_frame"));
break;
@ -717,8 +720,9 @@ Snes9xPreferences::move_settings_to_dialog (void)
set_combo ("frameskip_combo",
Settings.SkipFrames == AUTO_FRAMERATE ?
0 : Settings.SkipFrames + 1);
#ifdef USE_OPENGL
set_check ("bilinear_filter", config->bilinear_filter);
#ifdef USE_OPENGL
set_check ("sync_to_vblank", config->sync_to_vblank);
set_check ("sync_every_frame", config->sync_every_frame);
set_check ("use_pbos", config->use_pbos);
@ -826,6 +830,7 @@ Snes9xPreferences::get_settings_from_dialog (void)
config->ntsc_scanline_intensity = get_combo ("ntsc_scanline_intensity");
config->scanline_filter_intensity = get_combo ("scanline_filter_intensity");
config->hw_accel = hw_accel_value (get_combo ("hw_accel"));
config->bilinear_filter = get_check ("bilinear_filter");
config->num_threads = get_spin ("num_threads");
config->default_esc_behavior = get_combo ("default_esc_behavior");
config->prevent_screensaver = get_check ("prevent_screensaver");
@ -845,7 +850,6 @@ Snes9xPreferences::get_settings_from_dialog (void)
gfx_needs_restart = 1;
}
config->bilinear_filter = get_check ("bilinear_filter");
config->sync_to_vblank = get_check ("sync_to_vblank");
config->use_pbos = get_check ("use_pbos");
config->npot_textures = get_check ("npot_textures");

File diff suppressed because it is too large Load Diff