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));
186 uv_coords[
x][
y] = region_tile_uv_span *
float2(
float(
x - 1),
float(
y - 1)) +
194 TextureInfoBounds texture_info_bounds;
195 texture_info_bounds.tile_id =
int2(
x,
y);
198 uv_coords[
x + 1][
y + 1].x,
200 uv_coords[
x + 1][
y + 1].y);
201 info_bounds.
append(texture_info_bounds);
207 void assign_texture_infos_by_uv_bounds(Vector<TextureInfoBounds> &info_bounds,
208 Vector<TextureInfo *> &r_unassigned_textures)
211 bool assigned =
false;
212 for (TextureInfoBounds &info_bound : info_bounds) {
213 if (info_bound.info ==
nullptr &&
216 info_bound.info = &info;
217 info.tile_id = info_bound.tile_id;
223 r_unassigned_textures.
append(&info);
228 void assign_unused_texture_infos(Vector<TextureInfoBounds> &info_bounds,
229 Vector<TextureInfo *> &unassigned_textures)
231 for (TextureInfoBounds &info_bound : info_bounds) {
232 if (info_bound.info ==
nullptr) {
233 info_bound.info = unassigned_textures.
pop_last();
234 info_bound.info->tile_id = info_bound.tile_id;
235 info_bound.info->need_full_update =
true;
236 info_bound.info->clipping_uv_bounds = info_bound.uv_bounds;
241 void update_region_bounds_from_uv_bounds(
const rctf ®ion_uv_bounds,
const int2 region_size)
248 for (
const TextureInfo &info :
instance_data->texture_infos) {
249 if (info.tile_id ==
int2(0)) {
252 float3(info.clipping_uv_bounds.xmin, info.clipping_uv_bounds.ymin, 0.0)));
259 int2 bottom_left = tile_origin + texture_size * info.tile_id;
260 int2 top_right = bottom_left + texture_size;
261 BLI_rcti_init(&info.clipping_bounds, bottom_left.
x, top_right.
x, bottom_left.
y, top_right.
y);
266using namespace blender::bke::image::partial_update;
267using namespace blender::bke::image;
277 void add_shgroups()
const;
297 void do_partial_update_float_buffer(
300 void do_full_update_for_dirty_textures(const ::ImageUser *image_user)
const;
301 void do_full_update_gpu_texture(
TextureInfo &info, const ::ImageUser *image_user)
const;
306 void do_full_update_texture_slot(
const TextureInfo &texture_info,
307 ImBuf &texture_buffer,
BLI_INLINE int BLI_rcti_size_y(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])
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
void append(const T &value)
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_finish() const override
void draw_viewport() const override
void begin_sync() const override
void image_sync(::Image *image, ::ImageUser *iuser) const override
ScreenSpaceDrawingMode(Instance &instance)
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
const DRWContext * DRW_context_get()
constexpr float EPSILON_UV_BOUNDS
CartesianBasis invert(const CartesianBasis &basis)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
blender::float2 viewport_size_get() const
const c_style_mat & ptr() const
VecBase< T, 2 > xy() const
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.