moved clips to custom framebufferobject
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QtMath>
|
||||
#include <QAudioOutput>
|
||||
#include <math.h>
|
||||
|
||||
@@ -40,7 +40,6 @@ extern "C" {
|
||||
|
||||
#include <QApplication>
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QOpenGLPaintDevice>
|
||||
#include <QPainter>
|
||||
|
||||
|
||||
@@ -70,12 +70,44 @@ void FramebufferObject::Destroy()
|
||||
ctx_ = nullptr;
|
||||
}
|
||||
|
||||
const GLuint &FramebufferObject::buffer()
|
||||
void FramebufferObject::BindBuffer() const
|
||||
{
|
||||
if (ctx_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ctx_->functions()->glBindFramebuffer(GL_TEXTURE_2D, buffer_);
|
||||
}
|
||||
|
||||
void FramebufferObject::ReleaseBuffer() const
|
||||
{
|
||||
if (ctx_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ctx_->functions()->glBindFramebuffer(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
void FramebufferObject::BindTexture() const
|
||||
{
|
||||
if (ctx_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ctx_->functions()->glBindTexture(GL_TEXTURE_2D, texture_);
|
||||
}
|
||||
|
||||
void FramebufferObject::ReleaseTexture() const
|
||||
{
|
||||
if (ctx_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
ctx_->functions()->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
const GLuint &FramebufferObject::buffer() const
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
const GLuint &FramebufferObject::texture()
|
||||
const GLuint &FramebufferObject::texture() const
|
||||
{
|
||||
return texture_;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,14 @@ public:
|
||||
void Create(QOpenGLContext* ctx, int width, int height);
|
||||
void Destroy();
|
||||
|
||||
const GLuint& buffer();
|
||||
const GLuint& texture();
|
||||
const GLuint& buffer() const;
|
||||
const GLuint& texture() const;
|
||||
|
||||
void BindBuffer() const;
|
||||
void ReleaseBuffer() const;
|
||||
|
||||
void BindTexture() const;
|
||||
void ReleaseTexture() const;
|
||||
private:
|
||||
QOpenGLContext* ctx_;
|
||||
GLuint buffer_;
|
||||
|
||||
@@ -24,7 +24,6 @@ extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
}
|
||||
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDebug>
|
||||
@@ -86,8 +85,8 @@ void draw_clip(QOpenGLContext* ctx, GLuint fbo, GLuint texture, bool clear) {
|
||||
ctx->functions()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
GLuint draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bool clear) {
|
||||
fbo->bind();
|
||||
GLuint draw_clip(const FramebufferObject& fbo, GLuint texture, bool clear) {
|
||||
fbo.BindBuffer();
|
||||
|
||||
if (clear) {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
@@ -99,9 +98,9 @@ GLuint draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bool clear) {
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
fbo->release();
|
||||
fbo.ReleaseBuffer();
|
||||
|
||||
return fbo->texture();
|
||||
return fbo.texture();
|
||||
}
|
||||
|
||||
void process_effect(Clip* c,
|
||||
@@ -140,7 +139,7 @@ void process_effect(Clip* c,
|
||||
} else {
|
||||
// if the source texture is not already a framebuffer texture,
|
||||
// we'll need to make it one before drawing a superimpose effect on it
|
||||
if (composite_texture != c->fbo[0]->texture() && composite_texture != c->fbo[1]->texture()) {
|
||||
if (composite_texture != c->fbo[0].texture() && composite_texture != c->fbo[1].texture()) {
|
||||
draw_clip(c->fbo[!fbo_switcher], composite_texture, true);
|
||||
}
|
||||
|
||||
@@ -167,10 +166,10 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
playhead = rescale_frame_number(playhead, params.nests.at(i)->sequence->frame_rate, s->frame_rate);
|
||||
}
|
||||
|
||||
if (params.video && params.nests.last()->fbo != nullptr) {
|
||||
params.nests.last()->fbo[0]->bind();
|
||||
if (params.video && !params.nests.last()->fbo.isEmpty()) {
|
||||
params.nests.last()->fbo[0].BindBuffer();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
final_fbo = params.nests.last()->fbo[0]->handle();
|
||||
final_fbo = params.nests.last()->fbo[0].buffer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,14 +324,14 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
}
|
||||
|
||||
// prepare framebuffers for backend drawing operations
|
||||
if (c->fbo == nullptr) {
|
||||
if (c->fbo.isEmpty()) {
|
||||
// create 3 fbos for nested sequences, 2 for most clips
|
||||
int fbo_count = (c->media() != nullptr && c->media()->get_type() == MEDIA_TYPE_SEQUENCE) ? 3 : 2;
|
||||
|
||||
c->fbo = new QOpenGLFramebufferObject* [size_t(fbo_count)];
|
||||
c->fbo.resize(fbo_count);
|
||||
|
||||
for (int j=0;j<fbo_count;j++) {
|
||||
c->fbo[j] = new QOpenGLFramebufferObject(video_width, video_height);
|
||||
c->fbo[j].Create(params.ctx, video_width, video_height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,9 +472,9 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
GLuint backend_tex_1;
|
||||
GLuint backend_tex_2;
|
||||
if (params.nests.size() > 0) {
|
||||
back_buffer_1 = params.nests.last()->fbo[1]->handle();
|
||||
backend_tex_1 = params.nests.last()->fbo[1]->texture();
|
||||
backend_tex_2 = params.nests.last()->fbo[2]->texture();
|
||||
back_buffer_1 = params.nests.last()->fbo[1].buffer();
|
||||
backend_tex_1 = params.nests.last()->fbo[1].texture();
|
||||
backend_tex_2 = params.nests.last()->fbo[2].texture();
|
||||
} else {
|
||||
back_buffer_1 = params.backend_buffer1;
|
||||
backend_tex_1 = params.backend_attachment1;
|
||||
@@ -531,7 +530,7 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
// copy front buffer to back buffer (only if we're using a blending mode)
|
||||
if (coords.blendmode >= 0) {
|
||||
if (params.nests.size() > 0) {
|
||||
draw_clip(params.ctx, params.nests.last()->fbo[2]->handle(), params.nests.last()->fbo[0]->texture(), true);
|
||||
draw_clip(params.ctx, params.nests.last()->fbo[2].buffer(), params.nests.last()->fbo[0].texture(), true);
|
||||
} else {
|
||||
draw_clip(params.ctx, params.backend_buffer2, params.main_attachment, true);
|
||||
}
|
||||
@@ -665,11 +664,9 @@ GLuint compose_sequence(ComposeSequenceParams ¶ms) {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
// qDebug() << "compose sequence took" << QDateTime::currentMSecsSinceEpoch() - time;
|
||||
|
||||
if (!params.nests.isEmpty() && params.nests.last()->fbo != nullptr) {
|
||||
if (!params.nests.isEmpty() && !params.nests.last()->fbo.isEmpty()) {
|
||||
// returns nested clip's texture
|
||||
return params.nests.last()->fbo[0]->texture();
|
||||
return params.nests.last()->fbo[0].texture();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+1
-13
@@ -56,7 +56,6 @@ Clip::Clip(Sequence* s) :
|
||||
closing_transition = nullptr;
|
||||
undeletable = false;
|
||||
replaced = false;
|
||||
fbo = nullptr;
|
||||
open_ = false;
|
||||
|
||||
reset();
|
||||
@@ -515,18 +514,7 @@ void Clip::Close(bool wait) {
|
||||
}
|
||||
|
||||
// delete framebuffers
|
||||
if (fbo != nullptr) {
|
||||
// delete 3 fbos for nested sequences, 2 for most clips
|
||||
int fbo_count = (media() != nullptr && media()->get_type() == MEDIA_TYPE_SEQUENCE) ? 3 : 2;
|
||||
|
||||
for (int j=0;j<fbo_count;j++) {
|
||||
delete fbo[j];
|
||||
}
|
||||
|
||||
delete [] fbo;
|
||||
|
||||
fbo = nullptr;
|
||||
}
|
||||
fbo.clear();
|
||||
|
||||
if (UsesCacher()) {
|
||||
cacher.Close(wait);
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@
|
||||
#include "undo/comboaction.h"
|
||||
#include "project/media.h"
|
||||
#include "project/footage.h"
|
||||
#include "rendering/framebufferobject.h"
|
||||
|
||||
#include "marker.h"
|
||||
|
||||
@@ -152,7 +153,7 @@ public:
|
||||
QMutex cache_lock;
|
||||
|
||||
// video playback variables
|
||||
QOpenGLFramebufferObject** fbo;
|
||||
QVector<FramebufferObject> fbo;
|
||||
QOpenGLTexture* texture;
|
||||
long texture_frame;
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ extern "C" {
|
||||
#include <QAudioOutput>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QtMath>
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QMouseEvent>
|
||||
#include <QMimeData>
|
||||
#include <QDrag>
|
||||
|
||||
Reference in New Issue
Block a user