From 3ead9b2b3605580554cc330d2d2525f405e9c779 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 30 Mar 2021 08:23:09 +0200 Subject: Cleanup: Replace virtual methods with bitflags. --- .../compositor/intern/COM_ExecutionGroup.cc | 4 +-- .../blender/compositor/intern/COM_NodeOperation.h | 41 ++++++++++------------ .../compositor/intern/COM_NodeOperationBuilder.cc | 13 +++---- .../intern/COM_SingleThreadedOperation.cc | 1 + .../intern/COM_SingleThreadedOperation.h | 5 --- 5 files changed, 28 insertions(+), 36 deletions(-) (limited to 'source/blender/compositor/intern') diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index f44f6e952fb..87c9e6e8a69 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -106,7 +106,7 @@ bool ExecutionGroup::addOperation(NodeOperation *operation) !operation->get_flags().is_write_buffer_operation) { m_flags.complex = operation->get_flags().complex; m_flags.open_cl = operation->get_flags().open_cl; - m_flags.single_threaded = operation->isSingleThreaded(); + m_flags.single_threaded = operation->get_flags().single_threaded; m_flags.initialized = true; } @@ -191,7 +191,7 @@ blender::Array ExecutionGroup::determine_chunk_execution_order() c float centerY = 0.5f; ChunkOrdering order_type = ChunkOrdering::Default; - if (operation->isViewerOperation()) { + if (operation->get_flags().is_viewer_operation) { ViewerOperation *viewer = (ViewerOperation *)operation; centerX = viewer->getCenterX(); centerY = viewer->getCenterY(); diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 6ad97e5eba6..1a299160cee 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -182,6 +182,8 @@ struct NodeOperationFlags { */ bool open_cl : 1; + bool single_threaded : 1; + /** * Does the operation needs a viewer border. * Basically, setting border need to happen for only operations @@ -210,10 +212,22 @@ struct NodeOperationFlags { bool is_set_operation : 1; bool is_write_buffer_operation : 1; bool is_read_buffer_operation : 1; + bool is_proxy_operation : 1; + bool is_viewer_operation : 1; + bool is_preview_operation : 1; + + /** + * When set additional data conversion operations are added to + * convert the data. SocketProxyOperation don't always need to do data conversions. + * + * By default data conversions are enabled. + */ + bool use_datatype_conversion : 1; NodeOperationFlags() { complex = false; + single_threaded = false; open_cl = false; use_render_border = false; use_viewer_border = false; @@ -221,6 +235,10 @@ struct NodeOperationFlags { is_set_operation = false; is_read_buffer_operation = false; is_write_buffer_operation = false; + is_proxy_operation = false; + is_viewer_operation = false; + is_preview_operation = false; + use_datatype_conversion = true; } }; @@ -330,11 +348,6 @@ class NodeOperation { return false; } - virtual int isSingleThreaded() - { - return false; - } - void setbNodeTree(const bNodeTree *tree) { this->m_btree = tree; @@ -442,24 +455,6 @@ class NodeOperation { return CompositorPriority::Low; } - virtual bool isViewerOperation() const - { - return false; - } - virtual bool isPreviewOperation() const - { - return false; - } - virtual bool isProxyOperation() const - { - return false; - } - - virtual bool useDatatypeConversion() const - { - return true; - } - inline bool isBraked() const { return this->m_btree->test_break(this->m_btree->tbh); diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index 24b72fa737a..fdd48da3fb4 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -256,7 +256,8 @@ void NodeOperationBuilder::add_datatype_conversions() /* proxy operations can skip data type conversion */ NodeOperation *from_op = &link.from()->getOperation(); NodeOperation *to_op = &link.to()->getOperation(); - if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion())) { + if (!(from_op->get_flags().use_datatype_conversion || + to_op->get_flags().use_datatype_conversion)) { continue; } @@ -352,8 +353,8 @@ void NodeOperationBuilder::resolve_proxies() blender::Vector proxy_links; for (const Link &link : m_links) { /* don't replace links from proxy to proxy, since we may need them for replacing others! */ - if (link.from()->getOperation().isProxyOperation() && - !link.to()->getOperation().isProxyOperation()) { + if (link.from()->getOperation().get_flags().is_proxy_operation && + !link.to()->getOperation().get_flags().is_proxy_operation) { proxy_links.append(link); } } @@ -364,7 +365,7 @@ void NodeOperationBuilder::resolve_proxies() do { /* walk upstream bypassing the proxy operation */ from = from->getOperation().getInputSocket(0)->getLink(); - } while (from && from->getOperation().isProxyOperation()); + } while (from && from->getOperation().get_flags().is_proxy_operation); removeInputLink(to); /* we may not have a final proxy input link, @@ -380,7 +381,7 @@ void NodeOperationBuilder::determineResolutions() { /* determine all resolutions of the operations (Width/Height) */ for (NodeOperation *op : m_operations) { - if (op->isOutputOperation(m_context->isRendering()) && !op->isPreviewOperation()) { + if (op->isOutputOperation(m_context->isRendering()) && !op->get_flags().is_preview_operation) { unsigned int resolution[2] = {0, 0}; unsigned int preferredResolution[2] = {0, 0}; op->determineResolution(resolution, preferredResolution); @@ -389,7 +390,7 @@ void NodeOperationBuilder::determineResolutions() } for (NodeOperation *op : m_operations) { - if (op->isOutputOperation(m_context->isRendering()) && op->isPreviewOperation()) { + if (op->isOutputOperation(m_context->isRendering()) && op->get_flags().is_preview_operation) { unsigned int resolution[2] = {0, 0}; unsigned int preferredResolution[2] = {0, 0}; op->determineResolution(resolution, preferredResolution); diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.cc b/source/blender/compositor/intern/COM_SingleThreadedOperation.cc index c5e4c7ee9fd..01be6e1afed 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedOperation.cc +++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cc @@ -24,6 +24,7 @@ SingleThreadedOperation::SingleThreadedOperation() { this->m_cachedInstance = nullptr; flags.complex = true; + flags.single_threaded = true; } void SingleThreadedOperation::initExecution() diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.h b/source/blender/compositor/intern/COM_SingleThreadedOperation.h index 1f741578a95..9945f938ff9 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedOperation.h +++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.h @@ -53,11 +53,6 @@ class SingleThreadedOperation : public NodeOperation { void *initializeTileData(rcti *rect) override; virtual MemoryBuffer *createMemoryBuffer(rcti *rect) = 0; - - int isSingleThreaded() override - { - return true; - } }; } // namespace blender::compositor -- cgit v1.2.3