2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IMAGE_H__
|
|
|
|
#define __IMAGE_H__
|
|
|
|
|
2014-05-11 01:38:39 +00:00
|
|
|
#include "device.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "device_memory.h"
|
|
|
|
|
|
|
|
#include "util_string.h"
|
2012-09-27 17:42:09 +00:00
|
|
|
#include "util_thread.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "util_vector.h"
|
|
|
|
|
2012-11-05 08:05:24 +00:00
|
|
|
#include "kernel_types.h" /* for TEX_NUM_FLOAT_IMAGES */
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2014-05-11 01:38:39 +00:00
|
|
|
/* generic */
|
2014-06-13 21:40:39 +00:00
|
|
|
#define TEX_NUM_IMAGES 94
|
2012-09-04 13:29:07 +00:00
|
|
|
#define TEX_IMAGE_BYTE_START TEX_NUM_FLOAT_IMAGES
|
|
|
|
|
2014-05-11 01:38:39 +00:00
|
|
|
/* extended gpu */
|
|
|
|
#define TEX_EXTENDED_NUM_IMAGES_GPU 145
|
|
|
|
|
|
|
|
/* extended cpu */
|
2013-12-14 14:06:18 +00:00
|
|
|
#define TEX_EXTENDED_NUM_FLOAT_IMAGES 1024
|
2014-05-11 01:38:39 +00:00
|
|
|
#define TEX_EXTENDED_NUM_IMAGES_CPU 1024
|
2012-09-04 13:29:07 +00:00
|
|
|
#define TEX_EXTENDED_IMAGE_BYTE_START TEX_EXTENDED_NUM_FLOAT_IMAGES
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-07-04 11:48:42 +00:00
|
|
|
/* color to use when textures are not found */
|
|
|
|
#define TEX_IMAGE_MISSING_R 1
|
|
|
|
#define TEX_IMAGE_MISSING_G 0
|
|
|
|
#define TEX_IMAGE_MISSING_B 1
|
|
|
|
#define TEX_IMAGE_MISSING_A 1
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
class Device;
|
|
|
|
class DeviceScene;
|
|
|
|
class Progress;
|
|
|
|
|
|
|
|
class ImageManager {
|
|
|
|
public:
|
|
|
|
ImageManager();
|
|
|
|
~ImageManager();
|
|
|
|
|
2014-06-21 20:18:48 +00:00
|
|
|
int add_image(const string& filename, void *builtin_data, bool animated, float frame,
|
|
|
|
bool& is_float, bool& is_linear, InterpolationType interpolation, bool use_alpha);
|
2014-03-29 12:03:48 +00:00
|
|
|
void remove_image(int slot);
|
2014-03-07 22:16:09 +00:00
|
|
|
void remove_image(const string& filename, void *builtin_data, InterpolationType interpolation);
|
2014-07-18 13:28:33 +00:00
|
|
|
void tag_reload_image(const string& filename, void *builtin_data, InterpolationType interpolation);
|
2013-02-14 21:40:29 +00:00
|
|
|
bool is_float_image(const string& filename, void *builtin_data, bool& is_linear);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
void device_update(Device *device, DeviceScene *dscene, Progress& progress);
|
|
|
|
void device_free(Device *device, DeviceScene *dscene);
|
2014-05-19 12:45:52 +00:00
|
|
|
void device_free_builtin(Device *device, DeviceScene *dscene);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-05-31 16:21:30 +00:00
|
|
|
void set_osl_texture_system(void *texture_system);
|
2012-05-13 12:32:44 +00:00
|
|
|
void set_pack_images(bool pack_images_);
|
2014-05-11 01:38:39 +00:00
|
|
|
void set_extended_image_limits(const DeviceInfo& info);
|
2012-11-21 13:00:51 +00:00
|
|
|
bool set_animation_frame_update(int frame);
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
bool need_update;
|
|
|
|
|
2014-03-29 12:03:48 +00:00
|
|
|
boost::function<void(const string &filename, void *data, bool &is_float, int &width, int &height, int &depth, int &channels)> builtin_image_info_cb;
|
2013-01-30 13:42:12 +00:00
|
|
|
boost::function<bool(const string &filename, void *data, unsigned char *pixels)> builtin_image_pixels_cb;
|
|
|
|
boost::function<bool(const string &filename, void *data, float *pixels)> builtin_image_float_pixels_cb;
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
struct Image {
|
|
|
|
string filename;
|
2013-01-30 13:42:12 +00:00
|
|
|
void *builtin_data;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-05-07 14:36:44 +00:00
|
|
|
bool use_alpha;
|
2011-04-27 11:58:34 +00:00
|
|
|
bool need_load;
|
2012-11-21 13:00:51 +00:00
|
|
|
bool animated;
|
2014-06-21 20:18:48 +00:00
|
|
|
float frame;
|
2014-03-07 22:16:09 +00:00
|
|
|
InterpolationType interpolation;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
int users;
|
|
|
|
};
|
|
|
|
|
2014-03-29 12:03:48 +00:00
|
|
|
private:
|
|
|
|
int tex_num_images;
|
|
|
|
int tex_num_float_images;
|
|
|
|
int tex_image_byte_start;
|
|
|
|
thread_mutex device_mutex;
|
|
|
|
int animation_frame;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
vector<Image*> images;
|
2012-03-07 12:27:18 +00:00
|
|
|
vector<Image*> float_images;
|
2011-05-31 16:21:30 +00:00
|
|
|
void *osl_texture_system;
|
2012-05-13 12:32:44 +00:00
|
|
|
bool pack_images;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
bool file_load_image(Image *img, device_vector<uchar4>& tex_img);
|
2012-03-07 12:27:18 +00:00
|
|
|
bool file_load_float_image(Image *img, device_vector<float4>& tex_img);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-05-05 19:44:33 +00:00
|
|
|
void device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progess);
|
2011-04-27 11:58:34 +00:00
|
|
|
void device_free_image(Device *device, DeviceScene *dscene, int slot);
|
2012-05-13 12:32:44 +00:00
|
|
|
|
|
|
|
void device_pack_images(Device *device, DeviceScene *dscene, Progress& progess);
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __IMAGE_H__ */
|
|
|
|
|