[Bf-blender-cvs] [eefd68013cb] master: Cleanup: isolate image dirty flag access in functions

Brecht Van Lommel noreply at git.blender.org
Tue May 14 18:00:34 CEST 2019


Commit: eefd68013cb8b4c9e69bf76d9f7ad3d8bd68e065
Author: Brecht Van Lommel
Date:   Tue May 14 17:28:13 2019 +0200
Branches: master
https://developer.blender.org/rBeefd68013cb8b4c9e69bf76d9f7ad3d8bd68e065

Cleanup: isolate image dirty flag access in functions

===================================================================

M	source/blender/blenkernel/BKE_image.h
M	source/blender/blenkernel/intern/image.c
M	source/blender/collada/ImageExporter.cpp
M	source/blender/editors/object/object_bake_api.c
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_info/info_ops.c
M	source/blender/makesrna/intern/rna_image.c
M	source/blender/render/intern/source/multires_bake.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 28886a5a195..d5304ec5434 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -340,12 +340,15 @@ void BKE_image_buf_fill_checker_color(unsigned char *rect,
 unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame);
 float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame);
 
+/* Image modifications */
+bool BKE_image_is_dirty(struct Image *image);
+void BKE_image_mark_dirty(struct Image *image, struct ImBuf *ibuf);
+
 /* Guess offset for the first frame in the sequence */
 int BKE_image_sequence_guess_offset(struct Image *image);
 bool BKE_image_has_anim(struct Image *image);
 bool BKE_image_has_packedfile(struct Image *image);
 bool BKE_image_is_animated(struct Image *image);
-bool BKE_image_is_dirty(struct Image *image);
 void BKE_image_file_format_set(struct Image *image,
                                int ftype,
                                const struct ImbFormatOptions *options);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f23c58befdf..18c42da0bd4 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -5087,6 +5087,7 @@ bool BKE_image_is_animated(Image *image)
   return ELEM(image->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE);
 }
 
+/* Image modifications */
 bool BKE_image_is_dirty(Image *image)
 {
   bool is_dirty = false;
@@ -5110,6 +5111,11 @@ bool BKE_image_is_dirty(Image *image)
   return is_dirty;
 }
 
+void BKE_image_mark_dirty(Image *UNUSED(image), ImBuf *ibuf)
+{
+  ibuf->userflags |= IB_BITMAPDIRTY;
+}
+
 void BKE_image_file_format_set(Image *image, int ftype, const ImbFormatOptions *options)
 {
   BLI_spin_lock(&image_spin);
diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp
index 650e1bfcd57..b606799efde 100644
--- a/source/blender/collada/ImageExporter.cpp
+++ b/source/blender/collada/ImageExporter.cpp
@@ -61,7 +61,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
     return;
   }
 
-  bool is_dirty = (imbuf->userflags & IB_BITMAPDIRTY) != 0;
+  bool is_dirty = BKE_image_is_dirty(image);
 
   ImageFormatData imageFormat;
   BKE_imbuf_to_image_format(&imageFormat, imbuf);
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 5ae757cac56..da95db92332 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -277,7 +277,8 @@ static bool write_internal_bake_pixels(Image *image,
     RE_bake_margin(ibuf, mask_buffer, margin);
   }
 
-  ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_BITMAPDIRTY;
+  ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+  BKE_image_mark_dirty(image, ibuf);
 
   if (ibuf->rect_float) {
     ibuf->userflags |= IB_RECT_INVALID;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 5a45f4946f2..f7a589350f9 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -47,6 +47,7 @@
 #include "BKE_colorband.h"
 #include "BKE_context.h"
 #include "BKE_brush.h"
+#include "BKE_image.h"
 #include "BKE_main.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
@@ -154,7 +155,7 @@ void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int
     }
   }
 
-  ibuf->userflags |= IB_BITMAPDIRTY;
+  BKE_image_mark_dirty(ima, ibuf);
 
   if (tmpibuf) {
     IMB_freeImBuf(tmpibuf);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 9cc12b41a63..d7553d18d3b 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -1837,7 +1837,7 @@ static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
                                       false);
     }
 
-    pjIma->ibuf->userflags |= IB_BITMAPDIRTY;
+    BKE_image_mark_dirty(pjIma->ima, pjIma->ibuf);
     /* tile ready, publish */
     if (tinf->lock) {
       BLI_spin_lock(tinf->lock);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index cec2e1c68d9..c317cb26cb7 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2494,7 +2494,8 @@ static int image_invert_exec(bContext *C, wmOperator *op)
     return OPERATOR_CANCELLED;
   }
 
-  ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
+  ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+  BKE_image_mark_dirty(ima, ibuf);
 
   if (ibuf->mipmap[0]) {
     ibuf->userflags |= IB_MIPMAP_INVALID;
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 171d8505222..bf43e493cc5 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -160,19 +160,11 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
 {
   Main *bmain = CTX_data_main(C);
   Image *ima;
-  ImBuf *ibuf;
 
   // first check for dirty images
   for (ima = bmain->images.first; ima; ima = ima->id.next) {
-    if (BKE_image_has_loaded_ibuf(ima)) { /* XXX FIX */
-      ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
-
-      if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) {
-        BKE_image_release_ibuf(ima, ibuf, NULL);
-        break;
-      }
-
-      BKE_image_release_ibuf(ima, ibuf, NULL);
+    if (BKE_image_is_dirty(ima)) {
+      break;
     }
   }
 
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 34373e469c1..83ec33286f4 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -406,7 +406,8 @@ static void rna_Image_pixels_set(PointerRNA *ptr, const float *values)
         ((unsigned char *)ibuf->rect)[i] = unit_float_to_uchar_clamp(values[i]);
     }
 
-    ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID | IB_MIPMAP_INVALID;
+    ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_MIPMAP_INVALID;
+    BKE_image_mark_dirty(ima, ibuf);
     if (!G.background) {
       GPU_free_image(ima);
     }
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index 237debceb83..878a774ab37 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -1458,7 +1458,8 @@ static void finish_images(MultiresBakeRender *bkr, MultiresBakeResult *result)
 
     bake_ibuf_filter(ibuf, userdata->mask_buffer, bkr->bake_filter);
 
-    ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID;
+    ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+    BKE_image_mark_dirty(ima, ibuf);
 
     if (ibuf->rect_float) {
       ibuf->userflags |= IB_RECT_INVALID;



More information about the Bf-blender-cvs mailing list