Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Draw MovieClip Previews patch
diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc
index ffc39028400..0e1a43bfea2 100644
--- a/source/blender/blenkernel/intern/icons.cc
+++ b/source/blender/blenkernel/intern/icons.cc
@@ -41,6 +41,7 @@
#include "DNA_screen_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
+#include "DNA_movieclip_types.h"
#include "BLI_fileops.h"
#include "BLI_ghash.h"
@@ -379,6 +380,7 @@ PreviewImage **BKE_previewimg_id_get_p(const ID *id)
ID_PRV_CASE(ID_WO, World);
ID_PRV_CASE(ID_LA, Light);
ID_PRV_CASE(ID_IM, Image);
+ ID_PRV_CASE(ID_MC, MovieClip);
ID_PRV_CASE(ID_BR, Brush);
ID_PRV_CASE(ID_GR, Collection);
ID_PRV_CASE(ID_SCE, Scene);
@@ -444,7 +446,7 @@ void BKE_previewimg_id_custom_set(ID *id, const char *path)
bool BKE_previewimg_id_supports_jobs(const ID *id)
{
- return ELEM(GS(id->name), ID_OB, ID_MA, ID_TE, ID_LA, ID_WO, ID_IM, ID_BR);
+ return ELEM(GS(id->name), ID_OB, ID_MA, ID_TE, ID_LA, ID_WO, ID_IM, ID_MC, ID_BR);
}
void BKE_previewimg_deferred_release(PreviewImage *prv)
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 34fb9f71bd9..dca99acae88 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -62,6 +62,7 @@
#include "BKE_anim_data.h"
#include "BKE_colortools.h"
#include "BKE_global.h"
+#include "BKE_icons.h"
#include "BKE_idtype.h"
#include "BKE_image.h" /* openanim */
#include "BKE_lib_id.h"
@@ -115,6 +116,12 @@ static void movie_clip_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_s
BKE_color_managed_colorspace_settings_copy(&movie_clip_dst->colorspace_settings,
&movie_clip_src->colorspace_settings);
+ if (flag & LIB_ID_COPY_NO_PREVIEW) {
+ movie_clip_dst->preview = NULL;
+ }
+ else {
+ BKE_previewimg_id_copy(&movie_clip_dst->id, &movie_clip_dst->id);
+ }
}
static void movie_clip_free_data(ID *id)
@@ -125,6 +132,8 @@ static void movie_clip_free_data(ID *id)
free_buffers(movie_clip);
BKE_tracking_free(&movie_clip->tracking);
+
+ BKE_previewimg_free(&movie_clip->preview);
}
static void movie_clip_foreach_id(ID *id, LibraryForeachIDData *data)
@@ -236,6 +245,7 @@ static void movieclip_blend_write(BlendWriter *writer, ID *id, const void *id_ad
object = object->next;
}
+ BKE_previewimg_blend_write(writer, clip->preview);
}
static void direct_link_movieReconstruction(BlendDataReader *reader,
@@ -304,6 +314,8 @@ static void movieclip_blend_read_data(BlendDataReader *reader, ID *id)
direct_link_moviePlaneTracks(reader, &object->plane_tracks);
direct_link_movieReconstruction(reader, &object->reconstruction);
}
+ BLO_read_data_address(reader, &clip->preview);
+ BKE_previewimg_blend_read(reader, clip->preview);
}
static void lib_link_movieTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase)
diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h
index 8e01a9e1f1f..583cc4b0c75 100644
--- a/source/blender/makesdna/DNA_movieclip_types.h
+++ b/source/blender/makesdna/DNA_movieclip_types.h
@@ -127,6 +127,8 @@ typedef struct MovieClip {
ColorManagedColorspaceSettings colorspace_settings;
struct MovieClip_Runtime runtime;
+
+ struct PreviewImage *preview;
} MovieClip;
typedef struct MovieClipScopes {
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index ffdc99152b1..2fc42ef37bf 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3444,7 +3444,7 @@ typedef struct PreviewsIDEnsureData {
static void previews_id_ensure(bContext *C, Scene *scene, ID *id)
{
- BLI_assert(ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_WO, ID_LA));
+ BLI_assert(ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_MC, ID_WO, ID_LA));
/* Only preview non-library datablocks, lib ones do not pertain to this .blend file!
* Same goes for ID with no user. */
@@ -3466,7 +3466,7 @@ static int previews_id_ensure_callback(LibraryIDLinkCallbackData *cb_data)
ID *id = *cb_data->id_pointer;
if (id && (id->tag & LIB_TAG_DOIT)) {
- BLI_assert(ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_WO, ID_LA));
+ BLI_assert(ELEM(GS(id->name), ID_MA, ID_TE, ID_IM, ID_MC, ID_WO, ID_LA));
previews_id_ensure(data->C, data->scene, id);
id->tag &= ~LIB_TAG_DOIT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment