Cycles: merge of changes from tomato branch.
[blender-staging.git] / intern / cycles / device / device_task.h
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
19 #ifndef __DEVICE_TASK_H__
20 #define __DEVICE_TASK_H__
21
22 #include "device_memory.h"
23
24 #include "util_function.h"
25 #include "util_list.h"
26 #include "util_task.h"
27
28 CCL_NAMESPACE_BEGIN
29
30 /* Device Task */
31
32 class Device;
33 class RenderBuffers;
34 class RenderTile;
35 class Tile;
36
37 class DeviceTask : public Task {
38 public:
39         typedef enum { PATH_TRACE, TONEMAP, SHADER } Type;
40         Type type;
41
42         int x, y, w, h;
43         device_ptr rgba;
44         device_ptr buffer;
45         int sample;
46         int num_samples;
47         int resolution;
48         int offset, stride;
49
50         device_ptr shader_input;
51         device_ptr shader_output;
52         int shader_eval_type;
53         int shader_x, shader_w;
54
55         DeviceTask(Type type = PATH_TRACE);
56
57         void split(list<DeviceTask>& tasks, int num);
58         void split_max_size(list<DeviceTask>& tasks, int max_size);
59
60         void update_progress(RenderTile &rtile);
61
62         boost::function<bool(Device *device, RenderTile&)> acquire_tile;
63         boost::function<void(void)> update_progress_sample;
64         boost::function<void(RenderTile&)> update_tile_sample;
65         boost::function<void(RenderTile&)> release_tile;
66         boost::function<bool(void)> get_cancel;
67
68 protected:
69         double last_update_time;
70 };
71
72 CCL_NAMESPACE_END
73
74 #endif /* __DEVICE_TASK_H__ */
75