Skip to content
Browse files

Optimize ExposeEvent by using the dirty region

44s to 27s locally by avoiding unneeded repaint ops.
  • Loading branch information...
1 parent aebb16f commit 2d21a42041b998af0d3b2bef4f8bca10c7bd48e3 @sorear sorear committed Dec 4, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 bin/gtk-mandelbrot.pl
View
11 bin/gtk-mandelbrot.pl
@@ -267,7 +267,11 @@
method shift() {
$monitor.lock({
- $monitor.wait until @queue;
+ unless @queue {
+ say "Waiting for work at {times[0]}";
+ $monitor.wait until @queue;
+ say "Got work at {times[0]}";
+ }
shift @queue;
})
}
@@ -474,7 +478,7 @@ ($obj, $args)
Application.Quit;
};
-sub ExposeEvent($obj, $args) #OK not used
+sub ExposeEvent($obj, $args)
{
my $index = $obj.GetData("Id").ToInt32();
my $set = @windows[$index];
@@ -487,7 +491,8 @@ ($obj, $args)
}
my $gc = GdkGC.new($window);
- for ^$windowHeight -> $y {
+ my $y0 = $args.Event.Area.Y - $windowY;
+ for $y0..^($y0+$args.Event.Area.Height) -> $y {
if $y < $set.line-work-items && $set.line-work-items[$y].is-done {
$window.DrawRgbImage($gc, $windowX, $windowY+$y, $windowWidth, 1,
GdkRgbDither.Normal, $set.rows[$y], $windowWidth * 3);

0 comments on commit 2d21a42

Please sign in to comment.
Something went wrong with that request. Please try again.