~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/compositor/operations/COM_SplitViewerOperation.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2011, Blender Foundation.
3
 
 *
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.
8
 
 *
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.
13
 
 *
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.
17
 
 *
18
 
 * Contributor: 
19
 
 *              Jeroen Bakker 
20
 
 *              Monique Dewanchand
21
 
 */
22
 
 
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"
30
 
 
31
 
extern "C" {
32
 
        #include "MEM_guardedalloc.h"
33
 
        #include "IMB_imbuf.h"
34
 
        #include "IMB_imbuf_types.h"
35
 
}
36
 
 
37
 
 
38
 
SplitViewerOperation::SplitViewerOperation() : ViewerBaseOperation()
39
 
{
40
 
        this->addInputSocket(COM_DT_COLOR);
41
 
        this->addInputSocket(COM_DT_COLOR);
42
 
        this->m_image1Input = NULL;
43
 
        this->m_image2Input = NULL;
44
 
}
45
 
 
46
 
void SplitViewerOperation::initExecution()
47
 
{
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();
52
 
}
53
 
 
54
 
void SplitViewerOperation::deinitExecution()
55
 
{
56
 
        this->m_image1Input = NULL;
57
 
        this->m_image2Input = NULL;
58
 
        ViewerBaseOperation::deinitExecution();
59
 
}
60
 
 
61
 
 
62
 
void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber)
63
 
{
64
 
        float *buffer = this->m_outputBuffer;
65
 
        
66
 
        if (!buffer) return;
67
 
        int x1 = rect->xmin;
68
 
        int y1 = rect->ymin;
69
 
        int x2 = rect->xmax;
70
 
        int y2 = rect->ymax;
71
 
        int offset = (y1 * this->getWidth() + x1) * 4;
72
 
        int x;
73
 
        int y;
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++) {
77
 
                        bool image1;
78
 
                        image1 = this->m_xSplit ? x > perc : y > perc;
79
 
                        if (image1) {
80
 
                                this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
81
 
                        }
82
 
                        else {
83
 
                                this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST);
84
 
                        }
85
 
 
86
 
                        offset += 4;
87
 
                }
88
 
                offset += (this->getWidth() - (x2 - x1)) * 4;
89
 
        }
90
 
        updateImage(rect);
91
 
}
92