forked from blender/blender
Recreate PreviewEngine when render_delegate_name is changed #36
@ -1,6 +1,9 @@
|
|||||||
/* SPDX-License-Identifier: Apache-2.0
|
/* SPDX-License-Identifier: Apache-2.0
|
||||||
* Copyright 2011-2022 Blender Foundation */
|
* Copyright 2011-2022 Blender Foundation */
|
||||||
|
|
||||||
|
#include <pxr/imaging/hd/rendererPluginRegistry.h>
|
||||||
|
#include <pxr/imaging/hgi/tokens.h>
|
||||||
|
|
||||||
#include "DEG_depsgraph_query.h"
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
#include "BLI_timer.h"
|
#include "BLI_timer.h"
|
||||||
@ -14,16 +17,16 @@ const double LIFETIME = 180.0;
|
|||||||
std::unique_ptr<PreviewEngine> PreviewEngine::instance_;
|
std::unique_ptr<PreviewEngine> PreviewEngine::instance_;
|
||||||
|
|
||||||
PreviewEngine *PreviewEngine::get_instance(RenderEngine *bl_engine,
|
PreviewEngine *PreviewEngine::get_instance(RenderEngine *bl_engine,
|
||||||
const std::string &render_delegate_id)
|
const std::string &render_delegate_name)
|
||||||
{
|
{
|
||||||
if (!instance_) {
|
if (!instance_) {
|
||||||
instance_ = std::make_unique<PreviewEngine>(bl_engine, render_delegate_id);
|
instance_ = std::make_unique<PreviewEngine>(bl_engine, render_delegate_name);
|
||||||
}
|
}
|
||||||
if (BLI_timer_is_registered((uintptr_t)instance_.get())) {
|
if (BLI_timer_is_registered((uintptr_t)instance_.get())) {
|
||||||
/* Unregister timer while PreviewEngine is working */
|
/* Unregister timer while PreviewEngine is working */
|
||||||
BLI_timer_unregister((uintptr_t)instance_.get());
|
BLI_timer_unregister((uintptr_t)instance_.get());
|
||||||
}
|
}
|
||||||
instance_->update(bl_engine, render_delegate_id);
|
instance_->update(bl_engine, render_delegate_name);
|
||||||
|
|
||||||
return instance_.get();
|
return instance_.get();
|
||||||
}
|
}
|
||||||
@ -96,10 +99,13 @@ double PreviewEngine::free_instance(uintptr_t uuid, void *user_data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewEngine::update(RenderEngine *bl_engine, const std::string &render_delegate_id)
|
void PreviewEngine::update(RenderEngine *bl_engine, const std::string &render_delegate_name)
|
||||||
{
|
{
|
||||||
this->bl_engine_ = bl_engine;
|
bl_engine_ = bl_engine;
|
||||||
/* TODO: recreate render_delegate when render_delegate_id is changed */
|
if (render_delegate_name != render_delegate_name_) {
|
||||||
|
render_delegate_->Stop();
|
||||||
|
instance_.reset(new PreviewEngine(bl_engine, render_delegate_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewEngine::update_render_result(std::vector<float> &pixels)
|
void PreviewEngine::update_render_result(std::vector<float> &pixels)
|
||||||
|
@ -12,7 +12,7 @@ class PreviewEngine : public FinalEngine {
|
|||||||
using FinalEngine::FinalEngine;
|
using FinalEngine::FinalEngine;
|
||||||
|
|
||||||
static PreviewEngine *get_instance(RenderEngine *bl_engine,
|
static PreviewEngine *get_instance(RenderEngine *bl_engine,
|
||||||
const std::string &render_delegate_id);
|
const std::string &render_delegate_name);
|
||||||
static void schedule_free();
|
static void schedule_free();
|
||||||
|
|
||||||
void sync(Depsgraph *depsgraph,
|
void sync(Depsgraph *depsgraph,
|
||||||
@ -25,7 +25,7 @@ class PreviewEngine : public FinalEngine {
|
|||||||
static double free_instance(uintptr_t uuid, void *user_data);
|
static double free_instance(uintptr_t uuid, void *user_data);
|
||||||
static std::unique_ptr<PreviewEngine> instance_;
|
static std::unique_ptr<PreviewEngine> instance_;
|
||||||
|
|
||||||
void update(RenderEngine *bl_engine, const std::string &render_delegate_id);
|
void update(RenderEngine *bl_engine, const std::string &render_delegate_name);
|
||||||
void update_render_result(std::vector<float> &pixels);
|
void update_render_result(std::vector<float> &pixels);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user