diff options
author | Jacques Lucke <jacques@blender.org> | 2020-10-30 16:44:03 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-10-30 16:44:03 +0300 |
commit | bcb612e3615e216f6defb2d631ef0f8c3c6d6c82 (patch) | |
tree | 1797c55a543d234f59db5ce25d3509cce306b081 /source | |
parent | ada45463b3c24e2ba28bfd97ebe08acd970c7694 (diff) |
Refactor: move view3dshading .blend I/O to blenkernel
Ref T76372.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/screen.c | 17 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 14 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 14 |
4 files changed, 32 insertions, 21 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 35a3d0415a8..857d344cf7e 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -58,6 +58,8 @@ struct wmMsgBus; struct wmNotifier; struct wmWindow; struct wmWindowManager; +struct BlendWriter; +struct BlendDataReader; /* spacetype has everything stored to get an editor working, it gets initialized via * ED_spacetypes_init() in editors/space_api/spacetypes.c */ @@ -449,6 +451,12 @@ void BKE_screen_remove_unused_scrverts(struct bScreen *screen); void BKE_screen_header_alignment_reset(struct bScreen *screen); +/* .blend file I/O */ +void BKE_screen_view3d_shading_blend_write(struct BlendWriter *writer, + struct View3DShading *shading); +void BKE_screen_view3d_shading_blend_read_data(struct BlendDataReader *reader, + struct View3DShading *shading); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index d9686eba29a..098dbf6a84e 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -57,6 +57,8 @@ #include "BKE_screen.h" #include "BKE_workspace.h" +#include "BLO_read_write.h" + static void screen_free_data(ID *id) { bScreen *screen = (bScreen *)id; @@ -1111,3 +1113,18 @@ void BKE_screen_header_alignment_reset(bScreen *screen) } screen->do_refresh = true; } + +void BKE_screen_view3d_shading_blend_write(BlendWriter *writer, View3DShading *shading) +{ + if (shading->prop) { + IDP_BlendWrite(writer, shading->prop); + } +} + +void BKE_screen_view3d_shading_blend_read_data(BlendDataReader *reader, View3DShading *shading) +{ + if (shading->prop) { + BLO_read_data_address(reader, &shading->prop); + IDP_BlendDataRead(reader, &shading->prop); + } +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index dfc031c5206..dccd2756cc5 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4010,14 +4010,6 @@ static void direct_link_lightcache(BlendDataReader *reader, LightCache *cache) BLO_read_data_address(reader, &cache->grid_data); } -static void direct_link_view3dshading(BlendDataReader *reader, View3DShading *shading) -{ - if (shading->prop) { - BLO_read_data_address(reader, &shading->prop); - IDP_BlendDataRead(reader, &shading->prop); - } -} - /* check for cyclic set-scene, * libs can cause this case which is normally prevented, see (T#####) */ #define USE_SETSCENE_CHECK @@ -4626,7 +4618,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce) } EEVEE_lightcache_info_update(&sce->eevee); - direct_link_view3dshading(reader, &sce->display.shading); + BKE_screen_view3d_shading_blend_read_data(reader, &sce->display.shading); BLO_read_data_address(reader, &sce->layer_properties); IDP_BlendDataRead(reader, &sce->layer_properties); @@ -4790,7 +4782,7 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area) } v3d->shading.prev_type = OB_SOLID; - direct_link_view3dshading(reader, &v3d->shading); + BKE_screen_view3d_shading_blend_read_data(reader, &v3d->shading); blo_do_versions_view3d_split_250(v3d, &sl->regionbase); } @@ -5168,7 +5160,7 @@ static bool direct_link_area_map(BlendDataReader *reader, ScrAreaMap *area_map) static void direct_link_wm_xr_data(BlendDataReader *reader, wmXrData *xr_data) { - direct_link_view3dshading(reader, &xr_data->session_settings.shading); + BKE_screen_view3d_shading_blend_read_data(reader, &xr_data->session_settings.shading); } static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData *xr_data) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f7045311627..421566eb8c3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -155,6 +155,7 @@ #include "BKE_packedFile.h" #include "BKE_pointcache.h" #include "BKE_report.h" +#include "BKE_screen.h" #include "BKE_sequencer.h" #include "BKE_shader_fx.h" #include "BKE_subsurf.h" @@ -1319,13 +1320,6 @@ static void write_view_settings(BlendWriter *writer, ColorManagedViewSettings *v } } -static void write_view3dshading(BlendWriter *writer, View3DShading *shading) -{ - if (shading->prop) { - IDP_BlendWrite(writer, shading->prop); - } -} - static void write_paint(BlendWriter *writer, Paint *p) { if (p->cavity_curve) { @@ -1626,7 +1620,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) write_lightcache(writer, sce->eevee.light_cache_data); } - write_view3dshading(writer, &sce->display.shading); + BKE_screen_view3d_shading_blend_write(writer, &sce->display.shading); /* Freed on doversion. */ BLI_assert(sce->layer_properties == NULL); @@ -1634,7 +1628,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) static void write_wm_xr_data(BlendWriter *writer, wmXrData *xr_data) { - write_view3dshading(writer, &xr_data->session_settings.shading); + BKE_screen_view3d_shading_blend_write(writer, &xr_data->session_settings.shading); } static void write_region(BlendWriter *writer, ARegion *region, int spacetype) @@ -1761,7 +1755,7 @@ static void write_area_regions(BlendWriter *writer, ScrArea *area) BLO_write_struct(writer, View3D, v3d->localvd); } - write_view3dshading(writer, &v3d->shading); + BKE_screen_view3d_shading_blend_write(writer, &v3d->shading); } else if (sl->spacetype == SPACE_GRAPH) { SpaceGraph *sipo = (SpaceGraph *)sl; |