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.
21 #include "device_memory.h"
23 #include "util_image.h"
24 #include "util_string.h"
25 #include "util_thread.h"
26 #include "util_vector.h"
36 explicit ImageManager(const DeviceInfo& info);
40 IMAGE_DATA_TYPE_FLOAT4 = 0,
41 IMAGE_DATA_TYPE_BYTE4 = 1,
42 IMAGE_DATA_TYPE_FLOAT = 2,
43 IMAGE_DATA_TYPE_BYTE = 3,
44 IMAGE_DATA_TYPE_HALF4 = 4,
45 IMAGE_DATA_TYPE_HALF = 5,
50 int add_image(const string& filename,
56 InterpolationType interpolation,
57 ExtensionType extension,
59 void remove_image(int flat_slot);
60 void remove_image(const string& filename,
62 InterpolationType interpolation,
63 ExtensionType extension);
64 void tag_reload_image(const string& filename,
66 InterpolationType interpolation,
67 ExtensionType extension);
68 ImageDataType get_image_metadata(const string& filename, void *builtin_data, bool& is_linear);
70 void device_update(Device *device, DeviceScene *dscene, Progress& progress);
71 void device_update_slot(Device *device, DeviceScene *dscene, int flat_slot, Progress *progress);
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 function<void(const string &filename, void *data, bool &is_float, int &width, int &height, int &depth, int &channels)> builtin_image_info_cb;
82 function<bool(const string &filename, void *data, unsigned char *pixels)> builtin_image_pixels_cb;
83 function<bool(const string &filename, void *data, float *pixels)> builtin_image_float_pixels_cb;
93 InterpolationType interpolation;
94 ExtensionType extension;
100 int tex_num_images[IMAGE_DATA_NUM_TYPES];
101 int tex_start_images[IMAGE_DATA_NUM_TYPES];
103 thread_mutex device_mutex;
106 vector<Image*> images[IMAGE_DATA_NUM_TYPES];
107 void *osl_texture_system;
110 bool file_load_image_generic(Image *img, ImageInput **in, int &width, int &height, int &depth, int &components);
113 bool file_load_byte_image(Image *img, ImageDataType type, device_vector<T>& tex_img);
116 bool file_load_float_image(Image *img, ImageDataType type, device_vector<T>& tex_img);
119 bool file_load_half_image(Image *img, ImageDataType type, device_vector<T>& tex_img);
121 int type_index_to_flattened_slot(int slot, ImageDataType type);
122 int flattened_slot_to_type_index(int flat_slot, ImageDataType *type);
123 string name_from_type(int type);
125 uint8_t pack_image_options(ImageDataType type, size_t slot);
127 void device_load_image(Device *device, DeviceScene *dscene, ImageDataType type, int slot, Progress *progess);
128 void device_free_image(Device *device, DeviceScene *dscene, ImageDataType type, int slot);
130 void device_pack_images(Device *device, DeviceScene *dscene, Progress& progess);
135 #endif /* __IMAGE_H__ */