2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2011 Blender Foundation. */
|
2012-06-13 12:34:56 +00:00
|
|
|
|
2014-04-15 16:06:12 +02:00
|
|
|
#include "COM_SingleThreadedOperation.h"
|
2012-06-13 12:34:56 +00:00
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2020-08-07 15:58:58 +02:00
|
|
|
SingleThreadedOperation::SingleThreadedOperation()
|
2012-06-13 12:34:56 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
cached_instance_ = nullptr;
|
2021-10-13 23:01:53 +02:00
|
|
|
flags_.complex = true;
|
|
|
|
|
flags_.single_threaded = true;
|
2012-06-13 12:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void SingleThreadedOperation::init_execution()
|
2012-06-13 12:34:56 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
init_mutex();
|
2012-06-13 12:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void SingleThreadedOperation::execute_pixel(float output[4], int x, int y, void * /*data*/)
|
2012-06-13 12:34:56 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
cached_instance_->read_no_check(output, x, y);
|
2012-06-13 12:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void SingleThreadedOperation::deinit_execution()
|
2012-06-13 12:34:56 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
deinit_mutex();
|
|
|
|
|
if (cached_instance_) {
|
|
|
|
|
delete cached_instance_;
|
|
|
|
|
cached_instance_ = nullptr;
|
2012-06-13 12:34:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void *SingleThreadedOperation::initialize_tile_data(rcti *rect)
|
2012-06-13 12:34:56 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
if (cached_instance_) {
|
|
|
|
|
return cached_instance_;
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2018-06-17 17:05:29 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
lock_mutex();
|
|
|
|
|
if (cached_instance_ == nullptr) {
|
2012-06-13 12:34:56 +00:00
|
|
|
//
|
2021-10-13 23:01:15 +02:00
|
|
|
cached_instance_ = create_memory_buffer(rect);
|
2012-06-13 12:34:56 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
unlock_mutex();
|
|
|
|
|
return cached_instance_;
|
2012-06-13 12:34:56 +00:00
|
|
|
}
|
2021-03-23 17:12:27 +01:00
|
|
|
|
|
|
|
|
} // namespace blender::compositor
|