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:
authorCampbell Barton <ideasman42@gmail.com>2012-01-19 12:22:23 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-19 12:22:23 +0400
commit4786541285f6f190922ec9857753d620c528f181 (patch)
tree4eb00a6e2fe307d1147e7cb1d0a6785915c0432f
parent65fca39f77981db5a649d942f308fa457d18cb41 (diff)
add utility functions linearrgb_to_srgb_uchar4,
linearrgb_to_srgb_uchar3, was being done inline.
-rw-r--r--source/blender/blenkernel/intern/node.c6
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c28
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c2
-rw-r--r--source/blender/render/intern/source/rendercore.c11
4 files changed, 33 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 359470eecf2..61111e82cc7 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -790,16 +790,14 @@ void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage)
unsigned char *tar= preview->rect+ 4*((preview->xsize*y) + x);
if(do_manage) {
- tar[0]= FTOCHAR(linearrgb_to_srgb(col[0]));
- tar[1]= FTOCHAR(linearrgb_to_srgb(col[1]));
- tar[2]= FTOCHAR(linearrgb_to_srgb(col[2]));
+ linearrgb_to_srgb_uchar4(tar, col);
}
else {
tar[0]= FTOCHAR(col[0]);
tar[1]= FTOCHAR(col[1]);
tar[2]= FTOCHAR(col[2]);
+ tar[3]= FTOCHAR(col[3]);
}
- tar[3]= FTOCHAR(col[3]);
}
//else printf("prv out bound x y %d %d\n", x, y);
}
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index 1247632cf79..18b0e9c6278 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -62,6 +62,34 @@ MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
srgb[3] = linear[3];
}
+MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[4], const float linear[4])
+{
+ int r, g, b;
+
+ r = 255 * linearrgb_to_srgb(linear[0]) * 255;
+ g = 255 * linearrgb_to_srgb(linear[1]) * 255;
+ b = 255 * linearrgb_to_srgb(linear[2]) * 255;
+
+ srgb[0] = FTOCHAR(r);
+ srgb[1] = FTOCHAR(g);
+ srgb[2] = FTOCHAR(b);
+}
+
+MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
+{
+ int r, g, b, a;
+
+ r = 255 * linearrgb_to_srgb(linear[0]) * 255;
+ g = 255 * linearrgb_to_srgb(linear[1]) * 255;
+ b = 255 * linearrgb_to_srgb(linear[2]) * 255;
+ a = 255 * linear[3];
+
+ srgb[0] = FTOCHAR(r);
+ srgb[1] = FTOCHAR(g);
+ srgb[2] = FTOCHAR(b);
+ srgb[3] = FTOCHAR(a);
+}
+
/* predivide versions to work on associated/premultipled alpha. if this should
be done or not depends on the background the image will be composited over,
ideally you would never do color space conversion on an image with alpha
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 612b46746b8..5f836ec4ca7 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -103,7 +103,7 @@ static int ED_operator_uvedit_can_uv_sculpt(struct bContext *C)
return ED_space_image_show_uvedit(sima, obedit) && !(toolsettings->use_uv_sculpt);
}
-static int ED_operator_uvmap_mesh(bContext *C)
+static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
{
Object *ob= CTX_data_active_object(C);
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 630acf3d88a..c5d580b2e9f 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -2166,17 +2166,10 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
}
}
else {
- char *col= (char *)(bs->rect + bs->rectx*y + x);
+ unsigned char *col= (unsigned char *)(bs->rect + bs->rectx*y + x);
if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE) && (R.r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
- float srgb[3];
- srgb[0]= linearrgb_to_srgb(shr.combined[0]);
- srgb[1]= linearrgb_to_srgb(shr.combined[1]);
- srgb[2]= linearrgb_to_srgb(shr.combined[2]);
-
- col[0]= FTOCHAR(srgb[0]);
- col[1]= FTOCHAR(srgb[1]);
- col[2]= FTOCHAR(srgb[2]);
+ linearrgb_to_srgb_uchar3(col, shr.combined);
} else {
col[0]= FTOCHAR(shr.combined[0]);
col[1]= FTOCHAR(shr.combined[1]);