diff 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
line wrap: on
line diff
--- a/src/paint.c	Sun Nov 15 16:21:09 2009 +0800
+++ b/src/paint.c	Sun Nov 15 16:21:09 2009 +0800
@@ -92,13 +92,9 @@
 	    mbe_pattern_destroy(ptn);
 	linear->flags &= ~LIF_DIRTY;
 	ptn = mbe_pattern_create_linear(linear->x1, linear->y1,
-					  linear->x2, linear->y2);
-	for(i = 0; i < linear->n_stops; i++) {
-	    stop = &linear->stops[i];
-	    mbe_pattern_add_color_stop_rgba(ptn, stop->offset,
-					      stop->r, stop->g, stop->b,
-					      stop->a);
-	}
+					linear->x2, linear->y2,
+					linear->stops, linear->n_stops);
+	ASSERT(ptn != NULL);
 	linear->ptn = ptn;
     }
 
@@ -177,20 +173,15 @@
 static void paint_radial_prepare(paint_t *paint, mbe_t *cr) {
     paint_radial_t *radial = (paint_radial_t *)paint;
     mbe_pattern_t *ptn;
-    grad_stop_t *stop;
     int i;
 
     if(radial->flags & RDF_DIRTY) {
 	ptn = mbe_pattern_create_radial(radial->cx, radial->cy, 0,
 					  radial->cx, radial->cy,
-					  radial->r);
+					radial->r,
+					radial->stops,
+					radial->n_stops);
 	ASSERT(ptn != NULL);
-	stop = radial->stops;
-	for(i = 0; i < radial->n_stops; i++, stop++) {
-	    mbe_pattern_add_color_stop_rgba(ptn, stop->offset,
-					      stop->r, stop->g,
-					      stop->b, stop->a);
-	}
 	mbe_pattern_destroy(radial->ptn);
 	radial->ptn = ptn;
     }