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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines