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:
authorAntony Riakiotakis <kalast@gmail.com>2013-12-06 00:28:14 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-12-08 02:29:13 +0400
commit8e5b02359b8590ac84afe7a61dd9a6dc67cd632e (patch)
tree95201615fbf0eb4102d171cfc8b9d27cc6677cff /source/blender/editors/space_image
parent31871c763f155af05a12b049a236a19a78d6b500 (diff)
Fix T37326 inversion of image channels did not do an undo push. Now only do an undo if we are in image paint mode and use the paint undo stack. Also added missing GPU update.:
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_image/SConscript1
-rw-r--r--source/blender/editors/space_image/image_ops.c21
3 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt
index 50d8051a73e..62ac3c2d985 100644
--- a/source/blender/editors/space_image/CMakeLists.txt
+++ b/source/blender/editors/space_image/CMakeLists.txt
@@ -30,6 +30,7 @@ set(INC
../../render/extern/include
../../windowmanager
../../../../intern/guardedalloc
+ ../../gpu
)
set(INC_SYS
diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript
index 89def32e70f..d878a726b55 100644
--- a/source/blender/editors/space_image/SConscript
+++ b/source/blender/editors/space_image/SConscript
@@ -42,6 +42,7 @@ incs = [
'../../makesrna',
'../../render/extern/include',
'../../windowmanager',
+ '../../gpu',
]
incs = ' '.join(incs)
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 2c2e204b3b3..a37b50172cf 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -58,6 +58,8 @@
#include "BKE_report.h"
#include "BKE_screen.h"
+#include "GPU_draw.h"
+
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -85,6 +87,7 @@
#include "PIL_time.h"
#include "image_intern.h"
+#include "ED_sculpt.h"
/******************** view navigation utilities *********************/
@@ -1860,6 +1863,9 @@ static int image_invert_exec(bContext *C, wmOperator *op)
{
Image *ima = CTX_data_edit_image(C);
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
+ SpaceImage *sima = CTX_wm_space_image(C);
+ /* undo is supported only on image paint mode currently */
+ bool support_undo = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
/* flags indicate if this channel should be inverted */
const short r = RNA_boolean_get(op->ptr, "invert_r");
@@ -1872,6 +1878,14 @@ static int image_invert_exec(bContext *C, wmOperator *op)
if (ibuf == NULL) /* TODO: this should actually never happen, but does for render-results -> cleanup */
return OPERATOR_CANCELLED;
+ if (support_undo) {
+ ED_undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
+ ED_image_undo_restore, ED_image_undo_free);
+ /* not strictly needed, because we only imapaint_dirty_region to invalidate all tiles
+ * but better do this right in case someone copies this for a tool that uses partial redraw better */
+ ED_imapaint_clear_partial_redraw();
+ ED_imapaint_dirty_region(ima, ibuf, 0, 0, ibuf->x, ibuf->y);
+ }
/* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */
if (ibuf->rect_float) {
@@ -1903,9 +1917,16 @@ static int image_invert_exec(bContext *C, wmOperator *op)
}
ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
+
if (ibuf->mipmap[0])
ibuf->userflags |= IB_MIPMAP_INVALID;
+ if (support_undo)
+ ED_undo_paint_push_end(UNDO_PAINT_IMAGE);
+
+ /* force GPU reupload, all image is invalid */
+ GPU_free_image(ima);
+
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
BKE_image_release_ibuf(ima, ibuf, NULL);