Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_undo.c
| Show All 35 Lines | |||||
| #include "DNA_workspace_types.h" | #include "DNA_workspace_types.h" | ||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_global.h" | |||||
| #include "BKE_undo_system.h" | #include "BKE_undo_system.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "ED_paint.h" | #include "ED_paint.h" | ||||
| #include "ED_undo.h" | |||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "paint_intern.h" | #include "paint_intern.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Undo Conversion | /** \name Undo Conversion | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | static void image_undo_free_list(ListBase *lb) | ||||
| for (tile = lb->first; tile; tile = tile->next) { | for (tile = lb->first; tile; tile = tile->next) { | ||||
| MEM_freeN(tile->rect.pt); | MEM_freeN(tile->rect.pt); | ||||
| } | } | ||||
| } | } | ||||
| void ED_image_undo_push_begin(const char *name) | void ED_image_undo_push_begin(const char *name) | ||||
| { | { | ||||
| UndoStack *ustack = ED_undo_stack_get(); | |||||
| bContext *C = NULL; /* special case, we never read from this. */ | bContext *C = NULL; /* special case, we never read from this. */ | ||||
| wmWindowManager *wm = G.main->wm.first; | BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_IMAGE); | ||||
| BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_IMAGE); | |||||
| } | } | ||||
| void ED_image_undo_push_end(void) | void ED_image_undo_push_end(void) | ||||
| { | { | ||||
| wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ | UndoStack *ustack = ED_undo_stack_get(); | ||||
| BKE_undosys_step_push(wm->undo_stack, NULL, NULL); | BKE_undosys_step_push(ustack, NULL, NULL); | ||||
| } | } | ||||
| static void image_undo_invalidate(void) | static void image_undo_invalidate(void) | ||||
| { | { | ||||
| UndoImageTile *tile; | UndoImageTile *tile; | ||||
| ListBase *lb = ED_image_undo_get_tiles(); | ListBase *lb = ED_image_undo_get_tiles(); | ||||
| for (tile = lb->first; tile; tile = tile->next) { | for (tile = lb->first; tile; tile = tile->next) { | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
| ListBase *ED_image_undosys_step_get_tiles(UndoStep *us_p) | ListBase *ED_image_undosys_step_get_tiles(UndoStep *us_p) | ||||
| { | { | ||||
| ImageUndoStep *us = (ImageUndoStep *)us_p; | ImageUndoStep *us = (ImageUndoStep *)us_p; | ||||
| return &us->tiles; | return &us->tiles; | ||||
| } | } | ||||
| ListBase *ED_image_undo_get_tiles(void) | ListBase *ED_image_undo_get_tiles(void) | ||||
| { | { | ||||
| wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ | UndoStack *ustack = ED_undo_stack_get(); | ||||
| UndoStep *us = BKE_undosys_stack_init_or_active_with_type(wm->undo_stack, BKE_UNDOSYS_TYPE_IMAGE); | UndoStep *us = BKE_undosys_stack_init_or_active_with_type(ustack, BKE_UNDOSYS_TYPE_IMAGE); | ||||
| return ED_image_undosys_step_get_tiles(us); | return ED_image_undosys_step_get_tiles(us); | ||||
| } | } | ||||
| /* restore painting image to previous state. Used for anchored and drag-dot style brushes*/ | /* restore painting image to previous state. Used for anchored and drag-dot style brushes*/ | ||||
| void ED_image_undo_restore(UndoStep *us) | void ED_image_undo_restore(UndoStep *us) | ||||
| { | { | ||||
| ListBase *lb = ED_image_undosys_step_get_tiles(us); | ListBase *lb = ED_image_undosys_step_get_tiles(us); | ||||
| image_undo_restore_runtime(lb); | image_undo_restore_runtime(lb); | ||||
| image_undo_invalidate(); | image_undo_invalidate(); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||