Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-04-13 20:03:14 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-04-13 20:03:14 +0400
commit6f153046e0ffec912883ab24b9fda823e9fbeb38 (patch)
tree9a0d2705acdfe2a920eeaaeb0a0924cc9bf65e37 /source/blender/editors
parent5d79c2662e043c35feeb4a31f3c5eb288e93c9c1 (diff)
Reduce overhead when sampling texture images for brushes. The tests can
be cached and reused.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c15
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c4
4 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 97c1a994629..b1e4696cd02 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -162,7 +162,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
if (refresh) {
struct ImagePool *pool = NULL;
bool convert_to_linear = false;
- ImBuf *tex_ibuf;
+ struct ColorSpace *colorspace;
/* stencil is rotated later */
const float rotation = (mtex->brush_map_mode != MTEX_MAP_MODE_STENCIL) ?
-mtex->rot : 0;
@@ -223,10 +223,11 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
#endif
if (mtex->tex->type == TEX_IMAGE && mtex->tex->ima) {
- tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool);
+ ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool);
/* For consistency, sampling always returns color in linear space */
if (tex_ibuf && tex_ibuf->rect_float == NULL) {
convert_to_linear = true;
+ colorspace = tex_ibuf->rect_colorspace;
}
BKE_image_pool_release_ibuf(mtex->tex->ima, tex_ibuf, pool);
}
@@ -270,7 +271,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
if (col) {
float rgba[4];
- paint_get_tex_pixel_col(mtex, x, y, rgba, pool, thread_num, convert_to_linear, tex_ibuf);
+ paint_get_tex_pixel_col(mtex, x, y, rgba, pool, thread_num, convert_to_linear, colorspace);
buffer[index * 4] = rgba[0] * 255;
buffer[index * 4 + 1] = rgba[1] * 255;
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index bdb1c88c0ce..d8f7a3d8e05 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -37,7 +37,7 @@ struct bContext;
struct bglMats;
struct Brush;
struct ImagePool;
-struct ImBuf;
+struct ColorSpace;
struct ListBase;
struct Mesh;
struct MTex;
@@ -200,7 +200,7 @@ void paint_calc_redraw_planes(float planes[4][4],
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
-void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ImBuf *ibuf);
+void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
void paint_sample_color(const struct bContext *C, struct ARegion *ar, int x, int y);
void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index a8f3a6cbc72..d3b6d8cdd1a 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -47,6 +47,7 @@
#include "BKE_paint.h"
#include "BKE_brush.h"
#include "BKE_colortools.h"
+#include "BKE_image.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -57,6 +58,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
+#include "IMB_imbuf_types.h"
+
#include "paint_intern.h"
#include <float.h>
@@ -172,6 +175,18 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
copy_v2_v2(ups->tex_mouse, mouse);
copy_v2_v2(ups->mask_tex_mouse, mouse);
stroke->cached_size_pressure = pressure;
+
+ /* check here if color sampling the main brush should do color conversion. This is done here
+ * to avoid locking up to get the image buffer during sampling */
+ if (brush->mtex.tex && brush->mtex.tex->type == TEX_IMAGE && brush->mtex.tex->ima) {
+ ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(brush->mtex.tex->ima, &brush->mtex.tex->iuser, NULL);
+ if (tex_ibuf && tex_ibuf->rect_float == NULL) {
+ ups->do_linear_conversion = true;
+ ups->colorspace = tex_ibuf->rect_colorspace;
+ }
+ BKE_image_pool_release_ibuf(brush->mtex.tex->ima, tex_ibuf, NULL);
+ }
+
stroke->brush_init = true;
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 2eb397563e6..7316c58755c 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -179,7 +179,7 @@ float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool,
return intensity;
}
-void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, ImBuf *ibuf)
+void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
{
float co[3] = {u, v, 0.0f};
int hasrgb;
@@ -195,7 +195,7 @@ void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct
}
if (convert_to_linear)
- IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, ibuf->rect_colorspace);
+ IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, colorspace);
linearrgb_to_srgb_v3_v3(rgba, rgba);