Blender  V3.3
Classes | Namespaces | Typedefs | Functions | Variables
image_partial_update.cc File Reference
#include <optional>
#include "BKE_image.h"
#include "BKE_image_partial_update.hh"
#include "DNA_image_types.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "BLI_vector.hh"

Go to the source code of this file.

Classes

struct  blender::bke::image::partial_update::PartialUpdateUserImpl
 
struct  blender::bke::image::partial_update::TileChangeset
 Dirty chunks of an ImageTile. More...
 
struct  blender::bke::image::partial_update::Changeset
 Changeset keeping track of changes for an image. More...
 
struct  blender::bke::image::partial_update::PartialUpdateRegisterImpl
 Partial update changes stored inside the image runtime. More...
 

Namespaces

 blender
 
 blender::bke
 
 blender::bke::image
 
 blender::bke::image::partial_update
 

Typedefs

using blender::bke::image::partial_update::TileNumber = int32_t
 
using blender::bke::image::partial_update::ChangesetID = int64_t
 

Functions

static int blender::bke::image::partial_update::chunk_number_for_pixel (int pixel_offset)
 get the chunk number for the give pixel coordinate. More...
 
static struct PartialUpdateUser * blender::bke::image::partial_update::wrap (PartialUpdateUserImpl *user)
 
static PartialUpdateUserImplblender::bke::image::partial_update::unwrap (struct PartialUpdateUser *user)
 
static struct PartialUpdateRegister * blender::bke::image::partial_update::wrap (PartialUpdateRegisterImpl *partial_update_register)
 
static PartialUpdateRegisterImplblender::bke::image::partial_update::unwrap (struct PartialUpdateRegister *partial_update_register)
 
static PartialUpdateRegister * blender::bke::image::partial_update::image_partial_update_register_ensure (Image *image)
 
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. More...
 
ePartialUpdateIterResult blender::bke::image::partial_update::BKE_image_partial_update_get_next_change (struct PartialUpdateUser *user, struct PartialUpdateRegion *r_region)
 
struct PartialUpdateUser * BKE_image_partial_update_create (const struct Image *image)
 Create a new PartialUpdateUser. An Object that contains data to use partial updates. More...
 
void BKE_image_partial_update_free (PartialUpdateUser *user)
 free a partial update user. More...
 
void BKE_image_partial_update_register_free (Image *image)
 
void BKE_image_partial_update_mark_region (Image *image, const ImageTile *image_tile, const ImBuf *image_buffer, const rcti *updated_region)
 
void BKE_image_partial_update_mark_full_update (Image *image)
 Mark the whole image to be updated. More...
 

Variables

constexpr int blender::bke::image::partial_update::CHUNK_SIZE = 256
 Size of chunks to track changes. More...
 
constexpr int blender::bke::image::partial_update::MAX_HISTORY_LEN = 4
 Max number of changesets to keep in history. More...
 
constexpr ChangesetID blender::bke::image::partial_update::UnknownChangesetID = -1
 

Detailed Description

To reduce the overhead of image processing this file contains a mechanism to detect areas of the image that are changed. These areas are organized in chunks. Changes that happen over time are organized in changesets.

A common use case is to update GPUTexture for drawing where only that part is uploaded that only changed.

Usage:

Image *image = ...;
ImBuf *image_buffer = ...;
// Partial_update_user should be kept for the whole session where the changes needs to be
// tracked. Keep this instance alive as long as you need to track image changes.
PartialUpdateUser *partial_update_user = BKE_image_partial_update_create(image);
...
{
case ePartialUpdateCollectResult::FullUpdateNeeded:
// Unable to do partial updates. Perform a full update.
break;
case ePartialUpdateCollectResult::PartialChangesDetected:
PartialUpdateRegion change;
while (BKE_image_partial_update_get_next_change(partial_update_user, &change) ==
ePartialUpdateIterResult::ChangeAvailable){
// Do something with the change.
}
case ePartialUpdateCollectResult::NoChangesDetected:
break;
}
...
// Free partial_update_user.
BKE_image_partial_update_free(partial_update_user);
struct PartialUpdateUser * BKE_image_partial_update_create(const struct Image *image)
Create a new PartialUpdateUser. An Object that contains data to use partial updates.
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
ePartialUpdateCollectResult BKE_image_partial_update_collect_changes(struct Image *image, struct PartialUpdateUser *user)
collect the partial update since the last request.
ePartialUpdateIterResult BKE_image_partial_update_get_next_change(struct PartialUpdateUser *user, struct PartialUpdateRegion *r_region)

Definition in file image_partial_update.cc.

Function Documentation

◆ BKE_image_partial_update_create()

struct PartialUpdateUser* BKE_image_partial_update_create ( const struct Image image)

Create a new PartialUpdateUser. An Object that contains data to use partial updates.

Definition at line 546 of file image_partial_update.cc.

References image(), UNUSED_VARS, and blender::bke::image::partial_update::wrap().

Referenced by image_get_gpu_texture(), and blender::bke::image::partial_update::ImagePartialUpdateTest::SetUp().

◆ BKE_image_partial_update_free()

void BKE_image_partial_update_free ( PartialUpdateUser *  user)

◆ BKE_image_partial_update_mark_full_update()

void BKE_image_partial_update_mark_full_update ( Image image)

◆ BKE_image_partial_update_mark_region()

void BKE_image_partial_update_mark_region ( Image image,
const ImageTile image_tile,
const ImBuf image_buffer,
const rcti updated_region 
)

◆ BKE_image_partial_update_register_free()

void BKE_image_partial_update_register_free ( Image image)