Blender V4.3
blender::bke::image::partial_update Namespace Reference

Classes

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

Typedefs

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 (Image *image, PartialUpdateUser *user)
 collect the partial update since the last request.
 
ePartialUpdateIterResult BKE_image_partial_update_get_next_change (PartialUpdateUser *user, PartialUpdateRegion *r_region)
 
static int chunk_number_for_pixel (int pixel_offset)
 get the chunk number for the give pixel coordinate.
 
static PartialUpdateUser * wrap (PartialUpdateUserImpl *user)
 
static PartialUpdateUserImplunwrap (PartialUpdateUser *user)
 
static PartialUpdateRegister * wrap (PartialUpdateRegisterImpl *partial_update_register)
 
static PartialUpdateRegisterImplunwrap (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.
 
constexpr int MAX_HISTORY_LEN = 4
 Max number of changesets to keep in history.
 
constexpr ChangesetID UnknownChangesetID = -1
 
constexpr float black_color [4] = {0.0f, 0.0f, 0.0f, 1.0f}
 

Typedef Documentation

◆ ChangesetID

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 ( Image * image,
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_partial_update_register_ensure(), blender::bke::image::partial_update::PartialUpdateRegisterImpl::last_changeset_id, blender::bke::image::partial_update::PartialUpdateUserImpl::last_changeset_id, LISTBASE_FOREACH, NoChangesDetected, PartialChangesDetected, 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(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ BKE_image_partial_update_get_next_change()

◆ 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 85 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]

◆ TEST_F() [3/8]

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

◆ TEST_F() [4/8]

◆ TEST_F() [5/8]

◆ TEST_F() [6/8]

◆ TEST_F() [7/8]

◆ TEST_F() [8/8]

◆ unwrap() [1/2]

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

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

Definition at line 124 of file image_partial_update.cc.

◆ unwrap() [2/2]

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

◆ wrap() [1/2]

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

Wrap PartialUpdateRegisterImpl to its C-struct (PartialUpdateRegister).

Definition at line 116 of file image_partial_update.cc.

◆ wrap() [2/2]

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

Wrap PartialUpdateUserImpl to its C-struct (PartialUpdateUser).

Definition at line 100 of file image_partial_update.cc.

Referenced by BKE_image_partial_update_create(), and image_partial_update_register_ensure().

Variable Documentation

◆ black_color

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

Definition at line 26 of file image_partial_update_test.cc.

◆ CHUNK_SIZE

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

◆ MAX_HISTORY_LEN

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 78 of file image_partial_update.cc.

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

◆ UnknownChangesetID

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

Definition at line 130 of file image_partial_update.cc.