[retro-gtk] cairo-display: Allow to set a video filter
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] cairo-display: Allow to set a video filter
- Date: Fri, 10 Feb 2017 18:51:45 +0000 (UTC)
commit 01b3f4f02d86565fd2a6dccb5eb65a1816a4701a
Author: theawless <theawless gmail com>
Date: Fri Feb 10 22:57:39 2017 +0530
cairo-display: Allow to set a video filter
Add CairoDisplay.set_filter() and render the video with the given
filter.
https://bugzilla.gnome.org/show_bug.cgi?id=777987
retro-gtk/video/cairo-display.vala | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/retro-gtk/video/cairo-display.vala b/retro-gtk/video/cairo-display.vala
index a8608cc..3018324 100644
--- a/retro-gtk/video/cairo-display.vala
+++ b/retro-gtk/video/cairo-display.vala
@@ -4,11 +4,13 @@ public class RetroGtk.CairoDisplay : Gtk.DrawingArea {
public Gdk.Pixbuf pixbuf { set; get; }
private Retro.Core core;
+ private VideoFilter filter;
private ulong on_video_output_id;
private float aspect_ratio;
private bool show_surface;
construct {
+ filter = VideoFilter.SMOOTH;
show_surface = true;
notify["sensitive"].connect (queue_draw);
@@ -26,6 +28,11 @@ public class RetroGtk.CairoDisplay : Gtk.DrawingArea {
on_video_output_id = core.video_output.connect (on_video_output);
}
+ public void set_filter (VideoFilter filter) {
+ this.filter = filter;
+ queue_draw ();
+ }
+
private void on_video_output (uint8[] data, uint width, uint height, size_t pitch, Retro.PixelFormat
pixel_format, float aspect_ratio) {
this.aspect_ratio = aspect_ratio;
pixbuf = gdk_pixbuf_new_from_video (data, width, height, pitch, pixel_format);
@@ -65,6 +72,18 @@ public class RetroGtk.CairoDisplay : Gtk.DrawingArea {
cr.scale (xs, ys);
cr.set_source_surface (surface, x/xs, y/ys);
+ var source = cr.get_source ();
+ switch (filter) {
+ case VideoFilter.SHARP:
+ source.set_filter (Cairo.Filter.NEAREST);
+
+ break;
+ case VideoFilter.SMOOTH:
+ default:
+ source.set_filter (Cairo.Filter.BILINEAR);
+
+ break;
+ }
cr.paint ();
return true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]