Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_ScaleOperation.h « operations « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b4aecb1515d76a6b4f8d6bb36e37254dde653f3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * Copyright 2011, Blender Foundation.
 *
 * 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.
 *
 * Contributor:
 *		Jeroen Bakker
 *		Monique Dewanchand
 */

#ifndef __COM_SCALEOPERATION_H__
#define __COM_SCALEOPERATION_H__

#include "COM_NodeOperation.h"

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();
	bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
	void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);

	void initExecution();
	void deinitExecution();
};

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);
	void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);

	void initExecution();
	void deinitExecution();
};

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);
	void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
	void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);

	void initExecution();
	void deinitExecution();
	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; }
};

#endif