[retro-gtk] retro-cairo-display: Custom aspect ratio for pixbuf
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] retro-cairo-display: Custom aspect ratio for pixbuf
- Date: Wed, 14 Aug 2019 11:42:06 +0000 (UTC)
commit 0aa107b524032934056deec086f8119a8d1fbc46
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Wed Aug 14 13:58:00 2019 +0500
retro-cairo-display: Custom aspect ratio for pixbuf
Read 'aspect-ratio' options for the GdkPixbuf passed in
retro_gl_display_set_pixbuf() and use it instead of the core-provided
aspect ratio if it's present.
retro-gtk/retro-cairo-display.c | 10 ++++++++++
1 file changed, 10 insertions(+)
---
diff --git a/retro-gtk/retro-cairo-display.c b/retro-gtk/retro-cairo-display.c
index 379f52a..1fb637b 100644
--- a/retro-gtk/retro-cairo-display.c
+++ b/retro-gtk/retro-cairo-display.c
@@ -2,6 +2,7 @@
#include "retro-cairo-display.h"
+#include "retro-pixbuf.h"
#include "retro-pixdata.h"
struct _RetroCairoDisplay
@@ -312,11 +313,16 @@ retro_cairo_display_get_pixbuf (RetroCairoDisplay *self)
* @pixbuf: a #GdkPixbuf
*
* Sets @pixbuf as the currently displayed video frame.
+ *
+ * retro_pixbuf_set_aspect_ratio() can be used to specify the aspect ratio for
+ * the pixbuf. Otherwise the core's aspect ratio will be used.
*/
void
retro_cairo_display_set_pixbuf (RetroCairoDisplay *self,
GdkPixbuf *pixbuf)
{
+ gfloat aspect_ratio;
+
g_return_if_fail (self != NULL);
if (self->pixbuf == pixbuf)
@@ -327,6 +333,10 @@ retro_cairo_display_set_pixbuf (RetroCairoDisplay *self,
if (pixbuf != NULL)
self->pixbuf = g_object_ref (pixbuf);
+ aspect_ratio = retro_pixbuf_get_aspect_ratio (pixbuf);
+ if (aspect_ratio != 0.f)
+ self->aspect_ratio = aspect_ratio;
+
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PIXBUF]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]