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/editors/space_node/node_gizmo.cc
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/editors/space_node/node_gizmo.cc')
-rw-r--r--source/blender/editors/space_node/node_gizmo.cc43
1 files changed, 33 insertions, 10 deletions
diff --git a/source/blender/editors/space_node/node_gizmo.cc b/source/blender/editors/space_node/node_gizmo.cc
index 4f27f9baabc..832ec36ab34 100644
--- a/source/blender/editors/space_node/node_gizmo.cc
+++ b/source/blender/editors/space_node/node_gizmo.cc
@@ -38,25 +38,39 @@ namespace blender::ed::space_node {
static void node_gizmo_calc_matrix_space(const SpaceNode *snode,
const ARegion *region,
+ const float image_offset[2],
float matrix_space[4][4])
{
unit_m4(matrix_space);
mul_v3_fl(matrix_space[0], snode->zoom);
mul_v3_fl(matrix_space[1], snode->zoom);
- matrix_space[3][0] = (region->winx / 2) + snode->xof;
- matrix_space[3][1] = (region->winy / 2) + snode->yof;
+ const float offset_x = snode->xof + image_offset[0];
+ const float offset_y = snode->yof + image_offset[1];
+ matrix_space[3][0] = (region->winx / 2) + offset_x;
+ matrix_space[3][1] = (region->winy / 2) + offset_y;
}
static void node_gizmo_calc_matrix_space_with_image_dims(const SpaceNode *snode,
const ARegion *region,
+ const float image_offset[2],
const float image_dims[2],
float matrix_space[4][4])
{
unit_m4(matrix_space);
mul_v3_fl(matrix_space[0], snode->zoom * image_dims[0]);
mul_v3_fl(matrix_space[1], snode->zoom * image_dims[1]);
- matrix_space[3][0] = ((region->winx / 2) + snode->xof) - ((image_dims[0] / 2.0f) * snode->zoom);
- matrix_space[3][1] = ((region->winy / 2) + snode->yof) - ((image_dims[1] / 2.0f) * snode->zoom);
+ const float offset_x = snode->xof + image_offset[0];
+ const float offset_y = snode->yof + image_offset[1];
+ matrix_space[3][0] = ((region->winx / 2) + offset_x) - ((image_dims[0] / 2.0f) * snode->zoom);
+ matrix_space[3][1] = ((region->winy / 2) + offset_y) - ((image_dims[1] / 2.0f) * snode->zoom);
+}
+
+static void get_viewer_image_offset(const bContext *C, float r_offset[2])
+{
+ Main *bmain = CTX_data_main(C);
+ const Image *image = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
+ r_offset[0] = image->display_offset_x;
+ r_offset[1] = image->display_offset_y;
}
/** \} */
@@ -127,11 +141,13 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmGizmoGroup *
Main *bmain = CTX_data_main(C);
wmGizmo *cage = ((wmGizmoWrapper *)gzgroup->customdata)->gizmo;
const ARegion *region = CTX_wm_region(C);
- /* center is always at the origin */
- const float origin[3] = {float(region->winx / 2), float(region->winy / 2), 0.0f};
- void *lock;
Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
+ /* Center is always at the origin. */
+ const float origin[3] ={ (region->winx / 2) + (float)ima->display_offset_x,
+ (region->winy / 2) + (float)ima->display_offset_y};
+
+ void *lock;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
if (ibuf) {
@@ -340,7 +356,9 @@ static void WIDGETGROUP_node_crop_draw_prepare(const bContext *C, wmGizmoGroup *
SpaceNode *snode = CTX_wm_space_node(C);
- node_gizmo_calc_matrix_space(snode, region, gz->matrix_space);
+ float image_offset[2];
+ get_viewer_image_offset(C, image_offset);
+ node_gizmo_calc_matrix_space(snode, region, image_offset, gz->matrix_space);
}
static void WIDGETGROUP_node_crop_refresh(const bContext *C, wmGizmoGroup *gzgroup)
@@ -453,8 +471,10 @@ static void WIDGETGROUP_node_sbeam_draw_prepare(const bContext *C, wmGizmoGroup
SpaceNode *snode = CTX_wm_space_node(C);
+ float image_offset[2];
+ get_viewer_image_offset(C, image_offset);
node_gizmo_calc_matrix_space_with_image_dims(
- snode, region, sbeam_group->state.dims, gz->matrix_space);
+ snode, region, image_offset, sbeam_group->state.dims, gz->matrix_space);
}
static void WIDGETGROUP_node_sbeam_refresh(const bContext *C, wmGizmoGroup *gzgroup)
@@ -560,9 +580,12 @@ static void WIDGETGROUP_node_corner_pin_draw_prepare(const bContext *C, wmGizmoG
SpaceNode *snode = CTX_wm_space_node(C);
+ float image_offset[2];
+ get_viewer_image_offset(C, image_offset);
+
float matrix_space[4][4];
node_gizmo_calc_matrix_space_with_image_dims(
- snode, region, cpin_group->state.dims, matrix_space);
+ snode, region, image_offset, cpin_group->state.dims, matrix_space);
for (int i = 0; i < 4; i++) {
wmGizmo *gz = cpin_group->gizmos[i];