~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/render/intern/source/pixelblending.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Functions to blend pixels with or without alpha, in various formats
5
5
 * nzc - June 2000
6
6
 *
7
 
 * $Id: pixelblending.c,v 1.17 2006/12/05 16:43:00 ton Exp $
 
7
 * $Id: pixelblending.c,v 1.18 2007/04/04 13:18:30 campbellbarton Exp $
8
8
 *
9
9
 * ***** BEGIN GPL LICENSE BLOCK *****
10
10
 *
51
51
 
52
52
/* ------------------------------------------------------------------------- */
53
53
/* Debug/behaviour defines                                                   */
54
 
/* if defined: alpha blending with floats clips colour, as with shorts       */
55
 
/* #define RE_FLOAT_COLOUR_CLIPPING  */
 
54
/* if defined: alpha blending with floats clips color, as with shorts       */
 
55
/* #define RE_FLOAT_COLOR_CLIPPING  */
56
56
/* if defined: alpha values are clipped                                      */
57
57
/* For now, we just keep alpha clipping. We run into thresholding and        */
58
58
/* blending difficulties otherwise. Be careful here.                         */
62
62
 
63
63
/* Threshold for a 'full' pixel: pixels with alpha above this level are      */
64
64
/* considered opaque This is the decimal value for 0xFFF0 / 0xFFFF           */
65
 
#define RE_FULL_COLOUR_FLOAT 0.9998
 
65
#define RE_FULL_COLOR_FLOAT 0.9998
66
66
/* Threshold for an 'empty' pixel: pixels with alpha above this level are    */
67
67
/* considered completely transparent. This is the decimal value              */
68
68
/* for 0x000F / 0xFFFF                                                       */
69
 
#define RE_EMPTY_COLOUR_FLOAT 0.0002
 
69
#define RE_EMPTY_COLOR_FLOAT 0.0002
70
70
 
71
71
 
72
72
/* ------------------------------------------------------------------------- */
92
92
{
93
93
    float mul;
94
94
    
95
 
    if( (-RE_EMPTY_COLOUR_FLOAT < dest[3])
96
 
        && (dest[3] <  RE_EMPTY_COLOUR_FLOAT) ) {       
 
95
    if( (-RE_EMPTY_COLOR_FLOAT < dest[3])
 
96
        && (dest[3] <  RE_EMPTY_COLOR_FLOAT) ) {        
97
97
        dest[0] = source[0];
98
98
        dest[1] = source[1];
99
99
        dest[2] = source[2];
114
114
void addalphaAddfacFloat(float *dest, float *source, char addfac)
115
115
{
116
116
    float m; /* weiging factor of destination */
117
 
    float c; /* intermediate colour           */
 
117
    float c; /* intermediate color           */
118
118
 
119
119
    /* Addfac is a number between 0 and 1: rescale */
120
120
    /* final target is to diminish the influence of dest when addfac rises */
121
121
    m = 1.0 - ( source[3] * ((255.0 - addfac) / 255.0));
122
122
 
123
 
    /* blend colours*/
 
123
    /* blend colors*/
124
124
    c= (m * dest[0]) + source[0];
125
 
#ifdef RE_FLOAT_COLOUR_CLIPPING
126
 
    if(c >= RE_FULL_COLOUR_FLOAT) dest[0] = RE_FULL_COLOUR_FLOAT; 
 
125
#ifdef RE_FLOAT_COLOR_CLIPPING
 
126
    if(c >= RE_FULL_COLOR_FLOAT) dest[0] = RE_FULL_COLOR_FLOAT; 
127
127
    else 
128
128
#endif
129
129
        dest[0]= c;
130
130
   
131
131
    c= (m * dest[1]) + source[1];
132
 
#ifdef RE_FLOAT_COLOUR_CLIPPING
133
 
    if(c >= RE_FULL_COLOUR_FLOAT) dest[1] = RE_FULL_COLOUR_FLOAT; 
 
132
#ifdef RE_FLOAT_COLOR_CLIPPING
 
133
    if(c >= RE_FULL_COLOR_FLOAT) dest[1] = RE_FULL_COLOR_FLOAT; 
134
134
    else 
135
135
#endif
136
136
        dest[1]= c;
137
137
    
138
138
    c= (m * dest[2]) + source[2];
139
 
#ifdef RE_FLOAT_COLOUR_CLIPPING
140
 
    if(c >= RE_FULL_COLOUR_FLOAT) dest[2] = RE_FULL_COLOUR_FLOAT; 
 
139
#ifdef RE_FLOAT_COLOR_CLIPPING
 
140
    if(c >= RE_FULL_COLOR_FLOAT) dest[2] = RE_FULL_COLOR_FLOAT; 
141
141
    else 
142
142
#endif
143
143
        dest[2]= c;
144
144
 
145
145
        c= (m * dest[3]) + source[3];
146
146
#ifdef RE_ALPHA_CLIPPING
147
 
        if(c >= RE_FULL_COLOUR_FLOAT) dest[3] = RE_FULL_COLOUR_FLOAT; 
 
147
        if(c >= RE_FULL_COLOR_FLOAT) dest[3] = RE_FULL_COLOR_FLOAT; 
148
148
        else 
149
149
#endif
150
150
       dest[3]= c;
263
263
{
264
264
 
265
265
        /* Makes me wonder whether this is required... */
266
 
        if( dest[3] < RE_EMPTY_COLOUR_FLOAT) {
 
266
        if( dest[3] < RE_EMPTY_COLOR_FLOAT) {
267
267
                dest[0] = source[0];
268
268
                dest[1] = source[1];
269
269
                dest[2] = source[2];