media node upgrades to reference pixel format
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
|
||||
const int kRGBAChannels = 4;
|
||||
|
||||
ColorService::ColorService()
|
||||
ColorService::ColorService(const char* source_space, const char* dest_space)
|
||||
{
|
||||
// FIXME: Hardcoded values for testing purposes
|
||||
OCIO::ConstConfigRcPtr config = OCIO::Config::CreateFromFile("/run/media/matt/Home/OpenColorIO/ocio.configs.0.7v4/nuke-default/config.ocio");
|
||||
|
||||
processor = config->getProcessor("srgb",
|
||||
OCIO::ROLE_SCENE_LINEAR);
|
||||
processor = config->getProcessor(source_space,
|
||||
dest_space);
|
||||
}
|
||||
|
||||
void ColorService::ConvertFrame(FramePtr f)
|
||||
@@ -17,3 +17,8 @@ void ColorService::ConvertFrame(FramePtr f)
|
||||
|
||||
processor->apply(img);
|
||||
}
|
||||
|
||||
OpenColorIO::v1::ConstProcessorRcPtr ColorService::GetProcessor()
|
||||
{
|
||||
return processor;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,17 @@
|
||||
namespace OCIO = OCIO_NAMESPACE::v1;
|
||||
|
||||
#include "decoder/frame.h"
|
||||
#include "render/gl/shadergenerators.h"
|
||||
|
||||
class ColorService
|
||||
{
|
||||
public:
|
||||
ColorService();
|
||||
ColorService(const char *source_space, const char *dest_space);
|
||||
|
||||
void ConvertFrame(FramePtr f);
|
||||
|
||||
OCIO::ConstProcessorRcPtr GetProcessor();
|
||||
|
||||
private:
|
||||
OCIO::ConstProcessorRcPtr processor;
|
||||
};
|
||||
|
||||
@@ -41,9 +41,9 @@ public:
|
||||
static ShaderPtr DefaultPipeline(const QString &function_name = QString(), const QString &shader_code = QString());
|
||||
|
||||
static ShaderPtr OCIOPipeline(QOpenGLContext *ctx,
|
||||
GLuint &lut_texture,
|
||||
OCIO::ConstProcessorRcPtr processor,
|
||||
bool alpha_is_associated);
|
||||
GLuint &lut_texture,
|
||||
OCIO::ConstProcessorRcPtr processor,
|
||||
bool alpha_is_associated);
|
||||
|
||||
static QString AlphaDisassociateFunction(const QString& function_name);
|
||||
static QString AlphaReassociateFunction(const QString& function_name);
|
||||
|
||||
@@ -127,16 +127,10 @@ void RenderFramebuffer::AttachInternal(GLuint tex)
|
||||
// bind framebuffer for attaching
|
||||
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buffer_);
|
||||
|
||||
// bind texture
|
||||
f->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
context_->extraFunctions()->glFramebufferTexture2D(
|
||||
GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0
|
||||
);
|
||||
|
||||
// release texture
|
||||
f->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
// release framebuffer
|
||||
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ bool RenderInstance::Start()
|
||||
|
||||
buffer_.Create(&ctx_);
|
||||
|
||||
ctx_.functions()->glViewport(0, 0, width_, height_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "rendertexture.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
||||
#include "render/pixelservice.h"
|
||||
@@ -139,7 +140,7 @@ void RenderTexture::SwapFrontAndBack()
|
||||
back_texture_ = temp;
|
||||
}
|
||||
|
||||
void RenderTexture::Upload(void *data)
|
||||
void RenderTexture::Upload(const void *data)
|
||||
{
|
||||
if (!IsCreated()) {
|
||||
qWarning() << tr("RenderTexture::Upload() called while it wasn't created");
|
||||
@@ -163,16 +164,36 @@ void RenderTexture::Upload(void *data)
|
||||
Release();
|
||||
}
|
||||
|
||||
void *RenderTexture::Download() const
|
||||
uchar *RenderTexture::Download() const
|
||||
{
|
||||
if (!IsCreated()) {
|
||||
qWarning() << tr("RenderTexture::Download() called while it wasn't created");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// FIXME: Implement this
|
||||
QOpenGLFunctions* f = context_->functions();
|
||||
|
||||
return nullptr;
|
||||
GLuint read_fbo;
|
||||
|
||||
f->glGenFramebuffers(1, &read_fbo);
|
||||
|
||||
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, read_fbo);
|
||||
|
||||
context_->extraFunctions()->glFramebufferTexture2D(
|
||||
GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_, 0
|
||||
);
|
||||
|
||||
PixelFormatInfo format_info = PixelService::GetPixelFormatInfo(format_);
|
||||
|
||||
uchar* data = new uchar[PixelService::GetBufferSize(format_, width_, height_)];
|
||||
|
||||
f->glReadPixels(0, 0, width_, height_, format_info.pixel_format, format_info.pixel_type, data);
|
||||
|
||||
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
|
||||
f->glDeleteFramebuffers(1, &read_fbo);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void RenderTexture::CreateInternal(void *data)
|
||||
|
||||
@@ -64,9 +64,9 @@ public:
|
||||
const GLuint& back_texture() const;
|
||||
void SwapFrontAndBack();
|
||||
|
||||
void Upload(void* data);
|
||||
void Upload(const void *data);
|
||||
|
||||
void* Download() const;
|
||||
uchar *Download() const;
|
||||
|
||||
private:
|
||||
void CreateInternal(void *data = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user