From d3de5d7ca5608c53418ce4284cefe7e7d66a6b33 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 16 Jun 2020 16:59:52 +0200 Subject: Refactor: Move curvemapping .blend read/write to blenkernel This is necessary so that it can be accessed from `blendWrite` and `blendRead` callbacks from modifiers. --- source/blender/blenkernel/intern/colortools.c | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source/blender/blenkernel/intern/colortools.c') 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) -- cgit v1.2.3