Blender V4.3
image_partial_updater.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BKE_image.hh"
13
15 PartialUpdateUser *user;
16 const Image *image;
17
21 void ensure_image(const Image *new_image)
22 {
23 if (!is_valid(new_image)) {
24 free();
25 create(new_image);
26 }
27 }
28
30 {
31 free();
32 }
33
34 private:
40 bool is_valid(const Image *new_image) const
41 {
42 if (image != new_image) {
43 return false;
44 }
45
46 return user != nullptr;
47 }
48
49 void create(const Image *new_image)
50 {
51 BLI_assert(user == nullptr);
53 image = new_image;
54 }
55
56 void free()
57 {
58 if (user != nullptr) {
60 user = nullptr;
61 image = nullptr;
62 }
63 }
64};
void BKE_image_partial_update_free(PartialUpdateUser *user)
free a partial update user.
PartialUpdateUser * BKE_image_partial_update_create(const Image *image)
Create a new PartialUpdateUser. An Object that contains data to use partial updates.
#define BLI_assert(a)
Definition BLI_assert.h:50
void ensure_image(const Image *new_image)
Ensure that there is a partial update user for the given image.
PartialUpdateUser * user