Blender V5.0
tile_highlight.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "tile_highlight.h"
10
11#include "BLI_hash.hh"
12#include "BLI_rect.h"
13
14#include "RE_pipeline.h"
15
16namespace blender::render {
17
18TilesHighlight::Tile::Tile(const RenderResult *result) : rect(result->tilerect) {}
19
20TilesHighlight::Tile::Tile(const int x, const int y, const int width, const int height)
21{
22 BLI_rcti_init(&rect, x, x + width, y, y + height);
23}
24
25uint64_t TilesHighlight::Tile::hash() const
26{
27 return get_default_hash(rect.xmin, rect.xmax, rect.ymin, rect.ymax);
28}
29
35
41
42void TilesHighlight::highlight_tile(const int x, const int y, const int width, const int height)
43{
44 const Tile tile(x, y, width, height);
46}
47
48void TilesHighlight::unhighlight_tile(const int x, const int y, const int width, const int height)
49{
50 const Tile tile(x, y, width, height);
52}
53
55{
56 std::unique_lock lock(mutex_);
57
58 highlighted_tiles_set_.add(tile);
59 did_tiles_change_ = true;
60}
61
62void TilesHighlight::unhighlight_tile(const Tile &tile)
63{
64 std::unique_lock lock(mutex_);
65
66 highlighted_tiles_set_.remove(tile);
67 did_tiles_change_ = true;
68}
69
71{
72 std::unique_lock lock(mutex_);
73
74 highlighted_tiles_set_.clear();
75 cached_highlighted_tiles_.clear_and_shrink();
76}
77
79{
80 std::unique_lock lock(mutex_);
81
82 /* Updated cached flat list if needed. */
83 if (did_tiles_change_) {
84 if (highlighted_tiles_set_.is_empty()) {
85 cached_highlighted_tiles_.clear_and_shrink();
86 }
87 else {
88 cached_highlighted_tiles_.reserve(highlighted_tiles_set_.size());
89 for (const Tile &tile : highlighted_tiles_set_) {
90 cached_highlighted_tiles_.append(tile.rect);
91 }
92 }
93
94 did_tiles_change_ = false;
95 }
96
97 return cached_highlighted_tiles_;
98}
99
100} // namespace blender::render
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:414
volatile int lock
unsigned long long int uint64_t
void highlight_tile_for_result(const RenderResult *result)
void unhighlight_tile(int x, int y, int width, int height)
void unhighlight_tile_for_result(const RenderResult *result)
Span< rcti > get_all_highlighted_tiles() const
void highlight_tile(int x, int y, int width, int height)
const ccl_global KernelWorkTile * tile
uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:233