~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to agg/include/agg_span_gouraud_gray.h

  • Committer: corsixth.bot at gmail
  • Date: 2014-03-31 23:30:23 UTC
  • Revision ID: svn-v4:c39591fa-788f-11de-a72b-d90af8dea425:trunk:2687
Remove trailing whitespaces in .h, .cpp, .c and .lua files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
// Anti-Grain Geometry - Version 2.4
3
3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
4
//
5
 
// Permission to copy, use, modify, sell and distribute this software 
6
 
// is granted provided this copyright notice appears in all copies. 
 
5
// Permission to copy, use, modify, sell and distribute this software
 
6
// is granted provided this copyright notice appears in all copies.
7
7
// This software is provided "as is" without express or implied
8
8
// warranty, and with no claim as to its suitability for any purpose.
9
9
//
13
13
//          http://www.antigrain.com
14
14
//----------------------------------------------------------------------------
15
15
//
16
 
// Adaptation for high precision colors has been sponsored by 
 
16
// Adaptation for high precision colors has been sponsored by
17
17
// Liberty Technology Systems, Inc., visit http://lib-sys.com
18
18
//
19
19
// Liberty Technology Systems, Inc. is the provider of
20
20
// PostScript and PDF technology for software developers.
21
 
// 
 
21
//
22
22
//----------------------------------------------------------------------------
23
23
 
24
24
#ifndef AGG_SPAN_GOURAUD_GRAY_INCLUDED
41
41
        typedef span_gouraud<color_type> base_type;
42
42
        typedef typename base_type::coord_type coord_type;
43
43
        enum subpixel_scale_e
44
 
        { 
45
 
            subpixel_shift = 4, 
 
44
        {
 
45
            subpixel_shift = 4,
46
46
            subpixel_scale = 1 << subpixel_shift
47
47
        };
48
48
 
90
90
    public:
91
91
        //--------------------------------------------------------------------
92
92
        span_gouraud_gray() {}
93
 
        span_gouraud_gray(const color_type& c1, 
94
 
                          const color_type& c2, 
 
93
        span_gouraud_gray(const color_type& c1,
 
94
                          const color_type& c2,
95
95
                          const color_type& c3,
96
 
                          double x1, double y1, 
 
96
                          double x1, double y1,
97
97
                          double x2, double y2,
98
 
                          double x3, double y3, 
99
 
                          double d = 0) : 
 
98
                          double x3, double y3,
 
99
                          double d = 0) :
100
100
            base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d)
101
101
        {}
102
102
 
108
108
 
109
109
            m_y2 = int(coord[1].y);
110
110
 
111
 
            m_swap = cross_product(coord[0].x, coord[0].y, 
 
111
            m_swap = cross_product(coord[0].x, coord[0].y,
112
112
                                   coord[2].x, coord[2].y,
113
113
                                   coord[1].x, coord[1].y) < 0.0;
114
114
 
140
140
 
141
141
            if(m_swap)
142
142
            {
143
 
                // It means that the triangle is oriented clockwise, 
 
143
                // It means that the triangle is oriented clockwise,
144
144
                // so that we need to swap the controlling structures
145
145
                //-------------------------
146
146
                const gray_calc* t = pc2;
157
157
            dda_line_interpolator<14> v(pc1->m_v, pc2->m_v, nlen);
158
158
            dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen);
159
159
 
160
 
            // Calculate the starting point of the gradient with subpixel 
 
160
            // Calculate the starting point of the gradient with subpixel
161
161
            // accuracy and correct (roll back) the interpolators.
162
162
            // This operation will also clip the beginning of the span
163
163
            // if necessary.
164
164
            //-------------------------
165
165
            int start = pc1->m_x - (x << subpixel_shift);
166
 
            v    -= start; 
 
166
            v    -= start;
167
167
            a    -= start;
168
168
            nlen += start;
169
169
 
170
170
            int vv, va;
171
171
            enum lim_e { lim = color_type::base_mask };
172
172
 
173
 
            // Beginning part of the span. Since we rolled back the 
 
173
            // Beginning part of the span. Since we rolled back the
174
174
            // interpolators, the color values may have overflow.
175
 
            // So that, we render the beginning part with checking 
 
175
            // So that, we render the beginning part with checking
176
176
            // for overflow. It lasts until "start" is positive;
177
177
            // typically it's 1-2 pixels, but may be more in some cases.
178
178
            //-------------------------
184
184
                if(va < 0) va = 0; if(va > lim) va = lim;
185
185
                span->v = (value_type)vv;
186
186
                span->a = (value_type)va;
187
 
                v     += subpixel_scale; 
 
187
                v     += subpixel_scale;
188
188
                a     += subpixel_scale;
189
189
                nlen  -= subpixel_scale;
190
190
                start -= subpixel_scale;
194
194
 
195
195
            // Middle part, no checking for overflow.
196
196
            // Actual spans can be longer than the calculated length
197
 
            // because of anti-aliasing, thus, the interpolators can 
 
197
            // because of anti-aliasing, thus, the interpolators can
198
198
            // overflow. But while "nlen" is positive we are safe.
199
199
            //-------------------------
200
200
            while(len && nlen > 0)
201
201
            {
202
202
                span->v = (value_type)v.y();
203
203
                span->a = (value_type)a.y();
204
 
                v    += subpixel_scale; 
 
204
                v    += subpixel_scale;
205
205
                a    += subpixel_scale;
206
206
                nlen -= subpixel_scale;
207
207
                ++span;
219
219
                if(va < 0) va = 0; if(va > lim) va = lim;
220
220
                span->v = (value_type)vv;
221
221
                span->a = (value_type)va;
222
 
                v += subpixel_scale; 
 
222
                v += subpixel_scale;
223
223
                a += subpixel_scale;
224
224
                ++span;
225
225
                --len;