various small code cleanups and improvements
Largely refactoring work to make the code somewhat nicer to work with.
This commit is contained in:
@@ -117,8 +117,8 @@ void Exporter::FrameRendered(const rational &time, QVariant value)
|
||||
FramePtr frame = TextureToFrame(value);
|
||||
|
||||
// OCIO conversion requires a frame in 32F format
|
||||
if (frame->format() != olive::PIX_FMT_RGBA32F) {
|
||||
frame = PixelService::ConvertPixelFormat(frame, olive::PIX_FMT_RGBA32F);
|
||||
if (frame->format() != PixelFormat::PIX_FMT_RGBA32F) {
|
||||
frame = PixelService::ConvertPixelFormat(frame, PixelFormat::PIX_FMT_RGBA32F);
|
||||
}
|
||||
|
||||
// Color conversion must be done with unassociated alpha, and the pipeline is always associated
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
render/backend/opengl/functions.h
|
||||
render/backend/opengl/functions.cpp
|
||||
render/backend/opengl/openglbackend.h
|
||||
render/backend/opengl/openglbackend.cpp
|
||||
render/backend/opengl/openglcolorprocessor.h
|
||||
@@ -26,6 +24,8 @@ set(OLIVE_SOURCES
|
||||
render/backend/opengl/openglexporter.cpp
|
||||
render/backend/opengl/openglframebuffer.h
|
||||
render/backend/opengl/openglframebuffer.cpp
|
||||
render/backend/opengl/openglrenderfunctions.h
|
||||
render/backend/opengl/openglrenderfunctions.cpp
|
||||
render/backend/opengl/openglshader.h
|
||||
render/backend/opengl/openglshader.cpp
|
||||
render/backend/opengl/openglshadercache.h
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QEventLoop>
|
||||
#include <QThread>
|
||||
|
||||
#include "functions.h"
|
||||
#include "openglrenderfunctions.h"
|
||||
|
||||
OpenGLBackend::OpenGLBackend(QObject *parent) :
|
||||
VideoRenderBackend(parent),
|
||||
@@ -168,7 +168,7 @@ OpenGLTexturePtr OpenGLBackend::CopyTexture(OpenGLTexturePtr input)
|
||||
copy_buffer_.Bind();
|
||||
input->Bind();
|
||||
|
||||
olive::gl::Blit(copy_pipeline_);
|
||||
OpenGLRenderFunctions::Blit(copy_pipeline_);
|
||||
|
||||
input->Release();
|
||||
copy_buffer_.Release();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLFunctions>
|
||||
|
||||
#include "functions.h"
|
||||
#include "openglrenderfunctions.h"
|
||||
|
||||
void OpenGLColorProcessor::Enable(QOpenGLContext *context, bool alpha_is_associated)
|
||||
{
|
||||
@@ -31,7 +31,7 @@ OpenGLShaderPtr OpenGLColorProcessor::pipeline() const
|
||||
|
||||
void OpenGLColorProcessor::ProcessOpenGL()
|
||||
{
|
||||
olive::gl::OCIOBlit(pipeline_, ocio_lut_);
|
||||
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_);
|
||||
}
|
||||
|
||||
OpenGLColorProcessor::OpenGLColorProcessor(OCIO::ConstConfigRcPtr config, const QString &source_space, const QString &dest_space) :
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "openglexporter.h"
|
||||
|
||||
#include "render/backend/opengl/functions.h"
|
||||
#include "render/backend/opengl/openglrenderfunctions.h"
|
||||
#include "render/pixelservice.h"
|
||||
|
||||
OpenGLExporter::OpenGLExporter(ViewerOutput* viewer, const VideoRenderingParams& video_params, const AudioRenderingParams &audio_params, const QMatrix4x4 &transform, ColorProcessorPtr color_processor, Encoder *encoder, QObject* parent) :
|
||||
@@ -55,7 +55,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
|
||||
buffer_.Bind();
|
||||
input_tex->Bind();
|
||||
|
||||
olive::gl::Blit(pipeline_, false, transform_);
|
||||
OpenGLRenderFunctions::Blit(pipeline_, false, transform_);
|
||||
|
||||
input_tex->Release();
|
||||
buffer_.Release();
|
||||
@@ -65,7 +65,7 @@ FramePtr OpenGLExporter::TextureToFrame(const QVariant& texture)
|
||||
buffer_.Attach(texture_);
|
||||
buffer_.Bind();
|
||||
|
||||
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params_.format());
|
||||
PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params_.format());
|
||||
|
||||
f->glReadPixels(0,
|
||||
0,
|
||||
|
||||
+5
-5
@@ -18,7 +18,7 @@
|
||||
|
||||
***/
|
||||
|
||||
#include "functions.h"
|
||||
#include "openglrenderfunctions.h"
|
||||
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
@@ -63,7 +63,7 @@ const GLfloat flipped_blit_texcoords[] = {
|
||||
*
|
||||
* Currently active QOpenGLFunctions object (use context()->functions() if unsure).
|
||||
*/
|
||||
void olive::gl::PrepareToDraw(QOpenGLFunctions* f) {
|
||||
void OpenGLRenderFunctions::PrepareToDraw(QOpenGLFunctions* f) {
|
||||
f->glGenerateMipmap(GL_TEXTURE_2D);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
@@ -71,7 +71,7 @@ void olive::gl::PrepareToDraw(QOpenGLFunctions* f) {
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
void olive::gl::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix) {
|
||||
void OpenGLRenderFunctions::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix) {
|
||||
// FIXME: is currentContext() reliable here?
|
||||
QOpenGLFunctions* func = QOpenGLContext::currentContext()->functions();
|
||||
|
||||
@@ -123,7 +123,7 @@ void olive::gl::Blit(OpenGLShaderPtr pipeline, bool flipped, QMatrix4x4 matrix)
|
||||
func->glFinish();
|
||||
}
|
||||
|
||||
void olive::gl::OCIOBlit(OpenGLShaderPtr pipeline,
|
||||
void OpenGLRenderFunctions::OCIOBlit(OpenGLShaderPtr pipeline,
|
||||
GLuint lut,
|
||||
bool flipped,
|
||||
QMatrix4x4 matrix)
|
||||
@@ -139,7 +139,7 @@ void olive::gl::OCIOBlit(OpenGLShaderPtr pipeline,
|
||||
|
||||
pipeline->setUniformValue("ove_ociolut", 2);
|
||||
|
||||
olive::gl::Blit(pipeline, flipped, matrix);
|
||||
OpenGLRenderFunctions::Blit(pipeline, flipped, matrix);
|
||||
|
||||
pipeline->release();
|
||||
|
||||
+21
-24
@@ -26,31 +26,28 @@
|
||||
|
||||
#include "openglshader.h"
|
||||
|
||||
namespace olive {
|
||||
namespace gl {
|
||||
class OpenGLRenderFunctions {
|
||||
public:
|
||||
/**
|
||||
* @brief Draw texture on screen
|
||||
*
|
||||
* @param pipeline
|
||||
*
|
||||
* Shader to use for the texture drawing
|
||||
*
|
||||
* @param flipped
|
||||
*
|
||||
* Draw the texture vertically flipped (defaults to FALSE)
|
||||
*
|
||||
* @param matrix
|
||||
*
|
||||
* Transformation matrix to use when drawing (defaults to no transform)
|
||||
*/
|
||||
static void Blit(OpenGLShaderPtr pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
|
||||
|
||||
/**
|
||||
* @brief Draw texture on screen
|
||||
*
|
||||
* @param pipeline
|
||||
*
|
||||
* Shader to use for the texture drawing
|
||||
*
|
||||
* @param flipped
|
||||
*
|
||||
* Draw the texture vertically flipped (defaults to FALSE)
|
||||
*
|
||||
* @param matrix
|
||||
*
|
||||
* Transformation matrix to use when drawing (defaults to no transform)
|
||||
*/
|
||||
void Blit(OpenGLShaderPtr pipeline, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
|
||||
static void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
|
||||
|
||||
void OCIOBlit(OpenGLShaderPtr pipeline, GLuint lut, bool flipped = false, QMatrix4x4 matrix = QMatrix4x4());
|
||||
|
||||
void PrepareToDraw(QOpenGLFunctions* f);
|
||||
|
||||
}
|
||||
}
|
||||
static void PrepareToDraw(QOpenGLFunctions* f);
|
||||
};
|
||||
|
||||
#endif // OPENGLFUNCTIONS_H
|
||||
@@ -30,7 +30,7 @@ OpenGLTexture::OpenGLTexture() :
|
||||
texture_(0),
|
||||
width_(0),
|
||||
height_(0),
|
||||
format_(olive::PIX_FMT_INVALID)
|
||||
format_(PixelFormat::PIX_FMT_INVALID)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ bool OpenGLTexture::IsCreated() const
|
||||
return (texture_);
|
||||
}
|
||||
|
||||
void OpenGLTexture::Create(QOpenGLContext *ctx, int width, int height, const olive::PixelFormat &format, const void* data)
|
||||
void OpenGLTexture::Create(QOpenGLContext *ctx, int width, int height, const PixelFormat::Format &format, const void* data)
|
||||
{
|
||||
if (!ctx) {
|
||||
qWarning() << "OpenGLTexture::Create was passed an invalid context";
|
||||
@@ -115,7 +115,7 @@ const int &OpenGLTexture::height() const
|
||||
return height_;
|
||||
}
|
||||
|
||||
const olive::PixelFormat &OpenGLTexture::format() const
|
||||
const PixelFormat::Format &OpenGLTexture::format() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void OpenGLTexture::Upload(const void *data)
|
||||
|
||||
Bind();
|
||||
|
||||
PixelFormatInfo info = PixelService::GetPixelFormatInfo(format_);
|
||||
PixelFormat::Info info = PixelService::GetPixelFormatInfo(format_);
|
||||
|
||||
context->functions()->glTexSubImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
@@ -173,7 +173,7 @@ void OpenGLTexture::CreateInternal(QOpenGLContext* create_ctx, GLuint* tex, cons
|
||||
f->glBindTexture(GL_TEXTURE_2D, *tex);
|
||||
|
||||
// Allocate storage for texture
|
||||
const PixelFormatInfo& bit_depth = PixelService::GetPixelFormatInfo(format_);
|
||||
const PixelFormat::Info& bit_depth = PixelService::GetPixelFormatInfo(format_);
|
||||
|
||||
f->glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
|
||||
DISABLE_COPY_MOVE(OpenGLTexture)
|
||||
|
||||
void Create(QOpenGLContext* ctx, int width, int height, const olive::PixelFormat &format, const void *data = nullptr);
|
||||
void Create(QOpenGLContext* ctx, int width, int height, const PixelFormat::Format &format, const void *data = nullptr);
|
||||
void Create(QOpenGLContext* ctx, FramePtr frame);
|
||||
|
||||
bool IsCreated() const;
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
const int& height() const;
|
||||
|
||||
const olive::PixelFormat &format() const;
|
||||
const PixelFormat::Format &format() const;
|
||||
|
||||
const GLuint& texture() const;
|
||||
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
|
||||
int height_;
|
||||
|
||||
olive::PixelFormat format_;
|
||||
PixelFormat::Format format_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include "common/clamp.h"
|
||||
#include "core.h"
|
||||
#include "functions.h"
|
||||
#include "node/block/transition/transition.h"
|
||||
#include "node/node.h"
|
||||
#include "openglcolorprocessor.h"
|
||||
#include "openglrenderfunctions.h"
|
||||
#include "render/colormanager.h"
|
||||
#include "render/pixelservice.h"
|
||||
|
||||
@@ -72,14 +72,14 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable
|
||||
}
|
||||
|
||||
// OCIO's CPU conversion is more accurate, so for online we render on CPU but offline we render GPU
|
||||
if (video_params().mode() == olive::kOnline) {
|
||||
if (video_params().mode() == RenderMode::kOnline) {
|
||||
// If alpha is associated, disassociate for the color transform
|
||||
if (video_stream->premultiplied_alpha()) {
|
||||
ColorManager::DisassociateAlpha(frame);
|
||||
}
|
||||
|
||||
// Convert frame to float for OCIO
|
||||
frame = PixelService::ConvertPixelFormat(frame, olive::PIX_FMT_RGBA32F);
|
||||
frame = PixelService::ConvertPixelFormat(frame, PixelFormat::PIX_FMT_RGBA32F);
|
||||
|
||||
// Perform color transform
|
||||
color_processor->ConvertFrame(frame);
|
||||
@@ -96,7 +96,7 @@ void OpenGLWorker::FrameToValue(StreamPtr stream, FramePtr frame, NodeValueTable
|
||||
|
||||
OpenGLTextureCache::ReferencePtr footage_tex_ref = texture_cache_->Get(ctx_, footage_params, frame->data());
|
||||
|
||||
if (video_params().mode() == olive::kOffline) {
|
||||
if (video_params().mode() == RenderMode::kOffline) {
|
||||
if (!color_processor->IsEnabled()) {
|
||||
color_processor->Enable(ctx_, video_stream->premultiplied_alpha());
|
||||
}
|
||||
@@ -238,7 +238,7 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
|
||||
iterative_input = input_texture_count;
|
||||
}
|
||||
|
||||
olive::gl::PrepareToDraw(functions_);
|
||||
OpenGLRenderFunctions::PrepareToDraw(functions_);
|
||||
|
||||
input_texture_count++;
|
||||
break;
|
||||
@@ -322,7 +322,7 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const TimeRange &range,
|
||||
buffer_.Bind();
|
||||
|
||||
// Blit this texture through this shader
|
||||
olive::gl::Blit(shader);
|
||||
OpenGLRenderFunctions::Blit(shader);
|
||||
|
||||
buffer_.Release();
|
||||
buffer_.Detach();
|
||||
@@ -353,7 +353,7 @@ void OpenGLWorker::TextureToBuffer(const QVariant &tex_in, QByteArray &buffer)
|
||||
{
|
||||
OpenGLTextureCache::ReferencePtr texture = tex_in.value<OpenGLTextureCache::ReferencePtr>();
|
||||
|
||||
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params().format());
|
||||
PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params().format());
|
||||
|
||||
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
|
||||
buffer_.Attach(texture->texture());
|
||||
|
||||
@@ -136,7 +136,7 @@ void VideoRenderWorker::CloseInternal()
|
||||
|
||||
void VideoRenderWorker::Download(NodeDependency dep, QByteArray hash, QVariant texture, QString filename)
|
||||
{
|
||||
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(video_params().format());
|
||||
PixelFormat::Info format_info = PixelService::GetPixelFormatInfo(video_params().format());
|
||||
|
||||
// Set up OIIO::ImageSpec for compressing cached images on disk
|
||||
OIIO::ImageSpec spec(video_params().effective_width(), video_params().effective_height(), kRGBAChannels, format_info.oiio_desc);
|
||||
|
||||
Reference in New Issue
Block a user