ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/bin/kgsueme
(Generate patch)

Comparing kgsueme/bin/kgsueme (file contents):
Revision 1.22 by pcg, Fri May 30 11:39:56 2003 UTC vs.
Revision 1.24 by pcg, Fri May 30 11:59:28 2003 UTC

80 80
81 my $state = -r $staterc ? Storable::retrieve($staterc) : {}; 81 my $state = -r $staterc ? Storable::retrieve($staterc) : {};
82 my @widgets; 82 my @widgets;
83 83
84 $config = $state->{config} ||= {}; 84 $config = $state->{config} ||= {};
85
86 $config{speed} = 1;#d# optimize for speed or memory?
87 $config{conserve_memory} = 0;
85 88
86 # grr... more gtk+ brokenness 89 # grr... more gtk+ brokenness
87 my %get = ( 90 my %get = (
88 hpane_position => sub { ($_[0]->children)[0]->allocation->[2] }, 91 hpane_position => sub { ($_[0]->children)[0]->allocation->[2] },
89 vpane_position => sub { ($_[0]->children)[0]->allocation->[3] }, 92 vpane_position => sub { ($_[0]->children)[0]->allocation->[3] },
651 unless ($$c) { 654 unless ($$c) {
652 for my $stone ($mark & (MARK_W | MARK_GRAY_W) ? @::white_img : @::black_img) { 655 for my $stone ($mark & (MARK_W | MARK_GRAY_W) ? @::white_img : @::black_img) {
653 my $base = new_pixbuf $size + $shadow, $size + $shadow, 1, 1; 656 my $base = new_pixbuf $size + $shadow, $size + $shadow, 1, 1;
654 657
655 # zeroeth the shadow 658 # zeroeth the shadow
659 if ($mark & (MARK_B | MARK_W)) {
656 $::black_img[0]->composite ( 660 $::black_img[0]->composite (
657 $base, $shadow, $shadow, $size, $size, $shadow-0.5, $shadow-0.5, 661 $base, $shadow, $shadow, $size, $size, $shadow-0.5, $shadow-0.5,
658 $size / $stone->get_width, $size / $stone->get_height, 662 $size / $stone->get_width, $size / $stone->get_height,
659 INTERP_TILES, 128 663 $::config{speed} ? INTERP_NEAREST : INTERP_TILES, 128
660 ); 664 );
665 }
661 666
662 # first the big stones 667 # first the big stones
663 for ([MARK_B, 255], 668 for ([MARK_B, 255],
664 [MARK_W, 255], 669 [MARK_W, 255],
665 [MARK_GRAY_B, 128], 670 [MARK_GRAY_B, 128],
667 my ($mask, $alpha) = @$_; 672 my ($mask, $alpha) = @$_;
668 if ($mark & $mask) { 673 if ($mark & $mask) {
669 $stone->composite ( 674 $stone->composite (
670 $base, 0, 0, $size, $size, -0.5, -0.5, 675 $base, 0, 0, $size, $size, -0.5, -0.5,
671 $size / $stone->get_width, $size / $stone->get_height, 676 $size / $stone->get_width, $size / $stone->get_height,
672 INTERP_HYPER, $alpha 677 $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, $alpha
673 ); 678 );
674 } 679 }
675 } 680 }
676 681
677 # then the samll stones 682 # then the samll stones
680 my ($mask, $img) = @$_; 685 my ($mask, $img) = @$_;
681 if ($mark & $mask) { 686 if ($mark & $mask) {
682 $img->composite ( 687 $img->composite (
683 $base, ($size / 4) x2, (int ($size / 2 + 0.5)) x2, ($size / 4 - 0.5) x 2, 688 $base, ($size / 4) x2, (int ($size / 2 + 0.5)) x2, ($size / 4 - 0.5) x 2,
684 $size / $img->get_width / 2, $size / $img->get_height / 2, 689 $size / $img->get_width / 2, $size / $img->get_height / 2,
685 INTERP_HYPER, 192 690 $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, 192
686 ); 691 );
687 } 692 }
688 } 693 }
689 694
690 # and lastly any markers (labels NYI) 695 # and lastly any markers (labels NYI)
696 my ($mask, $img) = @$_; 701 my ($mask, $img) = @$_;
697 if ($mark & $mask) { 702 if ($mark & $mask) {
698 $img->composite ( 703 $img->composite (
699 $base, 0, 0, $size, $size, -0.5, -0.5, 704 $base, 0, 0, $size, $size, -0.5, -0.5,
700 $size / $img->get_width, $size / $img->get_height, 705 $size / $img->get_width, $size / $img->get_height,
701 INTERP_HYPER, 255 706 $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, 255
702 ); 707 );
703 } 708 }
704 } 709 }
705 710
706 push @$$c, $base; 711 push @$$c, $base;
722 $x -= $w * $s * 0.5; 727 $x -= $w * $s * 0.5;
723 $y -= $height * 0.5; 728 $y -= $height * 0.5;
724 729
725 $c->composite ($pixbuf, 730 $c->composite ($pixbuf,
726 $x, $y, $w*$s+0.5, $height+0.5, $x-0.5, $y-0.5, $s, $s, 731 $x, $y, $w*$s+0.5, $height+0.5, $x-0.5, $y-0.5, $s, $s,
727 INTERP_BILINEAR, 192); 732 $::config{speed} ? INTERP_NEAREST : INTERP_BILINEAR, 192);
728 733
729 } else { 734 } else {
730 warn "unable to render character '$text'"; 735 warn "unable to render character '$text'";
731 } 736 }
732} 737}
763 my $edge = int ($s2 / $size * 0.97); 768 my $edge = int ($s2 / $size * 0.97);
764 my $ofs = int ($edge / 2); 769 my $ofs = int ($edge / 2);
765 770
766 my @k = map int ($s2 * $_ / $size - $ofs + $border + 0.5), 0 .. $size; 771 my @k = map int ($s2 * $_ / $size - $ofs + $border + 0.5), 0 .. $size;
767 772
768 unless ($self->{background}) {
769 my $pixbuf; 773 my $pixbuf;
770 774
775 if ($self->{background}) {
776 $pixbuf = $self->{background}->copy;
777 } else {
771 my ($bw, $bh) = ($::board_img->get_width, $::board_img->get_height); 778 my ($bw, $bh) = ($::board_img->get_width, $::board_img->get_height);
772 779
773 if ($s < $bw && $s < $bh) { 780 if ($s < $bw && $s < $bh) {
774 $pixbuf = new_pixbuf $s, $s, 1, 0; 781 $pixbuf = new_pixbuf $s, $s, $::config{conserve_memory} ? 0 : 1, 0;
775 $::board_img->copy_area (0, 0, $s, $s, $pixbuf, 0, 0); 782 $::board_img->copy_area (0, 0, $s, $s, $pixbuf, 0, 0);
776 } else { 783 } else {
777 $pixbuf = scale_pixbuf $::board_img, $s, $s, INTERP_TILES; 784 $pixbuf = scale_pixbuf $::board_img, $s, $s, $::config{speed} ? INTERP_NEAREST : INTERP_TILES;
778 } 785 }
779 786
780 my $linew = int ($s / 500); 787 my $linew = int ($s / 500);
781 788
782 my $a = "A"; 789 my $a = "A";
791 798
792 $a++; 799 $a++;
793 $a++ if $a eq "I"; # not correct, instead of AA AB, we should get HH JJ KK... 800 $a++ if $a eq "I"; # not correct, instead of AA AB, we should get HH JJ KK...
794 } 801 }
795 802
803 unless ($::config->{conserve_memory}) {
796 $self->{background} = $pixbuf; 804 $self->{background} = $pixbuf;
805 $pixbuf = $pixbuf->copy;
806 }
797 } 807 }
798 808
799 my $pixbuf = $self->{pixbuf} = $self->{background}->copy; 809 $self->{pixbuf} = $pixbuf;
800 810
801 # hoshi-points(!)#d# 811 # hoshi-points(!)#d#
802 # caching of empty board gfx(!)#d# 812 # caching of empty board gfx(!)#d#
803 813
804 for my $x (1 .. $size) { 814 for my $x (1 .. $size) {
808 if ($mark) { 818 if ($mark) {
809 my ($dx, $dy) = ($k[$x] - $ofs, $k[$y] - $ofs); 819 my ($dx, $dy) = ($k[$x] - $ofs, $k[$y] - $ofs);
810 my $pb = $self->create_stack($mark, $edge, $x * 17 + $y * 11 ); 820 my $pb = $self->create_stack($mark, $edge, $x * 17 + $y * 11 );
811 821
812 $pb->composite ($pixbuf, $dx, $dy, $pb->get_width, $pb->get_height, 822 $pb->composite ($pixbuf, $dx, $dy, $pb->get_width, $pb->get_height,
813 $dx, $dy, 1, 1, INTERP_NEAREST, 255); 823 $dx, $dy, 1, 1, $::config{speed} ? INTERP_NEAREST : INTERP_NEAREST, 255);
814 824
815 #my ($pm, $bm) = $self->create_stack($gc, $mark, $edge, $x * 17 + $y * 11 ); 825 #my ($pm, $bm) = $self->create_stack($gc, $mark, $edge, $x * 17 + $y * 11 );
816 826
817 #$gc->set_clip_mask ($bm); 827 #$gc->set_clip_mask ($bm);
818 #$gc->set_clip_origin ($dx, $dy); 828 #$gc->set_clip_origin ($dx, $dy);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines