尝试修复粉紫屏未果
This commit is contained in:
@@ -74,7 +74,7 @@ void NodeParamViewContext::RemoveNode(Node *node, Node *ctx)
|
||||
|
||||
if (item->GetNode() == node && item->GetContext() == ctx) {
|
||||
emit AboutToDeleteItem(item);
|
||||
delete item;
|
||||
dock_area_->RemoveItem(item);
|
||||
it = items_.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
@@ -89,7 +89,7 @@ void NodeParamViewContext::RemoveNodesWithContext(Node *ctx)
|
||||
|
||||
if (item->GetContext() == ctx) {
|
||||
emit AboutToDeleteItem(item);
|
||||
delete item;
|
||||
dock_area_->RemoveItem(item);
|
||||
it = items_.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
|
||||
@@ -47,4 +47,14 @@ void NodeParamViewDockArea::AddItem(QDockWidget *item)
|
||||
addDockWidget(Qt::LeftDockWidgetArea, item);
|
||||
}
|
||||
|
||||
void NodeParamViewDockArea::RemoveItem(QDockWidget *item)
|
||||
{
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
removeDockWidget(item);
|
||||
item->setParent(nullptr);
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
virtual QMenu *createPopupMenu() override;
|
||||
|
||||
void AddItem(QDockWidget *item);
|
||||
void RemoveItem(QDockWidget *item);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -110,12 +110,22 @@ void NodeParamViewWidgetBridge::CreateWidgets()
|
||||
CreateSliders<FloatSlider>(GetSliderCount(t), parent);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kCombo: {
|
||||
case NodeValue::kCombo:
|
||||
case NodeValue::kStrCombo: {
|
||||
QComboBox *combobox = new QComboBox(parent);
|
||||
|
||||
QStringList items = GetInnerInput().GetComboBoxStrings();
|
||||
foreach (const QString &s, items) {
|
||||
combobox->addItem(s);
|
||||
QStringList values =
|
||||
GetInnerInput().GetProperty("combo_value_str").toStringList();
|
||||
const bool use_value_data =
|
||||
(t == NodeValue::kStrCombo) && !values.isEmpty();
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
const QString &label = items.at(i);
|
||||
if (use_value_data && i < values.size()) {
|
||||
combobox->addItem(label, values.at(i));
|
||||
} else {
|
||||
combobox->addItem(label);
|
||||
}
|
||||
}
|
||||
|
||||
widgets_.append(combobox);
|
||||
@@ -378,6 +388,16 @@ void NodeParamViewWidgetBridge::WidgetCallback()
|
||||
SetInputValue(index, 0);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kStrCombo: {
|
||||
QComboBox *cb = static_cast<QComboBox *>(widgets_.first());
|
||||
const QVariant data = cb->currentData();
|
||||
if (data.isValid()) {
|
||||
SetInputValue(data.toString(), 0);
|
||||
} else {
|
||||
SetInputValue(cb->currentText(), 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NodeValue::kBezier: {
|
||||
// Widget is a FloatSlider (child of BezierWidget)
|
||||
BezierWidget *bw = static_cast<BezierWidget *>(widgets_.first());
|
||||
@@ -561,6 +581,22 @@ void NodeParamViewWidgetBridge::UpdateWidgetValues()
|
||||
cb->blockSignals(false);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kStrCombo: {
|
||||
QComboBox *cb = static_cast<QComboBox *>(widgets_.first());
|
||||
cb->blockSignals(true);
|
||||
const QString current =
|
||||
GetInnerInput().GetValueAtTime(node_time).toString();
|
||||
for (int i = 0; i < cb->count(); ++i) {
|
||||
const QVariant data = cb->itemData(i);
|
||||
if ((data.isValid() && data.toString() == current) ||
|
||||
(!data.isValid() && cb->itemText(i) == current)) {
|
||||
cb->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
cb->blockSignals(false);
|
||||
break;
|
||||
}
|
||||
case NodeValue::kBezier: {
|
||||
BezierWidget *bw = static_cast<BezierWidget *>(widgets_.first());
|
||||
bw->SetValue(GetInnerInput().GetValueAtTime(node_time).value<Bezier>());
|
||||
@@ -772,7 +808,7 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key,
|
||||
}
|
||||
|
||||
// ComboBox strings changing
|
||||
if (data_type == NodeValue::kCombo) {
|
||||
if (data_type == NodeValue::kCombo || data_type == NodeValue::kStrCombo) {
|
||||
if (key == QStringLiteral("combo_str")) {
|
||||
QComboBox *cb = static_cast<QComboBox *>(widgets_.first());
|
||||
|
||||
@@ -784,14 +820,23 @@ void NodeParamViewWidgetBridge::SetProperty(const QString &key,
|
||||
cb->clear();
|
||||
|
||||
QStringList items = value.toStringList();
|
||||
QStringList values =
|
||||
GetInnerInput().GetProperty("combo_value_str").toStringList();
|
||||
const bool use_value_data =
|
||||
(data_type == NodeValue::kStrCombo) && !values.isEmpty();
|
||||
int index = 0;
|
||||
foreach (const QString &s, items) {
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
const QString &s = items.at(i);
|
||||
if (s.isEmpty()) {
|
||||
cb->insertSeparator(cb->count());
|
||||
cb->setItemData(cb->count() - 1, -1);
|
||||
} else {
|
||||
cb->addItem(s, index);
|
||||
index++;
|
||||
if (use_value_data && i < values.size()) {
|
||||
cb->addItem(s, values.at(i));
|
||||
} else {
|
||||
cb->addItem(s, index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1270,6 +1270,7 @@ RenderTicketWatcher *ViewerWidget::RequestNextFrameForQueue(bool increment)
|
||||
}
|
||||
|
||||
watcher = new RenderTicketWatcher();
|
||||
watcher->setProperty("start", QDateTime::currentMSecsSinceEpoch());
|
||||
watcher->setProperty("time", QVariant::fromValue(next_time));
|
||||
DetectMulticamNode(next_time);
|
||||
connect(watcher, &RenderTicketWatcher::Finished, this,
|
||||
@@ -1283,6 +1284,10 @@ RenderTicketWatcher *ViewerWidget::RequestNextFrameForQueue(bool increment)
|
||||
|
||||
RenderTicketPtr ViewerWidget::GetFrame(const rational &t)
|
||||
{
|
||||
if (IsPlaying() || prequeuing_video_) {
|
||||
return GetSingleFrame(t);
|
||||
}
|
||||
|
||||
QString cache_fn =
|
||||
GetConnectedNode()->video_frame_cache()->GetValidCacheFilename(t);
|
||||
|
||||
@@ -1447,21 +1452,45 @@ void ViewerWidget::RendererGeneratedFrameForQueue()
|
||||
|
||||
if (watcher->HasResult()) {
|
||||
QVariant frame = watcher->Get();
|
||||
bool drop_frame = false;
|
||||
|
||||
// Ignore this signal if we've paused now
|
||||
if (IsPlaying() || prequeuing_video_) {
|
||||
const qint64 start_ms =
|
||||
watcher->property("start").toLongLong();
|
||||
const qint64 now_ms =
|
||||
QDateTime::currentMSecsSinceEpoch();
|
||||
const int playback_step = qMax(1, qAbs(playback_speed_));
|
||||
const double frame_interval_ms = qMax(
|
||||
1.0,
|
||||
timebase().toDouble() * 1000.0 /
|
||||
static_cast<double>(playback_step));
|
||||
if (start_ms > 0 &&
|
||||
(now_ms - start_ms) > frame_interval_ms) {
|
||||
drop_frame = true;
|
||||
}
|
||||
|
||||
rational ts = watcher->property("time").value<rational>();
|
||||
|
||||
foreach (ViewerDisplayWidget *dw, playback_devices_) {
|
||||
QVariant push;
|
||||
if (dynamic_cast<MulticamDisplay *>(dw)) {
|
||||
push =
|
||||
watcher->GetTicket()->property("multicam_output");
|
||||
} else {
|
||||
push = frame;
|
||||
}
|
||||
if (!drop_frame) {
|
||||
foreach (ViewerDisplayWidget *dw, playback_devices_) {
|
||||
const bool is_multicam =
|
||||
dynamic_cast<MulticamDisplay *>(dw);
|
||||
QVariant push;
|
||||
if (is_multicam) {
|
||||
push = watcher->GetTicket()->property(
|
||||
"multicam_output");
|
||||
if (!push.isValid() || push.isNull()) {
|
||||
// Fall back to the primary frame when multicam isn't available.
|
||||
push = frame;
|
||||
}
|
||||
} else {
|
||||
push = frame;
|
||||
}
|
||||
|
||||
dw->queue()->AppendTimewise({ ts, push }, playback_speed_);
|
||||
dw->queue()->AppendTimewise({ ts, push },
|
||||
playback_speed_);
|
||||
}
|
||||
}
|
||||
|
||||
if (prequeuing_video_) {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "config/config.h"
|
||||
#include "core.h"
|
||||
#include "node/block/subtitle/subtitle.h"
|
||||
#include "codec/frame.h"
|
||||
#include "node/gizmo/path.h"
|
||||
#include "node/gizmo/point.h"
|
||||
#include "node/gizmo/polygon.h"
|
||||
@@ -401,8 +402,35 @@ void ViewerDisplayWidget::OnPaint()
|
||||
texture_->Upload(frame->data(), frame->linesize_pixels());
|
||||
}
|
||||
} else if (TexturePtr texture = load_frame_.value<TexturePtr>()) {
|
||||
// This is a GPU texture, switch to it directly
|
||||
texture_ = texture;
|
||||
// This is a GPU texture, switch to it directly when possible.
|
||||
if (texture && texture->renderer() &&
|
||||
texture->renderer() != renderer()) {
|
||||
bool copied = false;
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
if (ctx) {
|
||||
QOpenGLFunctions *funcs = ctx->functions();
|
||||
GLuint tex_id = texture->id().value<GLuint>();
|
||||
if (funcs && tex_id && funcs->glIsTexture(tex_id)) {
|
||||
FramePtr frame = Frame::Create();
|
||||
frame->set_video_params(texture->params());
|
||||
if (frame->allocate()) {
|
||||
renderer()->DownloadFromTexture(
|
||||
texture->id(), texture->params(),
|
||||
frame->data(), frame->linesize_pixels());
|
||||
texture_ = renderer()->CreateTexture(
|
||||
frame->video_params(), frame->data(),
|
||||
frame->linesize_pixels());
|
||||
copied = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!copied) {
|
||||
texture_ = texture;
|
||||
}
|
||||
} else {
|
||||
texture_ = texture;
|
||||
}
|
||||
} else {
|
||||
texture_ = LoadCustomTextureFromFrame(load_frame_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user