1 #define __NR_ARENA_SHAPE_C__
3 /*
4 * RGBA display list system for inkscape
5 *
6 * Author:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 *
9 * Copyright (C) 2001-2002 Lauris Kaplinski
10 * Copyright (C) 2001 Ximian, Inc.
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
17 #include <display/nr-arena.h>
18 #include <display/nr-arena-shape.h>
19 #include <libnr/n-art-bpath.h>
20 #include <libnr/nr-path.h>
21 #include <libnr/nr-pixops.h>
22 #include <libnr/nr-matrix-ops.h>
23 #include <libnr/nr-blit.h>
24 #include <livarot/Path.h>
25 #include <livarot/float-line.h>
26 #include <livarot/int-line.h>
27 #include <style.h>
29 //int showRuns=0;
30 void nr_pixblock_render_shape_mask_or (NRPixBlock &m,Shape* theS);
32 static void nr_arena_shape_class_init (NRArenaShapeClass *klass);
33 static void nr_arena_shape_init (NRArenaShape *shape);
34 static void nr_arena_shape_finalize (NRObject *object);
36 static NRArenaItem *nr_arena_shape_children (NRArenaItem *item);
37 static void nr_arena_shape_add_child (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref);
38 static void nr_arena_shape_remove_child (NRArenaItem *item, NRArenaItem *child);
39 static void nr_arena_shape_set_child_position (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref);
41 static guint nr_arena_shape_update (NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset);
42 static unsigned int nr_arena_shape_render (NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags);
43 static guint nr_arena_shape_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb);
44 static NRArenaItem *nr_arena_shape_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int sticky);
46 static NRArenaItemClass *shape_parent_class;
48 NRType
49 nr_arena_shape_get_type (void)
50 {
51 static NRType type = 0;
52 if (!type) {
53 type = nr_object_register_type (NR_TYPE_ARENA_ITEM,
54 "NRArenaShape",
55 sizeof (NRArenaShapeClass),
56 sizeof (NRArenaShape),
57 (void (*) (NRObjectClass *)) nr_arena_shape_class_init,
58 (void (*) (NRObject *)) nr_arena_shape_init);
59 }
60 return type;
61 }
63 static void
64 nr_arena_shape_class_init (NRArenaShapeClass *klass)
65 {
66 NRObjectClass *object_class;
67 NRArenaItemClass *item_class;
69 object_class = (NRObjectClass *) klass;
70 item_class = (NRArenaItemClass *) klass;
72 shape_parent_class = (NRArenaItemClass *) ((NRObjectClass *) klass)->parent;
74 object_class->finalize = nr_arena_shape_finalize;
75 object_class->cpp_ctor = NRObject::invoke_ctor<NRArenaShape>;
77 item_class->children = nr_arena_shape_children;
78 item_class->add_child = nr_arena_shape_add_child;
79 item_class->set_child_position = nr_arena_shape_set_child_position;
80 item_class->remove_child = nr_arena_shape_remove_child;
81 item_class->update = nr_arena_shape_update;
82 item_class->render = nr_arena_shape_render;
83 item_class->clip = nr_arena_shape_clip;
84 item_class->pick = nr_arena_shape_pick;
85 }
87 static void
88 nr_arena_shape_init (NRArenaShape *shape)
89 {
90 shape->curve = NULL;
91 shape->style = NULL;
92 shape->paintbox.x0 = shape->paintbox.y0 = 0.0F;
93 shape->paintbox.x1 = shape->paintbox.y1 = 256.0F;
95 nr_matrix_set_identity (&shape->ctm);
96 shape->fill_painter = NULL;
97 shape->stroke_painter = NULL;
98 shape->cached_fill = NULL;
99 shape->cached_stroke = NULL;
100 shape->fill_shp = NULL;
101 shape->stroke_shp = NULL;
103 shape->delayed_shp = false;
105 shape->approx_bbox.x0 = shape->approx_bbox.y0 = 0;
106 shape->approx_bbox.x1 = shape->approx_bbox.y1 = 0;
107 nr_matrix_set_identity(&shape->cached_fctm);
108 nr_matrix_set_identity(&shape->cached_sctm);
110 shape->markers = NULL;
111 }
113 static void
114 nr_arena_shape_finalize (NRObject *object)
115 {
116 NRArenaShape *shape = (NRArenaShape *) (object);
118 if (shape->fill_shp) delete shape->fill_shp;
119 if (shape->stroke_shp) delete shape->stroke_shp;
120 if (shape->cached_fill) delete shape->cached_fill;
121 if (shape->cached_stroke) delete shape->cached_stroke;
122 if (shape->fill_painter) sp_painter_free (shape->fill_painter);
123 if (shape->stroke_painter) sp_painter_free (shape->stroke_painter);
125 if (shape->style) sp_style_unref (shape->style);
126 if (shape->curve) sp_curve_unref (shape->curve);
128 ((NRObjectClass *) shape_parent_class)->finalize (object);
129 }
131 static NRArenaItem *
132 nr_arena_shape_children (NRArenaItem *item)
133 {
134 NRArenaShape *shape = (NRArenaShape *) item;
136 return shape->markers;
137 }
139 static void
140 nr_arena_shape_add_child (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref)
141 {
142 NRArenaShape *shape = (NRArenaShape *) item;
144 if (!ref) {
145 shape->markers = nr_arena_item_attach_ref (item, child, NULL, shape->markers);
146 } else {
147 ref->next = nr_arena_item_attach_ref (item, child, ref, ref->next);
148 }
150 nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE);
151 }
153 static void
154 nr_arena_shape_remove_child (NRArenaItem *item, NRArenaItem *child)
155 {
156 NRArenaShape *shape = (NRArenaShape *) item;
158 if (child->prev) {
159 nr_arena_item_detach_unref (item, child);
160 } else {
161 shape->markers = nr_arena_item_detach_unref (item, child);
162 }
164 nr_arena_item_request_update (item, NR_ARENA_ITEM_STATE_ALL, FALSE);
165 }
167 static void
168 nr_arena_shape_set_child_position (NRArenaItem *item, NRArenaItem *child, NRArenaItem *ref)
169 {
170 NRArenaShape *shape = (NRArenaShape *) item;
172 if (child->prev) {
173 nr_arena_item_detach_unref (item, child);
174 } else {
175 shape->markers = nr_arena_item_detach_unref (item, child);
176 }
178 if (!ref) {
179 shape->markers = nr_arena_item_attach_ref (item, child, NULL, shape->markers);
180 } else {
181 ref->next = nr_arena_item_attach_ref (item, child, ref, ref->next);
182 }
184 nr_arena_item_request_render (child);
185 }
187 void nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc);
188 void nr_arena_shape_update_fill(NRArenaShape *shape,NRGC *gc);
189 void nr_arena_shape_add_bboxes(NRArenaShape* shape,NRRect &bbox);
191 static guint
192 nr_arena_shape_update (NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, guint reset)
193 {
194 NRRect bbox;
196 NRArenaShape *shape = NR_ARENA_SHAPE (item);
198 unsigned int beststate = NR_ARENA_ITEM_STATE_ALL;
200 unsigned int newstate;
201 for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) {
202 newstate = nr_arena_item_invoke_update (child, area, gc, state, reset);
203 beststate = beststate & newstate;
204 }
206 if (!(state & NR_ARENA_ITEM_STATE_RENDER)) {
207 /* We do not have to create rendering structures */
208 shape->ctm = gc->transform;
209 if (state & NR_ARENA_ITEM_STATE_BBOX) {
210 if (shape->curve) {
211 NRBPath bp;
212 /* fixme: */
213 bbox.x0 = bbox.y0 = NR_HUGE;
214 bbox.x1 = bbox.y1 = -NR_HUGE;
215 bp.path = shape->curve->bpath;
216 nr_path_matrix_bbox_union(&bp, gc->transform, &bbox);
217 item->bbox.x0 = (gint32)(bbox.x0 - 1.0F);
218 item->bbox.y0 = (gint32)(bbox.y0 - 1.0F);
219 item->bbox.x1 = (gint32)(bbox.x1 + 1.9999F);
220 item->bbox.y1 = (gint32)(bbox.y1 + 1.9999F);
221 }
222 if (beststate & NR_ARENA_ITEM_STATE_BBOX) {
223 for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) {
224 nr_rect_l_union (&item->bbox, &item->bbox, &child->bbox);
225 }
226 }
227 }
228 return (state | item->state);
229 }
231 shape->delayed_shp=true;
232 shape->ctm = gc->transform;
233 bbox.x0 = bbox.y0 = NR_HUGE;
234 bbox.x1 = bbox.y1 = -NR_HUGE;
236 if (shape->curve) {
237 NRBPath bp;
238 /* fixme: */
239 bbox.x0 = bbox.y0 = NR_HUGE;
240 bbox.x1 = bbox.y1 = -NR_HUGE;
241 bp.path = shape->curve->bpath;
242 nr_path_matrix_bbox_union(&bp, gc->transform, &bbox);
243 if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE) {
244 float width, scale;
245 scale = NR_MATRIX_DF_EXPANSION (&gc->transform);
246 width = MAX (0.125, shape->_stroke.width * scale);
247 if ( fabs(shape->_stroke.width * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
248 bbox.x0-=width;
249 bbox.x1+=width;
250 bbox.y0-=width;
251 bbox.y1+=width;
252 }
253 // those pesky miters, now
254 float miterMax=width*shape->_stroke.mitre_limit;
255 if ( miterMax > 0.01 ) {
256 // grunt mode. we should compute the various miters instead (one for each point on the curve)
257 bbox.x0-=miterMax;
258 bbox.x1+=miterMax;
259 bbox.y0-=miterMax;
260 bbox.y1+=miterMax;
261 }
262 }
263 } else {
264 }
265 shape->approx_bbox.x0 = (gint32)(bbox.x0 - 1.0F);
266 shape->approx_bbox.y0 = (gint32)(bbox.y0 - 1.0F);
267 shape->approx_bbox.x1 = (gint32)(bbox.x1 + 1.9999F);
268 shape->approx_bbox.y1 = (gint32)(bbox.y1 + 1.9999F);
269 if ( area && nr_rect_l_test_intersect (area, &shape->approx_bbox) ) shape->delayed_shp=false;
271 /* Release state data */
272 if (TRUE || !nr_matrix_test_transform_equal (&gc->transform, &shape->ctm, NR_EPSILON)) {
273 /* Concept test */
274 if (shape->fill_shp) {
275 delete shape->fill_shp;
276 shape->fill_shp = NULL;
277 }
278 }
279 if (shape->stroke_shp) {
280 delete shape->stroke_shp;
281 shape->stroke_shp = NULL;
282 }
283 if (shape->fill_painter) {
284 sp_painter_free (shape->fill_painter);
285 shape->fill_painter = NULL;
286 }
287 if (shape->stroke_painter) {
288 sp_painter_free (shape->stroke_painter);
289 shape->stroke_painter = NULL;
290 }
292 if (!shape->curve || !shape->style) return NR_ARENA_ITEM_STATE_ALL;
293 if (sp_curve_is_empty (shape->curve)) return NR_ARENA_ITEM_STATE_ALL;
294 if ( ( shape->_fill.paint.type() == NRArenaShape::Paint::NONE ) &&
295 ( shape->_stroke.paint.type() == NRArenaShape::Paint::NONE ) )
296 {
297 return NR_ARENA_ITEM_STATE_ALL;
298 }
300 /* Build state data */
301 if ( shape->delayed_shp ) {
302 item->bbox=shape->approx_bbox;
303 } else {
304 nr_arena_shape_update_stroke(shape,gc);
305 nr_arena_shape_update_fill(shape,gc);
307 bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0;
308 nr_arena_shape_add_bboxes(shape,bbox);
310 shape->approx_bbox.x0 = (gint32)(bbox.x0 - 1.0F);
311 shape->approx_bbox.y0 = (gint32)(bbox.y0 - 1.0F);
312 shape->approx_bbox.x1 = (gint32)(bbox.x1 + 1.9999F);
313 shape->approx_bbox.y1 = (gint32)(bbox.y1 + 1.9999F);
314 }
316 if (nr_rect_d_test_empty (&bbox)) return NR_ARENA_ITEM_STATE_ALL;
318 item->bbox.x0 = (gint32)(bbox.x0 - 1.0F);
319 item->bbox.y0 = (gint32)(bbox.y0 - 1.0F);
320 item->bbox.x1 = (gint32)(bbox.x1 + 1.0F);
321 item->bbox.y1 = (gint32)(bbox.y1 + 1.0F);
322 nr_arena_request_render_rect (item->arena, &item->bbox);
324 item->render_opacity = TRUE;
325 if ( shape->_fill.paint.type() == NRArenaShape::Paint::SERVER ) {
326 if (gc && gc->parent) {
327 shape->fill_painter = sp_paint_server_painter_new (shape->_fill.paint.server(),
328 NR::Matrix (&gc->transform), NR::Matrix (&gc->parent->transform),
329 &shape->paintbox);
330 }
331 item->render_opacity = FALSE;
332 }
333 if ( shape->_stroke.paint.type() == NRArenaShape::Paint::SERVER ) {
334 if (gc && gc->parent) {
335 shape->stroke_painter = sp_paint_server_painter_new (shape->_stroke.paint.server(),
336 NR::Matrix (&gc->transform), NR::Matrix (&gc->parent->transform),
337 &shape->paintbox);
338 }
339 item->render_opacity = FALSE;
340 }
341 if ( item->render_opacity == TRUE &&
342 shape->_fill.paint.type() != NRArenaShape::Paint::NONE &&
343 shape->_stroke.paint.type() != NRArenaShape::Paint::NONE )
344 {
345 // don't merge item opacity with paint opacity if there is a stroke on the fill
346 item->render_opacity = FALSE;
347 }
349 if (beststate & NR_ARENA_ITEM_STATE_BBOX) {
350 for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) {
351 nr_rect_l_union (&item->bbox, &item->bbox, &child->bbox);
352 }
353 }
355 return NR_ARENA_ITEM_STATE_ALL;
356 }
358 int matrix_is_isometry(NR::Matrix p) {
359 NR::Matrix tp;
360 // transposition
361 tp[0]=p[0];
362 tp[1]=p[2];
363 tp[2]=p[1];
364 tp[3]=p[3];
365 for(int i = 4; i < 6; i++) // shut valgrind up :)
366 tp[i] = p[i] = 0;
367 NR::Matrix isom = tp*p; // A^T * A = adjunct?
368 // Is the adjunct nearly an identity function?
369 if (isom.is_translation(0.01)) {
370 // the transformation is an isometry -> no need to recompute
371 // the uncrossed polygon
372 if ( p.det() < 0 )
373 return -1;
374 else
375 return 1;
376 }
377 return 0;
378 }
380 void
381 nr_arena_shape_update_fill(NRArenaShape *shape,NRGC *gc)
382 {
383 shape->delayed_shp = false;
384 if ((shape->_fill.paint.type() != NRArenaShape::Paint::NONE) &&
385 ((shape->curve->end > 2) || (shape->curve->bpath[1].code == NR_CURVETO)) ) {
386 if (TRUE || !shape->fill_shp) {
387 NR::Matrix cached_to_new;
388 int isometry = 0;
389 if ( shape->cached_fill ) {
390 cached_to_new = shape->cached_fctm.inverse()*gc->transform;
391 isometry = matrix_is_isometry(cached_to_new);
392 }
393 if ( isometry == 0 ) {
394 if ( shape->cached_fill == NULL ) shape->cached_fill=new Shape;
395 shape->cached_fill->Reset();
397 Path* thePath=new Path;
398 Shape* theShape=new Shape;
399 {
400 NR::Matrix tempMat(gc->transform);
401 thePath->LoadArtBPath(shape->curve->bpath,tempMat,true);
402 }
404 thePath->Convert(1.0);
406 thePath->Fill(theShape, 0);
408 if ( shape->_fill.rule == NRArenaShape::EVEN_ODD ) {
409 shape->cached_fill->ConvertToShape(theShape, fill_oddEven);
410 // alternatively, this speeds up rendering of oddeven shapes but disables AA :(
411 //shape->cached_fill->Copy(theShape);
412 } else {
413 shape->cached_fill->ConvertToShape(theShape, fill_nonZero);
414 }
415 shape->cached_fctm=gc->transform;
416 delete theShape;
417 delete thePath;
418 if ( shape->fill_shp == NULL )
419 shape->fill_shp = new Shape;
421 shape->fill_shp->Copy(shape->cached_fill);
423 } else {
425 if ( shape->fill_shp == NULL )
426 shape->fill_shp=new Shape;
427 shape->fill_shp->Reset(shape->cached_fill->numberOfPoints(),
428 shape->cached_fill->numberOfEdges());
429 for (int i = 0; i < shape->cached_fill->numberOfPoints(); i++)
430 shape->fill_shp->AddPoint(shape->cached_fill->getPoint(i).x * cached_to_new);
431 if ( isometry == 1 ) {
432 for (int i = 0; i < shape->cached_fill->numberOfEdges(); i++)
433 shape->fill_shp->AddEdge(shape->cached_fill->getEdge(i).st,
434 shape->cached_fill->getEdge(i).en);
435 } else if ( isometry == -1 ) { // need to flip poly.
436 for (int i = 0; i < shape->cached_fill->numberOfEdges(); i++)
437 shape->fill_shp->AddEdge(shape->cached_fill->getEdge(i).en,
438 shape->cached_fill->getEdge(i).st);
439 }
440 shape->fill_shp->ForceToPolygon();
441 shape->fill_shp->needPointsSorting();
442 shape->fill_shp->needEdgesSorting();
443 }
444 }
445 }
446 }
448 void
449 nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc)
450 {
451 SPStyle* style = shape->style;
453 shape->delayed_shp = false;
455 const float scale = NR_MATRIX_DF_EXPANSION (&gc->transform);
457 if (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE ||
458 ((shape->_stroke.paint.type() != NRArenaShape::Paint::NONE) &&
459 ( fabs(shape->_stroke.width * scale) > 0.01 ))) { // sinon c'est 0=oon veut pas de bord
461 float width = MAX (0.125, shape->_stroke.width * scale);
462 if (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE)
463 width = 0.5; // 1 pixel wide, independent of zoom
465 NR::Matrix cached_to_new;
467 int isometry = 0;
468 if ( shape->cached_stroke ) {
469 cached_to_new = shape->cached_sctm.inverse() * gc->transform;
470 isometry = matrix_is_isometry(cached_to_new);
471 }
473 if ( isometry == 0 ) {
474 if ( shape->cached_stroke == NULL ) shape->cached_stroke=new Shape;
475 shape->cached_stroke->Reset();
476 Path* thePath = new Path;
477 Shape* theShape = new Shape;
478 {
479 NR::Matrix tempMat(gc->transform);
480 thePath->LoadArtBPath(shape->curve->bpath, tempMat, true);
481 }
483 if (NR_ARENA_ITEM(shape)->arena->rendermode != RENDERMODE_OUTLINE)
484 thePath->Convert(1.0);
485 else
486 thePath->Convert(4.0); // slightly rougher & faster
488 if (style->stroke_dash.n_dash && NR_ARENA_ITEM(shape)->arena->rendermode != RENDERMODE_OUTLINE) {
489 double dlen = 0.0;
490 for (int i = 0; i < style->stroke_dash.n_dash; i++) {
491 dlen += style->stroke_dash.dash[i] * scale;
492 }
493 if (dlen >= 1.0) {
494 NRVpathDash dash;
495 dash.offset = style->stroke_dash.offset * scale;
496 dash.n_dash = style->stroke_dash.n_dash;
497 dash.dash = g_new (double, dash.n_dash);
498 for (int i = 0; i < dash.n_dash; i++) {
499 dash.dash[i] = style->stroke_dash.dash[i] * scale;
500 }
501 int nbD=dash.n_dash;
502 float *dashs=(float*)malloc((nbD+1)*sizeof(float));
503 while ( dash.offset >= dlen ) dash.offset-=dlen;
504 dashs[0]=dash.dash[0];
505 for (int i=1; i<nbD; i++) {
506 dashs[i]=dashs[i-1]+dash.dash[i];
507 }
508 // modulo dlen
509 thePath->DashPolyline(0.0,0.0,dlen,nbD,dashs,true,dash.offset);
510 free(dashs);
511 g_free (dash.dash);
512 }
513 }
514 ButtType butt=butt_straight;
515 switch(shape->_stroke.cap) {
516 case NRArenaShape::BUTT_CAP:
517 butt = butt_straight;
518 break;
519 case NRArenaShape::ROUND_CAP:
520 butt = butt_round;
521 break;
522 case NRArenaShape::SQUARE_CAP:
523 butt = butt_square;
524 break;
525 }
526 JoinType join=join_straight;
527 switch(shape->_stroke.join) {
528 case NRArenaShape::MITRE_JOIN:
529 join = join_pointy;
530 break;
531 case NRArenaShape::ROUND_JOIN:
532 join = join_round;
533 break;
534 case NRArenaShape::BEVEL_JOIN:
535 join = join_straight;
536 break;
537 }
539 if (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE) {
540 butt = butt_straight;
541 join = join_straight;
542 }
544 thePath->Stroke(theShape, false, 0.5*width, join, butt,
545 0.5*width*shape->_stroke.mitre_limit);
548 if (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE) {
549 // speeds it up, but uses evenodd for the stroke shape (which does not matter for 1-pixel wide outline)
550 shape->cached_stroke->Copy(theShape);
551 } else {
552 shape->cached_stroke->ConvertToShape(theShape, fill_nonZero);
553 }
555 shape->cached_sctm=gc->transform;
556 delete thePath;
557 delete theShape;
558 if ( shape->stroke_shp == NULL ) shape->stroke_shp=new Shape;
560 shape->stroke_shp->Copy(shape->cached_stroke);
562 } else {
564 if ( shape->stroke_shp == NULL )
565 shape->stroke_shp=new Shape;
566 shape->stroke_shp->Reset(shape->cached_stroke->numberOfPoints(), shape->cached_stroke->numberOfEdges());
567 for (int i = 0; i < shape->cached_stroke->numberOfPoints(); i++)
568 shape->stroke_shp->AddPoint(shape->cached_stroke->getPoint(i).x * cached_to_new);
569 if ( isometry == 1 ) {
570 for (int i = 0; i < shape->cached_stroke->numberOfEdges(); i++)
571 shape->stroke_shp->AddEdge(shape->cached_stroke->getEdge(i).st,
572 shape->cached_stroke->getEdge(i).en);
573 } else if ( isometry == -1 ) {
574 for (int i = 0; i < shape->cached_stroke->numberOfEdges(); i++)
575 shape->stroke_shp->AddEdge(shape->cached_stroke->getEdge(i).en,
576 shape->cached_stroke->getEdge(i).st);
577 }
578 shape->stroke_shp->ForceToPolygon();
579 shape->stroke_shp->needPointsSorting();
580 shape->stroke_shp->needEdgesSorting();
581 }
582 }
583 }
586 void
587 nr_arena_shape_add_bboxes(NRArenaShape* shape, NRRect &bbox)
588 {
589 if ( shape->stroke_shp ) {
590 shape->stroke_shp->CalcBBox();
591 shape->stroke_shp->leftX=floor(shape->stroke_shp->leftX);
592 shape->stroke_shp->rightX=ceil(shape->stroke_shp->rightX);
593 shape->stroke_shp->topY=floor(shape->stroke_shp->topY);
594 shape->stroke_shp->bottomY=ceil(shape->stroke_shp->bottomY);
595 if ( bbox.x0 >= bbox.x1 ) {
596 if ( shape->stroke_shp->leftX < shape->stroke_shp->rightX ) {
597 bbox.x0=shape->stroke_shp->leftX;
598 bbox.x1=shape->stroke_shp->rightX;
599 }
600 } else {
601 if ( shape->stroke_shp->leftX < bbox.x0 )
602 bbox.x0=shape->stroke_shp->leftX;
603 if ( shape->stroke_shp->rightX > bbox.x1 )
604 bbox.x1=shape->stroke_shp->rightX;
605 }
606 if ( bbox.y0 >= bbox.y1 ) {
607 if ( shape->stroke_shp->topY < shape->stroke_shp->bottomY ) {
608 bbox.y0=shape->stroke_shp->topY;
609 bbox.y1=shape->stroke_shp->bottomY;
610 }
611 } else {
612 if ( shape->stroke_shp->topY < bbox.y0 )
613 bbox.y0=shape->stroke_shp->topY;
614 if ( shape->stroke_shp->bottomY > bbox.y1 )
615 bbox.y1=shape->stroke_shp->bottomY;
616 }
617 }
618 if ( shape->fill_shp ) {
619 shape->fill_shp->CalcBBox();
620 shape->fill_shp->leftX=floor(shape->fill_shp->leftX);
621 shape->fill_shp->rightX=ceil(shape->fill_shp->rightX);
622 shape->fill_shp->topY=floor(shape->fill_shp->topY);
623 shape->fill_shp->bottomY=ceil(shape->fill_shp->bottomY);
624 if ( bbox.x0 >= bbox.x1 ) {
625 if ( shape->fill_shp->leftX < shape->fill_shp->rightX ) {
626 bbox.x0=shape->fill_shp->leftX;
627 bbox.x1=shape->fill_shp->rightX;
628 }
629 } else {
630 if ( shape->fill_shp->leftX < bbox.x0 ) bbox.x0=shape->fill_shp->leftX;
631 if ( shape->fill_shp->rightX > bbox.x1 ) bbox.x1=shape->fill_shp->rightX;
632 }
633 if ( bbox.y0 >= bbox.y1 ) {
634 if ( shape->fill_shp->topY < shape->fill_shp->bottomY ) {
635 bbox.y0=shape->fill_shp->topY;
636 bbox.y1=shape->fill_shp->bottomY;
637 }
638 } else {
639 if ( shape->fill_shp->topY < bbox.y0 ) bbox.y0=shape->fill_shp->topY;
640 if ( shape->fill_shp->bottomY > bbox.y1 ) bbox.y1=shape->fill_shp->bottomY;
641 }
642 }
643 }
644 static unsigned int
645 nr_arena_shape_render (NRArenaItem *item, NRRectL *area, NRPixBlock *pb, unsigned int flags)
646 {
647 NRArenaShape *shape = NR_ARENA_SHAPE (item);
649 if (!shape->curve) return item->state;
650 if (!shape->style) return item->state;
652 if ( shape->delayed_shp ) {
653 if ( nr_rect_l_test_intersect (area, &item->bbox) ) {
654 NRGC tempGC(NULL);
655 tempGC.transform=shape->ctm;
656 nr_arena_shape_update_stroke(shape,&tempGC);
657 nr_arena_shape_update_fill(shape,&tempGC);
658 /* NRRect bbox;
659 bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0;
660 nr_arena_shape_add_bboxes(shape,bbox);
661 item->bbox.x0 = (gint32)(bbox.x0 - 1.0F);
662 item->bbox.y0 = (gint32)(bbox.y0 - 1.0F);
663 item->bbox.x1 = (gint32)(bbox.x1 + 1.0F);
664 item->bbox.y1 = (gint32)(bbox.y1 + 1.0F);
665 shape->approx_bbox=item->bbox;*/
666 }
667 }
669 SPStyle const *style = shape->style;
670 if ( shape->fill_shp && NR_ARENA_ITEM(shape)->arena->rendermode != RENDERMODE_OUTLINE) {
671 NRPixBlock m;
672 guint32 rgba;
674 nr_pixblock_setup_fast (&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
675 nr_pixblock_render_shape_mask_or (m,shape->fill_shp);
676 m.empty = FALSE;
678 if (shape->_fill.paint.type() == NRArenaShape::Paint::NONE) {
679 // do not render fill in any way
680 } else if (shape->_fill.paint.type() == NRArenaShape::Paint::COLOR) {
681 if ( item->render_opacity ) {
682 rgba = sp_color_get_rgba32_falpha (&shape->_fill.paint.color(),
683 shape->_fill.opacity *
684 SP_SCALE24_TO_FLOAT (style->opacity.value));
685 } else {
686 rgba = sp_color_get_rgba32_falpha (&shape->_fill.paint.color(),
687 shape->_fill.opacity);
688 }
689 nr_blit_pixblock_mask_rgba32 (pb, &m, rgba);
690 pb->empty = FALSE;
691 } else if (shape->_fill.paint.type() == NRArenaShape::Paint::SERVER) {
692 if (shape->fill_painter) {
693 nr_arena_render_paintserver_fill (pb, area, shape->fill_painter, shape->_fill.opacity, &m);
694 }
695 }
697 nr_pixblock_release (&m);
698 }
700 if ( shape->stroke_shp ) {
701 NRPixBlock m;
702 guint32 rgba;
704 nr_pixblock_setup_fast (&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
705 nr_pixblock_render_shape_mask_or (m, shape->stroke_shp);
706 m.empty = FALSE;
708 if (shape->_stroke.paint.type() == NRArenaShape::Paint::COLOR ||
709 NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE) {
710 if ( NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE) {
711 rgba = NR_ARENA_ITEM(shape)->arena->outlinecolor;
712 } else if ( item->render_opacity ) {
713 rgba = sp_color_get_rgba32_falpha (&shape->_stroke.paint.color(),
714 shape->_stroke.opacity *
715 SP_SCALE24_TO_FLOAT (style->opacity.value));
716 } else {
717 rgba = sp_color_get_rgba32_falpha (&shape->_stroke.paint.color(),
718 shape->_stroke.opacity);
719 }
720 nr_blit_pixblock_mask_rgba32 (pb, &m, rgba);
721 pb->empty = FALSE;
722 } else if (shape->_stroke.paint.type() == NRArenaShape::Paint::SERVER) {
723 if (shape->stroke_painter) {
724 nr_arena_render_paintserver_fill (pb, area, shape->stroke_painter, shape->_stroke.opacity, &m);
725 }
726 }
728 nr_pixblock_release (&m);
729 }
731 /* Just compose children into parent buffer */
732 for (NRArenaItem *child = shape->markers; child != NULL; child = child->next) {
733 unsigned int ret;
734 ret = nr_arena_item_invoke_render (child, area, pb, flags);
735 if (ret & NR_ARENA_ITEM_STATE_INVALID) return ret;
736 }
738 return item->state;
739 }
741 static guint
742 nr_arena_shape_clip (NRArenaItem *item, NRRectL *area, NRPixBlock *pb)
743 {
744 NRArenaShape *shape = NR_ARENA_SHAPE (item);
746 if (!shape->curve) return item->state;
748 if ( shape->delayed_shp ) {
749 if ( nr_rect_l_test_intersect (area, &item->bbox) ) {
750 NRGC tempGC(NULL);
751 tempGC.transform=shape->ctm;
752 nr_arena_shape_update_stroke(shape,&tempGC);
753 nr_arena_shape_update_fill(shape,&tempGC);
754 /* NRRect bbox;
755 bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0;
756 nr_arena_shape_add_bboxes(shape,bbox);
757 item->bbox.x0 = (gint32)(bbox.x0 - 1.0F);
758 item->bbox.y0 = (gint32)(bbox.y0 - 1.0F);
759 item->bbox.x1 = (gint32)(bbox.x1 + 1.0F);
760 item->bbox.y1 = (gint32)(bbox.y1 + 1.0F);
761 shape->approx_bbox=item->bbox;*/
762 }
763 }
765 if ( shape->fill_shp ) {
766 NRPixBlock m;
768 /* fixme: We can OR in one step (Lauris) */
769 nr_pixblock_setup_fast (&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
770 nr_pixblock_render_shape_mask_or (m,shape->fill_shp);
772 for (int y = area->y0; y < area->y1; y++) {
773 unsigned char *s, *d;
774 s = NR_PIXBLOCK_PX (&m) + (y - area->y0) * m.rs;
775 d = NR_PIXBLOCK_PX (pb) + (y - area->y0) * pb->rs;
776 for (int x = area->x0; x < area->x1; x++) {
777 *d = NR_A7_NORMALIZED(*s,*d);
778 d ++;
779 s ++;
780 }
781 }
782 nr_pixblock_release (&m);
783 pb->empty = FALSE;
784 }
786 return item->state;
787 }
789 static NRArenaItem *
790 nr_arena_shape_pick (NRArenaItem *item, NR::Point p, double delta, unsigned int /*sticky*/)
791 {
792 NRArenaShape *shape = NR_ARENA_SHAPE (item);
794 if (!shape->curve) return NULL;
795 if (!shape->style) return NULL;
796 if ( shape->delayed_shp ) {
797 NRRectL area;
798 area.x0=(int)floor(p[NR::X]);
799 area.x1=(int)ceil(p[NR::X]);
800 area.y0=(int)floor(p[NR::Y]);
801 area.y1=(int)ceil(p[NR::Y]);
802 int idelta = (int)ceil(delta) + 1;
803 // njh: inset rect
804 area.x0-=idelta;
805 area.x1+=idelta;
806 area.y0-=idelta;
807 area.y1+=idelta;
808 if ( nr_rect_l_test_intersect (&area, &item->bbox) ) {
809 NRGC tempGC(NULL);
810 tempGC.transform=shape->ctm;
811 nr_arena_shape_update_stroke(shape,&tempGC);
812 nr_arena_shape_update_fill(shape,&tempGC);
813 /* NRRect bbox;
814 bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0;
815 nr_arena_shape_add_bboxes(shape,bbox);
816 item->bbox.x0 = (gint32)(bbox.x0 - 1.0F);
817 item->bbox.y0 = (gint32)(bbox.y0 - 1.0F);
818 item->bbox.x1 = (gint32)(bbox.x1 + 1.0F);
819 item->bbox.y1 = (gint32)(bbox.y1 + 1.0F);
820 shape->approx_bbox=item->bbox;*/
821 }
822 }
824 if (item->state & NR_ARENA_ITEM_STATE_RENDER) {
825 if (shape->fill_shp && (shape->_fill.paint.type() != NRArenaShape::Paint::NONE)) {
826 if (shape->fill_shp->PtWinding(p) > 0 ) return item;
827 }
828 if (shape->stroke_shp && (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE)) {
829 if (shape->stroke_shp->PtWinding(p) > 0 ) return item;
830 }
831 if (delta > 1e-3) {
832 if (shape->fill_shp && (shape->_fill.paint.type() != NRArenaShape::Paint::NONE)) {
833 if (distanceLessThanOrEqual(shape->fill_shp, p, delta)) return item;
834 }
835 if (shape->stroke_shp && (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE)) {
836 if (distanceLessThanOrEqual(shape->stroke_shp, p, delta)) return item;
837 }
838 }
839 } else {
840 NRBPath bp;
841 bp.path = shape->curve->bpath;
842 double dist = NR_HUGE;
843 int wind = 0;
844 nr_path_matrix_point_bbox_wind_distance(&bp, shape->ctm, p, NULL, &wind, &dist, NR_EPSILON);
845 if (shape->_fill.paint.type() != NRArenaShape::Paint::NONE) {
846 if (!shape->style->fill_rule.computed) {
847 if (wind != 0) return item;
848 } else {
849 if (wind & 0x1) return item;
850 }
851 }
852 if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE) {
853 /* fixme: We do not take stroke width into account here (Lauris) */
854 if (dist < delta) return item;
855 }
856 }
858 return NULL;
859 }
861 /**
862 *
863 * Requests a render of the shape, then if the shape is already a curve it
864 * unrefs the old curve; if the new curve is valid it creates a copy of the
865 * curve and adds it to the shape. Finally, it requests an update of the
866 * arena for the shape.
867 */
868 void nr_arena_shape_set_path(NRArenaShape *shape, SPCurve *curve,bool justTrans)
869 {
870 g_return_if_fail (shape != NULL);
871 g_return_if_fail (NR_IS_ARENA_SHAPE (shape));
873 if ( justTrans == false ) {
874 // dirty cached versions
875 if ( shape->cached_fill ) {
876 delete shape->cached_fill;
877 shape->cached_fill=NULL;
878 }
879 if ( shape->cached_stroke ) {
880 delete shape->cached_stroke;
881 shape->cached_stroke=NULL;
882 }
883 }
885 nr_arena_item_request_render (NR_ARENA_ITEM (shape));
887 if (shape->curve) {
888 sp_curve_unref (shape->curve);
889 shape->curve = NULL;
890 }
892 if (curve) {
893 shape->curve = curve;
894 sp_curve_ref (curve);
895 }
897 nr_arena_item_request_update (NR_ARENA_ITEM (shape), NR_ARENA_ITEM_STATE_ALL, FALSE);
898 }
900 void NRArenaShape::setFill(SPPaintServer *server) {
901 _fill.paint.set(server);
902 _invalidateCachedFill();
903 }
905 void NRArenaShape::setFill(SPColor const &color) {
906 _fill.paint.set(color);
907 _invalidateCachedFill();
908 }
910 void NRArenaShape::setFillOpacity(double opacity) {
911 _fill.opacity = opacity;
912 _invalidateCachedFill();
913 }
915 void NRArenaShape::setFillRule(NRArenaShape::FillRule rule) {
916 _fill.rule = rule;
917 _invalidateCachedFill();
918 }
920 void NRArenaShape::setStroke(SPPaintServer *server) {
921 _stroke.paint.set(server);
922 _invalidateCachedStroke();
923 }
925 void NRArenaShape::setStroke(SPColor const &color) {
926 _stroke.paint.set(color);
927 _invalidateCachedStroke();
928 }
930 void NRArenaShape::setStrokeOpacity(double opacity) {
931 _stroke.opacity = opacity;
932 _invalidateCachedStroke();
933 }
935 void NRArenaShape::setStrokeWidth(double width) {
936 _stroke.width = width;
937 _invalidateCachedStroke();
938 }
940 void NRArenaShape::setMitreLimit(double limit) {
941 _stroke.mitre_limit = limit;
942 _invalidateCachedStroke();
943 }
945 void NRArenaShape::setLineCap(NRArenaShape::CapType cap) {
946 _stroke.cap = cap;
947 _invalidateCachedStroke();
948 }
950 void NRArenaShape::setLineJoin(NRArenaShape::JoinType join) {
951 _stroke.join = join;
952 _invalidateCachedStroke();
953 }
955 /** nr_arena_shape_set_style
956 *
957 * Unrefs any existing style and ref's to the given one, then requests an update of the arena
958 */
959 void
960 nr_arena_shape_set_style (NRArenaShape *shape, SPStyle *style)
961 {
962 g_return_if_fail (shape != NULL);
963 g_return_if_fail (NR_IS_ARENA_SHAPE (shape));
965 if (style) sp_style_ref (style);
966 if (shape->style) sp_style_unref (shape->style);
967 shape->style = style;
969 switch (style->fill.type) {
970 case SP_PAINT_TYPE_NONE: {
971 shape->setFill(NULL);
972 break;
973 }
974 case SP_PAINT_TYPE_COLOR: {
975 shape->setFill(style->fill.value.color);
976 break;
977 }
978 case SP_PAINT_TYPE_PAINTSERVER: {
979 shape->setFill(style->fill.value.paint.server);
980 break;
981 }
982 default: {
983 g_assert_not_reached();
984 }
985 }
986 shape->setFillOpacity(SP_SCALE24_TO_FLOAT(style->fill_opacity.value));
987 switch (style->fill_rule.computed) {
988 case SP_WIND_RULE_EVENODD: {
989 shape->setFillRule(NRArenaShape::EVEN_ODD);
990 break;
991 }
992 case SP_WIND_RULE_NONZERO: {
993 shape->setFillRule(NRArenaShape::NONZERO);
994 break;
995 }
996 default: {
997 g_assert_not_reached();
998 }
999 }
1001 switch (style->stroke.type) {
1002 case SP_PAINT_TYPE_NONE: {
1003 shape->setStroke(NULL);
1004 break;
1005 }
1006 case SP_PAINT_TYPE_COLOR: {
1007 shape->setStroke(style->stroke.value.color);
1008 break;
1009 }
1010 case SP_PAINT_TYPE_PAINTSERVER: {
1011 shape->setStroke(style->stroke.value.paint.server);
1012 break;
1013 }
1014 default: {
1015 g_assert_not_reached();
1016 }
1017 }
1018 shape->setStrokeWidth(style->stroke_width.computed);
1019 shape->setStrokeOpacity(SP_SCALE24_TO_FLOAT(style->stroke_opacity.value));
1020 switch (style->stroke_linecap.computed) {
1021 case SP_STROKE_LINECAP_ROUND: {
1022 shape->setLineCap(NRArenaShape::ROUND_CAP);
1023 break;
1024 }
1025 case SP_STROKE_LINECAP_SQUARE: {
1026 shape->setLineCap(NRArenaShape::SQUARE_CAP);
1027 break;
1028 }
1029 case SP_STROKE_LINECAP_BUTT: {
1030 shape->setLineCap(NRArenaShape::BUTT_CAP);
1031 break;
1032 }
1033 default: {
1034 g_assert_not_reached();
1035 }
1036 }
1037 switch (style->stroke_linejoin.computed) {
1038 case SP_STROKE_LINEJOIN_ROUND: {
1039 shape->setLineJoin(NRArenaShape::ROUND_JOIN);
1040 break;
1041 }
1042 case SP_STROKE_LINEJOIN_BEVEL: {
1043 shape->setLineJoin(NRArenaShape::BEVEL_JOIN);
1044 break;
1045 }
1046 case SP_STROKE_LINEJOIN_MITER: {
1047 shape->setLineJoin(NRArenaShape::MITRE_JOIN);
1048 break;
1049 }
1050 default: {
1051 g_assert_not_reached();
1052 }
1053 }
1054 shape->setMitreLimit(style->stroke_miterlimit.value);
1056 nr_arena_item_request_update(shape, NR_ARENA_ITEM_STATE_ALL, FALSE);
1057 }
1059 void
1060 nr_arena_shape_set_paintbox (NRArenaShape *shape, const NRRect *pbox)
1061 {
1062 g_return_if_fail (shape != NULL);
1063 g_return_if_fail (NR_IS_ARENA_SHAPE (shape));
1064 g_return_if_fail (pbox != NULL);
1066 if ((pbox->x0 < pbox->x1) && (pbox->y0 < pbox->y1)) {
1067 shape->paintbox = *pbox;
1068 } else {
1069 /* fixme: We kill warning, although not sure what to do here (Lauris) */
1070 shape->paintbox.x0 = shape->paintbox.y0 = 0.0F;
1071 shape->paintbox.x1 = shape->paintbox.y1 = 256.0F;
1072 }
1074 nr_arena_item_request_update(shape, NR_ARENA_ITEM_STATE_ALL, FALSE);
1075 }
1077 void NRArenaShape::setPaintBox(NR::Rect const &pbox)
1078 {
1079 paintbox.x0 = pbox.min()[NR::X];
1080 paintbox.y0 = pbox.min()[NR::Y];
1081 paintbox.x1 = pbox.max()[NR::X];
1082 paintbox.y1 = pbox.max()[NR::Y];
1084 nr_arena_item_request_update(this, NR_ARENA_ITEM_STATE_ALL, FALSE);
1085 }
1087 static void
1088 shape_run_A8_OR (raster_info &dest,void */*data*/,int st,float vst,int en,float ven)
1089 {
1090 if ( st >= en ) return;
1091 if ( vst < 0 ) vst=0;
1092 if ( vst > 1 ) vst=1;
1093 if ( ven < 0 ) ven=0;
1094 if ( ven > 1 ) ven=1;
1095 float sv=vst;
1096 float dv=ven-vst;
1097 int len=en-st;
1098 unsigned char* d=(unsigned char*)dest.buffer;
1099 d+=(st-dest.startPix);
1100 if ( fabs(dv) < 0.001 ) {
1101 if ( vst > 0.999 ) {
1102 /* Simple copy */
1103 while (len > 0) {
1104 d[0] = 255;
1105 d += 1;
1106 len -= 1;
1107 }
1108 } else {
1109 sv*=256;
1110 unsigned int c0_24=(int)sv;
1111 c0_24&=0xFF;
1112 while (len > 0) {
1113 unsigned int da;
1114 /* Draw */
1115 da = NR_A7(c0_24,d[0]);
1116 d[0] = NR_PREMUL_SINGLE(da);
1117 d += 1;
1118 len -= 1;
1119 }
1120 }
1121 } else {
1122 if ( en <= st+1 ) {
1123 sv=0.5*(vst+ven);
1124 sv*=256;
1125 unsigned int c0_24=(int)sv;
1126 c0_24&=0xFF;
1127 unsigned int da;
1128 /* Draw */
1129 da = NR_A7(c0_24,d[0]);
1130 d[0] = NR_PREMUL_SINGLE(da);
1131 } else {
1132 dv/=len;
1133 sv+=0.5*dv; // correction trapezoidale
1134 sv*=16777216;
1135 dv*=16777216;
1136 int c0_24 = static_cast<int>(CLAMP(sv, 0, 16777216));
1137 int s0_24 = static_cast<int>(dv);
1138 while (len > 0) {
1139 unsigned int ca, da;
1140 /* Draw */
1141 ca = c0_24 >> 16;
1142 if ( ca > 255 ) ca=255;
1143 da = NR_A7(ca,d[0]);
1144 d[0] = NR_PREMUL_SINGLE(da);
1145 d += 1;
1146 c0_24 += s0_24;
1147 c0_24 = CLAMP (c0_24, 0, 16777216);
1148 len -= 1;
1149 }
1150 }
1151 }
1152 }
1154 void nr_pixblock_render_shape_mask_or (NRPixBlock &m,Shape* theS)
1155 {
1157 theS->CalcBBox();
1158 float l=theS->leftX,r=theS->rightX,t=theS->topY,b=theS->bottomY;
1159 int il,ir,it,ib;
1160 il=(int)floor(l);
1161 ir=(int)ceil(r);
1162 it=(int)floor(t);
1163 ib=(int)ceil(b);
1165 if ( il >= m.area.x1 || ir <= m.area.x0 || it >= m.area.y1 || ib <= m.area.y0 ) return;
1166 if ( il < m.area.x0 ) il=m.area.x0;
1167 if ( it < m.area.y0 ) it=m.area.y0;
1168 if ( ir > m.area.x1 ) ir=m.area.x1;
1169 if ( ib > m.area.y1 ) ib=m.area.y1;
1171 // version par FloatLigne
1172 int curPt;
1173 float curY;
1174 theS->BeginQuickRaster(curY, curPt);
1176 FloatLigne* theI=new FloatLigne();
1177 IntLigne* theIL=new IntLigne();
1179 theS->DirectQuickScan(curY,curPt,(float)(it),true,1.0);
1181 char* mdata=(char*)m.data.px;
1182 if ( m.size == NR_PIXBLOCK_SIZE_TINY ) mdata=(char*)m.data.p;
1183 uint32_t* ligStart=((uint32_t*)(mdata+((il-m.area.x0)+m.rs*(it-m.area.y0))));
1184 for (int y=it;y<ib;y++) {
1185 theI->Reset();
1186 theS->QuickScan(curY,curPt,((float)(y+1)),theI,1.0);
1187 theI->Flatten();
1188 theIL->Copy(theI);
1190 raster_info dest;
1191 dest.startPix=il;
1192 dest.endPix=ir;
1193 dest.sth=il;
1194 dest.stv=y;
1195 dest.buffer=ligStart;
1196 theIL->Raster(dest,NULL,shape_run_A8_OR);
1197 ligStart=((uint32_t*)(((char*)ligStart)+m.rs));
1198 }
1199 theS->EndQuickRaster();
1200 delete theI;
1201 delete theIL;
1203 /* // version par BitLigne
1204 int curPt;
1205 float curY;
1206 theS->BeginRaster(curY,curPt,1.0);
1208 BitLigne* theI[4];
1209 for (int i=0;i<4;i++) theI[i]=new BitLigne(il,ir);
1210 IntLigne* theIL=new IntLigne();
1212 theS->Scan(curY,curPt,(float)(it),0.25);
1214 char* mdata=(char*)m.data.px;
1215 if ( m.size == NR_PIXBLOCK_SIZE_TINY ) mdata=(char*)m.data.p;
1216 uint32_t* ligStart=((uint32_t*)(mdata+((il-m.area.x0)+m.rs*(it-m.area.y0))));
1217 for (int y=it;y<ib;y++) {
1218 for (int i=0;i<4;i++) theI[i]->Reset();
1219 if ( y&0x00000003 ) {
1220 theS->Scan(curY,curPt,((float)(y+0.25)),fill_oddEven,theI[0],false,0.25);
1221 theS->Scan(curY,curPt,((float)(y+0.5)),fill_oddEven,theI[1],false,0.25);
1222 theS->Scan(curY,curPt,((float)(y+0.75)),fill_oddEven,theI[2],false,0.25);
1223 theS->Scan(curY,curPt,((float)(y+1.0)),fill_oddEven,theI[3],false,0.25);
1224 } else {
1225 theS->Scan(curY,curPt,((float)(y+0.25)),fill_oddEven,theI[0],true,0.25);
1226 theS->Scan(curY,curPt,((float)(y+0.5)),fill_oddEven,theI[1],true,0.25);
1227 theS->Scan(curY,curPt,((float)(y+0.75)),fill_oddEven,theI[2],true,0.25);
1228 theS->Scan(curY,curPt,((float)(y+1.0)),fill_oddEven,theI[3],true,0.25);
1229 }
1230 theIL->Copy(4,theI);
1232 raster_info dest;
1233 dest.startPix=il;
1234 dest.endPix=ir;
1235 dest.sth=il;
1236 dest.stv=y;
1237 dest.buffer=ligStart;
1238 theIL->Raster(dest,NULL,shape_run_A8_OR);
1239 ligStart=((uint32_t*)(((char*)ligStart)+m.rs));
1240 }
1241 theS->EndRaster();
1242 for (int i=0;i<4;i++) delete theI[i];
1243 delete theIL;*/
1245 /* // version par BitLigne directe
1246 int curPt;
1247 float curY;
1248 theS->BeginQuickRaster(curY,curPt,1.0);
1250 BitLigne* theI[4];
1251 for (int i=0;i<4;i++) theI[i]=new BitLigne(il,ir);
1252 IntLigne* theIL=new IntLigne();
1254 theS->DirectQuickScan(curY,curPt,(float)(it),true,0.25);
1256 char* mdata=(char*)m.data.px;
1257 if ( m.size == NR_PIXBLOCK_SIZE_TINY ) mdata=(char*)m.data.p;
1258 uint32_t* ligStart=((uint32_t*)(mdata+((il-m.area.x0)+m.rs*(it-m.area.y0))));
1259 for (int y=it;y<ib;y++) {
1260 for (int i=0;i<4;i++) theI[i]->Reset();
1261 if ( y&0x00000003 ) {
1262 theS->QuickScan(curY,curPt,((float)(y+0.25)),fill_oddEven,theI[0],false,0.25);
1263 theS->QuickScan(curY,curPt,((float)(y+0.5)),fill_oddEven,theI[1],false,0.25);
1264 theS->QuickScan(curY,curPt,((float)(y+0.75)),fill_oddEven,theI[2],false,0.25);
1265 theS->QuickScan(curY,curPt,((float)(y+1.0)),fill_oddEven,theI[3],false,0.25);
1266 } else {
1267 theS->QuickScan(curY,curPt,((float)(y+0.25)),fill_oddEven,theI[0],true,0.25);
1268 theS->QuickScan(curY,curPt,((float)(y+0.5)),fill_oddEven,theI[1],true,0.25);
1269 theS->QuickScan(curY,curPt,((float)(y+0.75)),fill_oddEven,theI[2],true,0.25);
1270 theS->QuickScan(curY,curPt,((float)(y+1.0)),fill_oddEven,theI[3],true,0.25);
1271 }
1272 theIL->Copy(4,theI);
1274 raster_info dest;
1275 dest.startPix=il;
1276 dest.endPix=ir;
1277 dest.sth=il;
1278 dest.stv=y;
1279 dest.buffer=ligStart;
1280 theIL->Raster(dest,NULL,shape_run_A8_OR);
1281 ligStart=((uint32_t*)(((char*)ligStart)+m.rs));
1282 }
1283 theS->EndQuickRaster();
1284 for (int i=0;i<4;i++) delete theI[i];
1285 delete theIL;*/
1286 }
1289 /*
1290 Local Variables:
1291 mode:c++
1292 c-file-style:"stroustrup"
1293 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1294 indent-tabs-mode:nil
1295 fill-column:99
1296 End:
1297 */
1298 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :