This commit makes BKE_image_acquire_ibuf referencing result, which means once some area requested for image buffer, it'll be guaranteed this buffer wouldn't be freed by image signal. To de-reference buffer BKE_image_release_ibuf should now always be used. To make referencing working correct we can not rely on result of image_get_ibuf_threadsafe called outside from thread lock. This is so because we need to guarantee getting image buffer from list of loaded buffers and it's referencing happens atomic. Without lock here it is possible that between call of image_get_ibuf_threadsafe and referencing the buffer IMA_SIGNAL_FREE would be called. Image signal handling too is blocking now to prevent such a situation. Threads are locking by spinlock, which are faster than mutexes. There were some slowdown reports in the past about render slowdown when using OSX on Xeon CPU. It shouldn't happen with spin locks, but more tests on different hardware would be really welcome. So far can not see speed regressions on own computers. This commit also removes BKE_image_get_ibuf, because it was not so intuitive when get_ibuf and acquire_ibuf should be used. Thanks to Ton and Brecht for discussion/review :)
86 lines
3.8 KiB
C++
86 lines
3.8 KiB
C++
/*
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
* All rights reserved.
|
|
*
|
|
* Contributor(s): Blender Foundation
|
|
*
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
*/
|
|
|
|
/** \file ED_image.h
|
|
* \ingroup editors
|
|
*/
|
|
|
|
#ifndef __ED_IMAGE_H__
|
|
#define __ED_IMAGE_H__
|
|
|
|
struct SpaceImage;
|
|
struct Main;
|
|
struct bContext;
|
|
struct Image;
|
|
struct ImageUser;
|
|
struct ToolSettings;
|
|
struct uiBlock;
|
|
struct wmWindowManager;
|
|
struct ARegion;
|
|
struct Scene;
|
|
|
|
/* image_edit.c, exported for transform */
|
|
struct Image *ED_space_image(struct SpaceImage *sima);
|
|
void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit, struct Image *ima);
|
|
struct Mask *ED_space_image_get_mask(struct SpaceImage *sima);
|
|
void ED_space_image_set_mask(struct bContext *C, struct SpaceImage *sima, struct Mask *mask);
|
|
|
|
int ED_space_image_color_sample(struct SpaceImage *sima, struct ARegion *ar, int mval[2], float r_col[3]);
|
|
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r);
|
|
void ED_space_image_release_buffer(struct SpaceImage *sima, struct ImBuf *ibuf, void *lock);
|
|
int ED_space_image_has_buffer(struct SpaceImage *sima);
|
|
|
|
void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height);
|
|
void ED_space_image_get_size_fl(struct SpaceImage *sima, float size[2]);
|
|
void ED_space_image_get_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
|
void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
|
|
void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
|
|
|
|
void ED_space_image_paint_update(struct wmWindowManager *wm, struct ToolSettings *settings);
|
|
void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings);
|
|
|
|
void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *aspx, float *aspy);
|
|
void ED_image_mouse_pos(struct SpaceImage *sima, struct ARegion *ar, const int mval[2], float co[2]);
|
|
void ED_image_point_pos(struct SpaceImage *sima, struct ARegion *ar, float x, float y, float *xr, float *yr);
|
|
void ED_image_point_pos__reverse(struct SpaceImage *sima, struct ARegion *ar, const float co[2], float r_co[2]);
|
|
|
|
int ED_space_image_show_render(struct SpaceImage *sima);
|
|
int ED_space_image_show_paint(struct SpaceImage *sima);
|
|
int ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object *obedit);
|
|
int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit);
|
|
|
|
int ED_space_image_check_show_maskedit(struct Scene *scene, struct SpaceImage *sima);
|
|
int ED_space_image_maskedit_poll(struct bContext *C);
|
|
int ED_space_image_maskedit_mask_poll(struct bContext *C);
|
|
|
|
/* UI level image (texture) updating... render calls own stuff (too) */
|
|
void ED_image_update_frame(const struct Main *mainp, int cfra);
|
|
|
|
void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
|
|
const unsigned char cp[4], const float fp[4], int *zp, float *zpf);
|
|
|
|
#endif /* __ED_IMAGE_H__ */
|
|
|