Fix #138868: Slow start up on when using certain OCIO config
Regression caused by #138433 Somehow the lazy nature of the is_linear and is_srgb got lost in the refactor and the fields were greedily initialized on startup and it is not a cheap operation. Pull Request: https://projects.blender.org/blender/blender/pulls/138945
This commit is contained in:
committed by
Sergey Sharybin
parent
906a27bdb2
commit
a3748b549b
@@ -131,7 +131,18 @@ LibOCIOColorSpace::LibOCIOColorSpace(const int index,
|
||||
this->index = index;
|
||||
|
||||
is_inveetible_ = color_space_is_invertible(ocio_color_space);
|
||||
color_space_is_builtin(ocio_config, ocio_color_space, is_scene_linear_, is_srgb_);
|
||||
}
|
||||
|
||||
bool LibOCIOColorSpace::is_scene_linear() const
|
||||
{
|
||||
ensure_srgb_scene_linear_info();
|
||||
return is_scene_linear_;
|
||||
}
|
||||
|
||||
bool LibOCIOColorSpace::is_srgb() const
|
||||
{
|
||||
ensure_srgb_scene_linear_info();
|
||||
return is_srgb_;
|
||||
}
|
||||
|
||||
const CPUProcessor *LibOCIOColorSpace::get_to_scene_linear_cpu_processor() const
|
||||
@@ -158,6 +169,15 @@ const CPUProcessor *LibOCIOColorSpace::get_from_scene_linear_cpu_processor() con
|
||||
});
|
||||
}
|
||||
|
||||
void LibOCIOColorSpace::ensure_srgb_scene_linear_info() const
|
||||
{
|
||||
if (is_info_cached_) {
|
||||
return;
|
||||
}
|
||||
color_space_is_builtin(ocio_config_, ocio_color_space_, is_scene_linear_, is_srgb_);
|
||||
is_info_cached_ = true;
|
||||
}
|
||||
|
||||
} // namespace blender::ocio
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,8 +24,11 @@ class LibOCIOColorSpace : public ColorSpace {
|
||||
std::string clean_description_;
|
||||
bool is_inveetible_ = false;
|
||||
|
||||
bool is_scene_linear_ = false;
|
||||
bool is_srgb_ = false;
|
||||
/* Mutable because they are lazily initialized and cached from the is_scene_linear() and
|
||||
* is_srgb(). */
|
||||
mutable bool is_info_cached_ = false;
|
||||
mutable bool is_scene_linear_ = false;
|
||||
mutable bool is_srgb_ = false;
|
||||
|
||||
CPUProcessorCache to_scene_linear_cpu_processor_;
|
||||
CPUProcessorCache from_scene_linear_cpu_processor_;
|
||||
@@ -50,14 +53,8 @@ class LibOCIOColorSpace : public ColorSpace {
|
||||
return is_inveetible_;
|
||||
}
|
||||
|
||||
bool is_scene_linear() const override
|
||||
{
|
||||
return is_scene_linear_;
|
||||
}
|
||||
bool is_srgb() const override
|
||||
{
|
||||
return is_srgb_;
|
||||
}
|
||||
bool is_scene_linear() const override;
|
||||
bool is_srgb() const override;
|
||||
|
||||
bool is_data() const override
|
||||
{
|
||||
@@ -68,6 +65,9 @@ class LibOCIOColorSpace : public ColorSpace {
|
||||
const CPUProcessor *get_from_scene_linear_cpu_processor() const override;
|
||||
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("LibOCIOColorSpace");
|
||||
|
||||
private:
|
||||
void ensure_srgb_scene_linear_info() const;
|
||||
};
|
||||
|
||||
} // namespace blender::ocio
|
||||
|
||||
Reference in New Issue
Block a user