164 #ifndef WITH_HEADLESS
167 const int fileflags =
G.fileflags;
178 G.fileflags = fileflags;
186 #ifndef WITH_HEADLESS
187 static bool base_initialized =
false;
189 if (!base_initialized) {
193 base_initialized =
true;
222 if (pr_main ==
NULL) {
239 return "Shader Ball";
245 return "World Sphere";
280 if (
STREQ(base->object->id.name + 2,
"Floor")) {
336 if (!allow_failure) {
337 BLI_assert(!
"ID type preview not supported.");
378 if (
id && sp->
sizex < 40) {
395 if (id_type ==
ID_TE) {
403 if (id_type ==
ID_MA) {
418 else if (sce->
world) {
450 if (base->object->id.name[2] ==
'p') {
458 int actcol =
max_ii(base->object->actcol - 1, 0);
460 if (matar && actcol < base->object->totcol) {
461 (*matar)[actcol] = mat;
464 else if (base->object->type ==
OB_LAMP) {
470 else if (id_type ==
ID_TE) {
487 else if (id_type ==
ID_LA) {
509 if (base->object->id.name[2] ==
'p') {
510 if (base->object->type ==
OB_LAMP) {
511 base->object->data = la;
523 else if (id_type ==
ID_WO) {
563 if (!
split || first) {
564 sprintf(name,
"Preview %p", (
void *)
area);
567 sprintf(name,
"SecondPreview %p", (
void *)
area);
577 newx = newx - newx / 2;
599 if (rv && rv->
rectf) {
608 "ed_preview_draw_rect");
609 float fx = rect->
xmin + offx;
610 float fy = rect->
ymin;
619 &
state, fx, fy, rres.
rectx, rres.
recty,
GPU_RGBA8,
false, rect_byte, 1.0f, 1.0f,
NULL);
639 ID *parent = (
ID *)parentp;
737 preview_data->
sizey);
762 const float pixelsize_old =
U.pixelsize;
763 char err_out[256] =
"unknown";
771 .sizex = preview_sized->
sizex,
772 .sizey = preview_sized->
sizey,
788 preview_sized->
sizex,
789 preview_sized->
sizey,
798 U.pixelsize = pixelsize_old;
820 char err_out[256] =
"";
831 if (camera_eval ==
NULL) {
832 printf(
"Scene has no camera, unable to render preview of %s without it.\n",
843 preview_sized->
sizex,
844 preview_sized->
sizey,
852 if (err_out[0] !=
'\0') {
853 printf(
"Error rendering Action %s preview: %s\n", preview->
id->
name + 2, err_out);
946 float *rect_float = rv->
rectf;
948 bool color_manage =
true;
961 rect_float[0] = texres.
tr;
962 rect_float[1] = texres.
tg;
963 rect_float[2] = texres.
tb;
964 rect_float[3] = texres.
talpha ? texres.
ta : 1.0f;
991 sizex = sp->
sizex / 2;
1004 sce->
r.
xsch = sizex;
1015 if (!
split || first) {
1016 sprintf(name,
"Preview %p", sp->
owner);
1019 sprintf(name,
"SecondPreview %p", sp->
owner);
1037 if (idtype ==
ID_MA) {
1040 else if (idtype ==
ID_TE) {
1058 if (sizex > sp->
sizey) {
1063 if (idtype ==
ID_TE) {
1087 if (idtype ==
ID_TE) {
1158 if (main_id_copy || sp->
id_copy) {
1232 uint *drect, *srect;
1233 float scaledx, scaledy;
1234 short ex, ey, dx, dy;
1248 if (ima->
x > ima->
y) {
1250 scaledy = ((
float)ima->
y / (
float)ima->
x) * (
float)
w;
1253 scaledx = ((
float)ima->
x / (
float)ima->
y) * (
float)h;
1258 ex =
MAX2(1, (
short)scaledx);
1259 ey =
MAX2(1, (
short)scaledy);
1274 drect += dy *
w + dx;
1275 for (; ey > 0; ey--) {
1276 memcpy(drect, srect, ex *
sizeof(
int));
1286 int a,
size = sizex * sizey;
1288 for (
a = 0;
a <
size;
a++, cp += 4) {
1301 int source = deferred_data[0];
1302 char *path = &deferred_data[1];
1322 if (idtype ==
ID_IM) {
1334 if (tile->
ok == 0) {
1357 else if (idtype ==
ID_BR) {
1372 else if (idtype ==
ID_SCR) {
1384 if (idtype ==
ID_WO) {
1415 const int pr_method,
1467 if ((preview_image->
w[i] == icon_size->
sizex) && (preview_image->
h[i] == icon_size->
sizey)) {
1472 BLI_assert(!
"The searched icon size does not match any in the preview image");
1484 for (cur_size = ip->
sizes.
first; cur_size; cur_size = cur_size->
next) {
1540 if (cur_size->
sizex == sizex && cur_size->
sizey == sizey) {
1545 cur_size = cur_size->
next;
1549 new_size->sizex = sizex;
1550 new_size->sizey = sizey;
1551 new_size->rect =
rect;
1573 if (prv_img->gputexture[i]) {
1575 prv_img->gputexture[i] =
NULL;
1615 short stop =
false,
update =
false;
1616 float progress = 0.0f;
1642 const bContext *
C,
void *owner,
ID *
id,
uint *
rect,
int sizex,
int sizey,
const bool delay)
typedef float(TangentPoint)[2]
void immDrawPixelsTex(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, void *rect, float xzoom, float yzoom, const float color[4])
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
const char * BKE_appdir_folder_id(const int folder_id, const char *subfolder)
bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob)
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct SpaceProperties * CTX_wm_space_properties(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
struct PreviewImage * BKE_previewimg_id_ensure(struct ID *id)
bool BKE_previewimg_id_supports_jobs(const struct ID *id)
void BKE_icon_changed(const int icon_id)
bool BKE_previewimg_is_finished(const struct PreviewImage *prv, const int size)
void BKE_previewimg_finish(struct PreviewImage *prv, const int size)
void BKE_previewimg_deferred_release(struct PreviewImage *prv)
int BKE_icon_id_ensure(struct ID *id)
struct IDProperty * IDP_GetProperties(struct ID *id, const bool create_if_needed) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_FreePropertyContent_ex(struct IDProperty *prop, const bool do_id_user)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
struct ImagePool * BKE_image_pool_new(void)
void BKE_imageuser_default(struct ImageUser *iuser)
void BKE_image_pool_free(struct ImagePool *pool)
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
void BKE_layer_collection_sync(const struct Scene *scene, struct ViewLayer *view_layer)
@ LIB_ID_COPY_NO_ANIMDATA
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag)
void BKE_libblock_free_datablock(struct ID *id, const int flag) ATTR_NONNULL()
General operations, lookup, etc. for blender lights.
struct Main * BKE_main_new(void)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
void BKE_main_free(struct Main *mainvar)
const char * BKE_main_blendfile_path_from_global(void)
General operations, lookup, etc. for materials.
struct Material *** BKE_object_material_array_p(struct Object *ob)
void ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree)
void BKE_node_preview_init_tree(struct bNodeTree *ntree, int xsize, int ysize, bool create_previews)
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_add(struct Main *bmain, struct ViewLayer *view_layer, int type, const char *name) ATTR_NONNULL(1
void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bmain)
struct Scene * BKE_scene_add(struct Main *bmain, const char *name)
void BKE_texture_fetch_images_for_pool(struct Tex *texture, struct ImagePool *pool)
void BKE_texture_get_value_ex(const struct Scene *scene, struct Tex *texture, const float *tex_co, struct TexResult *texres, struct ImagePool *pool, bool use_color_management)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void void void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
void mul_m3_m3_post(float R[3][3], const float B[3][3])
void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], const float wmat[4][4])
void axis_angle_to_mat3_single(float R[3][3], const char axis, const float angle)
void mat3_to_quat(float q[4], const float mat[3][3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file)
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
int BLI_thread_is_main(void)
#define ARRAY_SET_ITEMS(...)
external readfile function prototypes.
BlendFileData * BLO_read_from_memory(const void *mem, int memsize, eBLOReadSkip skip_flags, struct ReportList *reports)
void DEG_evaluate_on_refresh(Depsgraph *graph)
Depsgraph * DEG_graph_new(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode)
struct Depsgraph Depsgraph
void DEG_graph_free(Depsgraph *graph)
void DEG_graph_build_from_view_layer(struct Depsgraph *graph)
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
#define ID_BLEND_PATH_FROM_GLOBAL(_id)
#define PRV_DEFERRED_DATA(prv)
@ PRV_TAG_DEFFERED_DELETE
@ PRV_TAG_DEFFERED_RENDERING
Object groups, one object can be in many groups at once.
@ COLLECTION_RESTRICT_RENDER
Object is a sort of wrapper for general info.
#define OB_TYPE_SUPPORT_MATERIAL(_type)
#define R_TEXNODE_PREVIEW
@ SCE_DISPLAY_AA_SAMPLES_8
#define R_MATNODE_PREVIEW
char datatoc_preview_blend[]
int datatoc_preview_grease_pencil_blend_size
char datatoc_preview_grease_pencil_blend[]
int datatoc_preview_blend_size
void ED_screen_preview_render(const struct bScreen *screen, int size_x, int size_y, unsigned int *r_rect) ATTR_NONNULL()
bool ED_view3d_camera_to_view_selected(struct Main *bmain, struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *camera_ob)
struct ImBuf * ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph, struct Scene *scene, struct View3DShading *shading_override, eDrawType drawtype, struct Object *camera, int width, int height, eImBufFlags imbuf_flags, eV3DOffscreenDrawFlag draw_flags, int alpha_mode, const char *viewname, struct GPUOffScreen *ofs, char err_out[256])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
@ GPU_SHADER_2D_IMAGE_COLOR
void GPU_texture_free(GPUTexture *tex)
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_rect_from_float(struct ImBuf *ibuf)
void IMB_freeImBuf(struct ImBuf *ibuf)
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
void IMB_premultiply_alpha(struct ImBuf *ibuf)
bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Contains defines and structs used throughout the imbuf module.
struct ImBuf * IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
Read Guarded memory(de)allocation.
Platform independent time functions.
@ WM_JOB_TYPE_RENDER_PREVIEW
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
const Depsgraph * depsgraph
static CCL_NAMESPACE_BEGIN const double alpha
RenderEngineType * RE_engines_find(const char *idname)
void * BKE_image_get_tile
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
static void update(bNodeTree *ntree)
void RE_ReleaseResultImageViews(Render *re, RenderResult *rr)
Render * RE_GetRender(const char *name)
void RE_PreviewRender(Render *re, Main *bmain, Scene *sce)
Render * RE_NewRender(const char *name)
void RE_InitState(Render *re, Render *source, RenderData *rd, ListBase *render_layers, ViewLayer *single_layer, int winx, int winy, rcti *disprect)
void RE_ReleaseResult(Render *re)
RenderResult * RE_AcquireResultWrite(Render *re)
void RE_test_break_cb(Render *re, void *handle, int(*f)(void *handle))
void RE_display_update_cb(Render *re, void *handle, void(*f)(void *handle, RenderResult *rr, volatile rcti *rect))
void RE_AcquiredResultGet32(Render *re, RenderResult *result, unsigned int *rect, const int view_id)
void RE_AcquireResultImageViews(Render *re, RenderResult *rr)
void RE_SetScene(Render *re, Scene *sce)
void RE_ResultGet32(Render *re, unsigned int *rect)
static Scene * preview_get_scene(Main *pr_main)
static Object * object_preview_camera_create(Main *preview_main, ViewLayer *view_layer, Object *preview_object, int sizex, int sizey)
static void icon_preview_add_size(IconPreview *ip, uint *rect, int sizex, int sizey)
static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Render *re)
static void icon_preview_endjob(void *customdata)
static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short *do_update, float *progress)
static bool check_engine_supports_preview(Scene *scene)
static const char * preview_collection_name(const char pr_type)
static void shader_preview_free(void *customdata)
static Main * load_main_from_memory(const void *blend, int blend_size)
static void common_preview_startjob(void *customdata, short *stop, short *do_update, float *UNUSED(progress))
void ED_preview_ensure_dbase(void)
static Scene * object_preview_scene_create(const struct ObjectPreviewData *preview_data, Depsgraph **r_depsgraph)
void ED_preview_free_dbase(void)
void ED_preview_kill_jobs(wmWindowManager *wm, Main *UNUSED(bmain))
static void shader_preview_update(void *spv, RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect))
static void icon_preview_free(void *customdata)
struct IconPreviewSize IconPreviewSize
struct ShaderPreview ShaderPreview
static World * preview_get_localized_world(ShaderPreview *sp, World *world)
static void set_preview_visibility(Scene *scene, ViewLayer *view_layer, char pr_type, int pr_method)
static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect)
void ED_preview_icon_job(const bContext *C, void *owner, ID *id, uint *rect, int sizex, int sizey, const bool delay)
static Scene * preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_type, ShaderPreview *sp)
static void object_preview_render(IconPreview *preview, IconPreviewSize *preview_sized)
static int icon_previewimg_size_index_get(const IconPreviewSize *icon_size, const PreviewImage *preview_image)
static void action_preview_render(IconPreview *preview, IconPreviewSize *preview_sized)
static bool preview_method_is_render(int pr_method)
void ED_preview_icon_render(const bContext *C, Scene *scene, ID *id, uint *rect, int sizex, int sizey)
static void shader_preview_startjob(void *customdata, short *stop, short *do_update)
static Main * G_pr_main_grease_pencil
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
static void set_alpha(char *cp, int sizex, int sizey, char alpha)
static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int first)
static void preview_id_copy_free(ID *id)
static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect, rcti *newrect)
static ImBuf * icon_preview_imbuf_from_brush(Brush *brush)
static int shader_preview_break(void *spv)
static void shader_preview_updatejob(void *spv)
static void icon_preview_startjob(void *customdata, short *stop, short *do_update)
static ID * duplicate_ids(ID *id, const bool allow_failure)
struct IconPreview IconPreview
void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method)
static void other_id_types_preview_render(IconPreview *ip, IconPreviewSize *cur_size, const int pr_method, short *stop, short *do_update, float *progress)
RenderView * RE_RenderViewGetById(RenderResult *rr, const int view_id)
const char * RE_engine_id_BLENDER_EEVEE
struct ImBuf * icon_imbuf
struct IconPreviewSize * next
struct IconPreviewSize * prev
struct LayerCollection * next
ListBase layer_collections
struct Collection * collection
struct bNodeTree * nodetree
struct bNodeTree * nodetree
struct PreviewImage * preview
struct MaterialGPencilStyle * gp_style
struct Collection * master_collection
struct SceneDisplay display
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
struct bNodeTree * nodetree
struct ViewLayerEEVEE eevee
ListBase layer_collections
struct bNodeTree * nodetree
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)
__forceinline const avxi abs(const avxi &a)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_jobs_kill(wmWindowManager *wm, void *owner, void(*startjob)(void *, short int *, short int *, float *))
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
void * WM_jobs_customdata(wmWindowManager *wm, void *owner)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
void WM_jobs_delay_start(wmJob *wm_job, double delay_time)
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
void * WM_jobs_customdata_get(wmJob *wm_job)
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)