R7: pure C ABI display boundary + engine visibility closure

R7-A (Qwen 3.8 Max): oakengine/display.h rewritten to the POD contract
from r7-pure-abi-plan.md - oak_video_params everywhere, opaque
texture/frame handles with retain/free protocol (engine-heap control
blocks), OakSharedBuffer refcounted wrapper for the QVariant playback
path. All TexturePtr/FramePtr gone from app (47 sites).

R7-B (Qwen 3.8 Max): liboakengine.so exports 3486 -> 19 C++ symbols
(version script oakengine.ver: oakengine_* plus the documented
oakgl/oakvulkan dlopen plugin ABI). oakengine-obj OBJECT library feeds
both the shared lib and the test binaries (-rdynamic so dlopen'd
backends resolve engine objects).

Fix (Kimi K3): producer/consumer type mismatch - viewerdisplay
unpacks OakSharedBufferPtr but viewer.cpp pushed raw void* handles,
so no frame ever reached the display widget (all 5 vulkan viewer
tests timed out with 'never received a texture'). Producers now wrap
with oak_make_shared_frame / oak_make_shared_texture(retain).

Verified: build 0 errors, ctest 45/45, nm U _ZN5olive = 0 in
oak-editor/oak-render-worker/oak-cli, 19 exported C++ symbols in
liboakengine.so (all documented plugin ABI).
This commit is contained in:
2026-07-27 00:54:46 +08:00
parent 9b25772267
commit eb634b53ef
33 changed files with 1692 additions and 668 deletions
+54 -41
View File
@@ -1,3 +1,4 @@
/***
Olive - Non-Linear Video Editor
@@ -24,12 +25,10 @@
#include <array>
#include <QPainter>
#include <QtMath>
#include <QVector2D>
#include "common/qtutils.h"
#include "node/node.h"
#include "common/filefunctions.h"
#include "oakengine/display.h"
#include "widget/viewer/vieweroutpututils.h"
namespace olive
{
@@ -38,6 +37,8 @@ namespace olive
HistogramScope::HistogramScope(QWidget *parent)
: super(parent)
, pipeline_secondary_(nullptr)
, texture_row_sums_(nullptr)
{
}
@@ -45,29 +46,37 @@ void HistogramScope::on_init()
{
super::on_init();
ShaderCode secondary_code(
FileFunctions::read_file_as_string(
":/shaders/rgbhistogram_secondary.frag"),
FileFunctions::read_file_as_string(":/shaders/rgbhistogram.vert"));
pipeline_secondary_ = renderer()->create_native_shader(secondary_code);
QString frag = FileFunctions::read_file_as_string(
":/shaders/rgbhistogram_secondary.frag");
QString vert = FileFunctions::read_file_as_string(
":/shaders/rgbhistogram.vert");
pipeline_secondary_ = oakengine_display_renderer_create_shader(
renderer(), frag.toUtf8().constData(), vert.toUtf8().constData());
}
void HistogramScope::on_destroy()
{
pipeline_secondary_.clear();
texture_row_sums_ = nullptr;
if (pipeline_secondary_) {
oakengine_display_renderer_destroy_shader(renderer(),
pipeline_secondary_);
pipeline_secondary_ = nullptr;
}
if (texture_row_sums_) {
oakengine_display_texture_free(texture_row_sums_);
texture_row_sums_ = nullptr;
}
super::on_destroy();
}
ShaderCode HistogramScope::generate_shader_code()
ScopeShaderCode HistogramScope::generate_shader_code()
{
return ShaderCode(
return ScopeShaderCode{
FileFunctions::read_file_as_string(":/shaders/rgbhistogram.frag"),
FileFunctions::read_file_as_string(":/shaders/default.vert"));
FileFunctions::read_file_as_string(":/shaders/default.vert")};
}
void HistogramScope::draw_scope(TexturePtr managed_tex, QVariant pipeline)
void HistogramScope::draw_scope(void *managed_tex, void *pipeline)
{
float histogram_scale = 0.80f;
// This value is eyeballed for usefulness. Until we have a geometry
@@ -76,40 +85,45 @@ void HistogramScope::draw_scope(TexturePtr managed_tex, QVariant pipeline)
float histogram_base = 2.5f;
float histogram_power = 1.0f / histogram_base;
ShaderJob shader_job;
// Set up uniforms shared by both passes
oak_shader_uniform uniforms[3];
uniforms[0] = {"viewport", 1,
{static_cast<float>(width()), static_cast<float>(height())}};
uniforms[1] = {"histogram_scale", 0, {histogram_scale, 0.0f}};
uniforms[2] = {"histogram_power", 0, {histogram_power, 0.0f}};
shader_job.insert(QStringLiteral("viewport"),
NodeValue(NodeValue::k_vec2,
QVector2D(width(), height())));
shader_job.insert(QStringLiteral("histogram_scale"),
NodeValue(NodeValue::k_float, histogram_scale));
shader_job.insert(QStringLiteral("histogram_power"),
NodeValue(NodeValue::k_float, histogram_power));
// Recreate row-sums texture if size changed
bool need_recreate = false;
if (!texture_row_sums_) {
need_recreate = true;
} else if (oakengine_display_texture_width(texture_row_sums_) != width() ||
oakengine_display_texture_height(texture_row_sums_) !=
height()) {
need_recreate = true;
}
if (!texture_row_sums_ || texture_row_sums_->width() != this->width() ||
texture_row_sums_->height() != this->height()) {
if (need_recreate) {
if (texture_row_sums_) {
oakengine_display_texture_free(texture_row_sums_);
}
oak_video_params pod = {};
pod.width = width();
pod.height = height();
pod.format = managed_tex->format();
const VideoParams row_sums_params = video_params_from_pod(pod);
oakengine_display_renderer_create_texture(renderer(),
&row_sums_params, nullptr, 0,
&texture_row_sums_);
pod.format = oakengine_display_texture_format(managed_tex);
texture_row_sums_ =
oakengine_display_texture_create(renderer(), &pod, nullptr, 0);
}
// Draw managed texture to a sums texture
shader_job.insert(QStringLiteral("ove_maintex"),
NodeValue(NodeValue::k_texture,
QVariant::fromValue(managed_tex)));
renderer()->blit_to_texture(pipeline, shader_job, texture_row_sums_.get());
// Pass 1: Draw managed texture to row-sums texture
oakengine_display_renderer_blit_shader_uniforms(
renderer(), pipeline, managed_tex, uniforms, 3, texture_row_sums_,
nullptr);
// Draw sums into a histogram
shader_job.insert(QStringLiteral("ove_maintex"),
NodeValue(NodeValue::k_texture,
QVariant::fromValue(texture_row_sums_)));
renderer()->blit(pipeline_secondary_, shader_job,
texture_row_sums_->params());
// Pass 2: Draw row-sums into a histogram on screen
oak_video_params vp = get_viewport_params();
oakengine_display_renderer_blit_shader_uniforms(
renderer(), pipeline_secondary_, texture_row_sums_, uniforms, 3,
nullptr, &vp);
// Draw line overlays
QPainter p(paint_device());
@@ -135,7 +149,6 @@ void HistogramScope::draw_scope(TexturePtr managed_tex, QVariant pipeline)
float histogram_start_dim_y = ((height() - 1.0) - histogram_dim_y) / 2.0f;
float histogram_end_dim_x = (width() - 1.0) - histogram_start_dim_x;
// for (int i=0; i <= histogram_steps; i++) {
for (std::vector<float>::iterator it = histogram_increments.begin();
it != histogram_increments.end(); it++) {
histogram_lines[it - histogram_increments.begin()].setLine(
+4 -5
View File
@@ -40,16 +40,15 @@ protected slots:
virtual void on_destroy() override;
protected:
virtual ShaderCode generate_shader_code() override;
QVariant create_secondary_shader();
virtual ScopeShaderCode generate_shader_code() override;
virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline) override;
virtual void draw_scope(void *managed_tex, void *pipeline) override;
virtual void draw_scope_software(QPainter &p, const QImage &image) override;
private:
QVariant pipeline_secondary_;
TexturePtr texture_row_sums_;
void *pipeline_secondary_;
void *texture_row_sums_;
};
}
+123 -69
View File
@@ -26,9 +26,6 @@
#include "common/configwrapper.h"
#include "oakengine/display.h"
#include "oakengine/videoparams.h"
#include "render/job/colortransformjob.h"
#include "widget/viewer/vieweroutpututils.h"
#include "render/job/shaderjob.h"
namespace olive
{
@@ -37,16 +34,23 @@ namespace olive
ScopeBase::ScopeBase(QWidget *parent)
: super(parent)
, pipeline_(nullptr)
, texture_(nullptr)
, managed_tex_(nullptr)
, managed_tex_up_to_date_(false)
, software_tex_(nullptr)
, software_image_up_to_date_(false)
, local_texture_(nullptr)
{
enable_default_context_menu();
}
void ScopeBase::set_buffer(TexturePtr frame)
void ScopeBase::set_buffer(void *frame)
{
texture_ = frame;
if (texture_) {
oakengine_display_texture_free(texture_);
}
texture_ = oakengine_display_texture_retain(frame);
managed_tex_up_to_date_ = false;
software_image_up_to_date_ = false;
update();
@@ -57,20 +61,17 @@ void ScopeBase::showEvent(QShowEvent *e)
super::showEvent(e);
}
void ScopeBase::draw_scope(TexturePtr managed_tex, QVariant pipeline)
void ScopeBase::draw_scope(void *managed_tex, void *pipeline)
{
ShaderJob job;
job.insert(QStringLiteral("ove_maintex"),
NodeValue(NodeValue::k_texture,
QVariant::fromValue(managed_tex)));
renderer()->blit(pipeline, job, get_viewport_params());
oak_video_params vp = get_viewport_params();
oakengine_display_renderer_blit_shader(renderer(), pipeline, managed_tex,
&vp);
}
void ScopeBase::update_software_image()
{
if (!texture_ || texture_->is_dummy() || !renderer()) {
if (!texture_ || oakengine_display_texture_is_dummy(texture_) ||
!renderer()) {
software_image_ = QImage();
software_image_up_to_date_ = true;
return;
@@ -80,23 +81,29 @@ void ScopeBase::update_software_image()
// separate Vulkan device). The reference texture emitted by the viewer lives
// in the viewer's renderer, so we must download it to the CPU and re-upload
// it into this scope's renderer before we can sample it.
TexturePtr source_tex = texture_;
if (texture_->renderer() && texture_->renderer() != renderer()) {
FramePtr temp_frame;
oakengine_codec_frame_create(&temp_frame);
oakengine_codec_frame_set_video_params(temp_frame.get(),
&texture_->params());
oakengine_codec_frame_allocate(temp_frame.get());
oakengine_display_texture_download(texture_.get(), temp_frame->data(),
temp_frame->linesize_pixels());
void *source_tex = texture_;
void *tex_renderer = oakengine_display_texture_renderer(texture_);
if (tex_renderer && tex_renderer != renderer()) {
void *temp_frame = oakengine_codec_frame_create();
oak_video_params tex_params = {};
oakengine_display_texture_get_params(texture_, &tex_params);
oakengine_codec_frame_set_video_params(temp_frame, &tex_params);
oakengine_codec_frame_allocate(temp_frame);
oakengine_display_texture_download(
texture_, oakengine_codec_frame_data(temp_frame),
oakengine_codec_frame_linesize(temp_frame));
oakengine_display_renderer_create_texture(
renderer(), &temp_frame->video_params(), temp_frame->data(),
temp_frame->linesize_pixels(), &local_texture_);
if (local_texture_) {
oakengine_display_texture_free(local_texture_);
}
local_texture_ = oakengine_display_texture_create(
renderer(), &tex_params, oakengine_codec_frame_const_data(temp_frame),
oakengine_codec_frame_linesize(temp_frame));
oakengine_codec_frame_free(temp_frame);
source_tex = local_texture_;
}
if (!source_tex || source_tex->is_dummy()) {
if (!source_tex || oakengine_display_texture_is_dummy(source_tex)) {
software_image_ = QImage();
software_image_up_to_date_ = true;
return;
@@ -105,46 +112,60 @@ void ScopeBase::update_software_image()
const int texture_width = static_cast<int>(width() * devicePixelRatioF());
const int texture_height = static_cast<int>(height() * devicePixelRatioF());
oak_video_params pod = {};
pod.width = texture_width;
pod.height = texture_height;
pod.format = PixelFormat::u8;
const VideoParams offscreen_params(video_params_from_pod(pod));
oak_video_params offscreen_pod = {};
offscreen_pod.width = texture_width;
offscreen_pod.height = texture_height;
offscreen_pod.format = 0; // PixelFormat::u8
if (!software_tex_ || software_tex_->params() != offscreen_params) {
oakengine_display_renderer_create_texture(renderer(),
&offscreen_params, nullptr, 0,
&software_tex_);
software_buffer_.resize(
texture_width * texture_height *
oakengine_video_params_bytes_per_pixel(PixelFormat::u8,
4));
bool need_recreate = false;
if (!software_tex_) {
need_recreate = true;
} else {
oak_video_params cur = {};
oakengine_display_texture_get_params(software_tex_, &cur);
if (cur.width != offscreen_pod.width ||
cur.height != offscreen_pod.height ||
cur.format != offscreen_pod.format) {
need_recreate = true;
}
}
if (!software_tex_ || software_tex_->is_dummy()) {
if (need_recreate) {
if (software_tex_) {
oakengine_display_texture_free(software_tex_);
}
software_tex_ = oakengine_display_texture_create(
renderer(), &offscreen_pod, nullptr, 0);
software_buffer_.resize(texture_width * texture_height *
oakengine_video_params_bytes_per_pixel(0, 4));
}
if (!software_tex_ || oakengine_display_texture_is_dummy(software_tex_)) {
software_image_ = QImage();
software_image_up_to_date_ = true;
return;
}
ColorTransformJob job;
oakengine_color_transform_job_set_processor(&job, color_service().get());
job.set_input_texture(source_tex);
job.set_input_alpha_association(k_alpha_none);
job.set_clear_destination_enabled(true);
job.set_force_opaque(true);
oak_color_transform_job job = {};
job.processor = color_service().get();
job.input_texture = source_tex;
job.input_alpha_association = 0; // k_alpha_none
job.clear_destination = 1;
job.force_opaque = 1;
oakengine_display_renderer_blit_color_managed(renderer(), &job,
software_tex_.get(), nullptr);
renderer()->download_from_texture(software_tex_->id(),
software_tex_->params(),
software_buffer_.data(), 0);
software_tex_, nullptr);
int sw_id = oakengine_display_texture_id(software_tex_);
oak_video_params sw_params = {};
oakengine_display_texture_get_params(software_tex_, &sw_params);
oakengine_display_renderer_download_from_texture(
renderer(), sw_id, &sw_params, software_buffer_.data(), 0);
software_image_ = QImage(
reinterpret_cast<const uchar *>(software_buffer_.constData()),
texture_width, texture_height,
texture_width * oakengine_video_params_bytes_per_pixel(
PixelFormat::u8, 4),
texture_width * oakengine_video_params_bytes_per_pixel(0, 4),
QImage::Format_RGBA8888_Premultiplied);
software_image_.setDevicePixelRatio(devicePixelRatioF());
@@ -156,7 +177,11 @@ void ScopeBase::on_init()
super::on_init();
if (!is_backend_neutral()) {
pipeline_ = renderer()->create_native_shader(generate_shader_code());
ScopeShaderCode code = generate_shader_code();
pipeline_ = oakengine_display_renderer_create_shader(
renderer(), code.frag.toUtf8().constData(),
code.vert.isEmpty() ? nullptr
: code.vert.toUtf8().constData());
}
}
@@ -177,22 +202,36 @@ void ScopeBase::on_paint()
}
// Clear display surface
renderer()->clear_destination();
oakengine_display_renderer_clear(renderer(), 0.0, 0.0, 0.0);
if (texture_) {
// Convert reference frame to display space
if (!managed_tex_ || !managed_tex_up_to_date_ ||
managed_tex_->params() != texture_->params()) {
oakengine_display_renderer_create_texture(
renderer(), &texture_->params(), nullptr, 0, &managed_tex_);
bool need_recreate = false;
if (!managed_tex_ || !managed_tex_up_to_date_) {
need_recreate = true;
} else if (!oakengine_display_texture_params_equal(managed_tex_,
texture_)) {
need_recreate = true;
}
ColorTransformJob job;
oakengine_color_transform_job_set_processor(&job, color_service().get());
job.set_input_texture(texture_);
job.set_input_alpha_association(k_alpha_none);
if (need_recreate) {
if (managed_tex_) {
oakengine_display_texture_free(managed_tex_);
}
oak_video_params tex_params = {};
oakengine_display_texture_get_params(texture_, &tex_params);
managed_tex_ = oakengine_display_texture_create(
renderer(), &tex_params, nullptr, 0);
oak_color_transform_job job = {};
job.processor = color_service().get();
job.input_texture = texture_;
job.input_alpha_association = 0; // k_alpha_none
job.clear_destination = 0;
job.force_opaque = 0;
oakengine_display_renderer_blit_color_managed(
renderer(), &job, managed_tex_.get(), nullptr);
renderer(), &job, managed_tex_, nullptr);
managed_tex_up_to_date_ = true;
}
@@ -202,13 +241,28 @@ void ScopeBase::on_paint()
void ScopeBase::on_destroy()
{
local_texture_ = nullptr;
software_tex_ = nullptr;
if (local_texture_) {
oakengine_display_texture_free(local_texture_);
local_texture_ = nullptr;
}
if (software_tex_) {
oakengine_display_texture_free(software_tex_);
software_tex_ = nullptr;
}
software_buffer_.clear();
software_image_ = QImage();
managed_tex_ = nullptr;
texture_ = nullptr;
pipeline_.clear();
if (managed_tex_) {
oakengine_display_texture_free(managed_tex_);
managed_tex_ = nullptr;
}
if (texture_) {
oakengine_display_texture_free(texture_);
texture_ = nullptr;
}
if (pipeline_) {
oakengine_display_renderer_destroy_shader(renderer(), pipeline_);
pipeline_ = nullptr;
}
super::on_destroy();
}
+16 -10
View File
@@ -22,13 +22,19 @@
#ifndef OAK_SCOPEBASE_H
#define OAK_SCOPEBASE_H
#include "codec/frame.h"
#include "render/colorprocessor.h"
#include <QString>
#include "widget/manageddisplay/manageddisplay.h"
namespace olive
{
/** @brief Fragment + vertex shader source pair returned by scope subclasses. */
struct ScopeShaderCode {
QString frag;
QString vert;
};
class ScopeBase : public ManagedDisplayWidget {
public:
ScopeBase(QWidget *parent = nullptr);
@@ -36,7 +42,7 @@ public:
MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(ScopeBase)
public slots:
void set_buffer(TexturePtr frame);
void set_buffer(void *frame);
protected slots:
virtual void on_init() override;
@@ -48,14 +54,14 @@ protected slots:
protected:
virtual void showEvent(QShowEvent *e) override;
virtual ShaderCode generate_shader_code() = 0;
virtual ScopeShaderCode generate_shader_code() = 0;
/**
* @brief GPU-accelerated draw function used on OpenGL backends.
*
* Override this if your sub-class scope needs extra drawing.
*/
virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline);
virtual void draw_scope(void *managed_tex, void *pipeline);
/**
* @brief Software draw function used on backend-neutral paths (e.g. Vulkan).
@@ -68,20 +74,20 @@ protected:
private:
void update_software_image();
QVariant pipeline_;
void *pipeline_;
TexturePtr texture_;
void *texture_;
TexturePtr managed_tex_;
void *managed_tex_;
bool managed_tex_up_to_date_;
TexturePtr software_tex_;
void *software_tex_;
QByteArray software_buffer_;
QImage software_image_;
bool software_image_up_to_date_;
TexturePtr local_texture_;
void *local_texture_;
};
}
+28 -31
View File
@@ -23,11 +23,11 @@
#include <QPainter>
#include <QtMath>
#include <QVector2D>
#include <QVector3D>
#include "common/qtutils.h"
#include "node/node.h"
#include "common/filefunctions.h"
#include "oakengine/color.h"
#include "oakengine/display.h"
namespace olive
{
@@ -39,14 +39,14 @@ VectorscopeScope::VectorscopeScope(QWidget *parent)
{
}
ShaderCode VectorscopeScope::generate_shader_code()
ScopeShaderCode VectorscopeScope::generate_shader_code()
{
return ShaderCode(
return ScopeShaderCode{
FileFunctions::read_file_as_string(":/shaders/rgbvectorscope.frag"),
FileFunctions::read_file_as_string(":/shaders/rgbvectorscope.vert"));
FileFunctions::read_file_as_string(":/shaders/rgbvectorscope.vert")};
}
void VectorscopeScope::draw_scope(TexturePtr managed_tex, QVariant pipeline)
void VectorscopeScope::draw_scope(void *managed_tex, void *pipeline)
{
float vectorscope_scale = 0.80f;
float vectorscope_gain = 1.45f;
@@ -54,34 +54,31 @@ void VectorscopeScope::draw_scope(TexturePtr managed_tex, QVariant pipeline)
float vectorscope_intensity = 0.035f;
float vectorscope_sample_grid = 28.0f;
ShaderJob job;
job.insert(QStringLiteral("viewport"),
NodeValue(NodeValue::k_vec2, QVector2D(width(), height())));
double luma_coeffs[3] = { 0.0f, 0.0f, 0.0f };
oakengine_color_manager_default_luma_coefs(color_manager(), luma_coeffs);
job.insert(
QStringLiteral("luma_coeffs"),
NodeValue(NodeValue::k_vec3,
QVector3D(luma_coeffs[0], luma_coeffs[1], luma_coeffs[2])));
job.insert(QStringLiteral("vectorscope_scale"),
NodeValue(NodeValue::k_float, vectorscope_scale));
job.insert(QStringLiteral("vectorscope_gain"),
NodeValue(NodeValue::k_float, vectorscope_gain));
job.insert(QStringLiteral("vectorscope_point_radius"),
NodeValue(NodeValue::k_float, vectorscope_point_radius));
job.insert(QStringLiteral("vectorscope_intensity"),
NodeValue(NodeValue::k_float, vectorscope_intensity));
job.insert(QStringLiteral("vectorscope_sample_grid"),
NodeValue(NodeValue::k_float, vectorscope_sample_grid));
oak_shader_uniform uniforms[7];
uniforms[0] = {"viewport", 1,
{static_cast<float>(width()), static_cast<float>(height()),
0.0f, 0.0f}};
uniforms[1] = {"luma_coeffs", 3,
{static_cast<float>(luma_coeffs[0]),
static_cast<float>(luma_coeffs[1]),
static_cast<float>(luma_coeffs[2]), 0.0f}};
uniforms[2] = {"vectorscope_scale", 0,
{vectorscope_scale, 0.0f, 0.0f, 0.0f}};
uniforms[3] = {"vectorscope_gain", 0,
{vectorscope_gain, 0.0f, 0.0f, 0.0f}};
uniforms[4] = {"vectorscope_point_radius", 0,
{vectorscope_point_radius, 0.0f, 0.0f, 0.0f}};
uniforms[5] = {"vectorscope_intensity", 0,
{vectorscope_intensity, 0.0f, 0.0f, 0.0f}};
uniforms[6] = {"vectorscope_sample_grid", 0,
{vectorscope_sample_grid, 0.0f, 0.0f, 0.0f}};
job.insert(QStringLiteral("ove_maintex"),
NodeValue(NodeValue::k_texture,
QVariant::fromValue(managed_tex)));
renderer()->blit(pipeline, job, get_viewport_params());
oak_video_params vp = get_viewport_params();
oakengine_display_renderer_blit_shader_uniforms(
renderer(), pipeline, managed_tex, uniforms, 7, nullptr, &vp);
QPainter p(paint_device());
QFont font = p.font();
+2 -2
View File
@@ -35,9 +35,9 @@ public:
MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(VectorscopeScope)
protected:
virtual ShaderCode generate_shader_code() override;
virtual ScopeShaderCode generate_shader_code() override;
virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline) override;
virtual void draw_scope(void *managed_tex, void *pipeline) override;
virtual void draw_scope_software(QPainter &p, const QImage &image) override;
};
+22 -33
View File
@@ -26,13 +26,12 @@
#include <QMenu>
#include <QPainter>
#include <QtMath>
#include <QDebug>
#include <QVector2D>
#include <QVector3D>
#include "common/qtutils.h"
#include "common/configwrapper.h"
#include "node/node.h"
#include "common/filefunctions.h"
#include "oakengine/color.h"
#include "oakengine/display.h"
namespace olive
{
@@ -62,46 +61,36 @@ void WaveformScope::contextMenuEvent(QContextMenuEvent *event)
menu.exec(event->globalPos());
}
ShaderCode WaveformScope::generate_shader_code()
ScopeShaderCode WaveformScope::generate_shader_code()
{
return ShaderCode(
return ScopeShaderCode{
FileFunctions::read_file_as_string(":/shaders/rgbwaveform.frag"),
FileFunctions::read_file_as_string(":/shaders/rgbwaveform.vert"));
FileFunctions::read_file_as_string(":/shaders/rgbwaveform.vert")};
}
void WaveformScope::draw_scope(TexturePtr managed_tex, QVariant pipeline)
void WaveformScope::draw_scope(void *managed_tex, void *pipeline)
{
float waveform_scale = 0.80f;
// Draw waveform through shader
ShaderJob job;
// Set viewport size
job.insert(QStringLiteral("viewport"),
NodeValue(NodeValue::k_vec2, QVector2D(width(), height())));
// Set luma coefficients
double luma_coeffs[3] = { 0.0f, 0.0f, 0.0f };
oakengine_color_manager_default_luma_coefs(color_manager(), luma_coeffs);
job.insert(
QStringLiteral("luma_coeffs"),
NodeValue(NodeValue::k_vec3,
QVector3D(luma_coeffs[0], luma_coeffs[1], luma_coeffs[2])));
// Scale of the waveform relative to the viewport surface.
job.insert(QStringLiteral("waveform_scale"),
NodeValue(NodeValue::k_float, waveform_scale));
// Set up uniforms
oak_shader_uniform uniforms[4];
uniforms[0] = {"viewport", 1,
{static_cast<float>(width()), static_cast<float>(height()),
0.0f, 0.0f}};
uniforms[1] = {"luma_coeffs", 3,
{static_cast<float>(luma_coeffs[0]),
static_cast<float>(luma_coeffs[1]),
static_cast<float>(luma_coeffs[2]), 0.0f}};
uniforms[2] = {"waveform_scale", 0, {waveform_scale, 0.0f, 0.0f, 0.0f}};
uniforms[3] = {"parade_mode", 0,
{parade_mode_ ? 1.0f : 0.0f, 0.0f, 0.0f, 0.0f}};
// Overlay vs. RGB parade display
job.insert(QStringLiteral("parade_mode"),
NodeValue(NodeValue::k_float, parade_mode_ ? 1.0f : 0.0f));
// Insert source texture
job.insert(QStringLiteral("ove_maintex"),
NodeValue(NodeValue::k_texture,
QVariant::fromValue(managed_tex)));
renderer()->blit(pipeline, job, get_viewport_params());
oak_video_params vp = get_viewport_params();
oakengine_display_renderer_blit_shader_uniforms(
renderer(), pipeline, managed_tex, uniforms, 4, nullptr, &vp);
float waveform_dim_x = ceil((width() - 1.0) * waveform_scale);
float waveform_dim_y = ceil((height() - 1.0) * waveform_scale);
+2 -2
View File
@@ -42,9 +42,9 @@ public:
void set_parade_mode(bool enabled);
protected:
virtual ShaderCode generate_shader_code() override;
virtual ScopeShaderCode generate_shader_code() override;
virtual void draw_scope(TexturePtr managed_tex, QVariant pipeline) override;
virtual void draw_scope(void *managed_tex, void *pipeline) override;
virtual void draw_scope_software(QPainter &p, const QImage &image) override;