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
#ifndef _COM_SocketReader_h
24
#define _COM_SocketReader_h
26
#include "COM_defines.h"
28
#ifdef WITH_CXX_GUARDEDALLOC
29
#include "MEM_guardedalloc.h"
32
typedef enum PixelSampler {
40
* @brief Helper class for reading socket data.
41
* Only use this class for dispatching (un-ary and n-ary) executions.
48
* @brief Holds the width of the output of this operation.
53
* @brief Holds the height of the output of this operation.
55
unsigned int m_height;
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.
66
virtual void executePixel(float output[4], float x, float y, PixelSampler sampler) {}
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.
77
virtual void executePixel(float output[4], int x, int y, void *chunkData) {
78
executePixel(output, x, y, COM_PS_NEAREST);
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
89
* @param inputBuffers chunks that can be read by their ReadBufferOperation.
91
virtual void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {}
94
inline void read(float *result, float x, float y, PixelSampler sampler) {
95
executePixel(result, x, y, sampler);
97
inline void read(float *result, int x, int y, void *chunkData) {
98
executePixel(result, x, y, chunkData);
100
inline void read(float *result, float x, float y, float dx, float dy, PixelSampler sampler) {
101
executePixel(result, x, y, dx, dy, sampler);
104
virtual void *initializeTileData(rcti *rect) { return 0; }
105
virtual void deinitializeTileData(rcti *rect, void *data) {
108
virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; }
111
inline const unsigned int getWidth() const { return this->m_width; }
112
inline const unsigned int getHeight() const { return this->m_height; }
114
#ifdef WITH_CXX_GUARDEDALLOC
115
MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader")
119
#endif /* _COM_SocketReader_h */