2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
|
|
|
|
#include "COM_ScaleOperation.h"
|
2021-07-26 19:07:08 +02:00
|
|
|
#include "COM_ConstantOperation.h"
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2012-08-07 15:01:48 +00:00
|
|
|
#define USE_FORCE_BILINEAR
|
2023-02-09 11:30:25 +11:00
|
|
|
/* XXX(@ideasman42): ignore input and use default from old compositor,
|
2021-07-03 23:08:40 +10:00
|
|
|
* could become an option like the transform node.
|
2012-08-07 15:01:48 +00:00
|
|
|
*
|
2021-07-03 23:08:40 +10:00
|
|
|
* NOTE: use bilinear because bicubic makes fuzzy even when not scaling at all (1:1)
|
2012-08-07 15:01:48 +00:00
|
|
|
*/
|
2012-06-13 10:35:41 +00:00
|
|
|
|
2012-11-10 19:11:25 +00:00
|
|
|
BaseScaleOperation::BaseScaleOperation()
|
|
|
|
|
{
|
|
|
|
|
#ifdef USE_FORCE_BILINEAR
|
2022-09-25 18:33:28 +10:00
|
|
|
sampler_ = int(PixelSampler::Bilinear);
|
2012-11-10 19:11:25 +00:00
|
|
|
#else
|
2021-10-13 23:01:04 +02:00
|
|
|
sampler_ = -1;
|
2012-11-10 19:11:25 +00:00
|
|
|
#endif
|
2021-10-13 23:01:04 +02:00
|
|
|
variable_size_ = false;
|
2012-11-10 19:11:25 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
ScaleOperation::ScaleOperation() : ScaleOperation(DataType::Color) {}
|
2021-07-13 15:46:32 +02:00
|
|
|
|
|
|
|
|
ScaleOperation::ScaleOperation(DataType data_type) : BaseScaleOperation()
|
|
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
this->add_input_socket(data_type, ResizeMode::None);
|
|
|
|
|
this->add_input_socket(DataType::Value);
|
|
|
|
|
this->add_input_socket(DataType::Value);
|
|
|
|
|
this->add_output_socket(data_type);
|
2023-11-26 12:14:35 +01:00
|
|
|
flags_.can_be_constant = true;
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2021-07-26 19:07:08 +02:00
|
|
|
|
2021-07-26 22:44:10 +02:00
|
|
|
float ScaleOperation::get_constant_scale(const int input_op_idx, const float factor)
|
2021-07-26 19:07:08 +02:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
const bool is_constant = get_input_operation(input_op_idx)->get_flags().is_constant_operation;
|
2021-07-26 22:44:10 +02:00
|
|
|
if (is_constant) {
|
2021-10-13 23:01:15 +02:00
|
|
|
return ((ConstantOperation *)get_input_operation(input_op_idx))->get_constant_elem()[0] *
|
|
|
|
|
factor;
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-26 22:44:10 +02:00
|
|
|
return 1.0f;
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
float ScaleOperation::get_constant_scale_x(const float width)
|
2021-07-26 19:07:08 +02:00
|
|
|
{
|
2021-09-28 19:33:06 +02:00
|
|
|
return get_constant_scale(X_INPUT_INDEX, get_relative_scale_x_factor(width));
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
float ScaleOperation::get_constant_scale_y(const float height)
|
2021-07-26 19:07:08 +02:00
|
|
|
{
|
2021-09-28 19:33:06 +02:00
|
|
|
return get_constant_scale(Y_INPUT_INDEX, get_relative_scale_y_factor(height));
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
bool ScaleOperation::is_scaling_variable()
|
2021-07-26 19:07:08 +02:00
|
|
|
{
|
2021-09-28 19:33:06 +02:00
|
|
|
return !get_input_operation(X_INPUT_INDEX)->get_flags().is_constant_operation ||
|
|
|
|
|
!get_input_operation(Y_INPUT_INDEX)->get_flags().is_constant_operation;
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
void ScaleOperation::scale_area(rcti &area, float relative_scale_x, float relative_scale_y)
|
2021-07-26 19:07:08 +02:00
|
|
|
{
|
2021-09-28 19:33:06 +02:00
|
|
|
const rcti src_area = area;
|
|
|
|
|
const float center_x = BLI_rcti_size_x(&area) / 2.0f;
|
|
|
|
|
const float center_y = BLI_rcti_size_y(&area) / 2.0f;
|
|
|
|
|
area.xmin = floorf(scale_coord(area.xmin, center_x, relative_scale_x));
|
|
|
|
|
area.xmax = ceilf(scale_coord(area.xmax, center_x, relative_scale_x));
|
|
|
|
|
area.ymin = floorf(scale_coord(area.ymin, center_y, relative_scale_y));
|
|
|
|
|
area.ymax = ceilf(scale_coord(area.ymax, center_y, relative_scale_y));
|
|
|
|
|
|
|
|
|
|
float scale_offset_x, scale_offset_y;
|
|
|
|
|
ScaleOperation::get_scale_offset(src_area, area, scale_offset_x, scale_offset_y);
|
|
|
|
|
BLI_rcti_translate(&area, -scale_offset_x, -scale_offset_y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScaleOperation::clamp_area_size_max(rcti &area, Size2f max_size)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (BLI_rcti_size_x(&area) > max_size.x) {
|
|
|
|
|
area.xmax = area.xmin + max_size.x;
|
|
|
|
|
}
|
|
|
|
|
if (BLI_rcti_size_y(&area) > max_size.y) {
|
|
|
|
|
area.ymax = area.ymin + max_size.y;
|
|
|
|
|
}
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScaleOperation::init_data()
|
|
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
canvas_center_x_ = canvas_.xmin + get_width() / 2.0f;
|
|
|
|
|
canvas_center_y_ = canvas_.ymin + get_height() / 2.0f;
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
void ScaleOperation::get_scale_offset(const rcti &input_canvas,
|
|
|
|
|
const rcti &scale_canvas,
|
|
|
|
|
float &r_scale_offset_x,
|
|
|
|
|
float &r_scale_offset_y)
|
|
|
|
|
{
|
|
|
|
|
r_scale_offset_x = (BLI_rcti_size_x(&input_canvas) - BLI_rcti_size_x(&scale_canvas)) / 2.0f;
|
|
|
|
|
r_scale_offset_y = (BLI_rcti_size_y(&input_canvas) - BLI_rcti_size_y(&scale_canvas)) / 2.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScaleOperation::get_scale_area_of_interest(const rcti &input_canvas,
|
|
|
|
|
const rcti &scale_canvas,
|
|
|
|
|
const float relative_scale_x,
|
|
|
|
|
const float relative_scale_y,
|
|
|
|
|
const rcti &output_area,
|
|
|
|
|
rcti &r_input_area)
|
|
|
|
|
{
|
|
|
|
|
const float scale_center_x = BLI_rcti_size_x(&input_canvas) / 2.0f;
|
|
|
|
|
const float scale_center_y = BLI_rcti_size_y(&input_canvas) / 2.0f;
|
|
|
|
|
float scale_offset_x, scale_offset_y;
|
|
|
|
|
ScaleOperation::get_scale_offset(input_canvas, scale_canvas, scale_offset_x, scale_offset_y);
|
|
|
|
|
|
|
|
|
|
r_input_area.xmin = floorf(
|
|
|
|
|
scale_coord_inverted(output_area.xmin + scale_offset_x, scale_center_x, relative_scale_x));
|
|
|
|
|
r_input_area.xmax = ceilf(
|
|
|
|
|
scale_coord_inverted(output_area.xmax + scale_offset_x, scale_center_x, relative_scale_x));
|
|
|
|
|
r_input_area.ymin = floorf(
|
|
|
|
|
scale_coord_inverted(output_area.ymin + scale_offset_y, scale_center_y, relative_scale_y));
|
|
|
|
|
r_input_area.ymax = ceilf(
|
|
|
|
|
scale_coord_inverted(output_area.ymax + scale_offset_y, scale_center_y, relative_scale_y));
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-26 19:07:08 +02:00
|
|
|
void ScaleOperation::get_area_of_interest(const int input_idx,
|
|
|
|
|
const rcti &output_area,
|
|
|
|
|
rcti &r_input_area)
|
|
|
|
|
{
|
|
|
|
|
r_input_area = output_area;
|
2021-09-28 19:33:06 +02:00
|
|
|
if (input_idx != 0 || is_scaling_variable()) {
|
2021-07-26 19:07:08 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
NodeOperation *image_op = get_input_operation(IMAGE_INPUT_INDEX);
|
2021-10-13 23:01:15 +02:00
|
|
|
const float scale_x = get_constant_scale_x(image_op->get_width());
|
|
|
|
|
const float scale_y = get_constant_scale_y(image_op->get_height());
|
2021-09-28 19:33:06 +02:00
|
|
|
|
|
|
|
|
get_scale_area_of_interest(
|
|
|
|
|
image_op->get_canvas(), this->get_canvas(), scale_x, scale_y, output_area, r_input_area);
|
2021-10-13 23:01:04 +02:00
|
|
|
expand_area_for_sampler(r_input_area, (PixelSampler)sampler_);
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScaleOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
Span<MemoryBuffer *> inputs)
|
|
|
|
|
{
|
2021-09-28 19:33:06 +02:00
|
|
|
NodeOperation *input_image_op = get_input_operation(IMAGE_INPUT_INDEX);
|
2021-10-13 23:01:15 +02:00
|
|
|
const int input_image_width = input_image_op->get_width();
|
|
|
|
|
const int input_image_height = input_image_op->get_height();
|
2021-09-28 19:33:06 +02:00
|
|
|
const float scale_x_factor = get_relative_scale_x_factor(input_image_width);
|
|
|
|
|
const float scale_y_factor = get_relative_scale_y_factor(input_image_height);
|
|
|
|
|
const float scale_center_x = input_image_width / 2.0f;
|
|
|
|
|
const float scale_center_y = input_image_height / 2.0f;
|
|
|
|
|
float from_scale_offset_x, from_scale_offset_y;
|
|
|
|
|
ScaleOperation::get_scale_offset(
|
|
|
|
|
input_image_op->get_canvas(), this->get_canvas(), from_scale_offset_x, from_scale_offset_y);
|
|
|
|
|
|
|
|
|
|
const MemoryBuffer *input_image = inputs[IMAGE_INPUT_INDEX];
|
|
|
|
|
MemoryBuffer *input_x = inputs[X_INPUT_INDEX];
|
|
|
|
|
MemoryBuffer *input_y = inputs[Y_INPUT_INDEX];
|
2021-07-26 19:07:08 +02:00
|
|
|
BuffersIterator<float> it = output->iterate_with({input_x, input_y}, area);
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
|
|
|
|
const float rel_scale_x = *it.in(0) * scale_x_factor;
|
|
|
|
|
const float rel_scale_y = *it.in(1) * scale_y_factor;
|
2021-09-28 19:33:06 +02:00
|
|
|
const float scaled_x = scale_coord_inverted(
|
|
|
|
|
from_scale_offset_x + canvas_.xmin + it.x, scale_center_x, rel_scale_x);
|
|
|
|
|
const float scaled_y = scale_coord_inverted(
|
|
|
|
|
from_scale_offset_y + canvas_.ymin + it.y, scale_center_y, rel_scale_y);
|
|
|
|
|
|
|
|
|
|
input_image->read_elem_sampled(
|
2021-10-13 23:01:04 +02:00
|
|
|
scaled_x - canvas_.xmin, scaled_y - canvas_.ymin, (PixelSampler)sampler_, it.out);
|
2021-09-28 19:33:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScaleOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
|
|
|
|
{
|
|
|
|
|
const bool image_determined =
|
2021-10-13 23:01:15 +02:00
|
|
|
get_input_socket(IMAGE_INPUT_INDEX)->determine_canvas(preferred_area, r_area);
|
2021-09-28 19:33:06 +02:00
|
|
|
if (image_determined) {
|
|
|
|
|
rcti image_canvas = r_area;
|
2021-11-29 19:23:43 +01:00
|
|
|
rcti unused = COM_AREA_NONE;
|
2021-10-13 23:01:15 +02:00
|
|
|
NodeOperationInput *x_socket = get_input_socket(X_INPUT_INDEX);
|
|
|
|
|
NodeOperationInput *y_socket = get_input_socket(Y_INPUT_INDEX);
|
2021-09-28 19:33:06 +02:00
|
|
|
x_socket->determine_canvas(image_canvas, unused);
|
|
|
|
|
y_socket->determine_canvas(image_canvas, unused);
|
|
|
|
|
if (is_scaling_variable()) {
|
|
|
|
|
/* Do not scale canvas. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Determine scaled canvas. */
|
|
|
|
|
const float input_width = BLI_rcti_size_x(&r_area);
|
|
|
|
|
const float input_height = BLI_rcti_size_y(&r_area);
|
|
|
|
|
const float scale_x = get_constant_scale_x(input_width);
|
|
|
|
|
const float scale_y = get_constant_scale_y(input_height);
|
|
|
|
|
scale_area(r_area, scale_x, scale_y);
|
|
|
|
|
|
|
|
|
|
/* Re-determine canvases of x and y constant inputs with scaled canvas as preferred. */
|
|
|
|
|
get_input_operation(X_INPUT_INDEX)->unset_canvas();
|
|
|
|
|
get_input_operation(Y_INPUT_INDEX)->unset_canvas();
|
|
|
|
|
x_socket->determine_canvas(r_area, unused);
|
|
|
|
|
y_socket->determine_canvas(r_area, unused);
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
ScaleRelativeOperation::ScaleRelativeOperation() : ScaleOperation() {}
|
2021-07-26 19:07:08 +02:00
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
ScaleRelativeOperation::ScaleRelativeOperation(DataType data_type) : ScaleOperation(data_type) {}
|
2021-07-26 19:07:08 +02:00
|
|
|
|
2012-11-10 19:11:25 +00:00
|
|
|
ScaleFixedSizeOperation::ScaleFixedSizeOperation() : BaseScaleOperation()
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
this->add_input_socket(DataType::Color, ResizeMode::None);
|
|
|
|
|
this->add_output_socket(DataType::Color);
|
2021-09-28 19:32:49 +02:00
|
|
|
this->set_canvas_input_index(0);
|
2021-10-13 23:01:04 +02:00
|
|
|
is_offset_ = false;
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2021-07-26 19:07:08 +02:00
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
void ScaleFixedSizeOperation::init_data(const rcti &input_canvas)
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-09-28 19:33:06 +02:00
|
|
|
const int input_width = BLI_rcti_size_x(&input_canvas);
|
|
|
|
|
const int input_height = BLI_rcti_size_y(&input_canvas);
|
2022-09-25 18:33:28 +10:00
|
|
|
rel_x_ = input_width / float(new_width_);
|
|
|
|
|
rel_y_ = input_height / float(new_height_);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 07:50:27 +00:00
|
|
|
/* *** all the options below are for a fairly special case - camera framing *** */
|
2021-10-13 23:01:15 +02:00
|
|
|
if (offset_x_ != 0.0f || offset_y_ != 0.0f) {
|
2021-10-13 23:01:04 +02:00
|
|
|
is_offset_ = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
if (new_width_ > new_height_) {
|
|
|
|
|
offset_x_ *= new_width_;
|
|
|
|
|
offset_y_ *= new_width_;
|
2012-06-15 07:50:27 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2021-10-13 23:01:15 +02:00
|
|
|
offset_x_ *= new_height_;
|
|
|
|
|
offset_y_ *= new_height_;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 07:50:27 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
if (is_aspect_) {
|
2012-06-14 18:55:35 +00:00
|
|
|
/* apply aspect from clip */
|
2021-09-28 19:33:06 +02:00
|
|
|
const float w_src = input_width;
|
|
|
|
|
const float h_src = input_height;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-14 18:55:35 +00:00
|
|
|
/* destination aspect is already applied from the camera frame */
|
2021-10-13 23:01:15 +02:00
|
|
|
const float w_dst = new_width_;
|
|
|
|
|
const float h_dst = new_height_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-14 18:55:35 +00:00
|
|
|
const float asp_src = w_src / h_src;
|
|
|
|
|
const float asp_dst = w_dst / h_dst;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-14 18:55:35 +00:00
|
|
|
if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
|
2021-10-13 23:01:04 +02:00
|
|
|
if ((asp_src > asp_dst) == (is_crop_ == true)) {
|
2012-06-14 18:55:35 +00:00
|
|
|
/* fit X */
|
|
|
|
|
const float div = asp_src / asp_dst;
|
2021-10-13 23:01:15 +02:00
|
|
|
rel_x_ /= div;
|
|
|
|
|
offset_x_ += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
|
2024-02-28 16:59:16 +01:00
|
|
|
if (is_crop_) {
|
2021-10-13 23:01:15 +02:00
|
|
|
int fit_width = new_width_ * div;
|
2021-09-28 19:33:06 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
const int added_width = fit_width - new_width_;
|
|
|
|
|
new_width_ += added_width;
|
|
|
|
|
offset_x_ += added_width / 2.0f;
|
2021-09-28 19:33:06 +02:00
|
|
|
}
|
2012-06-14 18:55:35 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* fit Y */
|
|
|
|
|
const float div = asp_dst / asp_src;
|
2021-10-13 23:01:15 +02:00
|
|
|
rel_y_ /= div;
|
|
|
|
|
offset_y_ += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
|
2024-02-28 16:59:16 +01:00
|
|
|
if (is_crop_) {
|
2021-10-13 23:01:15 +02:00
|
|
|
int fit_height = new_height_ * div;
|
2021-09-28 19:33:06 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
const int added_height = fit_height - new_height_;
|
|
|
|
|
new_height_ += added_height;
|
|
|
|
|
offset_y_ += added_height / 2.0f;
|
2021-09-28 19:33:06 +02:00
|
|
|
}
|
2012-06-14 18:55:35 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
is_offset_ = true;
|
2012-06-15 07:50:27 +00:00
|
|
|
}
|
2012-06-14 18:55:35 +00:00
|
|
|
}
|
2012-06-15 07:50:27 +00:00
|
|
|
/* *** end framing options *** */
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:32:49 +02:00
|
|
|
void ScaleFixedSizeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-09-28 19:32:49 +02:00
|
|
|
rcti local_preferred = preferred_area;
|
2021-10-13 23:01:15 +02:00
|
|
|
local_preferred.xmax = local_preferred.xmin + new_width_;
|
|
|
|
|
local_preferred.ymax = local_preferred.ymin + new_height_;
|
2021-11-29 19:23:43 +01:00
|
|
|
rcti input_canvas = COM_AREA_NONE;
|
2021-10-13 23:01:15 +02:00
|
|
|
const bool input_determined = get_input_socket(0)->determine_canvas(local_preferred,
|
|
|
|
|
input_canvas);
|
2021-09-28 19:33:06 +02:00
|
|
|
if (input_determined) {
|
|
|
|
|
init_data(input_canvas);
|
|
|
|
|
r_area = input_canvas;
|
2024-02-28 16:59:16 +01:00
|
|
|
r_area.xmin /= rel_x_;
|
|
|
|
|
r_area.ymin /= rel_y_;
|
|
|
|
|
r_area.xmin += offset_x_;
|
|
|
|
|
r_area.ymin += offset_y_;
|
2021-09-28 19:33:06 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
r_area.xmax = r_area.xmin + new_width_;
|
|
|
|
|
r_area.ymax = r_area.ymin + new_height_;
|
2021-09-28 19:33:06 +02:00
|
|
|
}
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2021-03-23 17:12:27 +01:00
|
|
|
|
2021-07-26 19:07:08 +02:00
|
|
|
void ScaleFixedSizeOperation::get_area_of_interest(const int input_idx,
|
|
|
|
|
const rcti &output_area,
|
|
|
|
|
rcti &r_input_area)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(input_idx == 0);
|
|
|
|
|
UNUSED_VARS_NDEBUG(input_idx);
|
2021-09-28 19:33:06 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
r_input_area.xmax = ceilf((output_area.xmax - offset_x_) * rel_x_);
|
|
|
|
|
r_input_area.xmin = floorf((output_area.xmin - offset_x_) * rel_x_);
|
|
|
|
|
r_input_area.ymax = ceilf((output_area.ymax - offset_y_) * rel_y_);
|
|
|
|
|
r_input_area.ymin = floorf((output_area.ymin - offset_y_) * rel_y_);
|
2021-10-13 23:01:04 +02:00
|
|
|
expand_area_for_sampler(r_input_area, (PixelSampler)sampler_);
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScaleFixedSizeOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
Span<MemoryBuffer *> inputs)
|
|
|
|
|
{
|
|
|
|
|
const MemoryBuffer *input_img = inputs[0];
|
2021-10-13 23:01:04 +02:00
|
|
|
PixelSampler sampler = (PixelSampler)sampler_;
|
2021-07-26 19:07:08 +02:00
|
|
|
BuffersIterator<float> it = output->iterate_with({}, area);
|
2021-10-13 23:01:04 +02:00
|
|
|
if (is_offset_) {
|
2021-07-26 19:07:08 +02:00
|
|
|
for (; !it.is_end(); ++it) {
|
2021-10-13 23:01:15 +02:00
|
|
|
const float nx = (canvas_.xmin + it.x - offset_x_) * rel_x_;
|
|
|
|
|
const float ny = (canvas_.ymin + it.y - offset_y_) * rel_y_;
|
2021-09-28 19:33:06 +02:00
|
|
|
input_img->read_elem_sampled(nx - canvas_.xmin, ny - canvas_.ymin, sampler, it.out);
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (; !it.is_end(); ++it) {
|
2021-10-13 23:01:15 +02:00
|
|
|
input_img->read_elem_sampled((canvas_.xmin + it.x) * rel_x_ - canvas_.xmin,
|
|
|
|
|
(canvas_.ymin + it.y) * rel_y_ - canvas_.ymin,
|
2021-09-28 19:33:06 +02:00
|
|
|
sampler,
|
|
|
|
|
it.out);
|
2021-07-26 19:07:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
} // namespace blender::compositor
|