Mercurial > MadButterfly
comparison src/paint.c @ 480:e813ac222f48 Android_Skia
Merge add colors into constructor of gradient pattern.
Since we also define color stops for gradient pattern and rear change
it, mbe_pattern_add_color_stop_rgba() is merged into
mb_pattern_create_radial() and mb_pattern_create_linear(). It also
makes porting to graphic engines easier.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 15 Nov 2009 16:21:09 +0800 |
parents | ba64f928542b |
children | ac2e6468a22a f43224bf3524 |
comparison
equal
deleted
inserted
replaced
479:9a867333018b | 480:e813ac222f48 |
---|---|
90 if(linear->flags & LIF_DIRTY) { | 90 if(linear->flags & LIF_DIRTY) { |
91 if(ptn) | 91 if(ptn) |
92 mbe_pattern_destroy(ptn); | 92 mbe_pattern_destroy(ptn); |
93 linear->flags &= ~LIF_DIRTY; | 93 linear->flags &= ~LIF_DIRTY; |
94 ptn = mbe_pattern_create_linear(linear->x1, linear->y1, | 94 ptn = mbe_pattern_create_linear(linear->x1, linear->y1, |
95 linear->x2, linear->y2); | 95 linear->x2, linear->y2, |
96 for(i = 0; i < linear->n_stops; i++) { | 96 linear->stops, linear->n_stops); |
97 stop = &linear->stops[i]; | 97 ASSERT(ptn != NULL); |
98 mbe_pattern_add_color_stop_rgba(ptn, stop->offset, | |
99 stop->r, stop->g, stop->b, | |
100 stop->a); | |
101 } | |
102 linear->ptn = ptn; | 98 linear->ptn = ptn; |
103 } | 99 } |
104 | 100 |
105 mbe_set_source(cr, ptn); | 101 mbe_set_source(cr, ptn); |
106 } | 102 } |
175 #define RDF_DIRTY 0x1 | 171 #define RDF_DIRTY 0x1 |
176 | 172 |
177 static void paint_radial_prepare(paint_t *paint, mbe_t *cr) { | 173 static void paint_radial_prepare(paint_t *paint, mbe_t *cr) { |
178 paint_radial_t *radial = (paint_radial_t *)paint; | 174 paint_radial_t *radial = (paint_radial_t *)paint; |
179 mbe_pattern_t *ptn; | 175 mbe_pattern_t *ptn; |
180 grad_stop_t *stop; | |
181 int i; | 176 int i; |
182 | 177 |
183 if(radial->flags & RDF_DIRTY) { | 178 if(radial->flags & RDF_DIRTY) { |
184 ptn = mbe_pattern_create_radial(radial->cx, radial->cy, 0, | 179 ptn = mbe_pattern_create_radial(radial->cx, radial->cy, 0, |
185 radial->cx, radial->cy, | 180 radial->cx, radial->cy, |
186 radial->r); | 181 radial->r, |
182 radial->stops, | |
183 radial->n_stops); | |
187 ASSERT(ptn != NULL); | 184 ASSERT(ptn != NULL); |
188 stop = radial->stops; | |
189 for(i = 0; i < radial->n_stops; i++, stop++) { | |
190 mbe_pattern_add_color_stop_rgba(ptn, stop->offset, | |
191 stop->r, stop->g, | |
192 stop->b, stop->a); | |
193 } | |
194 mbe_pattern_destroy(radial->ptn); | 185 mbe_pattern_destroy(radial->ptn); |
195 radial->ptn = ptn; | 186 radial->ptn = ptn; |
196 } | 187 } |
197 mbe_set_source(cr, radial->ptn); | 188 mbe_set_source(cr, radial->ptn); |
198 } | 189 } |