diff options
author | Jacques Lucke <jacques@blender.org> | 2020-06-16 17:59:52 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-06-16 17:59:52 +0300 |
commit | d3de5d7ca5608c53418ce4284cefe7e7d66a6b33 (patch) | |
tree | f60179f320cb8e1529e822c1de61b1c1602bcee7 /source/blender/blenkernel/intern | |
parent | 4365de38700ccc05f98f601efdde0963de4645c1 (diff) |
Refactor: Move curvemapping .blend read/write to blenkernel
This is necessary so that it can be accessed from `blendWrite`
and `blendRead` callbacks from modifiers.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 28 |
1 files changed, 28 insertions, 0 deletions
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) |