large scale renderer rework

- Abstracts all OpenGL functionality including UI objects
- Cleans up several rendering codepaths
- Improves threading functionality
- Removes old code and problematic functions
This commit is contained in:
itsmattkc
2020-11-10 11:24:51 +11:00
parent 52b98f3fa3
commit 1d61f89920
42 changed files with 927 additions and 820 deletions
+134 -71
View File
@@ -62,6 +62,7 @@ OpenGLRenderer::OpenGLRenderer(QObject* parent) :
OpenGLRenderer::~OpenGLRenderer()
{
Destroy();
}
void OpenGLRenderer::Init(QOpenGLContext *existing_ctx)
@@ -97,13 +98,14 @@ bool OpenGLRenderer::Init()
void OpenGLRenderer::PostInit()
{
// Make context current on that surface
if (!context_->makeCurrent(&surface_)) {
if (context_->parent() == this && !context_->makeCurrent(&surface_)) {
qCritical() << "Failed to makeCurrent() on offscreen surface in thread" << thread();
return;
}
// Store OpenGL functions instance
functions_ = context_->functions();
// Store OpenGL functions instance
functions_->glBlendFunc(GL_ONE, GL_ZERO);
// Set up framebuffer used for various things
@@ -127,29 +129,58 @@ void OpenGLRenderer::PostInit()
void OpenGLRenderer::Destroy()
{
// Delete vertex array object
vao_.destroy();
if (context_) {
// Delete buffers
vert_vbo_.destroy();
frag_vbo_.destroy();
// Delete framebuffer
functions_->glDeleteFramebuffers(1, &framebuffer_);
// Delete vertex array object
vao_.destroy();
// Delete all shaders
qDeleteAll(shader_cache_);
shader_cache_.clear();
// Delete framebuffer
functions_->glDeleteFramebuffers(1, &framebuffer_);
// Delete context if it belongs to us
if (context_->parent() == this) {
delete context_;
}
context_ = nullptr;
// Delete all shaders
qDeleteAll(shader_cache_);
shader_cache_.clear();
// Destroy surface if we created it
if (surface_.isValid()) {
surface_.destroy();
// Delete context if it belongs to us
if (context_->parent() == this) {
delete context_;
}
context_ = nullptr;
// Destroy surface if we created it
if (surface_.isValid()) {
surface_.destroy();
}
}
}
QVariant OpenGLRenderer::CreateNativeTexture(const VideoParams &p, void *data, int linesize)
void OpenGLRenderer::ClearDestination(double r, double g, double b, double a)
{
functions_->glClearColor(r, g, b, a);
functions_->glClear(GL_COLOR_BUFFER_BIT);
}
void OpenGLRenderer::AttachTextureAsDestination(Renderer::Texture* texture)
{
functions_->glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
functions_->glFramebufferTexture2D(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
texture->id().value<GLuint>(),
0);
SetViewport(texture->width(), texture->height());
}
void OpenGLRenderer::DetachTextureAsDestination()
{
functions_->glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
QVariant OpenGLRenderer::CreateNativeTexture(VideoParams p, void *data, int linesize)
{
GLuint texture;
functions_->glGenTextures(1, &texture);
@@ -157,7 +188,7 @@ QVariant OpenGLRenderer::CreateNativeTexture(const VideoParams &p, void *data, i
functions_->glPixelStorei(GL_UNPACK_ROW_LENGTH, linesize);
functions_->glTexImage2D(GL_TEXTURE_2D, 0, GetInternalFormat(p.format()),
p.width(), p.height(), 0, GetPixelFormat(p.format()),
p.width(), p.height(), 0, GL_RGBA,
GetPixelType(p.format()), data);
functions_->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
@@ -171,6 +202,37 @@ void OpenGLRenderer::DestroyNativeTexture(QVariant texture)
functions_->glDeleteTextures(1, &t);
}
QVariant OpenGLRenderer::CreateNativeShader(ShaderCode code)
{
QOpenGLShaderProgram* program = new QOpenGLShaderProgram(context_);
if (!program->addShaderFromSourceCode(QOpenGLShader::Vertex, code.vert_code())) {
qCritical() << "Failed to add vertex code to shader";
goto error;
}
if (!program->addShaderFromSourceCode(QOpenGLShader::Fragment, code.frag_code())) {
qCritical() << "Failed to add fragment code to shader";
goto error;
}
if (!program->link()) {
qCritical() << "Failed to link shader";
goto error;
}
return Node::PtrToValue(program);
error:
delete program;
return QVariant();
}
void OpenGLRenderer::DestroyNativeShader(QVariant shader)
{
delete Node::ValueToPtr<QOpenGLShaderProgram>(shader);
}
void OpenGLRenderer::UploadToTexture(Texture *texture, void *data, int linesize)
{
GLuint t = texture->id().value<GLuint>();
@@ -186,7 +248,7 @@ void OpenGLRenderer::UploadToTexture(Texture *texture, void *data, int linesize)
functions_->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
p.effective_width(), p.effective_height(),
GetPixelFormat(p.format()), GetPixelType(p.format()),
GL_RGBA, GetPixelType(p.format()),
data);
functions_->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
@@ -210,7 +272,7 @@ void OpenGLRenderer::DownloadFromTexture(Texture* texture, void *data, int lines
0,
p.width(),
p.height(),
GetPixelFormat(p.format()),
GL_RGBA,
GetPixelType(p.format()),
data);
@@ -219,7 +281,7 @@ void OpenGLRenderer::DownloadFromTexture(Texture* texture, void *data, int lines
functions_->glBindTexture(GL_TEXTURE_2D, current_tex);
}
Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job, const VideoParams &params)
Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, ShaderJob job, VideoParams params)
{
// If this node is iterative, we'll pick up which input here
GLuint iterative_input = 0;
@@ -342,12 +404,6 @@ Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, const TimeR
{
TexturePtr texture = value.value<TexturePtr>();
if (texture) {
if (PixelFormat::FormatHasAlphaChannel(texture->format())) {
input_textures_have_alpha = true;
}
}
// Set value to bound texture
shader->setUniformValue(variable_location, textures_to_bind.size());
@@ -359,6 +415,10 @@ Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, const TimeR
GLuint tex_id = texture ? texture->id().value<GLuint>() : 0;
textures_to_bind.append(tex_id);
if (texture && texture->has_meaningful_alpha()) {
input_textures_have_alpha = true;
}
// Set enable flag if shader wants it
int enable_param_location = shader->uniformLocation(QStringLiteral("%1_enabled").arg(it.key()));
if (enable_param_location > -1) {
@@ -412,17 +472,6 @@ Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, const TimeR
static_cast<GLfloat>(params.height()));
// Create the output textures
PixelFormat::Format output_format = (input_textures_have_alpha || job.GetAlphaChannelRequired())
? PixelFormat::GetFormatWithAlphaChannel(params.format())
: PixelFormat::GetFormatWithoutAlphaChannel(params.format());
VideoParams output_params(params.width(),
params.height(),
params.time_base(),
output_format,
params.pixel_aspect_ratio(),
params.interlacing(),
params.divider());
int real_iteration_count;
if (job.GetIterationCount() > 1 && job.GetIterativeInput()) {
real_iteration_count = job.GetIterationCount();
@@ -431,11 +480,11 @@ Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, const TimeR
}
TexturePtr dst_refs[2];
dst_refs[0] = CreateTexture(output_params);
dst_refs[0] = CreateTexture(params);
// If this node requires multiple iterations, get a texture for it too
if (real_iteration_count > 1) {
dst_refs[1] = CreateTexture(output_params);
dst_refs[1] = CreateTexture(params);
}
// Some nodes use multiple iterations for optimization
@@ -483,20 +532,15 @@ Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, const TimeR
PrepareInputTexture(job.GetBilinearFiltering());
}
functions_->glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
functions_->glFramebufferTexture2D(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
output_tex->id().value<GLuint>(),
0);
AttachTextureAsDestination(output_tex.get());
// Blit this texture through this shader
functions_->glDrawArrays(GL_TRIANGLES, 0, blit_vertices.size() / 3);
// Reset framebuffer to default
functions_->glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Reset framebuffer to default
DetachTextureAsDestination();
// Release any textures we bound before
for (int i=textures_to_bind.size()-1; i>=0; i--) {
functions_->glActiveTexture(GL_TEXTURE0 + i);
@@ -509,26 +553,58 @@ Renderer::TexturePtr OpenGLRenderer::ProcessShader(const Node *node, const TimeR
// Release shader
shader->release();
output_tex->set_has_meaningful_alpha((input_textures_have_alpha || job.GetAlphaChannelRequired()));
return output_tex;
}
void OpenGLRenderer::SetViewport(int width, int height)
{
functions_->glViewport(0, 0, width, height);
}
void OpenGLRenderer::BlitColorManaged(ColorProcessorPtr color_processor, Texture *source, Renderer::Texture* destination)
{
qCritical() << "OpenGLRenderer::BlitColorMangaed is a stub!";
}
void OpenGLRenderer::Blit(Renderer::Texture *source, QVariant shader, Renderer::ShaderUniformMap parameters, Renderer::Texture *destination)
{
QOpenGLShaderProgram* program = Node::ValueToPtr<QOpenGLShaderProgram>(shader);
if (!program) {
qCritical() << "Attempted to blit with a null shader";
return;
}
if (destination) {
AttachTextureAsDestination(destination);
}
functions_->glBindTexture(GL_TEXTURE_2D, source->id().value<GLuint>());
program->bind();
qCritical() << "OpenGLRenderer::Blit is a stub!";
program->release();
functions_->glBindTexture(GL_TEXTURE_2D, 0);
if (destination) {
DetachTextureAsDestination();
}
}
GLint OpenGLRenderer::GetInternalFormat(PixelFormat::Format format)
{
switch (format) {
case PixelFormat::PIX_FMT_RGB8:
return GL_RGB8;
case PixelFormat::PIX_FMT_RGBA8:
return GL_RGBA8;
case PixelFormat::PIX_FMT_RGB16U:
return GL_RGB16;
case PixelFormat::PIX_FMT_RGBA16U:
return GL_RGBA16;
case PixelFormat::PIX_FMT_RGB16F:
return GL_RGB16F;
case PixelFormat::PIX_FMT_RGBA16F:
return GL_RGBA16F;
case PixelFormat::PIX_FMT_RGB32F:
return GL_RGB32F;
case PixelFormat::PIX_FMT_RGBA32F:
return GL_RGBA32F;
@@ -540,28 +616,15 @@ GLint OpenGLRenderer::GetInternalFormat(PixelFormat::Format format)
return GL_INVALID_VALUE;
}
GLenum OpenGLRenderer::GetPixelFormat(PixelFormat::Format format)
{
if (PixelFormat::FormatHasAlphaChannel(format)) {
return GL_RGBA;
} else {
return GL_RGB;
}
}
GLenum OpenGLRenderer::GetPixelType(PixelFormat::Format format)
{
switch (format) {
case PixelFormat::PIX_FMT_RGB8:
case PixelFormat::PIX_FMT_RGBA8:
return GL_UNSIGNED_BYTE;
case PixelFormat::PIX_FMT_RGB16U:
case PixelFormat::PIX_FMT_RGBA16U:
return GL_UNSIGNED_SHORT;
case PixelFormat::PIX_FMT_RGB16F:
case PixelFormat::PIX_FMT_RGBA16F:
return GL_HALF_FLOAT;
case PixelFormat::PIX_FMT_RGB32F:
case PixelFormat::PIX_FMT_RGBA32F:
return GL_FLOAT;
+20 -11
View File
@@ -49,26 +49,37 @@ public slots:
virtual void Destroy() override;
virtual QVariant CreateNativeTexture(const VideoParams& p, void* data = nullptr, int linesize = 0) override;
virtual void ClearDestination(double r = 0.0, double g = 0.0, double b = 0.0, double a = 0.0) override;
virtual void AttachTextureAsDestination(OLIVE_NAMESPACE::Renderer::Texture* texture) override;
virtual void DetachTextureAsDestination() override;
virtual QVariant CreateNativeTexture(OLIVE_NAMESPACE::VideoParams param, void* data = nullptr, int linesize = 0) override;
virtual void DestroyNativeTexture(QVariant texture) override;
virtual void UploadToTexture(Texture* texture, void* data, int linesize) override;
virtual QVariant CreateNativeShader(OLIVE_NAMESPACE::ShaderCode code) override;
virtual void DownloadFromTexture(Texture* texture, void* data, int linesize) override;
virtual void DestroyNativeShader(QVariant shader) override;
virtual void UploadToTexture(OLIVE_NAMESPACE::Renderer::Texture* texture, void* data, int linesize) override;
virtual void DownloadFromTexture(OLIVE_NAMESPACE::Renderer::Texture* texture, void* data, int linesize) override;
virtual TexturePtr ProcessShader(const OLIVE_NAMESPACE::Node* node,
const OLIVE_NAMESPACE::TimeRange &range,
const OLIVE_NAMESPACE::ShaderJob &job,
const OLIVE_NAMESPACE::VideoParams &params) override;
OLIVE_NAMESPACE::ShaderJob job,
OLIVE_NAMESPACE::VideoParams params) override;
virtual TexturePtr TransformColor(Texture* texture, OLIVE_NAMESPACE::ColorProcessorPtr processor) override;
virtual void SetViewport(int width, int height) override;
virtual void BlitColorManaged(OLIVE_NAMESPACE::ColorProcessorPtr color_processor, OLIVE_NAMESPACE::Renderer::Texture* source, OLIVE_NAMESPACE::Renderer::Texture *destination = nullptr) override;
virtual void Blit(OLIVE_NAMESPACE::Renderer::Texture* source, QVariant shader, OLIVE_NAMESPACE::Renderer::ShaderUniformMap parameters, OLIVE_NAMESPACE::Renderer::Texture* destination = nullptr) override;
private:
static GLint GetInternalFormat(PixelFormat::Format format);
static GLenum GetPixelFormat(PixelFormat::Format format);
static GLenum GetPixelType(PixelFormat::Format format);
void PrepareInputTexture(bool bilinear);
@@ -93,6 +104,4 @@ private:
OLIVE_NAMESPACE_EXIT
Q_DECLARE_METATYPE(OLIVE_NAMESPACE::OpenGLRenderer::TexturePtr);
#endif // OPENGLCONTEXT_H
+39 -14
View File
@@ -38,8 +38,6 @@ class Renderer : public QObject
public:
Renderer(QObject* parent = nullptr);
virtual ~Renderer() override;
virtual bool Init() = 0;
class Texture
@@ -48,7 +46,8 @@ public:
Texture(Renderer* renderer, const QVariant& native, const VideoParams& param) :
renderer_(renderer),
params_(param),
id_(native)
id_(native),
meaningful_alpha_(true)
{
}
@@ -67,7 +66,7 @@ public:
return params_;
}
void Upload(void* data, int linesize = 0)
void Upload(void* data, int linesize)
{
renderer_->UploadToTexture(this, data, linesize);
}
@@ -97,6 +96,16 @@ public:
return params_.pixel_aspect_ratio();
}
bool has_meaningful_alpha() const
{
return meaningful_alpha_;
}
void set_has_meaningful_alpha(bool e)
{
meaningful_alpha_ = e;
}
private:
Renderer* renderer_;
@@ -104,39 +113,53 @@ public:
QVariant id_;
bool meaningful_alpha_;
};
using TexturePtr = std::shared_ptr<Texture>;
TexturePtr CreateTexture(const VideoParams& param, void* data = nullptr, int linesize = 0);
struct ShaderValue {
QVariant data;
NodeParam::DataType type;
};
using ShaderUniformMap = QHash<QString, ShaderValue>;
public slots:
virtual void PostInit() = 0;
virtual void Destroy() = 0;
virtual QVariant CreateNativeTexture(const VideoParams& param, void* data = nullptr, int linesize = 0) = 0;
virtual void ClearDestination(double r = 0.0, double g = 0.0, double b = 0.0, double a = 0.0) = 0;
virtual void AttachTextureAsDestination(OLIVE_NAMESPACE::Renderer::Texture* texture) = 0;
virtual void DetachTextureAsDestination() = 0;
virtual QVariant CreateNativeTexture(OLIVE_NAMESPACE::VideoParams param, void* data = nullptr, int linesize = 0) = 0;
virtual void DestroyNativeTexture(QVariant texture) = 0;
virtual QVariant CreateNativeShader(const ShaderCode& code) = 0;
virtual QVariant CreateNativeShader(OLIVE_NAMESPACE::ShaderCode code) = 0;
virtual void DestroyNativeShader(QVariant shader) = 0;
virtual void UploadToTexture(Texture* texture, void* data, int linesize) = 0;
virtual void UploadToTexture(OLIVE_NAMESPACE::Renderer::Texture* texture, void* data, int linesize) = 0;
virtual void DownloadFromTexture(Texture* texture, void* data, int linesize) = 0;
virtual void DownloadFromTexture(OLIVE_NAMESPACE::Renderer::Texture* texture, void* data, int linesize) = 0;
virtual TexturePtr ProcessShader(const OLIVE_NAMESPACE::Node* node,
const OLIVE_NAMESPACE::TimeRange &range,
const OLIVE_NAMESPACE::ShaderJob &job,
const OLIVE_NAMESPACE::VideoParams &params) = 0;
OLIVE_NAMESPACE::ShaderJob job,
OLIVE_NAMESPACE::VideoParams params) = 0;
virtual TexturePtr TransformColor(Texture* texture, OLIVE_NAMESPACE::ColorProcessorPtr processor) = 0;
virtual void SetViewport(int width, int height) = 0;
virtual void Render() = 0;
virtual void BlitColorManaged(OLIVE_NAMESPACE::ColorProcessorPtr color_processor, OLIVE_NAMESPACE::Renderer::Texture* source, OLIVE_NAMESPACE::Renderer::Texture *destination = nullptr) = 0;
virtual void RenderToTexture(Texture* destination) = 0;
virtual void Blit(OLIVE_NAMESPACE::Renderer::Texture* source, QVariant shader, OLIVE_NAMESPACE::Renderer::ShaderUniformMap parameters, OLIVE_NAMESPACE::Renderer::Texture* destination = nullptr) = 0;
private:
@@ -145,4 +168,6 @@ private:
OLIVE_NAMESPACE_EXIT
Q_DECLARE_METATYPE(OLIVE_NAMESPACE::Renderer::TexturePtr);
#endif // RENDERCONTEXT_H
+81 -39
View File
@@ -22,12 +22,11 @@
OLIVE_NAMESPACE_ENTER
/*RendererThreadWrapper::RendererThreadWrapper(Renderer *inner, QObject *parent) :
RendererThreadWrapper::RendererThreadWrapper(Renderer *inner, QObject *parent) :
Renderer(parent),
inner_(inner),
thread_(nullptr)
{
inner_->setParent(this);
}
bool RendererThreadWrapper::Init()
@@ -38,11 +37,11 @@ bool RendererThreadWrapper::Init()
}
// Create thread
QThread* thread = new QThread(this);
thread->start(QThread::IdlePriority);
thread_ = new QThread(this);
thread_->start(QThread::IdlePriority);
// Move context to thread
inner_->moveToThread(thread);
inner_->moveToThread(thread_);
// Queue post-init in new thread
QMetaObject::invokeMethod(inner_, "PostInit", Qt::BlockingQueuedConnection);
@@ -50,10 +49,16 @@ bool RendererThreadWrapper::Init()
return true;
}
void RendererThreadWrapper::PostInit()
{
// Do nothing
}
void RendererThreadWrapper::Destroy()
{
if (thread_) {
QMetaObject::invokeMethod(inner_, "Destroy", Qt::BlockingQueuedConnection);
inner_ = nullptr;
thread_->quit();
thread_->wait();
@@ -62,76 +67,113 @@ void RendererThreadWrapper::Destroy()
}
}
QVariant RendererThreadWrapper::CreateTexture(const VideoParams &param, void *data, int linesize)
void RendererThreadWrapper::ClearDestination(double r, double g, double b, double a)
{
QMetaObject::invokeMethod(inner_, "ClearDestination", Qt::BlockingQueuedConnection,
Q_ARG(double, r),
Q_ARG(double, g),
Q_ARG(double, b),
Q_ARG(double, a));
}
void RendererThreadWrapper::AttachTextureAsDestination(Renderer::Texture *texture)
{
QMetaObject::invokeMethod(inner_, "AttachTextureAsDestination", Qt::BlockingQueuedConnection,
OLIVE_NS_ARG(Renderer::Texture*, texture));
}
void RendererThreadWrapper::DetachTextureAsDestination()
{
QMetaObject::invokeMethod(inner_, "DetachTextureAsDestination", Qt::BlockingQueuedConnection);
}
QVariant RendererThreadWrapper::CreateNativeTexture(VideoParams param, void *data, int linesize)
{
QVariant v;
QMetaObject::invokeMethod(inner_, "CreateTexture", Qt::BlockingQueuedConnection,
QMetaObject::invokeMethod(inner_, "CreateNativeTexture", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QVariant, v),
OLIVE_NS_CONST_ARG(VideoParams&, param),
OLIVE_NS_ARG(VideoParams, param),
Q_ARG(void*, data),
Q_ARG(int, linesize));
return v;
}
void RendererThreadWrapper::DestroyTexture(QVariant texture)
void RendererThreadWrapper::DestroyNativeTexture(QVariant texture)
{
QMetaObject::invokeMethod(inner_, "DestroyTexture", Qt::BlockingQueuedConnection,
QMetaObject::invokeMethod(inner_, "DestroyNativeTexture", Qt::BlockingQueuedConnection,
Q_ARG(QVariant, texture));
}
void RendererThreadWrapper::UploadToTexture(QVariant texture, void *data, int linesize)
QVariant RendererThreadWrapper::CreateNativeShader(ShaderCode code)
{
QVariant v;
QMetaObject::invokeMethod(inner_, "CreateNativeShader", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QVariant, v),
OLIVE_NS_ARG(ShaderCode, code));
return v;
}
void RendererThreadWrapper::DestroyNativeShader(QVariant shader)
{
QMetaObject::invokeMethod(inner_, "DestroyNativeShader", Qt::BlockingQueuedConnection,
Q_ARG(QVariant, shader));
}
void RendererThreadWrapper::UploadToTexture(Renderer::Texture *texture, void *data, int linesize)
{
QMetaObject::invokeMethod(inner_, "UploadToTexture", Qt::BlockingQueuedConnection,
Q_ARG(QVariant, texture),
OLIVE_NS_ARG(Renderer::Texture*, texture),
Q_ARG(void*, data),
Q_ARG(int, linesize));
}
void RendererThreadWrapper::DownloadFromTexture(QVariant texture, void *data, int linesize)
void RendererThreadWrapper::DownloadFromTexture(Renderer::Texture *texture, void *data, int linesize)
{
QMetaObject::invokeMethod(inner_, "DownloadFromTexture", Qt::BlockingQueuedConnection,
Q_ARG(QVariant, texture),
OLIVE_NS_ARG(Renderer::Texture*, texture),
Q_ARG(void*, data),
Q_ARG(int, linesize));
}
QVariant RendererThreadWrapper::ProcessShader(const Node *node, const TimeRange &range, const ShaderJob &job, const VideoParams &params)
Renderer::TexturePtr RendererThreadWrapper::ProcessShader(const Node *node, ShaderJob job, VideoParams params)
{
QVariant v;
Renderer::TexturePtr tex;
QMetaObject::invokeMethod(inner_, "ProcessShader", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QVariant, v),
QMetaObject::invokeMethod(inner_, "Blit", Qt::BlockingQueuedConnection,
OLIVE_NS_RETURN_ARG(Renderer::TexturePtr, tex),
OLIVE_NS_CONST_ARG(Node*, node),
OLIVE_NS_CONST_ARG(TimeRange&, range),
OLIVE_NS_CONST_ARG(ShaderJob&, job),
OLIVE_NS_CONST_ARG(VideoParams&, params));
OLIVE_NS_ARG(ShaderJob, job),
OLIVE_NS_ARG(VideoParams, params));
return v;
return tex;
}
QVariant RendererThreadWrapper::TransformColor(QVariant texture, ColorProcessorPtr processor)
void RendererThreadWrapper::SetViewport(int width, int height)
{
QVariant v;
QMetaObject::invokeMethod(inner_, "ProcessShader", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QVariant, v),
Q_ARG(QVariant, texture),
OLIVE_NS_ARG(ColorProcessorPtr, processor));
return v;
QMetaObject::invokeMethod(inner_, "SetViewport", Qt::BlockingQueuedConnection,
Q_ARG(int, width),
Q_ARG(int, height));
}
VideoParams RendererThreadWrapper::GetParamsFromTexture(QVariant texture)
void RendererThreadWrapper::BlitColorManaged(ColorProcessorPtr color_processor, Renderer::Texture *source, Renderer::Texture *destination)
{
VideoParams p;
QMetaObject::invokeMethod(inner_, "BlitColorManaged", Qt::BlockingQueuedConnection,
OLIVE_NS_ARG(ColorProcessorPtr, color_processor),
OLIVE_NS_ARG(Renderer::Texture*, source),
OLIVE_NS_ARG(Renderer::Texture*, destination));
}
QMetaObject::invokeMethod(inner_, "GetParamsFromTexture", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(VideoParams, p),
Q_ARG(QVariant, texture));
return p;
}*/
void RendererThreadWrapper::Blit(Renderer::Texture *source, QVariant shader, Renderer::ShaderUniformMap parameters, Renderer::Texture *destination)
{
QMetaObject::invokeMethod(inner_, "Blit", Qt::BlockingQueuedConnection,
OLIVE_NS_ARG(Renderer::Texture*, source),
Q_ARG(QVariant, shader),
Q_ARG(Renderer::ShaderUniformMap, parameters),
OLIVE_NS_ARG(Renderer::Texture*, destination));
}
OLIVE_NAMESPACE_EXIT
+25 -14
View File
@@ -27,7 +27,7 @@
OLIVE_NAMESPACE_ENTER
/*class RendererThreadWrapper : public Renderer
class RendererThreadWrapper : public Renderer
{
public:
RendererThreadWrapper(Renderer* inner, QObject* parent = nullptr);
@@ -35,39 +35,50 @@ public:
virtual ~RendererThreadWrapper() override
{
Destroy();
delete inner_;
}
virtual bool Init() override;
public slots:
virtual void PostInit() override{}
virtual void PostInit() override;
virtual void Destroy() override;
virtual QVariant CreateTexture(const VideoParams& param, void* data, int linesize) override;
virtual void ClearDestination(double r = 0.0, double g = 0.0, double b = 0.0, double a = 0.0) override;
virtual void DestroyTexture(QVariant texture) override;
virtual void AttachTextureAsDestination(OLIVE_NAMESPACE::Renderer::Texture* texture) override;
virtual void UploadToTexture(QVariant texture, void* data, int linesize) override;
virtual void DetachTextureAsDestination() override;
virtual void DownloadFromTexture(QVariant texture, void* data, int linesize) override;
virtual QVariant CreateNativeTexture(OLIVE_NAMESPACE::VideoParams param, void* data = nullptr, int linesize = 0) override;
virtual QVariant ProcessShader(const OLIVE_NAMESPACE::Node* node,
const OLIVE_NAMESPACE::TimeRange &range,
const OLIVE_NAMESPACE::ShaderJob &job,
const OLIVE_NAMESPACE::VideoParams &params) override;
virtual void DestroyNativeTexture(QVariant texture) override;
virtual QVariant TransformColor(QVariant texture,
OLIVE_NAMESPACE::ColorProcessorPtr processor) override;
virtual QVariant CreateNativeShader(OLIVE_NAMESPACE::ShaderCode code) override;
//virtual VideoParams GetParamsFromTexture(QVariant texture) override;
virtual void DestroyNativeShader(QVariant shader) override;
virtual void UploadToTexture(OLIVE_NAMESPACE::Renderer::Texture* texture, void* data, int linesize) override;
virtual void DownloadFromTexture(OLIVE_NAMESPACE::Renderer::Texture* texture, void* data, int linesize) override;
virtual TexturePtr ProcessShader(const OLIVE_NAMESPACE::Node* node,
OLIVE_NAMESPACE::ShaderJob job,
OLIVE_NAMESPACE::VideoParams params) override;
virtual void SetViewport(int width, int height) override;
virtual void BlitColorManaged(OLIVE_NAMESPACE::ColorProcessorPtr color_processor, OLIVE_NAMESPACE::Renderer::Texture* source, OLIVE_NAMESPACE::Renderer::Texture *destination = nullptr) override;
virtual void Blit(OLIVE_NAMESPACE::Renderer::Texture* source, QVariant shader, OLIVE_NAMESPACE::Renderer::ShaderUniformMap parameters, OLIVE_NAMESPACE::Renderer::Texture* destination = nullptr) override;
private:
Renderer* inner_;
QThread* thread_;
};*/
};
OLIVE_NAMESPACE_EXIT