Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2021-02-17 16:55:23 +0300
committerJeroen Bakker <jeroen@blender.org>2021-02-17 17:25:24 +0300
commit8bca03056cac5a4d24e6aa1cf05448d372cf01d9 (patch)
tree93514d01897ee5becf9ca45d13415c7ea1717e07
parentb7e1660d405d9d73f1aff54358a6d2d1461a75d0 (diff)
Cleanup: Make ChunkOrder a struct.
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.cpp24
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.h43
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp20
3 files changed, 37 insertions, 50 deletions
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp
index 7c9e5013c5d..91437aff9e0 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp
@@ -21,27 +21,27 @@
ChunkOrder::ChunkOrder()
{
- this->m_distance = 0.0;
- this->m_number = 0;
- this->m_x = 0;
- this->m_y = 0;
+ distance = 0.0;
+ number = 0;
+ x = 0;
+ y = 0;
}
-void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots)
+void ChunkOrder::update_distance(ChunkOrderHotspot **hotspots, unsigned int len_hotspots)
{
unsigned int index;
- double distance = FLT_MAX;
- for (index = 0; index < numberOfHotspots; index++) {
+ double new_distance = FLT_MAX;
+ for (index = 0; index < len_hotspots; index++) {
ChunkOrderHotspot *hotspot = hotspots[index];
- double ndistance = hotspot->determineDistance(this->m_x, this->m_y);
- if (ndistance < distance) {
- distance = ndistance;
+ double ndistance = hotspot->determineDistance(x, y);
+ if (ndistance < new_distance) {
+ new_distance = ndistance;
}
}
- this->m_distance = distance;
+ this->distance = new_distance;
}
bool operator<(const ChunkOrder &a, const ChunkOrder &b)
{
- return a.m_distance < b.m_distance;
+ return a.distance < b.distance;
}
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h
index 32d8c07de83..993622b346c 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.h
+++ b/source/blender/compositor/intern/COM_ChunkOrder.h
@@ -18,37 +18,24 @@
#pragma once
+#ifdef WITH_CXX_GUARDEDALLOC
+# include "MEM_guardedalloc.h"
+#endif
+
#include "COM_ChunkOrderHotspot.h"
-class ChunkOrder {
- private:
- unsigned int m_number;
- int m_x;
- int m_y;
- double m_distance;
+struct ChunkOrder {
+ unsigned int number;
+ int x;
+ int y;
+ double distance;
- public:
ChunkOrder();
- void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots);
+
friend bool operator<(const ChunkOrder &a, const ChunkOrder &b);
- void setChunkNumber(unsigned int chunknumber)
- {
- this->m_number = chunknumber;
- }
- void setX(int x)
- {
- this->m_x = x;
- }
- void setY(int y)
- {
- this->m_y = y;
- }
- unsigned int getChunkNumber()
- {
- return this->m_number;
- }
- double getDistance()
- {
- return this->m_distance;
- }
+ void update_distance(ChunkOrderHotspot **hotspots, unsigned int len_hotspots);
+
+#ifdef WITH_CXX_GUARDEDALLOC
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot")
+#endif
};
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index b026d2e60d9..9c21c91c370 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -251,15 +251,15 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
sizeof(ChunkOrder) * this->m_numberOfChunks, __func__);
for (index = 0; index < this->m_numberOfChunks; index++) {
determineChunkRect(&rect, index);
- chunkOrders[index].setChunkNumber(index);
- chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
- chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
- chunkOrders[index].determineDistance(hotspots, 1);
+ chunkOrders[index].number = index;
+ chunkOrders[index].x = rect.xmin - this->m_viewerBorder.xmin;
+ chunkOrders[index].y = rect.ymin - this->m_viewerBorder.ymin;
+ chunkOrders[index].update_distance(hotspots, 1);
}
std::sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks - 1]);
for (index = 0; index < this->m_numberOfChunks; index++) {
- chunkOrder[index] = chunkOrders[index].getChunkNumber();
+ chunkOrder[index] = chunkOrders[index].number;
}
delete hotspots[0];
@@ -290,16 +290,16 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
sizeof(ChunkOrder) * this->m_numberOfChunks, __func__);
for (index = 0; index < this->m_numberOfChunks; index++) {
determineChunkRect(&rect, index);
- chunkOrders[index].setChunkNumber(index);
- chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
- chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
- chunkOrders[index].determineDistance(hotspots, 9);
+ chunkOrders[index].number = index;
+ chunkOrders[index].x = rect.xmin - this->m_viewerBorder.xmin;
+ chunkOrders[index].y = rect.ymin - this->m_viewerBorder.ymin;
+ chunkOrders[index].update_distance(hotspots, 9);
}
std::sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks]);
for (index = 0; index < this->m_numberOfChunks; index++) {
- chunkOrder[index] = chunkOrders[index].getChunkNumber();
+ chunkOrder[index] = chunkOrders[index].number;
}
delete hotspots[0];