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:
authorManuel Castilla <manzanillawork@gmail.com>2021-07-19 18:55:46 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-07-19 21:06:21 +0300
commit45b46e5de9fbfb4985d81ac43cf61a6dcb339ff7 (patch)
treedf791225f15330a542bc5f527e8af9b807a39c77 /source/blender/compositor/COM_defines.h
parent582c5530b6205e0cb98595733d86043a6672cd91 (diff)
Compositor: Buffer iterators
Currently we mostly iterate buffer areas using x/y loops or through utility methods extending from base classes. To simplify code in simple operations this commit adds wrappers for specifying buffer areas and their iterators for raw buffers with any element stride: - BufferRange: Specifies a range of contiguous buffer elements from a given element index. - BufferRangeIterator: Iterates elements in a BufferRange. - BufferArea: Specifies a rectangle area of elements in a 2D buffer. - BufferAreaIterator: Iterates elements in a BufferArea. - BuffersIterator: Simultaneously iterates an area of elements in an output buffer and any number of input buffers. - BuffersIteratorBuilder: Helper for building BuffersIterator adding buffers one by one. For iterating areas coordinates it adds `XRange` and `YRange` methods that return `IndexRange`. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D11882
Diffstat (limited to 'source/blender/compositor/COM_defines.h')
-rw-r--r--source/blender/compositor/COM_defines.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index 9f8e6f10215..0e97bafbb0b 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -18,6 +18,9 @@
#pragma once
+#include "BLI_index_range.hh"
+#include "BLI_rect.h"
+
namespace blender::compositor {
enum class eExecutionModel {
@@ -109,4 +112,24 @@ constexpr float COM_PREVIEW_SIZE = 140.f;
constexpr float COM_RULE_OF_THIRDS_DIVIDER = 100.0f;
constexpr float COM_BLUR_BOKEH_PIXELS = 512;
+constexpr IndexRange XRange(const rcti &area)
+{
+ return IndexRange(area.xmin, area.xmax - area.xmin);
+}
+
+constexpr IndexRange YRange(const rcti &area)
+{
+ return IndexRange(area.ymin, area.ymax - area.ymin);
+}
+
+constexpr IndexRange XRange(const rcti *area)
+{
+ return XRange(*area);
+}
+
+constexpr IndexRange YRange(const rcti *area)
+{
+ return YRange(*area);
+}
+
} // namespace blender::compositor