Compositor: Only execute compositor if result is viewed
This patch makes it such that the compositor only executes when its result is viewed either through the backdrop or through an image editor. Pull Request: https://projects.blender.org/blender/blender/pulls/116326
This commit is contained in:
@@ -8,15 +8,20 @@
|
||||
|
||||
#include "AS_asset_representation.hh"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_gpencil_legacy_types.h"
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_light_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
#include "DNA_world_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
@@ -34,6 +39,7 @@
|
||||
#include "BKE_node_tree_zones.hh"
|
||||
#include "BKE_screen.hh"
|
||||
|
||||
#include "ED_image.hh"
|
||||
#include "ED_node.hh"
|
||||
#include "ED_node_preview.hh"
|
||||
#include "ED_render.hh"
|
||||
@@ -679,6 +685,28 @@ static void node_area_listener(const wmSpaceTypeListenerParams *params)
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns true if an image editor exists that views the compositor result. */
|
||||
static bool is_compositor_viewer_image_visible(const bContext *C)
|
||||
{
|
||||
wmWindowManager *window_manager = CTX_wm_manager(C);
|
||||
LISTBASE_FOREACH (wmWindow *, window, &window_manager->windows) {
|
||||
bScreen *screen = WM_window_get_active_screen(window);
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
SpaceLink *space_link = static_cast<SpaceLink *>(area->spacedata.first);
|
||||
if (!space_link || space_link->spacetype != SPACE_IMAGE) {
|
||||
continue;
|
||||
}
|
||||
const SpaceImage *space_image = reinterpret_cast<const SpaceImage *>(space_link);
|
||||
Image *image = ED_space_image(space_image);
|
||||
if (image && image->source == IMA_SRC_VIEWER) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void node_area_refresh(const bContext *C, ScrArea *area)
|
||||
{
|
||||
/* default now: refresh node is starting preview */
|
||||
@@ -698,7 +726,11 @@ static void node_area_refresh(const bContext *C, ScrArea *area)
|
||||
}
|
||||
else if (snode->runtime->recalc_regular_compositing) {
|
||||
snode->runtime->recalc_regular_compositing = false;
|
||||
ED_node_composite_job(C, snode->nodetree, scene);
|
||||
/* Only start compositing if its result will be visible either in the backdrop or in a
|
||||
* viewer image. */
|
||||
if (snode->flag & SNODE_BACKDRAW || is_compositor_viewer_image_visible(C)) {
|
||||
ED_node_composite_job(C, snode->nodetree, scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user