diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index fee55d989..0db6830ab 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -69,6 +69,7 @@ #include "utils.h" #include "video_out_gl.h" #include "video_context.h" +#include "video_frame.h" #include "visual_tool.h" /// Attribute list for gl canvases; set the canvases to doublebuffered rgba with an 8 bit stencil buffer @@ -158,10 +159,13 @@ bool VideoDisplay::InitContext() { } void VideoDisplay::UploadFrameData(FrameReadyEvent &evt) { - if (!InitContext()) { - evt.Skip(); + pending_frame = evt.frame; + Render(); +} + +void VideoDisplay::Render() try { + if (!con->videoController->IsLoaded() || !InitContext() || (!videoOut && !pending_frame)) return; - } if (!videoOut) videoOut.reset(new VideoOutGL); @@ -170,7 +174,10 @@ void VideoDisplay::UploadFrameData(FrameReadyEvent &evt) { cmd::call("video/tool/cross", con); try { - videoOut->UploadFrameData(*evt.frame); + if (pending_frame) { + videoOut->UploadFrameData(*pending_frame); + pending_frame.reset(); + } } catch (const VideoOutInitException& err) { wxLogError( @@ -179,19 +186,15 @@ void VideoDisplay::UploadFrameData(FrameReadyEvent &evt) { "Error message reported: %s", err.GetMessage()); con->videoController->SetVideo(""); + return; } catch (const VideoOutRenderException& err) { wxLogError( "Could not upload video frame to graphics card.\n" "Error message reported: %s", err.GetMessage()); - } - Render(); -} - -void VideoDisplay::Render() try { - if (!con->videoController->IsLoaded() || !videoOut || !InitContext() ) return; + } if (!viewport_height || !viewport_width) PositionVideo(); @@ -428,6 +431,7 @@ void VideoDisplay::Unload() { glContext.reset(); videoOut.reset(); tool.reset(); + pending_frame.reset(); } void VideoDisplay::OnSubtitlesSave() { diff --git a/aegisub/src/video_display.h b/aegisub/src/video_display.h index 076bd2261..a6a73fded 100644 --- a/aegisub/src/video_display.h +++ b/aegisub/src/video_display.h @@ -37,6 +37,7 @@ #ifndef AGI_PRE #include +#include #include #endif @@ -49,6 +50,7 @@ #include "vector2d.h" // Prototypes +class AegiVideoFrame; class FrameReadyEvent; class VideoContext; class VideoOutGL; @@ -114,6 +116,9 @@ class VideoDisplay : public wxGLCanvas { /// Whether the display can be freely resized by the user bool freeSize; + /// Frame which will replace the currently visible frame on the next render + std::tr1::shared_ptr pending_frame; + /// @brief Draw an overscan mask /// @param horizontal_percent The percent of the video reserved horizontally /// @param vertical_percent The percent of the video reserved vertically