Blender  V3.3
Classes | Typedefs | Enumerations | Functions | Variables
blender::bke::image::partial_update Namespace Reference

Classes

struct  PartialUpdateRegion
 A region to update. More...
 
class  AbstractTileData
 Abstract class to load tile data when using the PartialUpdateChecker. More...
 
class  NoTileData
 Class to not load any tile specific data when iterating over changes. More...
 
class  ImageTileData
 Load the ImageTile and ImBuf associated with the partial change. More...
 
struct  PartialUpdateChecker
 
struct  PartialUpdateUserImpl
 
struct  TileChangeset
 Dirty chunks of an ImageTile. More...
 
struct  Changeset
 Changeset keeping track of changes for an image. More...
 
struct  PartialUpdateRegisterImpl
 Partial update changes stored inside the image runtime. More...
 
class  ImagePartialUpdateTest
 

Typedefs

using TileNumber = int32_t
 
using ChangesetID = int64_t
 

Enumerations

enum class  ePartialUpdateCollectResult { FullUpdateNeeded , NoChangesDetected , PartialChangesDetected }
 Result codes of #BKE_image_partial_update_collect_changes. More...
 
enum class  ePartialUpdateIterResult { Finished = 0 , ChangeAvailable = 1 }
 Return codes of #BKE_image_partial_update_get_next_change. More...
 

Functions

ePartialUpdateCollectResult BKE_image_partial_update_collect_changes (struct Image *image, struct PartialUpdateUser *user)
 collect the partial update since the last request. More...
 
ePartialUpdateIterResult BKE_image_partial_update_get_next_change (struct PartialUpdateUser *user, struct PartialUpdateRegion *r_region)
 
static int chunk_number_for_pixel (int pixel_offset)
 get the chunk number for the give pixel coordinate. More...
 
static struct PartialUpdateUser * wrap (PartialUpdateUserImpl *user)
 
static PartialUpdateUserImplunwrap (struct PartialUpdateUser *user)
 
static struct PartialUpdateRegister * wrap (PartialUpdateRegisterImpl *partial_update_register)
 
static PartialUpdateRegisterImplunwrap (struct PartialUpdateRegister *partial_update_register)
 
static PartialUpdateRegister * image_partial_update_register_ensure (Image *image)
 
 TEST_F (ImagePartialUpdateTest, mark_full_update)
 
 TEST_F (ImagePartialUpdateTest, mark_single_tile)
 
 TEST_F (ImagePartialUpdateTest, mark_unconnected_tiles)
 
 TEST_F (ImagePartialUpdateTest, donot_mark_outside_image)
 
 TEST_F (ImagePartialUpdateTest, mark_inside_image)
 
 TEST_F (ImagePartialUpdateTest, sequential_mark_region)
 
 TEST_F (ImagePartialUpdateTest, mark_multiple_chunks)
 
 TEST_F (ImagePartialUpdateTest, iterator)
 

Variables

constexpr int CHUNK_SIZE = 256
 Size of chunks to track changes. More...
 
constexpr int MAX_HISTORY_LEN = 4
 Max number of changesets to keep in history. More...
 
constexpr ChangesetID UnknownChangesetID = -1
 
constexpr float black_color [4] = {0.0f, 0.0f, 0.0f, 1.0f}
 

Typedef Documentation

◆ ChangesetID

Definition at line 129 of file image_partial_update.cc.

◆ TileNumber

Definition at line 128 of file image_partial_update.cc.

Enumeration Type Documentation

◆ ePartialUpdateCollectResult

Result codes of BKE_image_partial_update_collect_changes.

Image partial updates.

Enumerator
FullUpdateNeeded 

Unable to construct partial updates. Caller should perform a full update.

NoChangesDetected 

No changes detected since the last time requested.

PartialChangesDetected 

Changes detected since the last time requested.

Definition at line 40 of file BKE_image_partial_update.hh.

◆ ePartialUpdateIterResult

Return codes of BKE_image_partial_update_get_next_change.

Enumerator
Finished 

no tiles left when iterating over tiles.

ChangeAvailable 

a chunk was available and has been loaded.

Definition at line 71 of file BKE_image_partial_update.hh.

Function Documentation

◆ BKE_image_partial_update_collect_changes()

ePartialUpdateCollectResult blender::bke::image::partial_update::BKE_image_partial_update_collect_changes ( struct Image image,
struct PartialUpdateUser *  user 
)

collect the partial update since the last request.

Invoke BKE_image_partial_update_get_next_change to iterate over the collected tiles.

Returns
ePartialUpdateCollectResult::FullUpdateNeeded: called should not use partial updates but recalculate the full image. This result can be expected when called for the first time for a user and when it isn't possible to reconstruct the changes as the internal state doesn't have enough data stored. ePartialUpdateCollectResult::NoChangesDetected: The have been no changes detected since last invoke for the same user. ePartialUpdateCollectResult::PartialChangesDetected: Parts of the image has been updated since last invoke for the same user. The changes can be read by using BKE_image_partial_update_get_next_change.

Definition at line 469 of file image_partial_update.cc.

References BLI_assert, BLI_rcti_init(), blender::bke::image::partial_update::PartialUpdateRegisterImpl::can_construct(), blender::bke::image::partial_update::PartialUpdateRegisterImpl::changed_tile_chunks_since(), CHUNK_SIZE, blender::bke::image::partial_update::PartialUpdateUserImpl::clear_updated_regions(), blender::bke::image::partial_update::PartialUpdateRegisterImpl::ensure_empty_changeset(), FullUpdateNeeded, image(), image_partial_update_register_ensure(), blender::bke::image::partial_update::PartialUpdateUserImpl::last_changeset_id, blender::bke::image::partial_update::PartialUpdateRegisterImpl::last_changeset_id, LISTBASE_FOREACH, NoChangesDetected, PartialChangesDetected, blender::bke::image::partial_update::PartialUpdateRegion::region, tile, blender::bke::image::partial_update::PartialUpdateRegion::tile_number, unwrap(), and blender::bke::image::partial_update::PartialUpdateUserImpl::updated_regions.

Referenced by blender::bke::image::partial_update::PartialUpdateChecker< TileData >::collect_changes(), and TEST_F().

◆ BKE_image_partial_update_get_next_change()

ePartialUpdateIterResult blender::bke::image::partial_update::BKE_image_partial_update_get_next_change ( struct PartialUpdateUser *  user,
struct PartialUpdateRegion r_region 
)

◆ chunk_number_for_pixel()

static int blender::bke::image::partial_update::chunk_number_for_pixel ( int  pixel_offset)
static

get the chunk number for the give pixel coordinate.

As chunks are squares the this member can be used for both x and y axis.

Definition at line 84 of file image_partial_update.cc.

References CHUNK_SIZE.

Referenced by blender::bke::image::partial_update::TileChangeset::mark_region().

◆ image_partial_update_register_ensure()

static PartialUpdateRegister* blender::bke::image::partial_update::image_partial_update_register_ensure ( Image image)
static

◆ TEST_F() [1/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
donot_mark_outside_image   
)

◆ TEST_F() [2/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
iterator   
)

◆ TEST_F() [3/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
mark_full_update   
)

◆ TEST_F() [4/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
mark_inside_image   
)

◆ TEST_F() [5/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
mark_multiple_chunks   
)

◆ TEST_F() [6/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
mark_single_tile   
)

◆ TEST_F() [7/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
mark_unconnected_tiles   
)

◆ TEST_F() [8/8]

blender::bke::image::partial_update::TEST_F ( ImagePartialUpdateTest  ,
sequential_mark_region   
)

◆ unwrap() [1/2]

static PartialUpdateRegisterImpl* blender::bke::image::partial_update::unwrap ( struct PartialUpdateRegister *  partial_update_register)
static

Unwrap the PartialUpdateRegister C-struct to its CPP counterpart (PartialUpdateRegisterImpl).

Definition at line 123 of file image_partial_update.cc.

◆ unwrap() [2/2]

static PartialUpdateUserImpl* blender::bke::image::partial_update::unwrap ( struct PartialUpdateUser *  user)
static

◆ wrap() [1/2]

static struct PartialUpdateRegister* blender::bke::image::partial_update::wrap ( PartialUpdateRegisterImpl partial_update_register)
static

Wrap PartialUpdateRegisterImpl to its C-struct (PartialUpdateRegister).

Definition at line 115 of file image_partial_update.cc.

◆ wrap() [2/2]

static struct PartialUpdateUser* blender::bke::image::partial_update::wrap ( PartialUpdateUserImpl user)
static

Wrap PartialUpdateUserImpl to its C-struct (PartialUpdateUser).

Definition at line 99 of file image_partial_update.cc.

Referenced by blender::ed::curves::any_point_selected(), BKE_image_partial_update_create(), BKE_image_stamp_buf(), blf_font_wrap_apply(), blinn_specular(), BPy_IDGroup_MapDataToPy(), GeometrySet::compute_boundbox_without_instances(), blender::bke::construct_curve_length_gvarray(), blender::nodes::node_geo_input_tangent_cc::construct_curve_tangent_gvarray(), blender::bke::curve_normals_varray(), blender::ed::curves::convert_from_particle_system::curves_convert_from_particle_system_exec(), blender::ed::curves::set_selection_domain::curves_set_selection_domain_exec(), do_2d_mapping(), do_text_effect(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_curves(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_points_curve(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::execute(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::execute(), blender::geometry::execute_realize_curve_task(), blender::geometry::execute_realize_curve_tasks(), blender::nodes::node_geo_curve_spline_parameter_cc::CurveParameterFieldInput::get_varray_for_context(), blender::nodes::node_geo_curve_spline_parameter_cc::CurveLengthParameterFieldInput::get_varray_for_context(), blender::nodes::node_geo_curve_spline_parameter_cc::IndexOnSplineFieldInput::get_varray_for_context(), GPU_context_active_get(), GPU_context_create(), GPU_indexbuf_calloc(), blender::ed::curves::has_anything_selected(), idprop_py_from_idp_idparray(), image_partial_update_register_ensure(), metadata_box_height_get(), blender::nodes::node_geo_deform_curves_on_surface_cc::node_geo_exec(), blender::geometry::preprocess_curves(), blender::io::usd::USDCurvesReader::read_curve_sample(), GeometryComponentEditData::remember_deformed_curve_positions_if_necessary(), blender::geometry::resample_to_evaluated(), blender::ed::sculpt_paint::retrieve_selected_curves(), blender::ed::sculpt_paint::retrieve_selected_points(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::curves::select_all::select_all_exec(), blender::ed::sculpt_paint::select_grow::select_grow_invoke_per_curve(), blender::ed::sculpt_paint::select_grow::select_grow_modal(), blender::ed::sculpt_paint::select_grow::select_grow_update(), blender::ed::curves::snap_curves_to_surface::snap_curves_to_surface_exec_object(), txt_find_string(), blender::ed::sculpt_paint::use_add_density_mode(), WM_cursor_grab_enable(), wm_macro_modal(), and wm_operator_invoke().

Variable Documentation

◆ black_color

constexpr float blender::bke::image::partial_update::black_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}
constexpr

Definition at line 23 of file image_partial_update_test.cc.

◆ CHUNK_SIZE

constexpr int blender::bke::image::partial_update::CHUNK_SIZE = 256
constexpr

◆ MAX_HISTORY_LEN

constexpr int blender::bke::image::partial_update::MAX_HISTORY_LEN = 4
constexpr

Max number of changesets to keep in history.

A higher number would need more memory and processing to calculate a changeset, but would lead to do partial updates for requests that don't happen every frame.

A to small number would lead to more full updates when changes couldn't be reconstructed from the available history.

Definition at line 77 of file image_partial_update.cc.

Referenced by blender::bke::image::partial_update::PartialUpdateRegisterImpl::limit_history().

◆ UnknownChangesetID

constexpr ChangesetID blender::bke::image::partial_update::UnknownChangesetID = -1
constexpr

Definition at line 130 of file image_partial_update.cc.