Blender V5.0
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 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 37 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 68 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: There 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 470 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, 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(), 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()

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 this member can be used for both x and y axis.

Definition at line 86 of file image_partial_update.cc.

References CHUNK_SIZE.

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

◆ image_partial_update_register_ensure()

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]

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

◆ unwrap() [2/2]

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

◆ wrap() [1/2]

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

Wrap PartialUpdateRegisterImpl to its C-struct (PartialUpdateRegister).

Definition at line 117 of file image_partial_update.cc.

◆ wrap() [2/2]

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

Wrap PartialUpdateUserImpl to its C-struct (PartialUpdateUser).

Definition at line 101 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 79 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 131 of file image_partial_update.cc.