nodes: further optimized merge node to passthrough RGB blend textures
This commit is contained in:
@@ -27,23 +27,29 @@ namespace olive {
|
||||
|
||||
class GenerateJob : public AcceleratedJob {
|
||||
public:
|
||||
enum AlphaChannelSetting {
|
||||
kAlphaAuto,
|
||||
kAlphaForceOn,
|
||||
kAlphaForceOff
|
||||
};
|
||||
|
||||
GenerateJob()
|
||||
{
|
||||
alpha_channel_required_ = false;
|
||||
alpha_channel_required_ = kAlphaAuto;
|
||||
}
|
||||
|
||||
bool GetAlphaChannelRequired() const
|
||||
AlphaChannelSetting GetAlphaChannelRequired() const
|
||||
{
|
||||
return alpha_channel_required_;
|
||||
}
|
||||
|
||||
void SetAlphaChannelRequired(bool e)
|
||||
void SetAlphaChannelRequired(AlphaChannelSetting e)
|
||||
{
|
||||
alpha_channel_required_ = e;
|
||||
}
|
||||
|
||||
private:
|
||||
bool alpha_channel_required_;
|
||||
AlphaChannelSetting alpha_channel_required_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -456,22 +456,7 @@ QVariant RenderProcessor::ProcessShader(const Node *node, const TimeRange &range
|
||||
|
||||
VideoParams tex_params = ticket_->property("vparam").value<VideoParams>();
|
||||
|
||||
bool input_textures_have_alpha = false;
|
||||
for (auto it=job.GetValues().cbegin(); it!=job.GetValues().cend(); it++) {
|
||||
if (it.value().type() == NodeValue::kTexture) {
|
||||
TexturePtr tex = it.value().data().value<TexturePtr>();
|
||||
if (tex && tex->channel_count() == VideoParams::kRGBAChannelCount) {
|
||||
input_textures_have_alpha = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (input_textures_have_alpha || job.GetAlphaChannelRequired()) {
|
||||
tex_params.set_channel_count(VideoParams::kRGBAChannelCount);
|
||||
} else {
|
||||
tex_params.set_channel_count(VideoParams::kRGBChannelCount);
|
||||
}
|
||||
tex_params.set_channel_count(GetChannelCountFromJob(job));
|
||||
|
||||
TexturePtr destination = render_ctx_->CreateTexture(tex_params);
|
||||
|
||||
@@ -521,12 +506,7 @@ QVariant RenderProcessor::ProcessFrameGeneration(const Node *node, const Generat
|
||||
FramePtr frame = Frame::Create();
|
||||
|
||||
VideoParams frame_params = ticket_->property("vparam").value<VideoParams>();
|
||||
if (job.GetAlphaChannelRequired()) {
|
||||
frame_params.set_channel_count(VideoParams::kRGBAChannelCount);
|
||||
} else {
|
||||
frame_params.set_channel_count(VideoParams::kRGBChannelCount);
|
||||
}
|
||||
|
||||
frame_params.set_channel_count(GetChannelCountFromJob(job));
|
||||
frame->set_video_params(frame_params);
|
||||
frame->allocate();
|
||||
|
||||
|
||||
@@ -28,12 +28,16 @@ const Texture::Interpolation Texture::kDefaultInterpolation = Texture::kMipmappe
|
||||
|
||||
Texture::~Texture()
|
||||
{
|
||||
renderer_->DestroyNativeTexture(id_);
|
||||
if (renderer_) {
|
||||
renderer_->DestroyNativeTexture(id_);
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::Upload(void *data, int linesize)
|
||||
{
|
||||
renderer_->UploadToTexture(this, data, linesize);
|
||||
if (renderer_) {
|
||||
renderer_->UploadToTexture(this, data, linesize);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,19 @@ public:
|
||||
|
||||
static const Interpolation kDefaultInterpolation;
|
||||
|
||||
/**
|
||||
* @brief Construct a dummy texture with no renderer backend
|
||||
*/
|
||||
Texture(const VideoParams& param) :
|
||||
renderer_(nullptr),
|
||||
params_(param),
|
||||
type_(k2D)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a real texture linked to a renderer backend
|
||||
*/
|
||||
Texture(Renderer* renderer, const QVariant& native, const VideoParams& param, Type type) :
|
||||
renderer_(renderer),
|
||||
params_(param),
|
||||
@@ -67,6 +80,11 @@ public:
|
||||
|
||||
void Upload(void* data, int linesize);
|
||||
|
||||
bool IsDummy() const
|
||||
{
|
||||
return !renderer_;
|
||||
}
|
||||
|
||||
int width() const
|
||||
{
|
||||
return params_.effective_width();
|
||||
|
||||
Reference in New Issue
Block a user