Olive
renderthread.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program 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 3 of the License, or
9  (at your option) any later version.
10 
11  This program 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.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef RENDERTHREAD_H
22 #define RENDERTHREAD_H
23 
24 #include <QThread>
25 #include <QMutex>
26 #include <QWaitCondition>
27 #include <QOffscreenSurface>
28 #include <QOpenGLContext>
29 #include <QOpenGLFramebufferObject>
30 #include <QOpenGLShaderProgram>
31 
32 #include "project/sequence.h"
33 #include "project/effect.h"
34 
35 // copied from source code to OCIODisplay
36 const int LUT3D_EDGE_SIZE = 32;
37 
38 // copied from source code to OCIODisplay, expanded from 3*LUT3D_EDGE_SIZE*LUT3D_EDGE_SIZE*LUT3D_EDGE_SIZE
39 const int NUM_3D_ENTRIES = 98304;
40 
41 class RenderThread : public QThread {
42  Q_OBJECT
43 public:
44  RenderThread();
45  ~RenderThread();
46  void run();
47  QMutex mutex;
48  GLuint front_buffer;
49  GLuint front_texture;
51  void paint();
52  void start_render(QOpenGLContext* share, SequencePtr s, const QString &save = nullptr, GLvoid *pixels = nullptr, int pixel_linesize = 0, int idivider = 0);
53  bool did_texture_fail();
54  void cancel();
55 
56 public slots:
57  // cleanup functions
58  void delete_ctx();
59 signals:
60  void ready();
61 private:
62  // cleanup functions
63  void delete_texture();
64  void delete_fbo();
65  void delete_shader_program();
66 
67  QWaitCondition waitCond;
68  QOffscreenSurface surface;
69  QOpenGLContext* share_ctx;
70  QOpenGLContext* ctx;
71  QOpenGLShaderProgram* blend_mode_program;
72  QOpenGLShaderProgram* premultiply_program;
73 
74  GLuint back_buffer_1;
75  GLuint back_buffer_2;
78 
80 
82  int divider;
83  int tex_width;
85  bool queued;
87  bool running;
88  QString save_fn;
89  GLvoid *pixel_buffer;
91 };
92 
93 #endif // RENDERTHREAD_H
void run()
Definition: renderthread.cpp:54
void delete_shader_program()
Definition: renderthread.cpp:295
void delete_ctx()
Definition: renderthread.cpp:304
GLuint front_texture
Definition: renderthread.h:49
~RenderThread()
Definition: renderthread.cpp:50
void start_render(QOpenGLContext *share, SequencePtr s, const QString &save=nullptr, GLvoid *pixels=nullptr, int pixel_linesize=0, int idivider=0)
Definition: renderthread.cpp:238
QOpenGLShaderProgram * premultiply_program
Definition: renderthread.h:72
GLuint front_buffer
Definition: renderthread.h:48
QOpenGLShaderProgram * blend_mode_program
Definition: renderthread.h:71
QOpenGLContext * share_ctx
Definition: renderthread.h:69
void cancel()
Definition: renderthread.cpp:269
int pixel_buffer_linesize
Definition: renderthread.h:90
bool texture_failed
Definition: renderthread.h:86
void paint()
Definition: renderthread.cpp:164
QOffscreenSurface surface
Definition: renderthread.h:68
QWaitCondition waitCond
Definition: renderthread.h:67
SequencePtr seq
Definition: renderthread.h:81
GLuint back_texture_1
Definition: renderthread.h:76
GLuint back_texture_2
Definition: renderthread.h:77
void delete_fbo()
Definition: renderthread.cpp:285
RenderThread()
Definition: renderthread.cpp:32
EffectPtr gizmos
Definition: renderthread.h:50
bool running
Definition: renderthread.h:87
GLuint back_buffer_1
Definition: renderthread.h:74
QMutex mutex
Definition: renderthread.h:47
GLvoid * pixel_buffer
Definition: renderthread.h:89
int divider
Definition: renderthread.h:82
std::shared_ptr< Sequence > SequencePtr
Definition: clip.h:48
int tex_width
Definition: renderthread.h:83
void delete_texture()
Definition: renderthread.cpp:275
const int NUM_3D_ENTRIES
Definition: renderthread.h:39
const int LUT3D_EDGE_SIZE
Definition: renderthread.h:36
std::shared_ptr< Effect > EffectPtr
Definition: effect.h:48
bool queued
Definition: renderthread.h:85
int tex_height
Definition: renderthread.h:84
GLuint back_buffer_2
Definition: renderthread.h:75
Definition: renderthread.h:41
QOpenGLContext * ctx
Definition: renderthread.h:70
float ocio_lut_data[NUM_3D_ENTRIES]
Definition: renderthread.h:79
QString save_fn
Definition: renderthread.h:88
bool did_texture_fail()
Definition: renderthread.cpp:265