14template<
typename T>
class BufferAreaIterator;
37 constexpr BufferArea(T *buffer,
int buffer_width,
const rcti &area,
int elem_stride = 1)
38 :
rcti(area), buffer_(buffer), buffer_width_(buffer_width), elem_stride_(elem_stride)
45 constexpr BufferArea(T *buffer,
int buffer_width,
int buffer_height,
int elem_stride = 1)
46 : buffer_(buffer), buffer_width_(buffer_width), elem_stride_(elem_stride)
53 return a.buffer_ ==
b.buffer_ &&
BLI_rcti_compare(&a, &
b) && a.elem_stride_ ==
b.elem_stride_;
79 return begin_iterator<Iterator>();
84 return end_iterator<Iterator>();
89 return begin_iterator<ConstIterator>();
94 return end_iterator<ConstIterator>();
98 template<
typename TIterator>
constexpr TIterator begin_iterator()
const
100 T *end_ptr = get_end_ptr();
101 if (elem_stride_ == 0) {
103 return TIterator(buffer_, end_ptr, 1, 1, 1);
106 T *begin_ptr = buffer_ + (
intptr_t)this->
ymin * buffer_width_ * elem_stride_ +
108 return TIterator(begin_ptr, end_ptr, buffer_width_,
BLI_rcti_size_x(
this), elem_stride_);
111 template<
typename TIterator>
constexpr TIterator end_iterator()
const
113 T *end_ptr = get_end_ptr();
114 if (elem_stride_ == 0) {
116 return TIterator(end_ptr, end_ptr, 1, 1, 1);
119 return TIterator(end_ptr, end_ptr, buffer_width_,
BLI_rcti_size_x(
this), elem_stride_);
122 T *get_end_ptr()
const
124 if (elem_stride_ == 0) {
127 return buffer_ + (
intptr_t)(this->
ymax - 1) * buffer_width_ * elem_stride_ +
153 T *current,
const T *end,
int buffer_width,
int area_width,
int elem_stride = 1)
154 : elem_stride_(elem_stride),
155 row_stride_(buffer_width * elem_stride),
156 rows_gap_(row_stride_ - area_width * elem_stride),
158 row_end_(current + area_width * elem_stride),
165 current_ += elem_stride_;
167 if (current_ == row_end_) {
169 if (current_ == end_) {
172 current_ += rows_gap_;
173 row_end_ += row_stride_;
182 return copied_iterator;
187 return a.current_ !=
b.current_;
192 return a.current_ ==
b.current_;
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
std::ptrdiff_t difference_type
constexpr friend bool operator==(const BufferAreaIterator &a, const BufferAreaIterator &b)
constexpr BufferAreaIterator(T *current, const T *end, int buffer_width, int area_width, int elem_stride=1)
constexpr BufferAreaIterator & operator++()
constexpr BufferAreaIterator operator++(int) const
constexpr BufferAreaIterator()=default
std::input_iterator_tag iterator_category
constexpr T * operator*() const
constexpr friend bool operator!=(const BufferAreaIterator &a, const BufferAreaIterator &b)
constexpr BufferArea(T *buffer, int buffer_width, const rcti &area, int elem_stride=1)
constexpr int height() const
constexpr Iterator begin()
constexpr BufferArea(T *buffer, int buffer_width, int buffer_height, int elem_stride=1)
constexpr ConstIterator begin() const
constexpr const rcti & get_rect() const
constexpr BufferArea()=default
constexpr friend bool operator==(const BufferArea &a, const BufferArea &b)
constexpr int width() const
constexpr ConstIterator end() const
local_group_size(16, 16) .push_constant(Type b