2 * Copyright 2011-2013 Blender Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "device/device.h"
21 #include "device/device_memory.h"
23 #include "util/util_image.h"
24 #include "util/util_string.h"
25 #include "util/util_thread.h"
26 #include "util/util_vector.h"
37 explicit ImageManager(const DeviceInfo& info);
40 int add_image(const string& filename,
46 InterpolationType interpolation,
47 ExtensionType extension,
49 void remove_image(int flat_slot);
50 void remove_image(const string& filename,
52 InterpolationType interpolation,
53 ExtensionType extension,
55 void tag_reload_image(const string& filename,
57 InterpolationType interpolation,
58 ExtensionType extension,
60 ImageDataType get_image_metadata(const string& filename, void *builtin_data, bool& is_linear);
62 void device_prepare_update(DeviceScene *dscene);
63 void device_update(Device *device,
67 void device_update_slot(Device *device,
72 void device_free(Device *device, DeviceScene *dscene);
73 void device_free_builtin(Device *device, DeviceScene *dscene);
75 void set_osl_texture_system(void *texture_system);
76 void set_pack_images(bool pack_images_);
77 bool set_animation_frame_update(int frame);
81 /* NOTE: Here pixels_size is a size of storage, which equals to
82 * width * height * depth.
83 * Use this to avoid some nasty memory corruptions.
85 function<void(const string &filename,
91 int &channels)> builtin_image_info_cb;
92 function<bool(const string &filename,
94 unsigned char *pixels,
95 const size_t pixels_size)> builtin_image_pixels_cb;
96 function<bool(const string &filename,
99 const size_t pixels_size)> builtin_image_float_pixels_cb;
109 InterpolationType interpolation;
110 ExtensionType extension;
116 int tex_num_images[IMAGE_DATA_NUM_TYPES];
118 bool has_half_images;
119 bool cuda_fermi_limits;
121 thread_mutex device_mutex;
124 vector<Image*> images[IMAGE_DATA_NUM_TYPES];
125 void *osl_texture_system;
128 bool file_load_image_generic(Image *img, ImageInput **in, int &width, int &height, int &depth, int &components);
130 template<TypeDesc::BASETYPE FileFormat,
131 typename StorageType,
133 bool file_load_image(Image *img,
136 device_vector<DeviceType>& tex_img);
138 int max_flattened_slot(ImageDataType type);
139 int type_index_to_flattened_slot(int slot, ImageDataType type);
140 int flattened_slot_to_type_index(int flat_slot, ImageDataType *type);
141 string name_from_type(int type);
143 uint8_t pack_image_options(ImageDataType type, size_t slot);
145 void device_load_image(Device *device,
151 void device_free_image(Device *device,
157 void device_pack_images_type(
159 const vector<device_vector<T>*>& cpu_textures,
160 device_vector<T> *device_image,
163 void device_pack_images(Device *device,
170 #endif /* __IMAGE_H__ */