Skip to content

Commit

Permalink
imagebox: Use xvimagesink instead of glimagesink
Browse files Browse the repository at this point in the history
glimagesink does not preform very well for me compared to xvimagesink.
  • Loading branch information
ahodesuka committed Nov 24, 2017
1 parent 766eb69 commit 3fdd157
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A GTK2 image viewer, manga reader, and booru browser.
* libcurl `>= 7.32.0`
* libxml2
* gstreamer-1.0 `optional`
* gst-plugins-bad (opengl)
* gst-plugins-base
* gst-plugins-good `runtime`
* gst-plugins-vpx or gst-plugins-libav `runtime`
* libsecret `optional`
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if test x"$windows" != xtrue; then
)

if test x"$enable_gst" != xno; then
PKG_CHECK_MODULES([gstreamer], [gstreamer-1.0 gstreamer-video-1.0 gstreamer-gl-1.0],
PKG_CHECK_MODULES([gstreamer], [gstreamer-1.0 gstreamer-video-1.0 gstreamer-plugins-base-1.0],
[
AC_DEFINE(HAVE_GSTREAMER, 1, [Define to have webm support through GStreamer])
],
Expand Down
22 changes: 10 additions & 12 deletions src/imagebox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ using namespace AhoViewer;

#ifdef HAVE_GSTREAMER
#include <gst/video/videooverlay.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif // GDK_WINDOWING_X11
#ifdef GDK_WINDOWING_WIN32
#include <gdk/gdkwin32.h>
#endif // GDK_WINDOWING_WIN32

GstBusSyncReply ImageBox::create_window(GstBus*, GstMessage *message, void *userp)
{
Expand Down Expand Up @@ -68,9 +63,10 @@ ImageBox::ImageBox(BaseObjectType *cobj, const Glib::RefPtr<Gtk::Builder> &bldr)

#ifdef HAVE_GSTREAMER
m_Playbin = gst_element_factory_make("playbin", "playbin"),
m_VideoSink = gst_element_factory_make("glimagesink", "videosink");
m_VideoSink = gst_element_factory_make("xvimagesink", "videosink");

gst_video_overlay_handle_events(GST_VIDEO_OVERLAY(m_VideoSink), false);
if (!m_VideoSink)
m_VideoSink = gst_element_factory_make("ximagesink", "videosink");

g_object_set(m_Playbin,
"audio-sink", gst_element_factory_make("fakesink", "audiosink"),
Expand All @@ -84,12 +80,7 @@ ImageBox::ImageBox(BaseObjectType *cobj, const Glib::RefPtr<Gtk::Builder> &bldr)

m_DrawingArea->signal_realize().connect([ this ]()
{
#ifdef GDK_WINDOWING_X11
m_WindowHandle = GDK_WINDOW_XID(m_DrawingArea->get_window()->gobj());
#endif // GDK_WINDOWING_X11
#ifdef GDK_WINDOWING_WIN32
m_WindowHandle = GDK_WINDOW_HWND(m_DrawingArea->get_window()->gobj());
#endif // GDK_WINDOWING_WIN32
gst_element_set_state(m_Playbin, GST_STATE_READY);
});
#endif // HAVE_GSTREAMER
Expand Down Expand Up @@ -537,11 +528,14 @@ void ImageBox::draw_image(bool scroll)
m_Layout->move(*m_GtkImage, x, y);
m_GtkImage->set(tempPixbuf);
}
#ifdef HAVE_GSTREAMER
else
{
m_Layout->move(*m_DrawingArea, x, y);
m_DrawingArea->set_size_request(scaledWidth, scaledHeight);
gst_video_overlay_expose(GST_VIDEO_OVERLAY(m_VideoSink));
}
#endif // HAVE_GSTREAMER

// Reset the scrollbar positions
if (scroll || m_FirstDraw)
Expand Down Expand Up @@ -619,6 +613,10 @@ void ImageBox::scroll(const int x, const int y, const bool panning, const bool f

if (nY <= adjustUpperY)
m_VAdjust->set_value(nY);
#ifdef HAVE_GSTREAMER
if (m_Playing && m_Image->is_webm())
gst_video_overlay_expose(GST_VIDEO_OVERLAY(m_VideoSink));
#endif // HAVE_GSTREAMER
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/ui.glade
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<child>
<object class="GtkDrawingArea" id="ImageBox::DrawingArea">
<property name="can_focus">False</property>
<property name="double_buffered">False</property>
<property name="no_show_all">True</property>
</object>
</child>
Expand Down

0 comments on commit 3fdd157

Please sign in to comment.