This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/compositor/operations/COM_ScaleOperation.h
Manuel Castilla 209aff0a35 Compositor: Fix convert resolutions linking different socket datatypes
Link sockets are always connected to inserted translate or scale
operation `Color` sockets even when they have different data type.
This causes crashes on full frame mode when operations read inputs 
with non expected datatypes.

Because data type conversions need to be executed before, convert
resolutions must ensure same datatypes are linked.
2021-07-13 22:32:53 +02:00

137 lines
3.8 KiB
C++

/*
* 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.
*
* Copyright 2011, Blender Foundation.
*/
#pragma once
#include "COM_NodeOperation.h"
namespace blender::compositor {
class BaseScaleOperation : public NodeOperation {
public:
void setSampler(PixelSampler sampler)
{
this->m_sampler = (int)sampler;
}
void setVariableSize(bool variable_size)
{
m_variable_size = variable_size;
};
protected:
BaseScaleOperation();
PixelSampler getEffectiveSampler(PixelSampler sampler)
{
return (m_sampler == -1) ? sampler : (PixelSampler)m_sampler;
}
int m_sampler;
bool m_variable_size;
};
class ScaleOperation : public BaseScaleOperation {
private:
SocketReader *m_inputOperation;
SocketReader *m_inputXOperation;
SocketReader *m_inputYOperation;
float m_centerX;
float m_centerY;
public:
ScaleOperation();
ScaleOperation(DataType data_type);
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
void initExecution() override;
void deinitExecution() override;
};
class ScaleAbsoluteOperation : public BaseScaleOperation {
SocketReader *m_inputOperation;
SocketReader *m_inputXOperation;
SocketReader *m_inputYOperation;
float m_centerX;
float m_centerY;
public:
ScaleAbsoluteOperation();
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
void initExecution() override;
void deinitExecution() override;
};
class ScaleFixedSizeOperation : public BaseScaleOperation {
SocketReader *m_inputOperation;
int m_newWidth;
int m_newHeight;
float m_relX;
float m_relY;
/* center is only used for aspect correction */
float m_offsetX;
float m_offsetY;
bool m_is_aspect;
bool m_is_crop;
/* set from other properties on initialization,
* check if we need to apply offset */
bool m_is_offset;
public:
ScaleFixedSizeOperation();
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;
void determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2]) override;
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
void initExecution() override;
void deinitExecution() override;
void setNewWidth(int width)
{
this->m_newWidth = width;
}
void setNewHeight(int height)
{
this->m_newHeight = height;
}
void setIsAspect(bool is_aspect)
{
this->m_is_aspect = is_aspect;
}
void setIsCrop(bool is_crop)
{
this->m_is_crop = is_crop;
}
void setOffset(float x, float y)
{
this->m_offsetX = x;
this->m_offsetY = y;
}
};
} // namespace blender::compositor