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>
* app/widgets/gimpcolormapeditor.[ch]: renamed member "palette"
......
......@@ -32,6 +32,7 @@
#include "core/gimpimage.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimprender.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
......@@ -39,7 +40,6 @@
#include "display/gimpdisplayoptions.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h"
#include "display/gimpdisplayshell-render.h"
#include "display/gimpdisplayshell-selection.h"
#include "actions.h"
......@@ -629,17 +629,17 @@ view_actions_check_type_notify (GimpDisplayConfig *config,
GimpRGB color;
gimp_rgba_set_uchar (&color,
render_blend_light_check[0],
render_blend_light_check[1],
render_blend_light_check[2],
gimp_render_blend_light_check[0],
gimp_render_blend_light_check[1],
gimp_render_blend_light_check[2],
255);
gimp_action_group_set_action_color (group, "view-padding-color-light-check",
&color, FALSE);
gimp_rgba_set_uchar (&color,
render_blend_dark_check[0],
render_blend_dark_check[1],
render_blend_dark_check[2],
gimp_render_blend_dark_check[0],
gimp_render_blend_dark_check[1],
gimp_render_blend_dark_check[2],
255);
gimp_action_group_set_action_color (group, "view-padding-color-dark-check",
&color, FALSE);
......
......@@ -30,6 +30,7 @@
#include "core/gimpimage.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimprender.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h"
......@@ -40,7 +41,6 @@
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-selection.h"
#include "gimpdisplayshell-render.h"
#define GET_OPTIONS(shell) \
......@@ -542,16 +542,16 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell,
case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
gimp_rgb_set_uchar (&color,
render_blend_light_check[0],
render_blend_light_check[1],
render_blend_light_check[2]);
gimp_render_blend_light_check[0],
gimp_render_blend_light_check[1],
gimp_render_blend_light_check[2]);
break;
case GIMP_CANVAS_PADDING_MODE_DARK_CHECK:
gimp_rgb_set_uchar (&color,
render_blend_dark_check[0],
render_blend_dark_check[1],
render_blend_dark_check[2]);
gimp_render_blend_dark_check[0],
gimp_render_blend_dark_check[1],
gimp_render_blend_dark_check[2]);
break;
case GIMP_CANVAS_PADDING_MODE_CUSTOM:
......
......@@ -32,6 +32,7 @@
#include "vectors/gimpstroke.h"
#include "vectors/gimpvectors.h"
#include "widgets/gimprender.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpcanvas.h"
......@@ -502,14 +503,14 @@ gimp_display_shell_draw_area (GimpDisplayShell *shell,
/* display the image in RENDER_BUF_WIDTH x RENDER_BUF_HEIGHT
* 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;
dx = MIN (x2 - j, GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH);
dy = MIN (y2 - i, GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT);
dx = MIN (x2 - j, GIMP_RENDER_BUF_WIDTH);
dy = MIN (y2 - i, GIMP_RENDER_BUF_HEIGHT);
gimp_display_shell_render (shell,
j - shell->disp_xoffset,
......
......@@ -36,6 +36,8 @@
#include "core/gimpimage-colormap.h"
#include "core/gimpprojection.h"
#include "widgets/gimprender.h"
#include "gimpcanvas.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
......@@ -72,25 +74,14 @@ static void render_setup_notify (gpointer config,
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 guint tile_shift = 0;
static guint check_mod = 0;
static guint check_shift = 0;
static guchar *tile_buf = NULL;
static guint tile_shift = 0;
static guint check_mod = 0;
static guint check_shift = 0;
void
render_init (Gimp *gimp)
gimp_display_shell_render_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
......@@ -105,7 +96,7 @@ render_init (Gimp *gimp)
}
void
render_exit (Gimp *gimp)
gimp_display_shell_render_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
......@@ -118,48 +109,6 @@ render_exit (Gimp *gimp)
g_free (tile_buf);
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,
GParamSpec *param_spec,
Gimp *gimp)
{
GimpCheckType check_type;
GimpCheckSize check_size;
guchar light, dark;
gint i, j;
g_object_get (config,
"transparency-type", &check_type,
"transparency-size", &check_size,
NULL);
......@@ -187,28 +132,7 @@ render_setup_notify (gpointer config,
/* allocate a buffer for arranging information from a row of tiles */
if (! tile_buf)
tile_buf = g_new (guchar,
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);
}
tile_buf = g_new (guchar, GIMP_RENDER_BUF_WIDTH * MAX_CHANNELS);
switch (check_size)
{
......@@ -225,41 +149,6 @@ render_setup_notify (gpointer config,
check_shift = 4;
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,
shell->render_buf,
w, h,
3,
3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH);
3 * GIMP_RENDER_BUF_WIDTH);
/* dim pixels outside the highlighted rectangle */
if (highlight)
......@@ -355,7 +244,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
x + shell->disp_xoffset, y + shell->disp_yoffset,
w, h,
shell->render_buf,
3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH,
3 * GIMP_RENDER_BUF_WIDTH,
shell->offset_x, shell->offset_y);
}
......@@ -395,7 +284,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x = 0; x < w; 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++)
......@@ -406,7 +295,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x += rect.width; x < w; 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++)
......@@ -414,7 +303,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x = 0; x < w; x++)
GIMP_DISPLAY_SHELL_DIM_PIXEL (buf, x)
buf += 3 * GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH;
buf += 3 * GIMP_RENDER_BUF_WIDTH;
}
}
else
......@@ -424,7 +313,7 @@ gimp_display_shell_render_highlight (GimpDisplayShell *shell,
for (x = 0; x < w; 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)
if (dark_light & 0x1)
{
r = render_blend_dark_check[(a | cmap[val + 0])];
g = render_blend_dark_check[(a | cmap[val + 1])];
b = render_blend_dark_check[(a | cmap[val + 2])];
r = gimp_render_blend_dark_check[(a | cmap[val + 0])];
g = gimp_render_blend_dark_check[(a | cmap[val + 1])];
b = gimp_render_blend_dark_check[(a | cmap[val + 2])];
}
else
{
r = render_blend_light_check[(a | cmap[val + 0])];
g = render_blend_light_check[(a | cmap[val + 1])];
b = render_blend_light_check[(a | cmap[val + 2])];
r = gimp_render_blend_light_check[(a | cmap[val + 0])];
g = gimp_render_blend_light_check[(a | cmap[val + 1])];
b = gimp_render_blend_light_check[(a | cmap[val + 2])];
}
dest[0] = r;
......@@ -676,9 +565,9 @@ render_image_gray_a (RenderInfo *info)
guint val;
if (dark_light & 0x1)
val = render_blend_dark_check[(a | src[GRAY_PIX])];
val = gimp_render_blend_dark_check[(a | src[GRAY_PIX])];
else
val = render_blend_light_check[(a | src[GRAY_PIX])];
val = gimp_render_blend_light_check[(a | src[GRAY_PIX])];
src += 2;
......@@ -794,15 +683,15 @@ render_image_rgb_a (RenderInfo *info)
if (dark_light & 0x1)
{
r = render_blend_dark_check[(a | src[RED_PIX])];
g = render_blend_dark_check[(a | src[GREEN_PIX])];
b = render_blend_dark_check[(a | src[BLUE_PIX])];
r = gimp_render_blend_dark_check[(a | src[RED_PIX])];
g = gimp_render_blend_dark_check[(a | src[GREEN_PIX])];
b = gimp_render_blend_dark_check[(a | src[BLUE_PIX])];
}
else
{
r = render_blend_light_check[(a | src[RED_PIX])];
g = render_blend_light_check[(a | src[GREEN_PIX])];
b = render_blend_light_check[(a | src[BLUE_PIX])];
r = gimp_render_blend_light_check[(a | src[RED_PIX])];
g = gimp_render_blend_light_check[(a | src[GREEN_PIX])];
b = gimp_render_blend_light_check[(a | src[BLUE_PIX])];
}
src += 4;
......@@ -859,7 +748,7 @@ render_image_init_info (RenderInfo *info,
info->src_bpp = gimp_projection_get_bytes (gimage->projection);
info->dest = shell->render_buf;
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->scale = render_image_accelerate_scaling (w,
info->x, info->scalex);
......@@ -903,7 +792,7 @@ render_image_accelerate_scaling (gint width,
gint i;
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++)
{
......
......@@ -20,31 +20,15 @@
#define __GIMP_DISPLAY_SHELL_RENDER_H__
#define GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH 256
#define GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT 256
void render_init (Gimp *gimp);
void render_exit (Gimp *gimp);
void gimp_display_shell_render (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h,
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;
void gimp_display_shell_render_init (Gimp *gimp);
void gimp_display_shell_render_exit (Gimp *gimp);
void gimp_display_shell_render (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h,
GdkRectangle *highlight);
#endif /* __GIMP_DISPLAY_SHELL_RENDER_H__ */
......@@ -41,6 +41,7 @@
#include "core/gimpimage-snap.h"
#include "core/gimpmarshal.h"
#include "widgets/gimprender.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimpuimanager.h"
......@@ -60,7 +61,6 @@
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-filter.h"
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-selection.h"
#include "gimpdisplayshell-title.h"
......@@ -270,9 +270,9 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->menubar = NULL;
shell->statusbar = NULL;
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT *
3);
shell->render_buf = g_malloc (GIMP_RENDER_BUF_WIDTH *
GIMP_RENDER_BUF_HEIGHT *
3);
shell->title_idle_id = 0;
......
......@@ -51,6 +51,7 @@
#include "widgets/gimpdevicestatus.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdnd.h"
#include "widgets/gimprender.h"
#include "widgets/gimphelp.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
......@@ -392,7 +393,8 @@ gui_restore_callback (Gimp *gimp,
actions_init (gimp);
menus_init (gimp, global_action_factory);
render_init (gimp);
gimp_render_init (gimp);
gimp_display_shell_render_init (gimp);
dialogs_init (gimp, global_menu_factory);
......@@ -508,7 +510,8 @@ gui_exit_after_callback (Gimp *gimp,
session_exit (gimp);
menus_exit (gimp);
actions_exit (gimp);
render_exit (gimp);
gimp_display_shell_render_exit (gimp);
gimp_render_exit (gimp);
dialogs_exit (gimp);
gimp_controllers_exit (gimp);
......
......@@ -207,6 +207,8 @@ libappwidgets_a_sources = \
gimpprogressdialog.h \
gimppropwidgets.c \
gimppropwidgets.h \
gimprender.c \
gimprender.h \
gimpsamplepointeditor.c \
gimpsamplepointeditor.h \
gimpselectiondata.c \
......
......@@ -36,11 +36,6 @@
#include "widgets-types.h"
#ifdef __GNUC__
#warning FIXME #include "display/display-types.h"
#endif
#include "display/display-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
......@@ -48,10 +43,9 @@
#include "core/gimpimage-colormap.h"
#include "core/gimpmarshal.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpcolormapeditor.h"
#include "gimpdnd.h"
#include "gimprender.h"
#include "gimpmenufactory.h"
#include "gimpuimanager.h"
......@@ -472,8 +466,8 @@ gimp_colormap_editor_draw (GimpColormapEditor *editor)
row[l * 3 + b] = (((((i * cellsize + k) & 0x4) ?
(l) :
(l + 0x4)) & 0x4) ?
render_blend_light_check[0] :
render_blend_dark_check[0]);
gimp_render_blend_light_check[0] :
gimp_render_blend_dark_check[0]);
gtk_preview_draw_row (GTK_PREVIEW (editor->preview), row, 0,
i * cellsize + k,
......@@ -583,7 +577,7 @@ gimp_colormap_editor_clear (GimpColormapEditor *editor,
{
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
((j + offset) & 0x4) ?
render_blend_dark_check[0] : render_blend_light_check[0];
gimp_render_blend_dark_check[0] : gimp_render_blend_light_check[0];
}
for (j = 0; j < (4 - (start_row & 0x3)) && start_row + j < height; j++)
......@@ -601,7 +595,7 @@ gimp_colormap_editor_clear (GimpColormapEditor *editor,
{
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
((j + offset) & 0x4) ?
render_blend_dark_check[0] : render_blend_light_check[0];
gimp_render_blend_dark_check[0] : gimp_render_blend_light_check[0];
}
for (j = 0; j < 4 && i + j < height; j++)
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "widgets-types.h"
#include "core/gimp.h"