Commit 19ea2a9d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/widgets/Makefile.am new files keeping the render acceleration check

2005-07-19  Michael Natterer  <mitch@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/gimprender.[ch]: new files keeping the render
	acceleration check buffers.

	* app/display/gimpdisplayshell-render.[ch]: removed them here.

	* app/gui/gui.c: initialize/shutdown the new buffers.

	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimpviewrenderer.c
	* app/widgets/gimpviewrenderergradient.c
	* app/actions/view-actions.c
	* app/display/gimpdisplayshell-appearance.c
	* app/display/gimpdisplayshell-draw.c
	* app/display/gimpdisplayshell.c: use the new stuff. Removes
	lots of broken widgets -> display dependencies.
parent 7e11ba99
2005-07-19 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/gimprender.[ch]: new files keeping the render
acceleration check buffers.
* app/display/gimpdisplayshell-render.[ch]: removed them here.
* app/gui/gui.c: initialize/shutdown the new buffers.
* app/widgets/gimpcolormapeditor.c
* app/widgets/gimpviewrenderer.c
* app/widgets/gimpviewrenderergradient.c
* app/actions/view-actions.c
* app/display/gimpdisplayshell-appearance.c
* app/display/gimpdisplayshell-draw.c
* app/display/gimpdisplayshell.c: use the new stuff. Removes
lots of broken widgets -> display dependencies.
2005-07-19 Michael Natterer <mitch@gimp.org> 2005-07-19 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcolormapeditor.[ch]: renamed member "palette" * app/widgets/gimpcolormapeditor.[ch]: renamed member "palette"
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "widgets/gimpactiongroup.h" #include "widgets/gimpactiongroup.h"
#include "widgets/gimprender.h"
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h" #include "widgets/gimpwidgets-utils.h"
...@@ -39,7 +40,6 @@ ...@@ -39,7 +40,6 @@
#include "display/gimpdisplayoptions.h" #include "display/gimpdisplayoptions.h"
#include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h" #include "display/gimpdisplayshell-appearance.h"
#include "display/gimpdisplayshell-render.h"
#include "display/gimpdisplayshell-selection.h" #include "display/gimpdisplayshell-selection.h"
#include "actions.h" #include "actions.h"
...@@ -629,17 +629,17 @@ view_actions_check_type_notify (GimpDisplayConfig *config, ...@@ -629,17 +629,17 @@ view_actions_check_type_notify (GimpDisplayConfig *config,
GimpRGB color; GimpRGB color;
gimp_rgba_set_uchar (&color, gimp_rgba_set_uchar (&color,
render_blend_light_check[0], gimp_render_blend_light_check[0],
render_blend_light_check[1], gimp_render_blend_light_check[1],
render_blend_light_check[2], gimp_render_blend_light_check[2],
255); 255);
gimp_action_group_set_action_color (group, "view-padding-color-light-check", gimp_action_group_set_action_color (group, "view-padding-color-light-check",
&color, FALSE); &color, FALSE);
gimp_rgba_set_uchar (&color, gimp_rgba_set_uchar (&color,
render_blend_dark_check[0], gimp_render_blend_dark_check[0],
render_blend_dark_check[1], gimp_render_blend_dark_check[1],
render_blend_dark_check[2], gimp_render_blend_dark_check[2],
255); 255);
gimp_action_group_set_action_color (group, "view-padding-color-dark-check", gimp_action_group_set_action_color (group, "view-padding-color-dark-check",
&color, FALSE); &color, FALSE);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "widgets/gimpactiongroup.h" #include "widgets/gimpactiongroup.h"
#include "widgets/gimprender.h"
#include "widgets/gimpuimanager.h" #include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h" #include "widgets/gimpwidgets-utils.h"
...@@ -40,7 +41,6 @@ ...@@ -40,7 +41,6 @@
#include "gimpdisplayshell-appearance.h" #include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-callbacks.h" #include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-selection.h" #include "gimpdisplayshell-selection.h"
#include "gimpdisplayshell-render.h"
#define GET_OPTIONS(shell) \ #define GET_OPTIONS(shell) \
...@@ -542,16 +542,16 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell, ...@@ -542,16 +542,16 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell,
case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK: case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
gimp_rgb_set_uchar (&color, gimp_rgb_set_uchar (&color,
render_blend_light_check[0], gimp_render_blend_light_check[0],
render_blend_light_check[1], gimp_render_blend_light_check[1],
render_blend_light_check[2]); gimp_render_blend_light_check[2]);
break; break;
case GIMP_CANVAS_PADDING_MODE_DARK_CHECK: case GIMP_CANVAS_PADDING_MODE_DARK_CHECK:
gimp_rgb_set_uchar (&color, gimp_rgb_set_uchar (&color,
render_blend_dark_check[0], gimp_render_blend_dark_check[0],
render_blend_dark_check[1], gimp_render_blend_dark_check[1],
render_blend_dark_check[2]); gimp_render_blend_dark_check[2]);
break; break;
case GIMP_CANVAS_PADDING_MODE_CUSTOM: case GIMP_CANVAS_PADDING_MODE_CUSTOM:
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "vectors/gimpstroke.h" #include "vectors/gimpstroke.h"
#include "vectors/gimpvectors.h" #include "vectors/gimpvectors.h"
#include "widgets/gimprender.h"
#include "widgets/gimpwidgets-utils.h" #include "widgets/gimpwidgets-utils.h"
#include "gimpcanvas.h" #include "gimpcanvas.h"
...@@ -502,14 +503,14 @@ gimp_display_shell_draw_area (GimpDisplayShell *shell, ...@@ -502,14 +503,14 @@ gimp_display_shell_draw_area (GimpDisplayShell *shell,
/* display the image in RENDER_BUF_WIDTH x RENDER_BUF_HEIGHT /* display the image in RENDER_BUF_WIDTH x RENDER_BUF_HEIGHT
* sized chunks * sized chunks
*/ */
for (i = y; i < y2; i += GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT) for (i = y; i < y2; i += GIMP_RENDER_BUF_HEIGHT)
{ {
for (j = x; j < x2; j += GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH) for (j = x; j < x2; j += GIMP_RENDER_BUF_WIDTH)
{ {
gint dx, dy; gint dx, dy;
dx = MIN (x2 - j, GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH); dx = MIN (x2 - j, GIMP_RENDER_BUF_WIDTH);
dy = MIN (y2 - i, GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT); dy = MIN (y2 - i, GIMP_RENDER_BUF_HEIGHT);
gimp_display_shell_render (shell, gimp_display_shell_render (shell,
j - shell->disp_xoffset, j - shell->disp_xoffset,
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "core/gimpimage-colormap.h" #include "core/gimpimage-colormap.h"
#include "core/gimpprojection.h" #include "core/gimpprojection.h"
#include "widgets/gimprender.h"
#include "gimpcanvas.h" #include "gimpcanvas.h"
#include "gimpdisplay.h" #include "gimpdisplay.h"
#include "gimpdisplayshell.h" #include "gimpdisplayshell.h"
...@@ -72,17 +74,6 @@ static void render_setup_notify (gpointer config, ...@@ -72,17 +74,6 @@ static void render_setup_notify (gpointer config,
Gimp *gimp); Gimp *gimp);
/* accelerate transparency of image scaling */
guchar *render_check_buf = NULL;
guchar *render_empty_buf = NULL;
guchar *render_white_buf = NULL;
guchar *render_temp_buf = NULL;
guchar *render_blend_dark_check = NULL;
guchar *render_blend_light_check = NULL;
guchar *render_blend_white = NULL;
static guchar *tile_buf = NULL; static guchar *tile_buf = NULL;
static guint tile_shift = 0; static guint tile_shift = 0;
static guint check_mod = 0; static guint check_mod = 0;
...@@ -90,7 +81,7 @@ static guint check_shift = 0; ...@@ -90,7 +81,7 @@ static guint check_shift = 0;
void void
render_init (Gimp *gimp) gimp_display_shell_render_init (Gimp *gimp)
{ {
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
...@@ -105,7 +96,7 @@ render_init (Gimp *gimp) ...@@ -105,7 +96,7 @@ render_init (Gimp *gimp)
} }
void void
render_exit (Gimp *gimp) gimp_display_shell_render_exit (Gimp *gimp)
{ {
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_GIMP (gimp));
...@@ -118,48 +109,6 @@ render_exit (Gimp *gimp) ...@@ -118,48 +109,6 @@ render_exit (Gimp *gimp)
g_free (tile_buf); g_free (tile_buf);
tile_buf = NULL; tile_buf = NULL;
} }
if (render_blend_dark_check)
{
g_free (render_blend_dark_check);
render_blend_dark_check = NULL;
}
if (render_blend_light_check)
{
g_free (render_blend_light_check);
render_blend_light_check = NULL;
}
if (render_blend_white)
{
g_free (render_blend_white);
render_blend_white = NULL;
}
if (render_check_buf)
{
g_free (render_check_buf);
render_check_buf = NULL;
}
if (render_empty_buf)
{
g_free (render_empty_buf);
render_empty_buf = NULL;
}
if (render_white_buf)
{
g_free (render_white_buf);
render_white_buf = NULL;
}
if (render_temp_buf)
{
g_free (render_temp_buf);
render_temp_buf = NULL;
}
} }
...@@ -168,13 +117,9 @@ render_setup_notify (gpointer config, ...@@ -168,13 +117,9 @@ render_setup_notify (gpointer config,
GParamSpec *param_spec, GParamSpec *param_spec,
Gimp *gimp) Gimp *gimp)
{ {
GimpCheckType check_type;
GimpCheckSize check_size; GimpCheckSize check_size;
guchar light, dark;
gint i, j;
g_object_get (config, g_object_get (config,
"transparency-type", &check_type,
"transparency-size", &check_size, "transparency-size", &check_size,
NULL); NULL);
...@@ -187,28 +132,7 @@ render_setup_notify (gpointer config, ...@@ -187,28 +132,7 @@ render_setup_notify (gpointer config,
/* allocate a buffer for arranging information from a row of tiles */ /* allocate a buffer for arranging information from a row of tiles */
if (! tile_buf) if (! tile_buf)
tile_buf = g_new (guchar, tile_buf = g_new (guchar, GIMP_RENDER_BUF_WIDTH * MAX_CHANNELS);
GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH * MAX_CHANNELS);
if (! render_blend_dark_check)
render_blend_dark_check = g_new (guchar, 65536);
if (! render_blend_light_check)
render_blend_light_check = g_new (guchar, 65536);
if (! render_blend_white)
render_blend_white = g_new (guchar, 65536);
gimp_checks_get_shades (check_type, &light, &dark);
for (i = 0; i < 256; i++)
for (j = 0; j < 256; j++)
{
render_blend_dark_check [(i << 8) + j] =
(guchar) ((j * i + dark * (255 - i)) / 255);
render_blend_light_check [(i << 8) + j] =
(guchar) ((j * i + light * (255 - i)) / 255);
render_blend_white [(i << 8) + j] =
(guchar) ((j * i + 255 * (255 - i)) / 255);
}
switch (check_size) switch (check_size)
{ {
...@@ -225,41 +149,6 @@ render_setup_notify (gpointer config, ...@@ -225,41 +149,6 @@ render_setup_notify (gpointer config,
check_shift = 4; check_shift = 4;
break; break;
} }
g_free (render_check_buf);
g_free (render_empty_buf);
g_free (render_white_buf);
g_free (render_temp_buf);
#define BUF_SIZE (MAX (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH, \
GIMP_VIEWABLE_MAX_PREVIEW_SIZE) + 4)
render_check_buf = g_new (guchar, BUF_SIZE * 3);
render_empty_buf = g_new0 (guchar, BUF_SIZE * 3);
render_white_buf = g_new (guchar, BUF_SIZE * 3);
render_temp_buf = g_new (guchar, BUF_SIZE * 3);
/* calculate check buffer for previews */
memset (render_white_buf, 255, BUF_SIZE * 3);
for (i = 0; i < BUF_SIZE; i++)
{
if (i & 0x4)
{
render_check_buf[i * 3 + 0] = render_blend_dark_check[0];
render_check_buf[i * 3 + 1] = render_blend_dark_check[0];
render_check_buf[i * 3 + 2] = render_blend_dark_check[0];
}
else
{
render_check_buf[i * 3 + 0] = render_blend_light_check[0];
render_check_buf[i * 3 + 1] = render_blend_light_check[0];
render_check_buf[i * 3 + 2] = render_blend_light_check[0];
}
}
#undef BUF_SIZE
} }
...@@ -344,7 +233,7 @@ gimp_display_shell_render (GimpDisplayShell *shell, ...@@ -344,7 +233,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
shell->render_buf, shell->render_buf,
w, h, w, h,
3, 3,
3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH); 3 * GIMP_RENDER_BUF_WIDTH);
/* dim pixels outside the highlighted rectangle */ /* dim pixels outside the highlighted rectangle */
if (highlight) if (highlight)
...@@ -355,7 +244,7 @@ gimp_display_shell_render (GimpDisplayShell *shell, ...@@ -355,7 +244,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
x + shell->disp_xoffset, y + shell->disp_yoffset, x + shell->disp_xoffset, y + shell->disp_yoffset,
w, h, w, h,
shell->render_buf, shell->render_buf,
3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH, 3 * GIMP_RENDER_BUF_WIDTH,
shell->offset_x, shell->offset_y); shell->offset_x, shell->offset_y);
} }
...@@ -395,7 +284,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell, ...@@ -395,7 +284,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x = 0; x < w; x++) for (x = 0; x < w; x++)
GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x) GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x)
buf += 3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH; buf += 3 * GIMP_RENDER_BUF_WIDTH;
} }
for ( ; y < rect.y + rect.height; y++) for ( ; y < rect.y + rect.height; y++)
...@@ -406,7 +295,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell, ...@@ -406,7 +295,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x += rect.width; x < w; x++) for (x += rect.width; x < w; x++)
GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x) GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x)
buf += 3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH; buf += 3 * GIMP_RENDER_BUF_WIDTH;
} }
for ( ; y < h; y++) for ( ; y < h; y++)
...@@ -414,7 +303,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell, ...@@ -414,7 +303,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x = 0; x < w; x++) for (x = 0; x < w; x++)
GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x) GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x)
buf += 3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH; buf += 3 * GIMP_RENDER_BUF_WIDTH;
} }
} }
else else
...@@ -424,7 +313,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell, ...@@ -424,7 +313,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x = 0; x < w; x++) for (x = 0; x < w; x++)
GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x) GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x)
buf += 3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH; buf += 3 * GIMP_RENDER_BUF_WIDTH;
} }
} }
} }
...@@ -540,15 +429,15 @@ render_image_indexed_a (RenderInfo *info) ...@@ -540,15 +429,15 @@ render_image_indexed_a (RenderInfo *info)
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = render_blend_dark_check[(a | cmap[val + 0])]; r = gimp_render_blend_dark_check[(a | cmap[val + 0])];
g = render_blend_dark_check[(a | cmap[val + 1])]; g = gimp_render_blend_dark_check[(a | cmap[val + 1])];
b = render_blend_dark_check[(a | cmap[val + 2])]; b = gimp_render_blend_dark_check[(a | cmap[val + 2])];
} }
else else
{ {
r = render_blend_light_check[(a | cmap[val + 0])]; r = gimp_render_blend_light_check[(a | cmap[val + 0])];
g = render_blend_light_check[(a | cmap[val + 1])]; g = gimp_render_blend_light_check[(a | cmap[val + 1])];
b = render_blend_light_check[(a | cmap[val + 2])]; b = gimp_render_blend_light_check[(a | cmap[val + 2])];
} }
dest[0] = r; dest[0] = r;
...@@ -676,9 +565,9 @@ render_image_gray_a (RenderInfo *info) ...@@ -676,9 +565,9 @@ render_image_gray_a (RenderInfo *info)
guint val; guint val;
if (dark_light & 0x1) if (dark_light & 0x1)
val = render_blend_dark_check[(a | src[GRAY_PIX])]; val = gimp_render_blend_dark_check[(a | src[GRAY_PIX])];
else else
val = render_blend_light_check[(a | src[GRAY_PIX])]; val = gimp_render_blend_light_check[(a | src[GRAY_PIX])];
src += 2; src += 2;
...@@ -794,15 +683,15 @@ render_image_rgb_a (RenderInfo *info) ...@@ -794,15 +683,15 @@ render_image_rgb_a (RenderInfo *info)
if (dark_light & 0x1) if (dark_light & 0x1)
{ {
r = render_blend_dark_check[(a | src[RED_PIX])]; r = gimp_render_blend_dark_check[(a | src[RED_PIX])];
g = render_blend_dark_check[(a | src[GREEN_PIX])]; g = gimp_render_blend_dark_check[(a | src[GREEN_PIX])];
b = render_blend_dark_check[(a | src[BLUE_PIX])]; b = gimp_render_blend_dark_check[(a | src[BLUE_PIX])];
} }
else else
{ {
r = render_blend_light_check[(a | src[RED_PIX])]; r = gimp_render_blend_light_check[(a | src[RED_PIX])];
g = render_blend_light_check[(a | src[GREEN_PIX])]; g = gimp_render_blend_light_check[(a | src[GREEN_PIX])];
b = render_blend_light_check[(a | src[BLUE_PIX])]; b = gimp_render_blend_light_check[(a | src[BLUE_PIX])];
} }
src += 4; src += 4;
...@@ -859,7 +748,7 @@ render_image_init_info (RenderInfo *info, ...@@ -859,7 +748,7 @@ render_image_init_info (RenderInfo *info,
info->src_bpp = gimp_projection_get_bytes (gimage->projection); info->src_bpp = gimp_projection_get_bytes (gimage->projection);
info->dest = shell->render_buf; info->dest = shell->render_buf;
info->dest_bpp = 3; info->dest_bpp = 3;
info->dest_bpl = info->dest_bpp * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH; info->dest_bpl = info->dest_bpp * GIMP_RENDER_BUF_WIDTH;
info->dest_width = info->w * info->dest_bpp; info->dest_width = info->w * info->dest_bpp;
info->scale = render_image_accelerate_scaling (w, info->scale = render_image_accelerate_scaling (w,
info->x, info->scalex); info->x, info->scalex);
...@@ -903,7 +792,7 @@ render_image_accelerate_scaling (gint width, ...@@ -903,7 +792,7 @@ render_image_accelerate_scaling (gint width,
gint i; gint i;
if (! scale) if (! scale)
scale = g_new (guchar, GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH + 1); scale = g_new (guchar, GIMP_RENDER_BUF_WIDTH + 1);
for (i = 0; i <= width; i++) for (i = 0; i <= width; i++)
{ {
......
...@@ -20,12 +20,8 @@ ...@@ -20,12 +20,8 @@
#define __GIMP_DISPLAY_SHELL_RENDER_H__ #define __GIMP_DISPLAY_SHELL_RENDER_H__
#define GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH 256 void gimp_display_shell_render_init (Gimp *gimp);
#define GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT 256 void gimp_display_shell_render_exit (Gimp *gimp);
void render_init (Gimp *gimp);
void render_exit (Gimp *gimp);
void gimp_display_shell_render (GimpDisplayShell *shell, void gimp_display_shell_render (GimpDisplayShell *shell,
gint x, gint x,
...@@ -34,17 +30,5 @@ void gimp_display_shell_render (GimpDisplayShell *shell, ...@@ -34,17 +30,5 @@ void gimp_display_shell_render (GimpDisplayShell *shell,
gint h, gint h,
GdkRectangle *highlight); GdkRectangle *highlight);
/*
* Extern variables
*/
extern guchar *render_check_buf;
extern guchar *render_empty_buf;
extern guchar *render_white_buf;
extern guchar *render_temp_buf;
extern guchar *render_blend_dark_check;
extern guchar *render_blend_light_check;
extern guchar *render_blend_white;
#endif /* __GIMP_DISPLAY_SHELL_RENDER_H__ */ #endif /* __GIMP_DISPLAY_SHELL_RENDER_H__ */
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "core/gimpimage-snap.h" #include "core/gimpimage-snap.h"