Commit 5953d527 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

spare a few CPU cycles.

2005-04-28  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell-render.c: spare a few CPU cycles.
parent d02dd977
2005-04-28 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-render.c: spare a few CPU cycles.
2005-04-27 Sven Neumann <sven@gimp.org> 2005-04-27 Sven Neumann <sven@gimp.org>
* app/base/tile-manager.c (tile_manager_get_tile): removed * app/base/tile-manager.c (tile_manager_get_tile): removed
......
...@@ -322,6 +322,8 @@ gimp_display_shell_render (GimpDisplayShell *shell, ...@@ -322,6 +322,8 @@ gimp_display_shell_render (GimpDisplayShell *shell,
RenderInfo info; RenderInfo info;
GimpImageType type; GimpImageType type;
g_return_if_fail (w > 0 && h > 0);
render_image_init_info (&info, shell, x, y, w, h); render_image_init_info (&info, shell, x, y, w, h);
type = gimp_projection_get_image_type (shell->gdisp->gimage->projection); type = gimp_projection_get_image_type (shell->gdisp->gimage->projection);
...@@ -448,7 +450,7 @@ render_image_indexed (RenderInfo *info) ...@@ -448,7 +450,7 @@ render_image_indexed (RenderInfo *info)
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
for (; y < ye; y++) while (TRUE)
{ {
gint error = gint error =
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley)); RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
...@@ -462,8 +464,6 @@ render_image_indexed (RenderInfo *info) ...@@ -462,8 +464,6 @@ render_image_indexed (RenderInfo *info)
const guchar *src = info->src; const guchar *src = info->src;
guchar *dest = info->dest; guchar *dest = info->dest;
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
guint val = src[INDEXED_PIX] * 3; guint val = src[INDEXED_PIX] * 3;
...@@ -477,16 +477,22 @@ render_image_indexed (RenderInfo *info) ...@@ -477,16 +477,22 @@ render_image_indexed (RenderInfo *info)
} }
} }
info->dest += info->dest_bpl; if (++y == ye)
break;
initial = FALSE; info->dest += info->dest_bpl;
if (error >= 1 && y + 1 < ye) if (error)
{ {
info->src_y += error; info->src_y += error;
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
initial = TRUE; initial = TRUE;
} }
else
{
initial = FALSE;
}
} }
} }
...@@ -508,7 +514,7 @@ render_image_indexed_a (RenderInfo *info) ...@@ -508,7 +514,7 @@ render_image_indexed_a (RenderInfo *info)
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
for (; y < ye; y++) while (TRUE)
{ {
gint error = gint error =
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley)); RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
...@@ -525,8 +531,6 @@ render_image_indexed_a (RenderInfo *info) ...@@ -525,8 +531,6 @@ render_image_indexed_a (RenderInfo *info)
dark_light = (y >> check_shift) + (info->x >> check_shift); dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
guint r, g, b, a = alpha[src[ALPHA_I_PIX]]; guint r, g, b, a = alpha[src[ALPHA_I_PIX]];
...@@ -557,16 +561,22 @@ render_image_indexed_a (RenderInfo *info) ...@@ -557,16 +561,22 @@ render_image_indexed_a (RenderInfo *info)
} }
} }
info->dest += info->dest_bpl; if (++y == ye)
break;
initial = FALSE; info->dest += info->dest_bpl;
if (error >= 1 && y + 1 < ye) if (error)
{ {
info->src_y += error; info->src_y += error;
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
initial = TRUE; initial = TRUE;
} }
else
{
initial = FALSE;
}
} }
} }
...@@ -583,7 +593,7 @@ render_image_gray (RenderInfo *info) ...@@ -583,7 +593,7 @@ render_image_gray (RenderInfo *info)
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
for (; y < ye; y++) while (TRUE)
{ {
gint error = gint error =
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley)); RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
...@@ -597,8 +607,6 @@ render_image_gray (RenderInfo *info) ...@@ -597,8 +607,6 @@ render_image_gray (RenderInfo *info)
const guchar *src = info->src; const guchar *src = info->src;
guchar *dest = info->dest; guchar *dest = info->dest;
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
guint val = src[GRAY_PIX]; guint val = src[GRAY_PIX];
...@@ -612,16 +620,22 @@ render_image_gray (RenderInfo *info) ...@@ -612,16 +620,22 @@ render_image_gray (RenderInfo *info)
} }
} }
info->dest += info->dest_bpl; if (++y == ye)
break;
initial = FALSE; info->dest += info->dest_bpl;
if (error >= 1 && y + 1 < ye) if (error)
{ {
info->src_y += error; info->src_y += error;
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
initial = TRUE; initial = TRUE;
} }
else
{
initial = FALSE;
}
} }
} }
...@@ -639,7 +653,7 @@ render_image_gray_a (RenderInfo *info) ...@@ -639,7 +653,7 @@ render_image_gray_a (RenderInfo *info)
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
for (; y < ye; y++) while (TRUE)
{ {
gint error = gint error =
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley)); RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
...@@ -656,8 +670,6 @@ render_image_gray_a (RenderInfo *info) ...@@ -656,8 +670,6 @@ render_image_gray_a (RenderInfo *info)
dark_light = (y >> check_shift) + (info->x >> check_shift); dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
guint a = alpha[src[ALPHA_G_PIX]]; guint a = alpha[src[ALPHA_G_PIX]];
...@@ -680,16 +692,22 @@ render_image_gray_a (RenderInfo *info) ...@@ -680,16 +692,22 @@ render_image_gray_a (RenderInfo *info)
} }
} }
info->dest += info->dest_bpl; if (++y == ye)
break;
initial = FALSE; info->dest += info->dest_bpl;
if (error >= 1 && y + 1 < ye) if (error)
{ {
info->src_y += error; info->src_y += error;
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
initial = TRUE; initial = TRUE;
} }
else
{
initial = FALSE;
}
} }
} }
...@@ -706,7 +724,7 @@ render_image_rgb (RenderInfo *info) ...@@ -706,7 +724,7 @@ render_image_rgb (RenderInfo *info)
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
for (; y < ye; y++) while (TRUE)
{ {
gint error = gint error =
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley)); RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
...@@ -717,21 +735,25 @@ render_image_rgb (RenderInfo *info) ...@@ -717,21 +735,25 @@ render_image_rgb (RenderInfo *info)
} }
else else
{ {
g_return_if_fail (info->src != NULL);
memcpy (info->dest, info->src, 3 * info->w); memcpy (info->dest, info->src, 3 * info->w);
} }
info->dest += info->dest_bpl; if (++y == ye)
break;
initial = FALSE; info->dest += info->dest_bpl;
if (error >= 1 && y + 1 < ye) if (error && y + 1 < ye)
{ {
info->src_y += error; info->src_y += error;
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
initial = TRUE; initial = TRUE;
} }
else
{
initial = FALSE;
}
} }
} }
...@@ -749,7 +771,7 @@ render_image_rgb_a (RenderInfo *info) ...@@ -749,7 +771,7 @@ render_image_rgb_a (RenderInfo *info)
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
for (; y < ye; y++) while (TRUE)
{ {
gint error = gint error =
RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley)); RINT (floor ((y + 1) / info->scaley) - floor (y / info->scaley));
...@@ -766,8 +788,6 @@ render_image_rgb_a (RenderInfo *info) ...@@ -766,8 +788,6 @@ render_image_rgb_a (RenderInfo *info)
dark_light = (y >> check_shift) + (info->x >> check_shift); dark_light = (y >> check_shift) + (info->x >> check_shift);
g_return_if_fail (src != NULL);
for (x = info->x; x < xe; x++) for (x = info->x; x < xe; x++)
{ {
guint r, g, b, a = alpha[src[ALPHA_PIX]]; guint r, g, b, a = alpha[src[ALPHA_PIX]];
...@@ -797,16 +817,22 @@ render_image_rgb_a (RenderInfo *info) ...@@ -797,16 +817,22 @@ render_image_rgb_a (RenderInfo *info)
} }
} }
info->dest += info->dest_bpl; if (++y == ye)
break;
initial = FALSE; info->dest += info->dest_bpl;
if (error >= 1 && y + 1 < ye) if (error)
{ {
info->src_y += error; info->src_y += error;
info->src = render_image_tile_fault (info); info->src = render_image_tile_fault (info);
initial = TRUE; initial = TRUE;
} }
else
{
initial = FALSE;
}
} }
} }
...@@ -892,23 +918,23 @@ static guchar * ...@@ -892,23 +918,23 @@ static guchar *
render_image_tile_fault (RenderInfo *info) render_image_tile_fault (RenderInfo *info)
{ {
Tile *tile; Tile *tile;
const guchar *data; const guchar *src;
const guchar *scale; const guchar *scale;
guchar *dest; guchar *dest;
gint width; gint width;
gint tilex; gint tilex;
gint step; gint step;
gint bpp = info->src_bpp; gint bpp = info->src_bpp;
gint x, b; gint x;
tile = tile_manager_get_tile (info->src_tiles, tile = tile_manager_get_tile (info->src_tiles,
info->src_x, info->src_y, TRUE, FALSE); info->src_x, info->src_y, TRUE, FALSE);
g_return_val_if_fail (tile != NULL, tile_buf); g_return_val_if_fail (tile != NULL, tile_buf);
data = tile_data_pointer (tile, src = tile_data_pointer (tile,
info->src_x % TILE_WIDTH, info->src_x % TILE_WIDTH,
info->src_y % TILE_HEIGHT); info->src_y % TILE_HEIGHT);
scale = info->scale; scale = info->scale;
dest = tile_buf; dest = tile_buf;
...@@ -917,17 +943,28 @@ render_image_tile_fault (RenderInfo *info) ...@@ -917,17 +943,28 @@ render_image_tile_fault (RenderInfo *info)
tilex = info->src_x / TILE_WIDTH; tilex = info->src_x / TILE_WIDTH;
while (width--) do
{ {
for (b = 0; b < bpp; b++) const guchar *s = src;
*dest++ = data[b];
switch (bpp)
{
case 4:
*dest++ = *s++;
case 3:
*dest++ = *s++;
case 2:
*dest++ = *s++;
case 1:
*dest++ = *s++;
}
step = *scale++; step = *scale++;
if (step != 0) if (step != 0)
{ {
x += step; x += step;
data += step * bpp; src += step * bpp;
if ((x >> tile_shift) != tilex) if ((x >> tile_shift) != tilex)
{ {
...@@ -939,12 +976,13 @@ render_image_tile_fault (RenderInfo *info) ...@@ -939,12 +976,13 @@ render_image_tile_fault (RenderInfo *info)
g_return_val_if_fail (tile != NULL, tile_buf); g_return_val_if_fail (tile != NULL, tile_buf);
data = tile_data_pointer (tile, src = tile_data_pointer (tile,
x % TILE_WIDTH, x % TILE_WIDTH,
info->src_y % TILE_HEIGHT); info->src_y % TILE_HEIGHT);
} }
} }
} }
while (--width);
tile_release (tile, FALSE); tile_release (tile, FALSE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment