Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_image/image_undo.c')
-rw-r--r--source/blender/editors/space_image/image_undo.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index c450d5122eb..577c4e24b11 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -70,7 +70,7 @@ static CLG_LogRef LOG = {"ed.image.undo"};
/** \name Thread Locking
* \{ */
-/* this is a static resource for non-globality,
+/* This is a non-global static resource,
* Maybe it should be exposed as part of the
* paint operation, but for now just give a public interface */
static SpinLock paint_tiles_lock;
@@ -457,6 +457,31 @@ static void ubuf_from_image_all_tiles(UndoImageBuf *ubuf, const ImBuf *ibuf)
IMB_freeImBuf(tmpibuf);
}
+/** Ensure we can copy the ubuf into the ibuf. */
+static void ubuf_ensure_compat_ibuf(const UndoImageBuf *ubuf, ImBuf *ibuf)
+{
+ /* We could have both float and rect buffers,
+ * in this case free the float buffer if it's unused. */
+ if ((ibuf->rect_float != NULL) && (ubuf->image_state.use_float == false)) {
+ imb_freerectfloatImBuf(ibuf);
+ }
+
+ if (ibuf->x == ubuf->image_dims[0] && ibuf->y == ubuf->image_dims[1] &&
+ (ubuf->image_state.use_float ? (void *)ibuf->rect_float : (void *)ibuf->rect)) {
+ return;
+ }
+
+ imb_freerectImbuf_all(ibuf);
+ IMB_rect_size_set(ibuf, ubuf->image_dims);
+
+ if (ubuf->image_state.use_float) {
+ imb_addrectfloatImBuf(ibuf);
+ }
+ else {
+ imb_addrectImBuf(ibuf);
+ }
+}
+
static void ubuf_free(UndoImageBuf *ubuf)
{
UndoImageBuf *ubuf_post = ubuf->post;
@@ -510,7 +535,8 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init)
bool changed = false;
for (UndoImageBuf *ubuf_iter = uh->buffers.first; ubuf_iter; ubuf_iter = ubuf_iter->next) {
UndoImageBuf *ubuf = use_init ? ubuf_iter : ubuf_iter->post;
- IMB_rect_size_set(ibuf, ubuf->image_dims);
+ ubuf_ensure_compat_ibuf(ubuf, ibuf);
+
int i = 0;
for (uint y_tile = 0; y_tile < ubuf->tiles_dims[1]; y_tile += 1) {
uint y = y_tile << ED_IMAGE_UNDO_TILE_BITS;