comparison src/redraw_man.c @ 29:f56c96b035a8

-
author Thinker K.F. Li <thinker@branda.to>
date Mon, 04 Aug 2008 21:13:32 +0800
parents 604bc90d509d
children e06a4a667ce2
comparison
equal deleted inserted replaced
28:604bc90d509d 29:f56c96b035a8
372 * The geo_t object of a changed shape is mark as dirty and 372 * The geo_t object of a changed shape is mark as dirty and
373 * put into dirty_geos list. 373 * put into dirty_geos list.
374 */ 374 */
375 int rdman_shape_changed(redraw_man_t *rdman, shape_t *shape) { 375 int rdman_shape_changed(redraw_man_t *rdman, shape_t *shape) {
376 return _rdman_shape_changed(rdman, shape); 376 return _rdman_shape_changed(rdman, shape);
377 }
378
379 int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint) {
380 shnode_t *node;
381 int r;
382
383 for(node = STAILQ_HEAD(paint->members);
384 node != NULL;
385 node = STAILQ_NEXT(shnode_t, next, node)) {
386 r = _rdman_shape_changed(rdman, node->shape);
387 if(r != OK)
388 return ERR;
389 }
390 return OK;
377 } 391 }
378 392
379 /* Clean dirties */ 393 /* Clean dirties */
380 394
381 static void clean_shape(shape_t *shape) { 395 static void clean_shape(shape_t *shape) {
488 } 502 }
489 503
490 return OK; 504 return OK;
491 } 505 }
492 506
507 static int clean_rdman_dirties(redraw_man_t *rdman) {
508 int r;
509
510 r = clean_rdman_coords(rdman);
511 if(r != OK)
512 return ERR;
513
514 r = clean_rdman_geos(rdman);
515 if(r != OK)
516 return ERR;
517
518 return OK;
519 }
520
521
493 /* Drawing and Redrawing 522 /* Drawing and Redrawing
494 * ============================================================ 523 * ============================================================
495 */ 524 */
496 525
497 #ifndef UNITTEST 526 #ifndef UNITTEST
642 int rdman_redraw_changed(redraw_man_t *rdman) { 671 int rdman_redraw_changed(redraw_man_t *rdman) {
643 int r; 672 int r;
644 int n_dirty_areas; 673 int n_dirty_areas;
645 area_t **dirty_areas; 674 area_t **dirty_areas;
646 675
647 r = clean_rdman_coords(rdman); 676 r = clean_rdman_dirties(rdman);
648 if(r != OK) 677 if(r != OK)
649 return ERR; 678 return ERR;
650 679
651 r = clean_rdman_geos(rdman);
652 if(r != OK)
653 return ERR;
654
655 n_dirty_areas = rdman->n_dirty_areas; 680 n_dirty_areas = rdman->n_dirty_areas;
656 dirty_areas = rdman->dirty_areas; 681 dirty_areas = rdman->dirty_areas;
657 if(n_dirty_areas > 0) { 682 if(n_dirty_areas > 0) {
658 clean_canvas(rdman->cr); 683 clean_canvas(rdman->cr);
659 draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas); 684 draw_shapes_in_areas(rdman, n_dirty_areas, dirty_areas);
666 return OK; 691 return OK;
667 } 692 }
668 693
669 int rdman_redraw_all(redraw_man_t *rdman) { 694 int rdman_redraw_all(redraw_man_t *rdman) {
670 geo_t *geo; 695 geo_t *geo;
671 696 int r;
672 clean_rdman_coords(rdman); 697
673 rdman->n_dirty_areas = 0; 698 r = clean_rdman_dirties(rdman);
699 if(r != OK)
700 return ERR;
674 701
675 for(geo = STAILQ_HEAD(rdman->all_geos); 702 for(geo = STAILQ_HEAD(rdman->all_geos);
676 geo != NULL; 703 geo != NULL;
677 geo = STAILQ_NEXT(geo_t, next, geo)) { 704 geo = STAILQ_NEXT(geo_t, next, geo)) {
678 if(geo->flags & GEF_DIRTY)
679 clean_shape(geo->shape);
680 draw_shape(rdman, geo->shape); 705 draw_shape(rdman, geo->shape);
681 } 706 }
682 copy_cr_2_backend(rdman, 0, NULL); 707 copy_cr_2_backend(rdman, 0, NULL);
683 rdman->n_dirty_geos = 0; 708 rdman->n_dirty_areas = 0;
684 709
685 return OK; 710 return OK;
686 } 711 }
687 712
688 shnode_t *shnode_new(redraw_man_t *rdman, shape_t *shape) { 713 shnode_t *shnode_new(redraw_man_t *rdman, shape_t *shape) {
692 if(node) { 717 if(node) {
693 node->shape = shape; 718 node->shape = shape;
694 node->next = NULL; 719 node->next = NULL;
695 } 720 }
696 return node; 721 return node;
697 }
698
699 int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint) {
700 shnode_t *node;
701 int r;
702
703 for(node = STAILQ_HEAD(paint->members);
704 node != NULL;
705 node = STAILQ_NEXT(shnode_t, next, node)) {
706 r = _rdman_shape_changed(rdman, node->shape);
707 if(r != OK)
708 return ERR;
709 }
710 return OK;
711 } 722 }
712 723
713 /* 724 /*
714 * Dirty of geo 725 * Dirty of geo
715 * A geo is dirty when any of the shape, size or positions is changed. 726 * A geo is dirty when any of the shape, size or positions is changed.