viewer: use internal texture to allow viewer to control texture as part of its

context

More intuitive code flow and allows the user to undock the viewer (which
forcibly destroys and recreates the context) and the viewer will handle
creation of the new texture in said new context.
This commit is contained in:
itsmattkc
2020-02-16 18:24:49 +11:00
parent 21755c7f20
commit ceb70a1870
14 changed files with 116 additions and 227 deletions
+2 -1
View File
@@ -278,7 +278,8 @@ void Exporter::VideoHashesComplete()
video_backend_->SetOperatingMode(VideoRenderWorker::kRenderOnly); video_backend_->SetOperatingMode(VideoRenderWorker::kRenderOnly);
video_backend_->SetOnlySignalLastFrameRequested(false); video_backend_->SetOnlySignalLastFrameRequested(false);
connect(video_backend_, &VideoRenderBackend::CachedFrameReady, this, &Exporter::FrameRendered); // FIXME: Exporting is now broken because of this
//connect(video_backend_, &VideoRenderBackend::CachedFrameReady, this, &Exporter::FrameRendered);
foreach (const TimeRange& range, ranges) { foreach (const TimeRange& range, ranges) {
video_backend_->InvalidateCache(range.in(), range.out()); video_backend_->InvalidateCache(range.in(), range.out());
@@ -7,7 +7,6 @@
OpenGLBackend::OpenGLBackend(QObject *parent) : OpenGLBackend::OpenGLBackend(QObject *parent) :
VideoRenderBackend(parent), VideoRenderBackend(parent),
master_texture_(nullptr),
proxy_(nullptr) proxy_(nullptr)
{ {
} }
@@ -49,17 +48,6 @@ bool OpenGLBackend::InitInternal()
connect(processor, &OpenGLWorker::RequestRunNodeAccelerated, proxy_, &OpenGLProxy::RunNodeAccelerated, Qt::BlockingQueuedConnection); connect(processor, &OpenGLWorker::RequestRunNodeAccelerated, proxy_, &OpenGLProxy::RunNodeAccelerated, Qt::BlockingQueuedConnection);
} }
// Create master texture (the one sent to the viewer)
master_texture_ = std::make_shared<OpenGLTexture>();
master_texture_->Create(QOpenGLContext::currentContext(),
params().effective_width(),
params().effective_height(),
params().format());
// Create copy buffer/pipeline
copy_buffer_.Create(QOpenGLContext::currentContext());
copy_pipeline_ = OpenGLShader::CreateDefault();
return true; return true;
} }
@@ -70,25 +58,9 @@ void OpenGLBackend::CloseInternal()
proxy_ = nullptr; proxy_ = nullptr;
} }
copy_buffer_.Destroy();
copy_pipeline_ = nullptr;
master_texture_ = nullptr;
VideoRenderBackend::CloseInternal(); VideoRenderBackend::CloseInternal();
} }
OpenGLTexturePtr OpenGLBackend::GetCachedFrameAsTexture(const rational &time)
{
const char* cached_frame = GetCachedFrame(time);
if (cached_frame) {
master_texture_->Upload(cached_frame);
return master_texture_;
}
return nullptr;
}
bool OpenGLBackend::CompileInternal() bool OpenGLBackend::CompileInternal()
{ {
return true; return true;
@@ -98,52 +70,10 @@ void OpenGLBackend::DecompileInternal()
{ {
} }
void OpenGLBackend::EmitCachedFrameReady(const rational &time, const QVariant &value, qint64 job_time)
{
OpenGLTextureCache::ReferencePtr ref = value.value<OpenGLTextureCache::ReferencePtr>();
OpenGLTexturePtr tex;
if (ref && ref->texture()) {
tex = CopyTexture(ref->texture());
} else {
tex = nullptr;
}
emit CachedFrameReady(time, QVariant::fromValue(tex), job_time);
}
void OpenGLBackend::ParamsChangedEvent() void OpenGLBackend::ParamsChangedEvent()
{ {
// If we're initiated, we need to recreate the texture. Otherwise this backend isn't active so it doesn't matter. // If we're initiated, we need to recreate the texture. Otherwise this backend isn't active so it doesn't matter.
if (IsInitiated()) { if (IsInitiated()) {
master_texture_->Destroy();
master_texture_->Create(QOpenGLContext::currentContext(),
params().effective_width(),
params().effective_height(),
params().format());
proxy_->SetParameters(params()); proxy_->SetParameters(params());
} }
} }
OpenGLTexturePtr OpenGLBackend::CopyTexture(OpenGLTexturePtr input)
{
QOpenGLContext* ctx = QOpenGLContext::currentContext();
OpenGLTexturePtr copy = std::make_shared<OpenGLTexture>();
copy->Create(ctx, input->width(), input->height(), input->format());
ctx->functions()->glViewport(0, 0, input->width(), input->height());
copy_buffer_.Attach(copy);
copy_buffer_.Bind();
input->Bind();
OpenGLRenderFunctions::Blit(copy_pipeline_);
input->Release();
copy_buffer_.Release();
copy_buffer_.Detach();
return copy;
}
-11
View File
@@ -16,8 +16,6 @@ public:
virtual ~OpenGLBackend() override; virtual ~OpenGLBackend() override;
OpenGLTexturePtr GetCachedFrameAsTexture(const rational& time);
protected: protected:
virtual bool InitInternal() override; virtual bool InitInternal() override;
@@ -27,18 +25,9 @@ protected:
virtual void DecompileInternal() override; virtual void DecompileInternal() override;
virtual void EmitCachedFrameReady(const rational &time, const QVariant& value, qint64 job_time) override;
virtual void ParamsChangedEvent() override; virtual void ParamsChangedEvent() override;
private: private:
OpenGLTexturePtr CopyTexture(OpenGLTexturePtr input);
OpenGLTexturePtr master_texture_;
OpenGLFramebuffer copy_buffer_;
OpenGLShaderPtr copy_pipeline_;
OpenGLProxy* proxy_; OpenGLProxy* proxy_;
}; };
+12 -33
View File
@@ -58,7 +58,7 @@ void OpenGLTexture::Create(QOpenGLContext *ctx, int width, int height, const Pix
height_ = height; height_ = height;
format_ = format; format_ = format;
connect(created_ctx_, SIGNAL(aboutToBeDestroyed()), this, SLOT(Destroy())); connect(created_ctx_, SIGNAL(aboutToBeDestroyed()), this, SLOT(Destroy()), Qt::DirectConnection);
// Create main texture // Create main texture
CreateInternal(created_ctx_, &texture_, data); CreateInternal(created_ctx_, &texture_, data);
@@ -83,26 +83,12 @@ void OpenGLTexture::Destroy()
void OpenGLTexture::Bind() void OpenGLTexture::Bind()
{ {
QOpenGLContext* context = QOpenGLContext::currentContext(); created_ctx_->functions()->glBindTexture(GL_TEXTURE_2D, texture_);
if (!context) {
qWarning() << "OpenGLTexture::Bind() called with an invalid context";
return;
}
context->functions()->glBindTexture(GL_TEXTURE_2D, texture_);
} }
void OpenGLTexture::Release() void OpenGLTexture::Release()
{ {
QOpenGLContext* context = QOpenGLContext::currentContext(); created_ctx_->functions()->glBindTexture(GL_TEXTURE_2D, 0);
if (!context) {
qWarning() << "OpenGLTexture::Release() called with an invalid context";
return;
}
context->functions()->glBindTexture(GL_TEXTURE_2D, 0);
} }
const int &OpenGLTexture::width() const const int &OpenGLTexture::width() const
@@ -132,26 +118,19 @@ void OpenGLTexture::Upload(const void *data)
return; return;
} }
QOpenGLContext* context = QOpenGLContext::currentContext();
if (!context) {
qWarning() << "OpenGLTexture::Release() called with an invalid context";
return;
}
Bind(); Bind();
PixelFormat::Info info = PixelService::GetPixelFormatInfo(format_); PixelFormat::Info info = PixelService::GetPixelFormatInfo(format_);
context->functions()->glTexSubImage2D(GL_TEXTURE_2D, created_ctx_->functions()->glTexSubImage2D(GL_TEXTURE_2D,
0, 0,
0, 0,
0, 0,
width_, width_,
height_, height_,
info.pixel_format, info.pixel_format,
info.gl_pixel_type, info.gl_pixel_type,
data); data);
Release(); Release();
} }
+9
View File
@@ -202,6 +202,15 @@ void RenderBackend::RegenerateCacheID()
CacheIDChangedEvent(cache_id_); CacheIDChangedEvent(cache_id_);
} }
bool RenderBackend::InitInternal()
{
return true;
}
void RenderBackend::CloseInternal()
{
}
bool RenderBackend::CanRender() bool RenderBackend::CanRender()
{ {
return true; return true;
+2 -2
View File
@@ -43,9 +43,9 @@ signals:
protected: protected:
void RegenerateCacheID(); void RegenerateCacheID();
virtual bool InitInternal() = 0; virtual bool InitInternal();
virtual void CloseInternal() = 0; virtual void CloseInternal();
virtual bool CompileInternal() = 0; virtual bool CompileInternal() = 0;
+5 -47
View File
@@ -42,17 +42,6 @@ VideoRenderBackend::VideoRenderBackend(QObject *parent) :
connect(DiskManager::instance(), &DiskManager::DeletedFrame, this, &VideoRenderBackend::FrameRemovedFromDiskCache); connect(DiskManager::instance(), &DiskManager::DeletedFrame, this, &VideoRenderBackend::FrameRemovedFromDiskCache);
} }
bool VideoRenderBackend::InitInternal()
{
ResizeCacheLoadBuffer();
return true;
}
void VideoRenderBackend::CloseInternal()
{
cache_frame_load_buffer_.clear();
}
void VideoRenderBackend::ConnectViewer(ViewerOutput *node) void VideoRenderBackend::ConnectViewer(ViewerOutput *node)
{ {
connect(node, &ViewerOutput::VideoChangedBetween, this, &VideoRenderBackend::InvalidateCache); connect(node, &ViewerOutput::VideoChangedBetween, this, &VideoRenderBackend::InvalidateCache);
@@ -81,9 +70,6 @@ void VideoRenderBackend::SetParameters(const VideoRenderingParams& params)
// Set new parameters // Set new parameters
params_ = params; params_ = params;
// Resize frame load buffer
ResizeCacheLoadBuffer();
// Handle custom events from derivatives // Handle custom events from derivatives
ParamsChangedEvent(); ParamsChangedEvent();
@@ -154,11 +140,6 @@ void VideoRenderBackend::ConnectWorkerToThis(RenderWorker *processor)
connect(video_processor, &VideoRenderWorker::HashAlreadyExists, this, &VideoRenderBackend::ThreadHashAlreadyExists, Qt::QueuedConnection); connect(video_processor, &VideoRenderWorker::HashAlreadyExists, this, &VideoRenderBackend::ThreadHashAlreadyExists, Qt::QueuedConnection);
} }
void VideoRenderBackend::EmitCachedFrameReady(const rational &time, const QVariant &value, qint64 job_time)
{
emit CachedFrameReady(time, value, job_time);
}
void VideoRenderBackend::InvalidateCacheInternal(const rational &start_range, const rational &end_range) void VideoRenderBackend::InvalidateCacheInternal(const rational &start_range, const rational &end_range)
{ {
TimeRange invalidated(start_range, end_range); TimeRange invalidated(start_range, end_range);
@@ -179,7 +160,7 @@ VideoRenderFrameCache *VideoRenderBackend::frame_cache()
return &frame_cache_; return &frame_cache_;
} }
const char *VideoRenderBackend::GetCachedFrame(const rational &time) QString VideoRenderBackend::GetCachedFrame(const rational &time)
{ {
last_time_requested_ = time; last_time_requested_ = time;
@@ -204,30 +185,12 @@ const char *VideoRenderBackend::GetCachedFrame(const rational &time)
QByteArray frame_hash = frame_cache_.TimeToHash(time); QByteArray frame_hash = frame_cache_.TimeToHash(time);
if (!frame_hash.isEmpty()) { if (!frame_hash.isEmpty()) {
QString fn = frame_cache_.CachePathName(frame_hash, params_.format()); DiskManager::instance()->Accessed(frame_hash);
if (QFileInfo::exists(fn)) { return frame_cache_.CachePathName(frame_hash, params_.format());
auto in = OIIO::ImageInput::open(fn.toStdString());
if (in) {
DiskManager::instance()->Accessed(frame_hash);
in->read_image(PixelService::GetPixelFormatInfo(params_.format()).oiio_desc, cache_frame_load_buffer_.data());
in->close();
#if OIIO_VERSION < 10903
OIIO::ImageInput::destroy(in);
#endif
return cache_frame_load_buffer_.constData();
} else {
qWarning() << "OIIO Error:" << OIIO::geterror().c_str();
}
}
} }
return nullptr; return QString();
} }
NodeInput *VideoRenderBackend::GetDependentInput() NodeInput *VideoRenderBackend::GetDependentInput()
@@ -368,7 +331,7 @@ void VideoRenderBackend::TruncateFrameCacheLength(const rational &length)
// If the playhead is past the length, update the viewer to a null texture because it won't be cached through the // If the playhead is past the length, update the viewer to a null texture because it won't be cached through the
// queue, but will now be a null texture // queue, but will now be a null texture
if (last_time_requested_ >= length) { if (last_time_requested_ >= length) {
emit CachedFrameReady(last_time_requested_, QVariant(), QDateTime::currentMSecsSinceEpoch()); emit CachedTimeReady(last_time_requested_, QDateTime::currentMSecsSinceEpoch());
} }
// Adjust queue for new invalidated range // Adjust queue for new invalidated range
@@ -422,8 +385,3 @@ void VideoRenderBackend::Requeue()
CacheNext(); CacheNext();
} }
void VideoRenderBackend::ResizeCacheLoadBuffer()
{
cache_frame_load_buffer_.resize(PixelService::GetBufferSize(params_.format(), params_.effective_width(), params_.effective_height()));
}
+2 -19
View File
@@ -60,21 +60,13 @@ public:
bool IsRendered(const rational& time) const; bool IsRendered(const rational& time) const;
QString GetCachedFrame(const rational& time);
VideoRenderFrameCache* frame_cache(); VideoRenderFrameCache* frame_cache();
const VideoRenderingParams& params() const; const VideoRenderingParams& params() const;
protected: protected:
/**
* @brief Allocate and start the multithreaded backend
*/
virtual bool InitInternal() override;
/**
* @brief Terminate and deallocate the multithreaded backend
*/
virtual void CloseInternal() override;
struct HashTimeMapping { struct HashTimeMapping {
rational time; rational time;
QByteArray hash; QByteArray hash;
@@ -84,8 +76,6 @@ protected:
virtual void DisconnectViewer(ViewerOutput* node) override; virtual void DisconnectViewer(ViewerOutput* node) override;
const char *GetCachedFrame(const rational& time);
virtual NodeInput* GetDependentInput() override; virtual NodeInput* GetDependentInput() override;
virtual bool CanRender() override; virtual bool CanRender() override;
@@ -101,8 +91,6 @@ protected:
virtual void ConnectWorkerToThis(RenderWorker* processor) override; virtual void ConnectWorkerToThis(RenderWorker* processor) override;
virtual void EmitCachedFrameReady(const rational &time, const QVariant& value, qint64 job_time);
virtual void InvalidateCacheInternal(const rational &start_range, const rational &end_range) override; virtual void InvalidateCacheInternal(const rational &start_range, const rational &end_range) override;
virtual void ParamsChangedEvent(); virtual void ParamsChangedEvent();
@@ -110,7 +98,6 @@ protected:
VideoRenderWorker::OperatingMode operating_mode_; VideoRenderWorker::OperatingMode operating_mode_;
signals: signals:
void CachedFrameReady(const rational& time, QVariant value, qint64 job_time);
void CachedTimeReady(const rational& time, qint64 job_time); void CachedTimeReady(const rational& time, qint64 job_time);
void RangeInvalidated(const TimeRange& range); void RangeInvalidated(const TimeRange& range);
@@ -124,12 +111,8 @@ private:
void Requeue(); void Requeue();
void ResizeCacheLoadBuffer();
VideoRenderingParams params_; VideoRenderingParams params_;
QByteArray cache_frame_load_buffer_;
VideoRenderFrameCache frame_cache_; VideoRenderFrameCache frame_cache_;
TimeRangeList invalidated_; TimeRangeList invalidated_;
+15
View File
@@ -58,6 +58,21 @@ void PixelService::SetConfiguredFormatForMode(RenderMode::Mode mode, PixelFormat
} }
} }
PixelFormat::Format PixelService::OIIOFormatToOliveFormat(OIIO::TypeDesc desc)
{
if (desc == OIIO::TypeDesc::UINT8) {
return PixelFormat::PIX_FMT_RGBA8;
} else if (desc == OIIO::TypeDesc::UINT16) {
return PixelFormat::PIX_FMT_RGBA16U;
} else if (desc == OIIO::TypeDesc::HALF) {
return PixelFormat::PIX_FMT_RGBA16F;
} else if (desc == OIIO::TypeDesc::FLOAT) {
return PixelFormat::PIX_FMT_RGBA32F;
}
return PixelFormat::PIX_FMT_INVALID;
}
PixelFormat::Info PixelService::GetPixelFormatInfo(const PixelFormat::Format &format) PixelFormat::Info PixelService::GetPixelFormatInfo(const PixelFormat::Format &format)
{ {
PixelFormat::Info info; PixelFormat::Info info;
+2
View File
@@ -41,6 +41,8 @@ public:
PixelFormat::Format GetConfiguredFormatForMode(RenderMode::Mode mode); PixelFormat::Format GetConfiguredFormatForMode(RenderMode::Mode mode);
void SetConfiguredFormatForMode(RenderMode::Mode mode, PixelFormat::Format format); void SetConfiguredFormatForMode(RenderMode::Mode mode, PixelFormat::Format format);
static PixelFormat::Format OIIOFormatToOliveFormat(OIIO::TypeDesc desc);
/** /**
* @brief Return a PixelFormatInfo containing information for a certain format * @brief Return a PixelFormatInfo containing information for a certain format
* *
+7 -18
View File
@@ -83,7 +83,6 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
// Start background renderers // Start background renderers
video_renderer_ = new OpenGLBackend(this); video_renderer_ = new OpenGLBackend(this);
connect(video_renderer_, &VideoRenderBackend::CachedFrameReady, this, &ViewerWidget::RendererCachedFrame);
connect(video_renderer_, &VideoRenderBackend::CachedTimeReady, this, &ViewerWidget::RendererCachedTime); connect(video_renderer_, &VideoRenderBackend::CachedTimeReady, this, &ViewerWidget::RendererCachedTime);
connect(video_renderer_, &VideoRenderBackend::CachedTimeReady, ruler(), &TimeRuler::CacheTimeReady); connect(video_renderer_, &VideoRenderBackend::CachedTimeReady, ruler(), &TimeRuler::CacheTimeReady);
connect(video_renderer_, &VideoRenderBackend::RangeInvalidated, ruler(), &TimeRuler::CacheInvalidatedRange); connect(video_renderer_, &VideoRenderBackend::RangeInvalidated, ruler(), &TimeRuler::CacheInvalidatedRange);
@@ -215,17 +214,16 @@ VideoRenderBackend *ViewerWidget::video_renderer() const
return video_renderer_; return video_renderer_;
} }
void ViewerWidget::SetTexture(OpenGLTexturePtr tex)
{
gl_widget_->SetTexture(tex);
}
void ViewerWidget::UpdateTextureFromNode(const rational& time) void ViewerWidget::UpdateTextureFromNode(const rational& time)
{ {
if (!GetConnectedNode()) { if (!GetConnectedNode() || time >= GetConnectedNode()->Length()) {
SetTexture(nullptr); gl_widget_->SetImage(QString());
} else { } else {
SetTexture(video_renderer_->GetCachedFrameAsTexture(time)); QString frame_fn = video_renderer_->GetCachedFrame(time);
if (!frame_fn.isEmpty()) {
gl_widget_->SetImage(frame_fn);
}
} }
} }
@@ -466,15 +464,6 @@ void ViewerWidget::PlaybackTimerUpdate()
} }
} }
void ViewerWidget::RendererCachedFrame(const rational &time, QVariant value, qint64 job_time)
{
if (GetTime() == time && job_time > frame_cache_job_time_) {
frame_cache_job_time_ = job_time;
SetTexture(value.value<OpenGLTexturePtr>());
}
}
void ViewerWidget::RendererCachedTime(const rational &time, qint64 job_time) void ViewerWidget::RendererCachedTime(const rational &time, qint64 job_time)
{ {
if (GetTime() == time && job_time > frame_cache_job_time_) { if (GetTime() == time && job_time > frame_cache_job_time_) {
-10
View File
@@ -72,15 +72,6 @@ public:
VideoRenderBackend* video_renderer() const; VideoRenderBackend* video_renderer() const;
public slots: public slots:
/**
* @brief Set the texture to draw and draw it
*
* Wrapper function for ViewerGLWidget::SetTexture().
*
* @param tex
*/
void SetTexture(OpenGLTexturePtr tex);
void Play(); void Play();
void Pause(); void Pause();
@@ -166,7 +157,6 @@ private:
private slots: private slots:
void PlaybackTimerUpdate(); void PlaybackTimerUpdate();
void RendererCachedFrame(const rational& time, QVariant value, qint64 job_time);
void RendererCachedTime(const rational& time, qint64 job_time); void RendererCachedTime(const rational& time, qint64 job_time);
void SizeChangedSlot(int width, int height); void SizeChangedSlot(int width, int height);
+53 -14
View File
@@ -20,6 +20,8 @@
#include "viewerglwidget.h" #include "viewerglwidget.h"
#include <OpenImageIO/imagebuf.h>
#include <QFileInfo>
#include <QMessageBox> #include <QMessageBox>
#include <QOpenGLContext> #include <QOpenGLContext>
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
@@ -27,10 +29,10 @@
#include "render/backend/opengl/openglrenderfunctions.h" #include "render/backend/opengl/openglrenderfunctions.h"
#include "render/backend/opengl/openglshader.h" #include "render/backend/opengl/openglshader.h"
#include "render/pixelservice.h"
ViewerGLWidget::ViewerGLWidget(QWidget *parent) : ViewerGLWidget::ViewerGLWidget(QWidget *parent) :
QOpenGLWidget(parent), QOpenGLWidget(parent),
texture_(0),
ocio_lut_(0), ocio_lut_(0),
color_manager_(nullptr) color_manager_(nullptr)
{ {
@@ -68,6 +70,51 @@ void ViewerGLWidget::SetMatrix(const QMatrix4x4 &mat)
update(); update();
} }
void ViewerGLWidget::SetImage(const QString &fn)
{
OIIO::ImageBuf* in;
if (fn.isEmpty()) {
// Backend had no filename
goto end;
}
if (!QFileInfo::exists(fn)) {
goto end;
}
in = new OIIO::ImageBuf(fn.toStdString());
if (in->read(0, 0, true)) {
PixelFormat::Format image_format = PixelService::OIIOFormatToOliveFormat(in->spec().format);
// Ensure the following texture operations are done in our context (in case we're in a separate window for instance)
makeCurrent();
if (!texture_.IsCreated()
|| texture_.width() != in->spec().width
|| texture_.height() != in->spec().height
|| texture_.format() != image_format) {
texture_.Destroy();
texture_.Create(context(), in->spec().width, in->spec().height, image_format);
}
texture_.Upload(in->localpixels());
doneCurrent();
} else {
qWarning() << "OIIO Error:" << OIIO::geterror().c_str();
}
delete in;
end:
update();
}
void ViewerGLWidget::SetOCIODisplay(const QString &display) void ViewerGLWidget::SetOCIODisplay(const QString &display)
{ {
ocio_display_ = display; ocio_display_ = display;
@@ -109,15 +156,6 @@ const QString &ViewerGLWidget::ocio_look() const
return ocio_look_; return ocio_look_;
} }
void ViewerGLWidget::SetTexture(OpenGLTexturePtr tex)
{
// Update the texture
texture_ = tex;
// Paint the texture
update();
}
void ViewerGLWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look) void ViewerGLWidget::SetOCIOParameters(const QString &display, const QString &view, const QString &look)
{ {
ocio_display_ = display; ocio_display_ = display;
@@ -144,15 +182,16 @@ void ViewerGLWidget::paintGL()
f->glClear(GL_COLOR_BUFFER_BIT); f->glClear(GL_COLOR_BUFFER_BIT);
// We only draw if we have a pipeline // We only draw if we have a pipeline
if (!pipeline_ || !texture_) { if (!pipeline_ || !texture_.IsCreated()) {
return; return;
} }
// Bind retrieved texture // Bind retrieved texture
f->glBindTexture(GL_TEXTURE_2D, texture_->texture()); f->glBindTexture(GL_TEXTURE_2D, texture_.texture());
// Blit using the pipeline retrieved in initializeGL() // Blit using the pipeline retrieved in initializeGL()
OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_, true, matrix_); //OpenGLRenderFunctions::OCIOBlit(pipeline_, ocio_lut_, true, matrix_);
OpenGLRenderFunctions::Blit(pipeline_, true, matrix_);
// Release retrieved texture // Release retrieved texture
f->glBindTexture(GL_TEXTURE_2D, 0); f->glBindTexture(GL_TEXTURE_2D, 0);
@@ -240,7 +279,7 @@ void ViewerGLWidget::ContextCleanup()
makeCurrent(); makeCurrent();
ClearOCIOLutTexture(); ClearOCIOLutTexture();
texture_.Destroy();
pipeline_ = nullptr; pipeline_ = nullptr;
doneCurrent(); doneCurrent();
+7 -2
View File
@@ -74,6 +74,11 @@ public:
*/ */
void SetMatrix(const QMatrix4x4& mat); void SetMatrix(const QMatrix4x4& mat);
/**
* @brief Set an image to load and display on screen
*/
void SetImage(const QString& fn);
public slots: public slots:
/** /**
* @brief Set the texture to draw and draw it * @brief Set the texture to draw and draw it
@@ -82,7 +87,7 @@ public slots:
* *
* @param tex * @param tex
*/ */
void SetTexture(OpenGLTexturePtr tex); //void SetTexture(OpenGLTexturePtr tex);
void SetOCIOParameters(const QString& display, const QString& view, const QString& look); void SetOCIOParameters(const QString& display, const QString& view, const QString& look);
@@ -157,7 +162,7 @@ private:
/** /**
* @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL(). * @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL().
*/ */
OpenGLTexturePtr texture_; OpenGLTexture texture_;
/** /**
* @brief Internal shader object to use as the pipeline shader * @brief Internal shader object to use as the pipeline shader