Permalink
Browse files

Remove more hot blocks.

  • Loading branch information...
1 parent be374e9 commit 6e1a38e4e5d10414a7d01a37c0997fe8534cb76b @headius headius committed Aug 24, 2011
Showing with 32 additions and 16 deletions.
  1. +32 −16 escape/gui/bitmap.rb
View
48 escape/gui/bitmap.rb
@@ -15,68 +15,84 @@ def initialize(width, height)
end
def draw(bitmap, x_offs, y_offs)
- bitmap.height.times do |y|
+ y, max_y = 0, bitmap.height
+ while y < max_y
y_pix = y + y_offs
- next if (y_pix < 0 || y_pix >= @height)
+ next(y += 1) if (y_pix < 0 || y_pix >= @height)
- bitmap.width.times do |x|
+ x, max_x = 0, bitmap.width
+ while x < max_x
x_pix = x + x_offs
- next if (x_pix < 0 || x_pix >= @width)
+ next(x += 1) if (x_pix < 0 || x_pix >= @width)
src = bitmap.pixels[x + y * bitmap.width]
@pixels[x_pix + y_pix * width] = src
+ x += 1
end
+ y += 1
end
end
def flip_draw(bitmap, x_offs, y_offs)
- bitmap.height.times do |y|
+ y, max_y = 0, bitmap.height
+ while y < max_y
y_pix = y + y_offs
- next if (y_pix < 0 || y_pix >= @height)
+ next(y += 1) if (y_pix < 0 || y_pix >= @height)
- bitmap.width.times do |x|
+ x, max_x = 0, bitmap.width
+ while x < max_x
x_pix = x_offs + bitmap.width - x - 1
- next if (x_pix < 0 || x_pix >= @width)
+ next(x += 1) if (x_pix < 0 || x_pix >= @width)
src = bitmap.pixels[x + y * bitmap.width]
@pixels[x_pix + y_pix * width] = src
+ x += 1
end
+ y += 1
end
end
def draw_bitmap(bitmap, x_offs, y_offs, xo, yo, w, h, col)
- h.times do |y|
+ y, max_y = 0, h
+ while y < max_y
y_pix = y + y_offs
- next if (y_pix < 0 || y_pix >= @height)
+ next(y += 1) if (y_pix < 0 || y_pix >= @height)
- w.times do |x|
+ x, max_x = 0, w
+ while x < max_x
x_pix = x + x_offs
- next if (x_pix < 0 || x_pix >= @width)
+ next(x += 1) if (x_pix < 0 || x_pix >= @width)
src = bitmap.pixels[(x + xo) + (y + yo) * bitmap.width]
if src >= 0
@pixels[x_pix + y_pix * width] = src * col
end
+ x += 1
end
+ y += 1
end
end
def scale_draw(bitmap, scale, x_offs, y_offs, xo, yo, w, h, col)
- (h * scale).times do |y|
+ y, max_y = 0, (h * scale)
+ while y < max_y
y_pix = y + y_offs
- next if (y_pix < 0 || y_pix >= @height)
+ next(y += 1) if (y_pix < 0 || y_pix >= @height)
- (w * scale).times do |x|
+ x, max_x = 0, (w * scale)
+ while x < max_x
x_pix = x + x_offs
- next if (x_pix < 0 || x_pix >= @width)
+ next(x += 1) if (x_pix < 0 || x_pix >= @width)
src = bitmap.pixels[(x / scale + xo) + (y / scale + yo) * bitmap.width]
if src >= 0
@pixels[x_pix + y_pix * width] = src * col
end
+ x += 1
end
+ y += 1
end
end

0 comments on commit 6e1a38e

Please sign in to comment.