Cleanup: enum class ChunkOrdering.

This commit is contained in:
2021-03-19 14:16:16 +01:00
parent 9c2d4ffbc1
commit b5f70d92c2
6 changed files with 22 additions and 22 deletions

View File

@@ -102,13 +102,13 @@ extern "C" {
* ExecutionGroups that have no viewer-node, * ExecutionGroups that have no viewer-node,
* will use a default one. * will use a default one.
* There are several possible chunk orders * There are several possible chunk orders
* - [@ref OrderOfChunks.COM_TO_CENTER_OUT]: * - [@ref ChunkOrdering.CenterOut]:
* Start calculating from a configurable point and order by nearest chunk. * Start calculating from a configurable point and order by nearest chunk.
* - [@ref OrderOfChunks.COM_TO_RANDOM]: * - [@ref ChunkOrdering.Random]:
* Randomize all chunks. * Randomize all chunks.
* - [@ref OrderOfChunks.COM_TO_TOP_DOWN]: * - [@ref ChunkOrdering.TopDown]:
* Start calculation from the bottom to the top of the image. * Start calculation from the bottom to the top of the image.
* - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]: * - [@ref ChunkOrdering.RuleOfThirds]:
* Experimental order based on 9 hot-spots in the image. * Experimental order based on 9 hot-spots in the image.
* *
* When the chunk-order is determined, the first few chunks will be checked if they can be scheduled. * When the chunk-order is determined, the first few chunks will be checked if they can be scheduled.
@@ -122,7 +122,7 @@ extern "C" {
* *
* \see ExecutionGroup.execute * \see ExecutionGroup.execute
* \see ViewerOperation.getChunkOrder * \see ViewerOperation.getChunkOrder
* \see OrderOfChunks * \see ChunkOrdering
* *
* \section interest Area of interest * \section interest Area of interest
* An ExecutionGroup can have dependencies to other ExecutionGroup's. * An ExecutionGroup can have dependencies to other ExecutionGroup's.

View File

@@ -87,18 +87,18 @@ enum class CompositorPriority {
* \brief The order of chunks to be scheduled * \brief The order of chunks to be scheduled
* \ingroup Execution * \ingroup Execution
*/ */
typedef enum OrderOfChunks { enum class ChunkOrdering {
/** \brief order from a distance to centerX/centerY */ /** \brief order from a distance to centerX/centerY */
COM_TO_CENTER_OUT = 0, CenterOut = 0,
/** \brief order randomly */ /** \brief order randomly */
COM_TO_RANDOM = 1, Random = 1,
/** \brief no ordering */ /** \brief no ordering */
COM_TO_TOP_DOWN = 2, TopDown = 2,
/** \brief experimental ordering with 9 hot-spots. */ /** \brief experimental ordering with 9 hot-spots. */
COM_TO_RULE_OF_THIRDS = 3, RuleOfThirds = 3,
} OrderOfChunks;
#define COM_ORDER_OF_CHUNKS_DEFAULT COM_TO_CENTER_OUT Default = ChunkOrdering::CenterOut,
};
#define COM_RULE_OF_THIRDS_DIVIDER 100.0f #define COM_RULE_OF_THIRDS_DIVIDER 100.0f

View File

@@ -194,7 +194,7 @@ blender::Array<unsigned int> ExecutionGroup::determine_chunk_execution_order() c
NodeOperation *operation = this->getOutputOperation(); NodeOperation *operation = this->getOutputOperation();
float centerX = 0.5f; float centerX = 0.5f;
float centerY = 0.5f; float centerY = 0.5f;
OrderOfChunks order_type = COM_ORDER_OF_CHUNKS_DEFAULT; ChunkOrdering order_type = ChunkOrdering::Default;
if (operation->isViewerOperation()) { if (operation->isViewerOperation()) {
ViewerOperation *viewer = (ViewerOperation *)operation; ViewerOperation *viewer = (ViewerOperation *)operation;
@@ -207,7 +207,7 @@ blender::Array<unsigned int> ExecutionGroup::determine_chunk_execution_order() c
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder); const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
switch (order_type) { switch (order_type) {
case COM_TO_RANDOM: { case ChunkOrdering::Random: {
static blender::RandomNumberGenerator rng; static blender::RandomNumberGenerator rng;
blender::MutableSpan<unsigned int> span = chunk_order.as_mutable_span(); blender::MutableSpan<unsigned int> span = chunk_order.as_mutable_span();
/* Shuffle twice to make it more random. */ /* Shuffle twice to make it more random. */
@@ -215,7 +215,7 @@ blender::Array<unsigned int> ExecutionGroup::determine_chunk_execution_order() c
rng.shuffle(span); rng.shuffle(span);
break; break;
} }
case COM_TO_CENTER_OUT: { case ChunkOrdering::CenterOut: {
ChunkOrderHotspot hotspot(border_width * centerX, border_height * centerY, 0.0f); ChunkOrderHotspot hotspot(border_width * centerX, border_height * centerY, 0.0f);
blender::Array<ChunkOrder> chunk_orders(m_chunks_len); blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
for (index = 0; index < this->m_chunks_len; index++) { for (index = 0; index < this->m_chunks_len; index++) {
@@ -234,7 +234,7 @@ blender::Array<unsigned int> ExecutionGroup::determine_chunk_execution_order() c
break; break;
} }
case COM_TO_RULE_OF_THIRDS: { case ChunkOrdering::RuleOfThirds: {
unsigned int tx = border_width / 6; unsigned int tx = border_width / 6;
unsigned int ty = border_height / 6; unsigned int ty = border_height / 6;
unsigned int mx = border_width / 2; unsigned int mx = border_width / 2;
@@ -273,7 +273,7 @@ blender::Array<unsigned int> ExecutionGroup::determine_chunk_execution_order() c
break; break;
} }
case COM_TO_TOP_DOWN: case ChunkOrdering::TopDown:
default: default:
break; break;
} }

View File

@@ -60,7 +60,7 @@ void SplitViewerNode::convertToOperations(NodeConverter &converter,
/* defaults - the viewer node has these options but not exposed for split view /* defaults - the viewer node has these options but not exposed for split view
* we could use the split to define an area of interest on one axis at least */ * we could use the split to define an area of interest on one axis at least */
viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT); viewerOperation->setChunkOrder(ChunkOrdering::Default);
viewerOperation->setCenterX(0.5f); viewerOperation->setCenterX(0.5f);
viewerOperation->setCenterY(0.5f); viewerOperation->setCenterY(0.5f);

View File

@@ -47,7 +47,7 @@ void ViewerNode::convertToOperations(NodeConverter &converter,
viewerOperation->setbNodeTree(context.getbNodeTree()); viewerOperation->setbNodeTree(context.getbNodeTree());
viewerOperation->setImage(image); viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser); viewerOperation->setImageUser(imageUser);
viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); viewerOperation->setChunkOrder((ChunkOrdering)editorNode->custom1);
viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterX(editorNode->custom3);
viewerOperation->setCenterY(editorNode->custom4); viewerOperation->setCenterY(editorNode->custom4);
/* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */

View File

@@ -32,7 +32,7 @@ class ViewerOperation : public NodeOperation {
bool m_active; bool m_active;
float m_centerX; float m_centerX;
float m_centerY; float m_centerY;
OrderOfChunks m_chunkOrder; ChunkOrdering m_chunkOrder;
bool m_doDepthBuffer; bool m_doDepthBuffer;
ImBuf *m_ibuf; ImBuf *m_ibuf;
bool m_useAlphaInput; bool m_useAlphaInput;
@@ -82,7 +82,7 @@ class ViewerOperation : public NodeOperation {
{ {
this->m_centerY = centerY; this->m_centerY = centerY;
} }
void setChunkOrder(OrderOfChunks tileOrder) void setChunkOrder(ChunkOrdering tileOrder)
{ {
this->m_chunkOrder = tileOrder; this->m_chunkOrder = tileOrder;
} }
@@ -94,7 +94,7 @@ class ViewerOperation : public NodeOperation {
{ {
return this->m_centerY; return this->m_centerY;
} }
OrderOfChunks getChunkOrder() const ChunkOrdering getChunkOrder() const
{ {
return this->m_chunkOrder; return this->m_chunkOrder;
} }