[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36878] branches/soc-2011-onion/source/ blender: GSOC-2011\n\naesthetic changes/comments, no functional change
Ryakiotakis Antonis
kalast at gmail.com
Tue May 24 21:01:48 CEST 2011
Revision: 36878
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36878
Author: psy-fi
Date: 2011-05-24 19:01:48 +0000 (Tue, 24 May 2011)
Log Message:
-----------
GSOC-2011\n\naesthetic changes/comments, no functional change
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c
branches/soc-2011-onion/source/blender/imbuf/intern/divers.c
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c 2011-05-24 18:34:07 UTC (rev 36877)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_image.c 2011-05-24 19:01:48 UTC (rev 36878)
@@ -4058,7 +4058,6 @@
static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
{
if(ibuf->rect_float)
- /* TODO - should just update a portion from imapaintpartial! */
ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */
if(ibuf->mipmap[0])
Modified: branches/soc-2011-onion/source/blender/imbuf/intern/divers.c
===================================================================
--- branches/soc-2011-onion/source/blender/imbuf/intern/divers.c 2011-05-24 18:34:07 UTC (rev 36877)
+++ branches/soc-2011-onion/source/blender/imbuf/intern/divers.c 2011-05-24 19:01:48 UTC (rev 36878)
@@ -107,88 +107,88 @@
void IMB_rect_from_float(struct ImBuf *ibuf)
{
/* quick method to convert floatbuf to byte */
- float *tof = (float *)ibuf->rect_float;
+ float *srcFloatPxl = (float *)ibuf->rect_float;
// int do_dither = ibuf->dither != 0.f;
float dither= ibuf->dither / 255.0f;
float srgb[4];
int i, channels= ibuf->channels;
short profile= ibuf->profile;
- unsigned char *to = (unsigned char *) ibuf->rect;
+ unsigned char *dstBytePxl = (unsigned char *) ibuf->rect;
- if(tof==NULL) return;
- if(to==NULL) {
+ if(srcFloatPxl==NULL) return;
+ if(dstBytePxl==NULL) {
imb_addrectImBuf(ibuf);
- to = (unsigned char *) ibuf->rect;
+ dstBytePxl = (unsigned char *) ibuf->rect;
}
if(channels==1) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof++)
- to[1]= to[2]= to[3]= to[0] = FTOCHAR(tof[0]);
+ for (i = ibuf->x * ibuf->y; i > 0; i--, dstBytePxl+=4, srcFloatPxl++)
+ dstBytePxl[1]= dstBytePxl[2]= dstBytePxl[3]= dstBytePxl[0] = FTOCHAR(srcFloatPxl[0]);
}
else if (profile == IB_PROFILE_LINEAR_RGB) {
if(channels == 3) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=3) {
- srgb[0]= linearrgb_to_srgb(tof[0]);
- srgb[1]= linearrgb_to_srgb(tof[1]);
- srgb[2]= linearrgb_to_srgb(tof[2]);
+ for (i = ibuf->x * ibuf->y; i > 0; i--, dstBytePxl+=4, srcFloatPxl+=3) {
+ srgb[0]= linearrgb_to_srgb(srcFloatPxl[0]);
+ srgb[1]= linearrgb_to_srgb(srcFloatPxl[1]);
+ srgb[2]= linearrgb_to_srgb(srcFloatPxl[2]);
- to[0] = FTOCHAR(srgb[0]);
- to[1] = FTOCHAR(srgb[1]);
- to[2] = FTOCHAR(srgb[2]);
- to[3] = 255;
+ dstBytePxl[0] = FTOCHAR(srgb[0]);
+ dstBytePxl[1] = FTOCHAR(srgb[1]);
+ dstBytePxl[2] = FTOCHAR(srgb[2]);
+ dstBytePxl[3] = 255;
}
}
else if (channels == 4) {
if (dither != 0.f) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) {
+ for (i = ibuf->x * ibuf->y; i > 0; i--, dstBytePxl+=4, srcFloatPxl+=4) {
const float d = (BLI_frand()-0.5f)*dither;
- srgb[0]= d + linearrgb_to_srgb(tof[0]);
- srgb[1]= d + linearrgb_to_srgb(tof[1]);
- srgb[2]= d + linearrgb_to_srgb(tof[2]);
- srgb[3]= d + tof[3];
+ srgb[0]= d + linearrgb_to_srgb(srcFloatPxl[0]);
+ srgb[1]= d + linearrgb_to_srgb(srcFloatPxl[1]);
+ srgb[2]= d + linearrgb_to_srgb(srcFloatPxl[2]);
+ srgb[3]= d + srcFloatPxl[3];
- to[0] = FTOCHAR(srgb[0]);
- to[1] = FTOCHAR(srgb[1]);
- to[2] = FTOCHAR(srgb[2]);
- to[3] = FTOCHAR(srgb[3]);
+ dstBytePxl[0] = FTOCHAR(srgb[0]);
+ dstBytePxl[1] = FTOCHAR(srgb[1]);
+ dstBytePxl[2] = FTOCHAR(srgb[2]);
+ dstBytePxl[3] = FTOCHAR(srgb[3]);
}
} else {
- floatbuf_to_srgb_byte(tof, to, 0, ibuf->x, 0, ibuf->y, ibuf->x);
+ floatbuf_to_srgb_byte(srcFloatPxl, dstBytePxl, 0, ibuf->x, 0, ibuf->y, ibuf->x);
}
}
}
else if(ELEM(profile, IB_PROFILE_NONE, IB_PROFILE_SRGB)) {
if(channels==3) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=3) {
- to[0] = FTOCHAR(tof[0]);
- to[1] = FTOCHAR(tof[1]);
- to[2] = FTOCHAR(tof[2]);
- to[3] = 255;
+ for (i = ibuf->x * ibuf->y; i > 0; i--, dstBytePxl+=4, srcFloatPxl+=3) {
+ dstBytePxl[0] = FTOCHAR(srcFloatPxl[0]);
+ dstBytePxl[1] = FTOCHAR(srcFloatPxl[1]);
+ dstBytePxl[2] = FTOCHAR(srcFloatPxl[2]);
+ dstBytePxl[3] = 255;
}
}
else {
if (dither != 0.f) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) {
+ for (i = ibuf->x * ibuf->y; i > 0; i--, dstBytePxl+=4, srcFloatPxl+=4) {
const float d = (BLI_frand()-0.5f)*dither;
float col[4];
- col[0]= d + tof[0];
- col[1]= d + tof[1];
- col[2]= d + tof[2];
- col[3]= d + tof[3];
+ col[0]= d + srcFloatPxl[0];
+ col[1]= d + srcFloatPxl[1];
+ col[2]= d + srcFloatPxl[2];
+ col[3]= d + srcFloatPxl[3];
- to[0] = FTOCHAR(col[0]);
- to[1] = FTOCHAR(col[1]);
- to[2] = FTOCHAR(col[2]);
- to[3] = FTOCHAR(col[3]);
+ dstBytePxl[0] = FTOCHAR(col[0]);
+ dstBytePxl[1] = FTOCHAR(col[1]);
+ dstBytePxl[2] = FTOCHAR(col[2]);
+ dstBytePxl[3] = FTOCHAR(col[3]);
}
} else {
- for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) {
- to[0] = FTOCHAR(tof[0]);
- to[1] = FTOCHAR(tof[1]);
- to[2] = FTOCHAR(tof[2]);
- to[3] = FTOCHAR(tof[3]);
+ for (i = ibuf->x * ibuf->y; i > 0; i--, dstBytePxl+=4, srcFloatPxl+=4) {
+ dstBytePxl[0] = FTOCHAR(srcFloatPxl[0]);
+ dstBytePxl[1] = FTOCHAR(srcFloatPxl[1]);
+ dstBytePxl[2] = FTOCHAR(srcFloatPxl[2]);
+ dstBytePxl[3] = FTOCHAR(srcFloatPxl[3]);
}
}
}
@@ -199,87 +199,96 @@
-/* assume converting from linear float to sRGB byte for part of the texture*/
+/*converts from linear float to sRGB byte for part of the texture*/
void IMB_partial_rect_from_float(struct ImBuf *ibuf, int x, int y, int w, int h)
{
- /* quick method to convert floatbuf to byte */
- float *tof, *init_tof = (float *)ibuf->rect_float;
-// int do_dither = ibuf->dither != 0.f;
+ /*indices to source and destination image pixels*/
+ float *srcFloatPxl;
+ unsigned char *dstBytePxl;
+
+ /*convenience pointers to start of image buffers*/
+ const float *init_srcFloatPxl = (float *)ibuf->rect_float;
+ const unsigned char *init_dstBytePxl = (unsigned char *) ibuf->rect;
+
+ /*Dithering factor*/
float dither= ibuf->dither / 255.0f;
+ /*temporary srgb result holder*/
float srgb[4];
- int i, j, channels= ibuf->channels;
+ /*respective attributes of image*/
short profile= ibuf->profile;
- unsigned char *to, *init_to = (unsigned char *) ibuf->rect;
-
+ int channels= ibuf->channels;
+
+ int i, j;
+
/*
if called -only- from GPU_paint_update_image this test will never fail
but leaving it here for better or worse
*/
- if(init_tof==NULL) return;
- if(init_to==NULL) {
+ if(init_srcFloatPxl==NULL) return;
+ if(init_dstBytePxl==NULL) {
imb_addrectImBuf(ibuf);
- init_to = (unsigned char *) ibuf->rect;
+ init_dstBytePxl = (unsigned char *) ibuf->rect;
}
if(channels==1) {
for (j = 0; j < h; j++){
- to = init_to + (ibuf->x*(y + j) + x)*4;
- tof = init_tof + (ibuf->x*(y + j) + x)*4;
- for(i = 0; i < w; i++, to+=4, tof+=4) {
- to[1]= to[2]= to[3]= to[0] = FTOCHAR(tof[0]);
+ dstBytePxl = init_dstBytePxl + (ibuf->x*(y + j) + x)*4;
+ srcFloatPxl = init_srcFloatPxl + (ibuf->x*(y + j) + x)*4;
+ for(i = 0; i < w; i++, dstBytePxl+=4, srcFloatPxl+=4) {
+ dstBytePxl[1]= dstBytePxl[2]= dstBytePxl[3]= dstBytePxl[0] = FTOCHAR(srcFloatPxl[0]);
}
}
}
else if (profile == IB_PROFILE_LINEAR_RGB) {
if(channels == 3) {
for (j = 0; j < h; j++){
- to = init_to + (ibuf->x*(y + j) + x)*4;
- tof = init_tof + (ibuf->x*(y + j) + x)*4;
- for(i = 0; i < w; i++, to+=4, tof+=4) {
+ dstBytePxl = init_dstBytePxl + (ibuf->x*(y + j) + x)*4;
+ srcFloatPxl = init_srcFloatPxl + (ibuf->x*(y + j) + x)*4;
+ for(i = 0; i < w; i++, dstBytePxl+=4, srcFloatPxl+=4) {
- srgb[0]= linearrgb_to_srgb(tof[0]);
- srgb[1]= linearrgb_to_srgb(tof[1]);
- srgb[2]= linearrgb_to_srgb(tof[2]);
+ srgb[0]= linearrgb_to_srgb(srcFloatPxl[0]);
+ srgb[1]= linearrgb_to_srgb(srcFloatPxl[1]);
+ srgb[2]= linearrgb_to_srgb(srcFloatPxl[2]);
- to[0] = FTOCHAR(srgb[0]);
- to[1] = FTOCHAR(srgb[1]);
- to[2] = FTOCHAR(srgb[2]);
- to[3] = 255;
+ dstBytePxl[0] = FTOCHAR(srgb[0]);
+ dstBytePxl[1] = FTOCHAR(srgb[1]);
+ dstBytePxl[2] = FTOCHAR(srgb[2]);
+ dstBytePxl[3] = 255;
}
}
}
else if (channels == 4) {
if (dither != 0.f) {
for (j = 0; j < h; j++){
- to = init_to + (ibuf->x*(y + j) + x)*4;
- tof = init_tof + (ibuf->x*(y + j) + x)*4;
- for(i = 0; i < w; i++, to+=4, tof+=4) {
+ dstBytePxl = init_dstBytePxl + (ibuf->x*(y + j) + x)*4;
+ srcFloatPxl = init_srcFloatPxl + (ibuf->x*(y + j) + x)*4;
+ for(i = 0; i < w; i++, dstBytePxl+=4, srcFloatPxl+=4) {
const float d = (BLI_frand()-0.5f)*dither;
- srgb[0]= d + linearrgb_to_srgb(tof[0]);
- srgb[1]= d + linearrgb_to_srgb(tof[1]);
- srgb[2]= d + linearrgb_to_srgb(tof[2]);
- srgb[3]= d + tof[3];
+ srgb[0]= d + linearrgb_to_srgb(srcFloatPxl[0]);
+ srgb[1]= d + linearrgb_to_srgb(srcFloatPxl[1]);
+ srgb[2]= d + linearrgb_to_srgb(srcFloatPxl[2]);
+ srgb[3]= d + srcFloatPxl[3];
- to[0] = FTOCHAR(srgb[0]);
- to[1] = FTOCHAR(srgb[1]);
- to[2] = FTOCHAR(srgb[2]);
- to[3] = FTOCHAR(srgb[3]);
+ dstBytePxl[0] = FTOCHAR(srgb[0]);
+ dstBytePxl[1] = FTOCHAR(srgb[1]);
+ dstBytePxl[2] = FTOCHAR(srgb[2]);
+ dstBytePxl[3] = FTOCHAR(srgb[3]);
}
}
} else {
for (j = 0; j < h; j++){
- to = init_to + (ibuf->x*(y + j) + x)*4;
- tof = init_tof + (ibuf->x*(y + j) + x)*4;
- for(i = 0; i < w; i++, to+=4, tof+=4) {
- srgb[0]= linearrgb_to_srgb(tof[0]);
- srgb[1]= linearrgb_to_srgb(tof[1]);
- srgb[2]= linearrgb_to_srgb(tof[2]);
- srgb[3]= tof[3];
+ dstBytePxl = init_dstBytePxl + (ibuf->x*(y + j) + x)*4;
+ srcFloatPxl = init_srcFloatPxl + (ibuf->x*(y + j) + x)*4;
+ for(i = 0; i < w; i++, dstBytePxl+=4, srcFloatPxl+=4) {
+ srgb[0]= linearrgb_to_srgb(srcFloatPxl[0]);
+ srgb[1]= linearrgb_to_srgb(srcFloatPxl[1]);
+ srgb[2]= linearrgb_to_srgb(srcFloatPxl[2]);
+ srgb[3]= srcFloatPxl[3];
- to[0] = FTOCHAR(srgb[0]);
- to[1] = FTOCHAR(srgb[1]);
- to[2] = FTOCHAR(srgb[2]);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list