2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#include "COM_SplitViewerOperation.h"
24
#include "COM_SocketConnection.h"
25
#include "BLI_listbase.h"
26
#include "BKE_image.h"
27
#include "BLI_utildefines.h"
28
#include "BLI_math_color.h"
29
#include "BLI_math_vector.h"
32
#include "MEM_guardedalloc.h"
33
#include "IMB_imbuf.h"
34
#include "IMB_imbuf_types.h"
38
SplitViewerOperation::SplitViewerOperation() : ViewerBaseOperation()
40
this->addInputSocket(COM_DT_COLOR);
41
this->addInputSocket(COM_DT_COLOR);
42
this->m_image1Input = NULL;
43
this->m_image2Input = NULL;
46
void SplitViewerOperation::initExecution()
48
// When initializing the tree during initial load the width and height can be zero.
49
this->m_image1Input = getInputSocketReader(0);
50
this->m_image2Input = getInputSocketReader(1);
51
ViewerBaseOperation::initExecution();
54
void SplitViewerOperation::deinitExecution()
56
this->m_image1Input = NULL;
57
this->m_image2Input = NULL;
58
ViewerBaseOperation::deinitExecution();
62
void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
64
float *buffer = this->m_outputBuffer;
71
int offset = (y1 * this->getWidth() + x1) * 4;
74
int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f;
75
for (y = y1; y < y2; y++) {
76
for (x = x1; x < x2; x++) {
78
image1 = this->m_xSplit ? x > perc : y > perc;
80
this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
83
this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
88
offset += (this->getWidth() - (x2 - x1)) * 4;