[Bf-blender-cvs] [d3de5d7ca56] master: Refactor: Move curvemapping .blend read/write to blenkernel
Jacques Lucke
noreply at git.blender.org
Tue Jun 16 17:01:52 CEST 2020
Commit: d3de5d7ca5608c53418ce4284cefe7e7d66a6b33
Author: Jacques Lucke
Date: Tue Jun 16 16:59:52 2020 +0200
Branches: master
https://developer.blender.org/rBd3de5d7ca5608c53418ce4284cefe7e7d66a6b33
Refactor: Move curvemapping .blend read/write to blenkernel
This is necessary so that it can be accessed from `blendWrite`
and `blendRead` callbacks from modifiers.
===================================================================
M source/blender/blenkernel/BKE_colortools.h
M source/blender/blenkernel/intern/colortools.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h
index 94b8d59b3db..0623e0e5395 100644
--- a/source/blender/blenkernel/BKE_colortools.h
+++ b/source/blender/blenkernel/BKE_colortools.h
@@ -37,6 +37,8 @@ struct Histogram;
struct ImBuf;
struct Scopes;
struct rctf;
+struct BlendWriter;
+struct BlendDataReader;
void BKE_curvemapping_set_defaults(
struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy);
@@ -100,6 +102,11 @@ void BKE_curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array
/* non-const, these modify the curve */
void BKE_curvemapping_premultiply(struct CurveMapping *cumap, int restore);
+void BKE_curvemapping_blend_write(struct BlendWriter *writer, const struct CurveMapping *cumap);
+void BKE_curvemapping_curves_blend_write(struct BlendWriter *writer,
+ const struct CurveMapping *cumap);
+void BKE_curvemapping_blend_read(struct BlendDataReader *reader, struct CurveMapping *cumap);
+
void BKE_histogram_update_sample_line(struct Histogram *hist,
struct ImBuf *ibuf,
const struct ColorManagedViewSettings *view_settings,
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 3da384a2745..4f4eb8f9f9d 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -44,6 +44,8 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
+#include "BLO_read_write.h"
+
/* ********************************* color curve ********************* */
/* ***************** operations on full struct ************* */
@@ -1238,6 +1240,32 @@ void BKE_curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *
}
}
+void BKE_curvemapping_blend_write(BlendWriter *writer, const CurveMapping *cumap)
+{
+ BLO_write_struct(writer, CurveMapping, cumap);
+ BKE_curvemapping_curves_blend_write(writer, cumap);
+}
+
+void BKE_curvemapping_curves_blend_write(BlendWriter *writer, const CurveMapping *cumap)
+{
+ for (int a = 0; a < CM_TOT; a++) {
+ BLO_write_struct_array(writer, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
+ }
+}
+
+/* cumap itself has been read already. */
+void BKE_curvemapping_blend_read(BlendDataReader *reader, CurveMapping *cumap)
+{
+ /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
+ cumap->flag &= ~CUMA_PREMULLED;
+
+ for (int a = 0; a < CM_TOT; a++) {
+ BLO_read_data_address(reader, &cumap->cm[a].curve);
+ cumap->cm[a].table = NULL;
+ cumap->cm[a].premultable = NULL;
+ }
+}
+
/* ***************** Histogram **************** */
#define INV_255 (1.f / 255.f)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index f3b92b1f6a4..2e7532c5b46 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2887,16 +2887,7 @@ static void direct_link_id_common(
/* cuma itself has been read! */
static void direct_link_curvemapping(BlendDataReader *reader, CurveMapping *cumap)
{
- int a;
-
- /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
- cumap->flag &= ~CUMA_PREMULLED;
-
- for (a = 0; a < CM_TOT; a++) {
- BLO_read_data_address(reader, &cumap->cm[a].curve);
- cumap->cm[a].table = NULL;
- cumap->cm[a].premultable = NULL;
- }
+ BKE_curvemapping_blend_read(reader, cumap);
}
/** \} */
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 2cc6cecd815..909a12a48aa 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -155,6 +155,7 @@
#include "BKE_blender_version.h"
#include "BKE_bpath.h"
#include "BKE_collection.h"
+#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
@@ -969,16 +970,12 @@ static void write_animdata(BlendWriter *writer, AnimData *adt)
static void write_curvemapping_curves(BlendWriter *writer, CurveMapping *cumap)
{
- for (int a = 0; a < CM_TOT; a++) {
- BLO_write_struct_array(writer, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve);
- }
+ BKE_curvemapping_curves_blend_write(writer, cumap);
}
static void write_curvemapping(BlendWriter *writer, CurveMapping *cumap)
{
- BLO_write_struct(writer, CurveMapping, cumap);
-
- write_curvemapping_curves(writer, cumap);
+ BKE_curvemapping_blend_write(writer, cumap);
}
static void write_CurveProfile(BlendWriter *writer, CurveProfile *profile)
More information about the Bf-blender-cvs
mailing list