~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to source/blender/compositor/intern/COM_SocketReader.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

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
#ifndef _COM_SocketReader_h
 
24
#define _COM_SocketReader_h
 
25
#include "BLI_rect.h"
 
26
#include "COM_defines.h"
 
27
 
 
28
#ifdef WITH_CXX_GUARDEDALLOC
 
29
#include "MEM_guardedalloc.h"
 
30
#endif
 
31
 
 
32
typedef enum PixelSampler {
 
33
        COM_PS_NEAREST = 0,
 
34
        COM_PS_BILINEAR = 1,
 
35
        COM_PS_BICUBIC = 2
 
36
} PixelSampler;
 
37
 
 
38
class MemoryBuffer;
 
39
/**
 
40
 * @brief Helper class for reading socket data.
 
41
 * Only use this class for dispatching (un-ary and n-ary) executions.
 
42
 * @ingroup Execution
 
43
 */
 
44
class SocketReader {
 
45
private:
 
46
protected:
 
47
        /**
 
48
         * @brief Holds the width of the output of this operation.
 
49
         */
 
50
        unsigned int m_width;
 
51
 
 
52
        /**
 
53
         * @brief Holds the height of the output of this operation.
 
54
         */
 
55
        unsigned int m_height;
 
56
 
 
57
 
 
58
        /**
 
59
         * @brief calculate a single pixel
 
60
         * @note this method is called for non-complex
 
61
         * @param result is a float[4] array to store the result
 
62
         * @param x the x-coordinate of the pixel to calculate in image space
 
63
         * @param y the y-coordinate of the pixel to calculate in image space
 
64
         * @param inputBuffers chunks that can be read by their ReadBufferOperation.
 
65
         */
 
66
        virtual void executePixel(float output[4], float x, float y, PixelSampler sampler) {}
 
67
 
 
68
        /**
 
69
         * @brief calculate a single pixel
 
70
         * @note this method is called for complex
 
71
         * @param result is a float[4] array to store the result
 
72
         * @param x the x-coordinate of the pixel to calculate in image space
 
73
         * @param y the y-coordinate of the pixel to calculate in image space
 
74
         * @param inputBuffers chunks that can be read by their ReadBufferOperation.
 
75
         * @param chunkData chunk specific data a during execution time.
 
76
         */
 
77
        virtual void executePixel(float output[4], int x, int y, void *chunkData) {
 
78
                executePixel(output, x, y, COM_PS_NEAREST);
 
79
        }
 
80
 
 
81
        /**
 
82
         * @brief calculate a single pixel using an EWA filter
 
83
         * @note this method is called for complex
 
84
         * @param result is a float[4] array to store the result
 
85
         * @param x the x-coordinate of the pixel to calculate in image space
 
86
         * @param y the y-coordinate of the pixel to calculate in image space
 
87
         * @param dx
 
88
         * @param dy
 
89
         * @param inputBuffers chunks that can be read by their ReadBufferOperation.
 
90
         */
 
91
        virtual void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {}
 
92
 
 
93
public:
 
94
        inline void read(float *result, float x, float y, PixelSampler sampler) {
 
95
                executePixel(result, x, y, sampler);
 
96
        }
 
97
        inline void read(float *result, int x, int y, void *chunkData) {
 
98
                executePixel(result, x, y, chunkData);
 
99
        }
 
100
        inline void read(float *result, float x, float y, float dx, float dy, PixelSampler sampler) {
 
101
                executePixel(result, x, y, dx, dy, sampler);
 
102
        }
 
103
 
 
104
        virtual void *initializeTileData(rcti *rect) { return 0; }
 
105
        virtual void deinitializeTileData(rcti *rect, void *data) {
 
106
        }
 
107
        
 
108
        virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; }
 
109
 
 
110
 
 
111
        inline const unsigned int getWidth() const { return this->m_width; }
 
112
        inline const unsigned int getHeight() const { return this->m_height; }
 
113
 
 
114
#ifdef WITH_CXX_GUARDEDALLOC
 
115
        MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader")
 
116
#endif
 
117
};
 
118
 
 
119
#endif /* _COM_SocketReader_h */