Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r--source/blender/editors/render/CMakeLists.txt21
-rw-r--r--source/blender/editors/render/render_intern.hh20
-rw-r--r--source/blender/editors/render/render_internal.cc27
-rw-r--r--source/blender/editors/render/render_opengl.cc77
-rw-r--r--source/blender/editors/render/render_ops.cc20
-rw-r--r--source/blender/editors/render/render_preview.cc389
-rw-r--r--source/blender/editors/render/render_shading.cc23
-rw-r--r--source/blender/editors/render/render_update.cc19
-rw-r--r--source/blender/editors/render/render_view.cc20
9 files changed, 335 insertions, 281 deletions
diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt
index 1f867c6f1f7..dde1f138bac 100644
--- a/source/blender/editors/render/CMakeLists.txt
+++ b/source/blender/editors/render/CMakeLists.txt
@@ -1,19 +1,4 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# ***** END GPL LICENSE BLOCK *****
+# SPDX-License-Identifier: GPL-2.0-or-later
set(INC
../include
@@ -67,8 +52,4 @@ if(WITH_FREESTYLE)
add_definitions(-DWITH_FREESTYLE)
endif()
-if(WITH_INTERNATIONAL)
- add_definitions(-DWITH_INTERNATIONAL)
-endif()
-
blender_add_lib(bf_editor_render "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/editors/render/render_intern.hh b/source/blender/editors/render/render_intern.hh
index d374717664b..fc40fb06851 100644
--- a/source/blender/editors/render/render_intern.hh
+++ b/source/blender/editors/render/render_intern.hh
@@ -1,21 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2008 Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup edrend
diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc
index cd3b8183d48..03c0f3977b7 100644
--- a/source/blender/editors/render/render_internal.cc
+++ b/source/blender/editors/render/render_internal.cc
@@ -1,21 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2008 Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup edrend
@@ -90,7 +74,7 @@ struct RenderJob {
Scene *scene;
ViewLayer *single_layer;
Scene *current_scene;
- /* TODO(sergey): Should not be needed once engine will have own
+ /* TODO(sergey): Should not be needed once engine will have its own
* depsgraph and copy-on-write will be implemented.
*/
Depsgraph *depsgraph;
@@ -987,7 +971,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
rj->scene = scene;
rj->current_scene = rj->scene;
rj->single_layer = single_layer;
- /* TODO(sergey): Render engine should be using own depsgraph.
+ /* TODO(sergey): Render engine should be using its own depsgraph.
*
* NOTE: Currently is only used by ED_update_for_newframe() at the end of the render, so no
* need to ensure evaluation here. */
@@ -1210,5 +1194,6 @@ void RENDER_OT_shutter_curve_preset(wmOperatorType *ot)
ot->exec = render_shutter_curve_preset_exec;
prop = RNA_def_enum(ot->srna, "shape", prop_shape_items, CURVE_PRESET_SMOOTH, "Mode", "");
- RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
+ RNA_def_property_translation_context(prop,
+ BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
}
diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc
index 4a012e63952..be66e87f2e5 100644
--- a/source/blender/editors/render/render_opengl.cc
+++ b/source/blender/editors/render/render_opengl.cc
@@ -1,21 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2008 Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup render
@@ -72,8 +56,11 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+
#include "RE_pipeline.h"
+#include "BLT_translation.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
@@ -612,30 +599,30 @@ static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data)
const ID_Type id_type = GS(id->name);
switch (id_type) {
/* Whitelist: */
- case ID_ME: /* Mesh */
- case ID_CU: /* Curve */
- case ID_MB: /* MetaBall */
- case ID_MA: /* Material */
- case ID_TE: /* Tex (Texture) */
- case ID_IM: /* Image */
- case ID_LT: /* Lattice */
- case ID_LA: /* Light */
- case ID_CA: /* Camera */
- case ID_KE: /* Key (shape key) */
- case ID_VF: /* VFont (Vector Font) */
- case ID_TXT: /* Text */
- case ID_SPK: /* Speaker */
- case ID_SO: /* Sound */
- case ID_AR: /* bArmature */
- case ID_NT: /* bNodeTree */
- case ID_PA: /* ParticleSettings */
- case ID_MC: /* MovieClip */
- case ID_MSK: /* Mask */
- case ID_LP: /* LightProbe */
- case ID_HA: /* Hair */
- case ID_PT: /* PointCloud */
- case ID_VO: /* Volume */
- case ID_SIM: /* Simulation */
+ case ID_ME: /* Mesh */
+ case ID_CU_LEGACY: /* Curve */
+ case ID_MB: /* MetaBall */
+ case ID_MA: /* Material */
+ case ID_TE: /* Tex (Texture) */
+ case ID_IM: /* Image */
+ case ID_LT: /* Lattice */
+ case ID_LA: /* Light */
+ case ID_CA: /* Camera */
+ case ID_KE: /* Key (shape key) */
+ case ID_VF: /* VFont (Vector Font) */
+ case ID_TXT: /* Text */
+ case ID_SPK: /* Speaker */
+ case ID_SO: /* Sound */
+ case ID_AR: /* bArmature */
+ case ID_NT: /* bNodeTree */
+ case ID_PA: /* ParticleSettings */
+ case ID_MC: /* MovieClip */
+ case ID_MSK: /* Mask */
+ case ID_LP: /* LightProbe */
+ case ID_CV: /* Curves */
+ case ID_PT: /* PointCloud */
+ case ID_VO: /* Volume */
+ case ID_SIM: /* Simulation */
break;
/* Blacklist: */
@@ -1326,12 +1313,12 @@ static char *screen_opengl_render_description(struct bContext *UNUSED(C),
}
if (RNA_boolean_get(ptr, "render_keyed_only")) {
- return BLI_strdup(
+ return BLI_strdup(TIP_(
"Render the viewport for the animation range of this scene, but only render keyframes of "
- "selected objects");
+ "selected objects"));
}
- return BLI_strdup("Render the viewport for the animation range of this scene");
+ return BLI_strdup(TIP_("Render the viewport for the animation range of this scene"));
}
void RENDER_OT_opengl(wmOperatorType *ot)
diff --git a/source/blender/editors/render/render_ops.cc b/source/blender/editors/render/render_ops.cc
index 0f10d186e6e..1583ce44ee5 100644
--- a/source/blender/editors/render/render_ops.cc
+++ b/source/blender/editors/render/render_ops.cc
@@ -1,21 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2009 Blender Foundation. All rights reserved. */
/** \file
* \ingroup edrend
diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc
index df078bbd890..eca30a6ac25 100644
--- a/source/blender/editors/render/render_preview.cc
+++ b/source/blender/editors/render/render_preview.cc
@@ -1,21 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright Blender Foundation. All rights reserved. */
/** \file
* \ingroup edrend
@@ -26,6 +10,7 @@
#include <cmath>
#include <cstdlib>
#include <cstring>
+#include <list>
#ifndef WIN32
# include <unistd.h>
@@ -767,7 +752,7 @@ struct ObjectPreviewData {
/* The main for the preview, not of the current file. */
Main *pr_main;
/* Copy of the object to create the preview for. The copy is for thread safety (and to insert
- * it into an own main). */
+ * it into its own main). */
Object *object;
/* Current frame. */
int cfra;
@@ -1386,89 +1371,73 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
ShaderPreview *sp = static_cast<ShaderPreview *>(customdata);
if (sp->pr_method == PR_ICON_DEFERRED) {
- PreviewImage *prv = static_cast<PreviewImage *>(sp->owner);
- ImBuf *thumb;
- char *deferred_data = static_cast<char *>(PRV_DEFERRED_DATA(prv));
- ThumbSource source = static_cast<ThumbSource>(deferred_data[0]);
- char *path = &deferred_data[1];
-
- // printf("generating deferred %d×%d preview for %s\n", sp->sizex, sp->sizey, path);
-
- thumb = IMB_thumb_manage(path, THB_LARGE, source);
-
- if (thumb) {
- /* PreviewImage assumes premultiplied alhpa... */
- IMB_premultiply_alpha(thumb);
-
- icon_copy_rect(thumb, sp->sizex, sp->sizey, sp->pr_rect);
- IMB_freeImBuf(thumb);
- }
+ BLI_assert_unreachable();
+ return;
}
- else {
- ID *id = sp->id;
- short idtype = GS(id->name);
- BLI_assert(id != nullptr);
-
- if (idtype == ID_IM) {
- Image *ima = (Image *)id;
- ImBuf *ibuf = nullptr;
- ImageUser iuser;
- BKE_imageuser_default(&iuser);
+ ID *id = sp->id;
+ short idtype = GS(id->name);
- if (ima == nullptr) {
- return;
- }
+ BLI_assert(id != nullptr);
- /* setup dummy image user */
- iuser.framenr = 1;
- iuser.scene = sp->scene;
-
- /* NOTE(@elubie): this needs to be changed: here image is always loaded if not
- * already there. Very expensive for large images. Need to find a way to
- * only get existing `ibuf`. */
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
- if (ibuf == nullptr || (ibuf->rect == nullptr && ibuf->rect_float == nullptr)) {
- BKE_image_release_ibuf(ima, ibuf, nullptr);
- return;
- }
+ if (idtype == ID_IM) {
+ Image *ima = (Image *)id;
+ ImBuf *ibuf = nullptr;
+ ImageUser iuser;
+ BKE_imageuser_default(&iuser);
- icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect);
+ if (ima == nullptr) {
+ return;
+ }
- *do_update = true;
+ /* setup dummy image user */
+ iuser.framenr = 1;
+ iuser.scene = sp->scene;
+ /* NOTE(@elubie): this needs to be changed: here image is always loaded if not
+ * already there. Very expensive for large images. Need to find a way to
+ * only get existing `ibuf`. */
+ ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
+ if (ibuf == nullptr || (ibuf->rect == nullptr && ibuf->rect_float == nullptr)) {
BKE_image_release_ibuf(ima, ibuf, nullptr);
+ return;
}
- else if (idtype == ID_BR) {
- Brush *br = (Brush *)id;
- br->icon_imbuf = icon_preview_imbuf_from_brush(br);
+ icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect);
- memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(uint));
+ *do_update = true;
- if (!(br->icon_imbuf) || !(br->icon_imbuf->rect)) {
- return;
- }
+ BKE_image_release_ibuf(ima, ibuf, nullptr);
+ }
+ else if (idtype == ID_BR) {
+ Brush *br = (Brush *)id;
- icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);
+ br->icon_imbuf = icon_preview_imbuf_from_brush(br);
- *do_update = true;
- }
- else if (idtype == ID_SCR) {
- bScreen *screen = (bScreen *)id;
+ memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(uint));
- ED_screen_preview_render(screen, sp->sizex, sp->sizey, sp->pr_rect);
- *do_update = true;
+ if (!(br->icon_imbuf) || !(br->icon_imbuf->rect)) {
+ return;
}
- else {
- /* re-use shader job */
- shader_preview_startjob(customdata, stop, do_update);
- /* world is rendered with alpha=0, so it wasn't displayed
- * this could be render option for sky to, for later */
- if (idtype == ID_WO) {
- set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
- }
+ icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);
+
+ *do_update = true;
+ }
+ else if (idtype == ID_SCR) {
+ bScreen *screen = (bScreen *)id;
+
+ ED_screen_preview_render(screen, sp->sizex, sp->sizey, sp->pr_rect);
+ *do_update = true;
+ }
+ else {
+ /* re-use shader job */
+ shader_preview_startjob(customdata, stop, do_update);
+
+ /* world is rendered with alpha=0, so it wasn't displayed
+ * this could be render option for sky to, for later */
+ if (idtype == ID_WO) {
+ set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
}
}
}
@@ -1686,6 +1655,197 @@ static void icon_preview_endjob(void *customdata)
}
}
+/**
+ * Background job to manage requests for deferred loading of previews from the hard drive.
+ *
+ * Launches a single job to manage all incoming preview requests. The job is kept running until all
+ * preview requests are done loading (or it's otherwise aborted, e.g. by closing Blender).
+ *
+ * Note that this will use the OS thumbnail cache, i.e. load a preview from there or add it if not
+ * there yet. These two cases may lead to different performance.
+ */
+class PreviewLoadJob {
+ struct RequestedPreview {
+ PreviewImage *preview;
+ /** Requested size. */
+ eIconSizes icon_size;
+ };
+
+ /** The previews that are still to be loaded. */
+ ThreadQueue *todo_queue_; /* RequestedPreview * */
+ /** All unfinished preview requests, #update_fn() calls #finish_preview_request() on loaded
+ * previews and removes them from this list. Only access from the main thread! */
+ std::list<struct RequestedPreview> requested_previews_;
+
+ public:
+ PreviewLoadJob();
+ ~PreviewLoadJob();
+
+ static PreviewLoadJob &ensure_job(wmWindowManager *, wmWindow *);
+ static void load_jobless(PreviewImage *, eIconSizes);
+
+ void push_load_request(PreviewImage *, eIconSizes);
+
+ private:
+ static void run_fn(void *, short *, short *, float *);
+ static void update_fn(void *);
+ static void end_fn(void *);
+ static void free_fn(void *);
+
+ /** Mark a single requested preview as being done, remove the request. */
+ static void finish_request(RequestedPreview &);
+};
+
+PreviewLoadJob::PreviewLoadJob() : todo_queue_(BLI_thread_queue_init())
+{
+}
+
+PreviewLoadJob::~PreviewLoadJob()
+{
+ BLI_thread_queue_free(todo_queue_);
+}
+
+PreviewLoadJob &PreviewLoadJob::ensure_job(wmWindowManager *wm, wmWindow *win)
+{
+ wmJob *wm_job = WM_jobs_get(wm, win, nullptr, "Load Previews", 0, WM_JOB_TYPE_LOAD_PREVIEW);
+
+ if (!WM_jobs_is_running(wm_job)) {
+ PreviewLoadJob *job_data = MEM_new<PreviewLoadJob>("PreviewLoadJobData");
+
+ WM_jobs_customdata_set(wm_job, job_data, free_fn);
+ WM_jobs_timer(wm_job, 0.1, NC_WINDOW, NC_WINDOW);
+ WM_jobs_callbacks(wm_job, run_fn, nullptr, update_fn, end_fn);
+
+ WM_jobs_start(wm, wm_job);
+ }
+
+ return *reinterpret_cast<PreviewLoadJob *>(WM_jobs_customdata_get(wm_job));
+}
+
+void PreviewLoadJob::load_jobless(PreviewImage *preview, const eIconSizes icon_size)
+{
+ PreviewLoadJob job_data{};
+
+ job_data.push_load_request(preview, icon_size);
+
+ short stop = 0, do_update = 0;
+ float progress = 0;
+ run_fn(&job_data, &stop, &do_update, &progress);
+ update_fn(&job_data);
+ end_fn(&job_data);
+}
+
+void PreviewLoadJob::push_load_request(PreviewImage *preview, const eIconSizes icon_size)
+{
+ BLI_assert(preview->tag & PRV_TAG_DEFFERED);
+ RequestedPreview requested_preview{};
+ requested_preview.preview = preview;
+ requested_preview.icon_size = icon_size;
+
+ preview->flag[icon_size] |= PRV_RENDERING;
+ /* Warn main thread code that this preview is being rendered and cannot be freed. */
+ preview->tag |= PRV_TAG_DEFFERED_RENDERING;
+
+ requested_previews_.push_back(requested_preview);
+ BLI_thread_queue_push(todo_queue_, &requested_previews_.back());
+}
+
+void PreviewLoadJob::run_fn(void *customdata,
+ short *stop,
+ short *do_update,
+ float *UNUSED(progress))
+{
+ PreviewLoadJob *job_data = reinterpret_cast<PreviewLoadJob *>(customdata);
+
+ IMB_thumb_locks_acquire();
+
+ while (RequestedPreview *request = reinterpret_cast<RequestedPreview *>(
+ BLI_thread_queue_pop_timeout(job_data->todo_queue_, 100))) {
+ if (*stop) {
+ break;
+ }
+
+ PreviewImage *preview = request->preview;
+
+ const char *deferred_data = static_cast<char *>(PRV_DEFERRED_DATA(preview));
+ const ThumbSource source = static_cast<ThumbSource>(deferred_data[0]);
+ const char *path = &deferred_data[1];
+
+ // printf("loading deferred %d×%d preview for %s\n", request->sizex, request->sizey, path);
+
+ IMB_thumb_path_lock(path);
+ ImBuf *thumb = IMB_thumb_manage(path, THB_LARGE, source);
+ IMB_thumb_path_unlock(path);
+
+ if (thumb) {
+ /* PreviewImage assumes premultiplied alpha... */
+ IMB_premultiply_alpha(thumb);
+
+ icon_copy_rect(thumb,
+ preview->w[request->icon_size],
+ preview->h[request->icon_size],
+ preview->rect[request->icon_size]);
+ IMB_freeImBuf(thumb);
+ }
+
+ *do_update = true;
+ }
+
+ IMB_thumb_locks_release();
+}
+
+/* Only execute on the main thread! */
+void PreviewLoadJob::finish_request(RequestedPreview &request)
+{
+ PreviewImage *preview = request.preview;
+
+ preview->tag &= ~PRV_TAG_DEFFERED_RENDERING;
+ BKE_previewimg_finish(preview, request.icon_size);
+
+ BLI_assert_msg(BLI_thread_is_main(),
+ "Deferred releasing of preview images should only run on the main thread");
+ if (preview->tag & PRV_TAG_DEFFERED_DELETE) {
+ BLI_assert(preview->tag & PRV_TAG_DEFFERED);
+ BKE_previewimg_deferred_release(preview);
+ }
+}
+
+void PreviewLoadJob::update_fn(void *customdata)
+{
+ PreviewLoadJob *job_data = reinterpret_cast<PreviewLoadJob *>(customdata);
+
+ for (auto request_it = job_data->requested_previews_.begin();
+ request_it != job_data->requested_previews_.end();) {
+ RequestedPreview &requested = *request_it;
+ /* Skip items that are not done loading yet. */
+ if (requested.preview->tag & PRV_TAG_DEFFERED_RENDERING) {
+ ++request_it;
+ continue;
+ }
+ finish_request(requested);
+
+ /* Remove properly finished previews from the job data. */
+ auto next_it = job_data->requested_previews_.erase(request_it);
+ request_it = next_it;
+ }
+}
+
+void PreviewLoadJob::end_fn(void *customdata)
+{
+ PreviewLoadJob *job_data = reinterpret_cast<PreviewLoadJob *>(customdata);
+
+ /* Finish any possibly remaining queued previews. */
+ for (RequestedPreview &request : job_data->requested_previews_) {
+ finish_request(request);
+ }
+ job_data->requested_previews_.clear();
+}
+
+void PreviewLoadJob::free_fn(void *customdata)
+{
+ MEM_delete(reinterpret_cast<PreviewLoadJob *>(customdata));
+}
+
static void icon_preview_free(void *customdata)
{
IconPreview *ip = (IconPreview *)customdata;
@@ -1714,8 +1874,19 @@ bool ED_preview_id_is_supported(const ID *id)
}
void ED_preview_icon_render(
- const bContext *C, Scene *scene, ID *id, uint *rect, int sizex, int sizey)
+ const bContext *C, Scene *scene, PreviewImage *prv_img, ID *id, eIconSizes icon_size)
{
+ /* Deferred loading of previews from the file system. */
+ if (prv_img->tag & PRV_TAG_DEFFERED) {
+ if (prv_img->flag[icon_size] & PRV_RENDERING) {
+ /* Already in the queue, don't add it again. */
+ return;
+ }
+
+ PreviewLoadJob::load_jobless(prv_img, icon_size);
+ return;
+ }
+
IconPreview ip = {nullptr};
short stop = false, update = false;
float progress = 0.0f;
@@ -1732,7 +1903,10 @@ void ED_preview_icon_render(
ip.id_copy = duplicate_ids(id, true);
ip.active_object = CTX_data_active_object(C);
- icon_preview_add_size(&ip, rect, sizex, sizey);
+ prv_img->flag[icon_size] |= PRV_RENDERING;
+
+ icon_preview_add_size(
+ &ip, prv_img->rect[icon_size], prv_img->w[icon_size], prv_img->h[icon_size]);
icon_preview_startjob_all_sizes(&ip, &stop, &update, &progress);
@@ -1745,20 +1919,31 @@ void ED_preview_icon_render(
}
void ED_preview_icon_job(
- const bContext *C, void *owner, ID *id, uint *rect, int sizex, int sizey, const bool delay)
+ const bContext *C, PreviewImage *prv_img, ID *id, eIconSizes icon_size, const bool delay)
{
- wmJob *wm_job;
+ /* Deferred loading of previews from the file system. */
+ if (prv_img->tag & PRV_TAG_DEFFERED) {
+ if (prv_img->flag[icon_size] & PRV_RENDERING) {
+ /* Already in the queue, don't add it again. */
+ return;
+ }
+ PreviewLoadJob &load_job = PreviewLoadJob::ensure_job(CTX_wm_manager(C), CTX_wm_window(C));
+ load_job.push_load_request(prv_img, icon_size);
+
+ return;
+ }
+
IconPreview *ip, *old_ip;
ED_preview_ensure_dbase();
/* suspended start means it starts after 1 timer step, see WM_jobs_timer below */
- wm_job = WM_jobs_get(CTX_wm_manager(C),
- CTX_wm_window(C),
- owner,
- "Icon Preview",
- WM_JOB_EXCL_RENDER,
- WM_JOB_TYPE_RENDER_PREVIEW);
+ wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
+ CTX_wm_window(C),
+ prv_img,
+ "Icon Preview",
+ WM_JOB_EXCL_RENDER,
+ WM_JOB_TYPE_RENDER_PREVIEW);
ip = MEM_cnew<IconPreview>("icon preview");
@@ -1773,20 +1958,14 @@ void ED_preview_icon_job(
ip->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ip->scene = DEG_get_input_scene(ip->depsgraph);
ip->active_object = CTX_data_active_object(C);
- ip->owner = owner;
+ ip->owner = prv_img;
ip->id = id;
ip->id_copy = duplicate_ids(id, false);
- icon_preview_add_size(ip, rect, sizex, sizey);
+ prv_img->flag[icon_size] |= PRV_RENDERING;
- /* Special threading hack:
- * warn main code that this preview is being rendered and cannot be freed... */
- {
- PreviewImage *prv_img = static_cast<PreviewImage *>(owner);
- if (prv_img->tag & PRV_TAG_DEFFERED) {
- prv_img->tag |= PRV_TAG_DEFFERED_RENDERING;
- }
- }
+ icon_preview_add_size(
+ ip, prv_img->rect[icon_size], prv_img->w[icon_size], prv_img->h[icon_size]);
/* setup job */
WM_jobs_customdata_set(wm_job, ip, icon_preview_free);
diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc
index 19ab6841e22..cd395674177 100644
--- a/source/blender/editors/render/render_shading.cc
+++ b/source/blender/editors/render/render_shading.cc
@@ -1,20 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2009 Blender Foundation. All rights reserved. */
/** \file
* \ingroup edrend
@@ -325,7 +310,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
- else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) {
Nurb *nu;
ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
@@ -426,7 +411,7 @@ static int material_slot_de_select(bContext *C, bool select)
changed = EDBM_deselect_by_material(em, mat_nr_active, select);
}
}
- else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) {
ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
Nurb *nu;
BPoint *bp;
diff --git a/source/blender/editors/render/render_update.cc b/source/blender/editors/render/render_update.cc
index b1e8e3927ef..3d26e764211 100644
--- a/source/blender/editors/render/render_update.cc
+++ b/source/blender/editors/render/render_update.cc
@@ -1,20 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2009 Blender Foundation. All rights reserved. */
/** \file
* \ingroup edrend
diff --git a/source/blender/editors/render/render_view.cc b/source/blender/editors/render/render_view.cc
index 980cd899120..a7ff2aad05a 100644
--- a/source/blender/editors/render/render_view.cc
+++ b/source/blender/editors/render/render_view.cc
@@ -1,21 +1,5 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2008 Blender Foundation.
- * All rights reserved.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup edrend