尝试修复粉紫屏未果

This commit is contained in:
2026-01-16 21:11:24 +08:00
parent 3f774dfa53
commit e851653fa3
30 changed files with 1377 additions and 238 deletions
+30 -2
View File
@@ -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_);
}