2 Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "video_view.h"
22 #include "lib/signaller.h"
23 #include "lib/position.h"
24 #include "lib/warnings.h"
25 DCPOMATIC_DISABLE_WARNINGS
26 #include <wx/glcanvas.h>
28 DCPOMATIC_ENABLE_WARNINGS
30 #include <boost/atomic.hpp>
31 #include <boost/thread.hpp>
32 #include <boost/thread/condition.hpp>
41 Texture (GLint unpack_alignment);
44 Texture (Texture const&) = delete;
45 Texture& operator= (Texture const&) = delete;
48 bool set (std::shared_ptr<const Image> image);
52 GLint _unpack_alignment;
53 boost::optional<dcp::Size> _size;
57 class GLVideoView : public VideoView
60 GLVideoView (FilmViewer* viewer, wxWindow* parent);
63 wxWindow* get () const override {
66 void update () override;
67 void start () override;
68 void stop () override;
70 NextFrameResult display_next_frame (bool) override;
72 bool vsync_enabled () const {
73 return _vsync_enabled;
76 std::map<GLenum, std::string> information () const {
81 void set_image (std::shared_ptr<const PlayerVideo> pv);
82 void set_image_and_draw ();
83 void draw (Position<int> inter_position, dcp::Size inter_size);
85 void thread_playing ();
86 void request_one_shot ();
87 void check_for_butler_errors ();
88 void ensure_context ();
89 void size_changed (wxSizeEvent const &);
90 void setup_shaders ();
91 void set_border_colour (GLuint program);
94 wxGLContext* _context;
96 boost::atomic<wxSize> _canvas_size;
97 std::unique_ptr<Texture> _video_texture;
99 boost::thread _thread;
101 boost::mutex _playing_mutex;
102 boost::condition _thread_work_condition;
103 boost::atomic<bool> _playing;
104 boost::atomic<bool> _one_shot;
107 GLint _fragment_type;
108 bool _setup_shaders_done = false;
110 std::shared_ptr<wxTimer> _timer;
112 std::map<GLenum, std::string> _information;