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:
authorHabib Gahbiche <zazizizou>2022-03-17 01:27:52 +0300
committerHabib Gahbiche <habibgahbiche@gmail.com>2022-03-17 01:28:36 +0300
commit33409f9f1cd42e899f2706fe7878e5e89b50d617 (patch)
tree1b33eac06e04867add023aa5e88c8cf577e5dc01 /source/blender/compositor
parent22de21bef1a31718d45e89aedc574055a5983b7d (diff)
Compositor: Support backdrop offset for the Viewer node
This is only part of the experimental "Full Frame" mode (disabled by default). See T88150. Currently the viewer node uses buffer paddings to display image offset in the backdrop as a temporal solution implemented for {D12466}. This solution is inefficient memory and performance-wise. Another issue is that the paddings are part the image when saved. This patch instead sets the offset in the Viewer node image as variables and makes the backdrop take it into account when drawing the image or any related gizmo. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D12750
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cc46
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h3
2 files changed, 14 insertions, 35 deletions
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cc b/source/blender/compositor/operations/COM_ViewerOperation.cc
index bc7e08ee98a..7f0eaecfff7 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cc
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cc
@@ -10,9 +10,9 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-namespace blender::compositor {
+#include "DNA_node_types.h"
-static int MAX_VIEWER_TRANSLATION_PADDING = 12000;
+namespace blender::compositor {
ViewerOperation::ViewerOperation()
{
@@ -137,23 +137,12 @@ void ViewerOperation::init_image()
return;
}
- int padding_x = abs(canvas_.xmin) * 2;
- int padding_y = abs(canvas_.ymin) * 2;
- if (padding_x > MAX_VIEWER_TRANSLATION_PADDING) {
- padding_x = MAX_VIEWER_TRANSLATION_PADDING;
- }
- if (padding_y > MAX_VIEWER_TRANSLATION_PADDING) {
- padding_y = MAX_VIEWER_TRANSLATION_PADDING;
- }
-
- display_width_ = get_width() + padding_x;
- display_height_ = get_height() + padding_y;
- if (ibuf->x != display_width_ || ibuf->y != display_height_) {
+ if (ibuf->x != get_width() || ibuf->y != get_height()) {
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
IMB_freezbuffloatImBuf(ibuf);
- ibuf->x = display_width_;
- ibuf->y = display_height_;
+ ibuf->x = get_width();
+ ibuf->y = get_height();
/* zero size can happen if no image buffers exist to define a sensible resolution */
if (ibuf->x > 0 && ibuf->y > 0) {
imb_addrectfloatImBuf(ibuf);
@@ -187,11 +176,13 @@ void ViewerOperation::update_image(const rcti *rect)
return;
}
+ image_->display_offset_x = canvas_.xmin;
+ image_->display_offset_y = canvas_.ymin;
float *buffer = output_buffer_;
IMB_partial_display_buffer_update(ibuf_,
buffer,
nullptr,
- display_width_,
+ get_width(),
0,
0,
view_settings_,
@@ -224,32 +215,23 @@ void ViewerOperation::update_memory_buffer_partial(MemoryBuffer *UNUSED(output),
return;
}
- const int offset_x = area.xmin + (canvas_.xmin > 0 ? canvas_.xmin * 2 : 0);
- const int offset_y = area.ymin + (canvas_.ymin > 0 ? canvas_.ymin * 2 : 0);
MemoryBuffer output_buffer(
- output_buffer_, COM_DATA_TYPE_COLOR_CHANNELS, display_width_, display_height_);
+ output_buffer_, COM_DATA_TYPE_COLOR_CHANNELS, get_width(), get_height());
const MemoryBuffer *input_image = inputs[0];
- output_buffer.copy_from(input_image, area, offset_x, offset_y);
+ output_buffer.copy_from(input_image, area);
if (use_alpha_input_) {
const MemoryBuffer *input_alpha = inputs[1];
- output_buffer.copy_from(
- input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, offset_x, offset_y, 3);
+ output_buffer.copy_from(input_alpha, area, 0, COM_DATA_TYPE_VALUE_CHANNELS, 3);
}
if (depth_buffer_) {
MemoryBuffer depth_buffer(
- depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, display_width_, display_height_);
+ depth_buffer_, COM_DATA_TYPE_VALUE_CHANNELS, get_width(), get_height());
const MemoryBuffer *input_depth = inputs[2];
- depth_buffer.copy_from(input_depth, area, offset_x, offset_y);
+ depth_buffer.copy_from(input_depth, area);
}
- rcti display_area;
- BLI_rcti_init(&display_area,
- offset_x,
- offset_x + BLI_rcti_size_x(&area),
- offset_y,
- offset_y + BLI_rcti_size_y(&area));
- update_image(&display_area);
+ update_image(&area);
}
void ViewerOperation::clear_display_buffer()
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index 1ad6cc51269..ed9e5871eae 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -35,9 +35,6 @@ class ViewerOperation : public MultiThreadedOperation {
SocketReader *alpha_input_;
SocketReader *depth_input_;
- int display_width_;
- int display_height_;
-
public:
ViewerOperation();
void init_execution() override;