Subversion Repositories Kolibri OS

Rev

Rev 1891 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1891 Rev 3931
Line 48... Line 48...
48
    return 1 - t * (1 / (2 * M_PI)); /* Scale t to [0, 1] and
48
    return 1 - t * (1 / (2 * M_PI)); /* Scale t to [0, 1] and
49
				      * make rotation CCW
49
				      * make rotation CCW
50
				      */
50
				      */
51
}
51
}
Line 52... Line 52...
52
 
52
 
53
static void
53
static uint32_t *
54
conical_gradient_get_scanline_32 (pixman_image_t *image,
-
 
55
                                  int             x,
-
 
56
                                  int             y,
-
 
57
                                  int             width,
-
 
58
                                  uint32_t *      buffer,
-
 
59
                                  const uint32_t *mask)
54
conical_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
60
{
55
{
-
 
56
    pixman_image_t *image = iter->image;
-
 
57
    int x = iter->x;
-
 
58
    int y = iter->y;
-
 
59
    int width = iter->width;
-
 
60
    uint32_t *buffer = iter->buffer;
61
    source_image_t *source = (source_image_t *)image;
61
 
62
    gradient_t *gradient = (gradient_t *)source;
62
    gradient_t *gradient = (gradient_t *)image;
63
    conical_gradient_t *conical = (conical_gradient_t *)image;
63
    conical_gradient_t *conical = (conical_gradient_t *)image;
64
    uint32_t       *end = buffer + width;
64
    uint32_t       *end = buffer + width;
65
    pixman_gradient_walker_t walker;
65
    pixman_gradient_walker_t walker;
66
    pixman_bool_t affine = TRUE;
66
    pixman_bool_t affine = TRUE;
Line 69... Line 69...
69
    double cz = 0.;
69
    double cz = 0.;
70
    double rx = x + 0.5;
70
    double rx = x + 0.5;
71
    double ry = y + 0.5;
71
    double ry = y + 0.5;
72
    double rz = 1.;
72
    double rz = 1.;
Line 73... Line 73...
73
 
73
 
Line 74... Line 74...
74
    _pixman_gradient_walker_init (&walker, gradient, source->common.repeat);
74
    _pixman_gradient_walker_init (&walker, gradient, image->common.repeat);
75
 
75
 
76
    if (source->common.transform)
76
    if (image->common.transform)
Line 77... Line 77...
77
    {
77
    {
78
	pixman_vector_t v;
78
	pixman_vector_t v;
79
 
79
 
80
	/* reference point is the center of the pixel */
80
	/* reference point is the center of the pixel */
Line 81... Line 81...
81
	v.vector[0] = pixman_int_to_fixed (x) + pixman_fixed_1 / 2;
81
	v.vector[0] = pixman_int_to_fixed (x) + pixman_fixed_1 / 2;
82
	v.vector[1] = pixman_int_to_fixed (y) + pixman_fixed_1 / 2;
82
	v.vector[1] = pixman_int_to_fixed (y) + pixman_fixed_1 / 2;
Line 83... Line 83...
83
	v.vector[2] = pixman_fixed_1;
83
	v.vector[2] = pixman_fixed_1;
84
 
84
 
85
	if (!pixman_transform_point_3d (source->common.transform, &v))
85
	if (!pixman_transform_point_3d (image->common.transform, &v))
Line 86... Line 86...
86
	    return;
86
	    return iter->buffer;
87
 
87
 
88
	cx = source->common.transform->matrix[0][0] / 65536.;
88
	cx = image->common.transform->matrix[0][0] / 65536.;
Line 89... Line 89...
89
	cy = source->common.transform->matrix[1][0] / 65536.;
89
	cy = image->common.transform->matrix[1][0] / 65536.;
90
	cz = source->common.transform->matrix[2][0] / 65536.;
90
	cz = image->common.transform->matrix[2][0] / 65536.;
91
 
91
 
92
	rx = v.vector[0] / 65536.;
92
	rx = v.vector[0] / 65536.;
Line 93... Line 93...
93
	ry = v.vector[1] / 65536.;
93
	ry = v.vector[1] / 65536.;
94
	rz = v.vector[2] / 65536.;
94
	rz = v.vector[2] / 65536.;
Line 153... Line 153...
153
	    rx += cx;
153
	    rx += cx;
154
	    ry += cy;
154
	    ry += cy;
155
	    rz += cz;
155
	    rz += cz;
156
	}
156
	}
157
    }
157
    }
-
 
158
 
-
 
159
    iter->y++;
-
 
160
    return iter->buffer;
158
}
161
}
Line 159... Line 162...
159
 
162
 
160
static void
163
static uint32_t *
161
conical_gradient_property_changed (pixman_image_t *image)
164
conical_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
-
 
165
{
-
 
166
    uint32_t *buffer = conical_get_scanline_narrow (iter, NULL);
-
 
167
 
-
 
168
    pixman_expand_to_float (
-
 
169
	(argb_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width);
-
 
170
 
-
 
171
    return buffer;
-
 
172
}
-
 
173
 
-
 
174
void
-
 
175
_pixman_conical_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter)
-
 
176
{
162
{
177
    if (iter->iter_flags & ITER_NARROW)
-
 
178
	iter->get_scanline = conical_get_scanline_narrow;
163
    image->common.get_scanline_32 = conical_gradient_get_scanline_32;
179
    else
164
    image->common.get_scanline_64 = _pixman_image_get_scanline_generic_64;
180
	iter->get_scanline = conical_get_scanline_wide;
Line 165... Line 181...
165
}
181
}
166
 
182
 
167
PIXMAN_EXPORT pixman_image_t *
183
PIXMAN_EXPORT pixman_image_t *
168
pixman_image_create_conical_gradient (pixman_point_fixed_t *        center,
184
pixman_image_create_conical_gradient (const pixman_point_fixed_t *  center,
169
                                      pixman_fixed_t                angle,
185
                                      pixman_fixed_t                angle,
170
                                      const pixman_gradient_stop_t *stops,
186
                                      const pixman_gradient_stop_t *stops,
171
                                      int                           n_stops)
187
                                      int                           n_stops)
Line 189... Line 205...
189
    image->type = CONICAL;
205
    image->type = CONICAL;
Line 190... Line 206...
190
 
206
 
191
    conical->center = *center;
207
    conical->center = *center;
Line 192... Line -...
192
    conical->angle = (pixman_fixed_to_double (angle) / 180.0) * M_PI;
-
 
193
 
-
 
194
    image->common.property_changed = conical_gradient_property_changed;
208
    conical->angle = (pixman_fixed_to_double (angle) / 180.0) * M_PI;
195
 
209