69 rctf new_clipping_uv_bounds;
81 rcti new_clipping_bounds;
114 struct TextureInfoBounds {
142 float2 region_uv_span = region_uv_max - region_uv_min;
148 assign_texture_infos_by_uv_bounds(info_bounds, unassigned_textures);
149 assign_unused_texture_infos(info_bounds, unassigned_textures);
152 rctf region_uv_bounds;
154 ®ion_uv_bounds, region_uv_min.x, region_uv_max.x, region_uv_min.y, region_uv_max.y);
155 update_region_bounds_from_uv_bounds(region_uv_bounds,
int2(region->
winx, region->
winy));
164 int2 texture_size(
ceil(viewport_size.x / Divisions),
ceil(viewport_size.y / Divisions));
180 float2 region_tile_uv_span = region_uv_span /
float2(
float(Divisions));
185 uv_coords[
x][
y] = region_tile_uv_span *
float2(
float(
x - 1),
float(
y - 1)) +
190 Vector<TextureInfoBounds> info_bounds;
193 TextureInfoBounds texture_info_bounds;
194 texture_info_bounds.tile_id =
int2(
x,
y);
197 uv_coords[
x + 1][
y + 1].x,
199 uv_coords[
x + 1][
y + 1].y);
200 info_bounds.append(texture_info_bounds);
206 void assign_texture_infos_by_uv_bounds(Vector<TextureInfoBounds> &info_bounds,
207 Vector<TextureInfo *> &r_unassigned_textures)
210 bool assigned =
false;
211 for (TextureInfoBounds &info_bound : info_bounds) {
212 if (info_bound.info ==
nullptr &&
215 info_bound.info = &info;
216 info.tile_id = info_bound.tile_id;
222 r_unassigned_textures.append(&info);
227 void assign_unused_texture_infos(Vector<TextureInfoBounds> &info_bounds,
228 Vector<TextureInfo *> &unassigned_textures)
230 for (TextureInfoBounds &info_bound : info_bounds) {
231 if (info_bound.info ==
nullptr) {
232 info_bound.info = unassigned_textures.pop_last();
233 info_bound.info->tile_id = info_bound.tile_id;
234 info_bound.info->need_full_update =
true;
235 info_bound.info->clipping_uv_bounds = info_bound.uv_bounds;
240 void update_region_bounds_from_uv_bounds(
const rctf ®ion_uv_bounds,
const int2 region_size)
248 if (info.tile_id ==
int2(0)) {
251 float3(info.clipping_uv_bounds.xmin, info.clipping_uv_bounds.ymin, 0.0)));
258 int2 bottom_left = tile_origin + texture_size * info.tile_id;
259 int2 top_right = bottom_left + texture_size;
260 BLI_rcti_init(&info.clipping_bounds, bottom_left.
x, top_right.
x, bottom_left.
y, top_right.
y);
265using namespace blender::bke::image;
275 void add_shgroups()
const;
295 void do_partial_update_float_buffer(
ImBuf *float_buffer,
ImBuf *src,
const rcti ®ion)
const;
299 void apply_partial_change(
ImBuf *src_buffer,
301 const rcti ®ion)
const;
308 void do_full_update_texture_slot(
const TextureInfo &texture_info,
309 ImBuf &texture_buffer,
A running instance of the engine.
virtual void update_bounds(const ARegion *region)=0
Update the uv and region bounds of all texture_infos of instance_data.
BaseTextureMethod(State *instance_data)
virtual void ensure_texture_infos()=0
Ensure enough texture infos are allocated in instance_data.
virtual void ensure_gpu_textures_allocation()=0
void update_bounds(const ARegion *region) override
Update the uv and region bounds of all texture_infos of instance_data.
void ensure_gpu_textures_allocation() override
void ensure_texture_infos() override
Ensure enough texture infos are allocated in instance_data.
OneTexture(State *instance_data)
void draw_viewport() const override
void begin_sync() const override
ScreenSpaceDrawingMode(Instance &instance)
void image_sync(blender::Image *image, blender::ImageUser *iuser) const override
int2 gpu_texture_size() const
ScreenTileTextures(State *instance_data)
void ensure_texture_infos() override
Ensure enough texture infos are allocated in instance_data.
void update_bounds(const ARegion *region) override
Update the uv and region bounds of all texture_infos of instance_data.
static const size_t TexturesPerDimension
static const size_t TexturesRequired
void ensure_gpu_textures_allocation() override
static const size_t VerticesPerDimension
constexpr float EPSILON_UV_BOUNDS
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
const DRWContext * DRW_context_get()
MatBase< float, 3, 3 > float3x3
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
VecBase< float, 3 > float3
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
float2 viewport_size_get() const
const c_style_mat & ptr() const
Vector< TextureInfo > texture_infos
float3x3 ss_to_texture
Transform matrix to convert a normalized screen space coordinates to texture space.
rctf clipping_uv_bounds
uv area of the texture in screen space.
rcti clipping_bounds
area of the texture in screen space.
void ensure_gpu_texture(int2 texture_size)
bool need_full_update
does this texture need a full update.