Fix for #111028, thanks to J. Ali Harlow, who writes: I found that the

2003-06-28  Tor Lillqvist  <tml@iki.fi>

	Fix for #111028, thanks to J. Ali Harlow, who writes:
	I found that the GdkPixmap->GdkImage reference really isn't
	important. It's only really there to have somewhere convenient to
	store the location of the pixel data in the pixmap and as an easy
	way of accessing the dimensions of that data. I have therefore put
	together a fix which removes this reference entirely which seems
	to solve the problem.

	* gdk/win32/gdkpixmap-win32.h (struct _GdkPixmapImplWin32):
	Instead of a pointer to a GdkImage, keep a pointer to the pixels
	directly.

	* gdk/win32/gdkimage-win32.c (_gdk_win32_setup_pixmap_image): Remove.
	(_gdk_win32_new_image): New function, replacing the above. Creates
	a GdkImage without any associated GdkPixmap.
	(gdk_image_new_bitmap, _gdk_image_new_for_depth): Use it instead.

	* gdk/win32/gdkprivate-win32.h: Remove from here, too.

	* gdk/win32/gdkcursor-win32.c (gdk_cursor_new_from_pixmap)
	* gdk/win32/gdkdrawable-win32.c (blit_from_pixmap)
	* gdk/win32/gdkgc-win32.c (_gdk_win32_bitmap_to_hrgn)
	* gdk/win32/gdkmain-win32.c (_gdk_win32_drawable_description):
	* gdk/win32/gdkpixmap-win32.c (gdk_pixmap_impl_win32_finalize,
	gdk_pixmap_new, gdk_bitmap_create_from_data, gdk_pixmap_foreign_new)
	Corresponding changes.
This commit is contained in:
Tor Lillqvist 2003-06-28 01:12:51 +00:00 committed by Tor Lillqvist
parent 8597f10089
commit 323bcc614d
13 changed files with 212 additions and 65 deletions

View File

@ -1,3 +1,32 @@
2003-06-28 Tor Lillqvist <tml@iki.fi>
Fix for #111028, thanks to J. Ali Harlow, who writes:
I found that the GdkPixmap->GdkImage reference really isn't
important. It's only really there to have somewhere convenient to
store the location of the pixel data in the pixmap and as an easy
way of accessing the dimensions of that data. I have therefore put
together a fix which removes this reference entirely which seems
to solve the problem.
* gdk/win32/gdkpixmap-win32.h (struct _GdkPixmapImplWin32):
Instead of a pointer to a GdkImage, keep a pointer to the pixels
directly.
* gdk/win32/gdkimage-win32.c (_gdk_win32_setup_pixmap_image): Remove.
(_gdk_win32_new_image): New function, replacing the above. Creates
a GdkImage without any associated GdkPixmap.
(gdk_image_new_bitmap, _gdk_image_new_for_depth): Use it instead.
* gdk/win32/gdkprivate-win32.h: Remove from here, too.
* gdk/win32/gdkcursor-win32.c (gdk_cursor_new_from_pixmap)
* gdk/win32/gdkdrawable-win32.c (blit_from_pixmap)
* gdk/win32/gdkgc-win32.c (_gdk_win32_bitmap_to_hrgn)
* gdk/win32/gdkmain-win32.c (_gdk_win32_drawable_description):
* gdk/win32/gdkpixmap-win32.c (gdk_pixmap_impl_win32_finalize,
gdk_pixmap_new, gdk_bitmap_create_from_data, gdk_pixmap_foreign_new)
Corresponding changes.
Thu Jun 26 21:41:16 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeviewcolumn.c

View File

@ -1,3 +1,32 @@
2003-06-28 Tor Lillqvist <tml@iki.fi>
Fix for #111028, thanks to J. Ali Harlow, who writes:
I found that the GdkPixmap->GdkImage reference really isn't
important. It's only really there to have somewhere convenient to
store the location of the pixel data in the pixmap and as an easy
way of accessing the dimensions of that data. I have therefore put
together a fix which removes this reference entirely which seems
to solve the problem.
* gdk/win32/gdkpixmap-win32.h (struct _GdkPixmapImplWin32):
Instead of a pointer to a GdkImage, keep a pointer to the pixels
directly.
* gdk/win32/gdkimage-win32.c (_gdk_win32_setup_pixmap_image): Remove.
(_gdk_win32_new_image): New function, replacing the above. Creates
a GdkImage without any associated GdkPixmap.
(gdk_image_new_bitmap, _gdk_image_new_for_depth): Use it instead.
* gdk/win32/gdkprivate-win32.h: Remove from here, too.
* gdk/win32/gdkcursor-win32.c (gdk_cursor_new_from_pixmap)
* gdk/win32/gdkdrawable-win32.c (blit_from_pixmap)
* gdk/win32/gdkgc-win32.c (_gdk_win32_bitmap_to_hrgn)
* gdk/win32/gdkmain-win32.c (_gdk_win32_drawable_description):
* gdk/win32/gdkpixmap-win32.c (gdk_pixmap_impl_win32_finalize,
gdk_pixmap_new, gdk_bitmap_create_from_data, gdk_pixmap_foreign_new)
Corresponding changes.
Thu Jun 26 21:41:16 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeviewcolumn.c

View File

@ -1,3 +1,32 @@
2003-06-28 Tor Lillqvist <tml@iki.fi>
Fix for #111028, thanks to J. Ali Harlow, who writes:
I found that the GdkPixmap->GdkImage reference really isn't
important. It's only really there to have somewhere convenient to
store the location of the pixel data in the pixmap and as an easy
way of accessing the dimensions of that data. I have therefore put
together a fix which removes this reference entirely which seems
to solve the problem.
* gdk/win32/gdkpixmap-win32.h (struct _GdkPixmapImplWin32):
Instead of a pointer to a GdkImage, keep a pointer to the pixels
directly.
* gdk/win32/gdkimage-win32.c (_gdk_win32_setup_pixmap_image): Remove.
(_gdk_win32_new_image): New function, replacing the above. Creates
a GdkImage without any associated GdkPixmap.
(gdk_image_new_bitmap, _gdk_image_new_for_depth): Use it instead.
* gdk/win32/gdkprivate-win32.h: Remove from here, too.
* gdk/win32/gdkcursor-win32.c (gdk_cursor_new_from_pixmap)
* gdk/win32/gdkdrawable-win32.c (blit_from_pixmap)
* gdk/win32/gdkgc-win32.c (_gdk_win32_bitmap_to_hrgn)
* gdk/win32/gdkmain-win32.c (_gdk_win32_drawable_description):
* gdk/win32/gdkpixmap-win32.c (gdk_pixmap_impl_win32_finalize,
gdk_pixmap_new, gdk_bitmap_create_from_data, gdk_pixmap_foreign_new)
Corresponding changes.
Thu Jun 26 21:41:16 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeviewcolumn.c

View File

@ -1,3 +1,32 @@
2003-06-28 Tor Lillqvist <tml@iki.fi>
Fix for #111028, thanks to J. Ali Harlow, who writes:
I found that the GdkPixmap->GdkImage reference really isn't
important. It's only really there to have somewhere convenient to
store the location of the pixel data in the pixmap and as an easy
way of accessing the dimensions of that data. I have therefore put
together a fix which removes this reference entirely which seems
to solve the problem.
* gdk/win32/gdkpixmap-win32.h (struct _GdkPixmapImplWin32):
Instead of a pointer to a GdkImage, keep a pointer to the pixels
directly.
* gdk/win32/gdkimage-win32.c (_gdk_win32_setup_pixmap_image): Remove.
(_gdk_win32_new_image): New function, replacing the above. Creates
a GdkImage without any associated GdkPixmap.
(gdk_image_new_bitmap, _gdk_image_new_for_depth): Use it instead.
* gdk/win32/gdkprivate-win32.h: Remove from here, too.
* gdk/win32/gdkcursor-win32.c (gdk_cursor_new_from_pixmap)
* gdk/win32/gdkdrawable-win32.c (blit_from_pixmap)
* gdk/win32/gdkgc-win32.c (_gdk_win32_bitmap_to_hrgn)
* gdk/win32/gdkmain-win32.c (_gdk_win32_drawable_description):
* gdk/win32/gdkpixmap-win32.c (gdk_pixmap_impl_win32_finalize,
gdk_pixmap_new, gdk_bitmap_create_from_data, gdk_pixmap_foreign_new)
Corresponding changes.
Thu Jun 26 21:41:16 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeviewcolumn.c

View File

@ -1,3 +1,32 @@
2003-06-28 Tor Lillqvist <tml@iki.fi>
Fix for #111028, thanks to J. Ali Harlow, who writes:
I found that the GdkPixmap->GdkImage reference really isn't
important. It's only really there to have somewhere convenient to
store the location of the pixel data in the pixmap and as an easy
way of accessing the dimensions of that data. I have therefore put
together a fix which removes this reference entirely which seems
to solve the problem.
* gdk/win32/gdkpixmap-win32.h (struct _GdkPixmapImplWin32):
Instead of a pointer to a GdkImage, keep a pointer to the pixels
directly.
* gdk/win32/gdkimage-win32.c (_gdk_win32_setup_pixmap_image): Remove.
(_gdk_win32_new_image): New function, replacing the above. Creates
a GdkImage without any associated GdkPixmap.
(gdk_image_new_bitmap, _gdk_image_new_for_depth): Use it instead.
* gdk/win32/gdkprivate-win32.h: Remove from here, too.
* gdk/win32/gdkcursor-win32.c (gdk_cursor_new_from_pixmap)
* gdk/win32/gdkdrawable-win32.c (blit_from_pixmap)
* gdk/win32/gdkgc-win32.c (_gdk_win32_bitmap_to_hrgn)
* gdk/win32/gdkmain-win32.c (_gdk_win32_drawable_description):
* gdk/win32/gdkpixmap-win32.c (gdk_pixmap_impl_win32_finalize,
gdk_pixmap_new, gdk_bitmap_create_from_data, gdk_pixmap_foreign_new)
Corresponding changes.
Thu Jun 26 21:41:16 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtktreeviewcolumn.c

View File

@ -129,7 +129,8 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
GdkCursorPrivate *private;
GdkCursor *cursor;
GdkPixmapImplWin32 *source_impl, *mask_impl;
GdkImage *source_image, *mask_image;
guchar *source_bits, *mask_bits;
gint source_bpl, mask_bpl;
HCURSOR hcursor;
guchar *p, *q, *xor_mask, *and_mask;
gint width, height, cursor_width, cursor_height;
@ -158,12 +159,16 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
residue = (1 << ((8-(width%8))%8)) - 1;
source_image = source_impl->image;
mask_image = mask_impl->image;
source_bits = source_impl->bits;
mask_bits = mask_impl->bits;
g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
g_return_val_if_fail (GDK_PIXMAP_OBJECT (source)->depth == 1
&& GDK_PIXMAP_OBJECT (mask)->depth == 1,
NULL);
source_bpl = ((width - 1)/32 + 1)*4;
mask_bpl = ((mask_impl->width - 1)/32 + 1)*4;
#ifdef G_ENABLE_DEBUG
if (_gdk_debug_flags & GDK_DEBUG_CURSOR)
{
@ -174,7 +179,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
if (iy == 16)
break;
p = (guchar *) source_image->mem + iy*source_image->bpl;
p = source_bits + iy*source_bpl;
for (ix = 0; ix < width; ix++)
{
if (ix == 79)
@ -191,7 +196,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
if (iy == 16)
break;
p = (guchar *) mask_image->mem + iy*source_image->bpl;
p = mask_bits + iy*source_bpl;
for (ix = 0; ix < width; ix++)
{
if (ix == 79)
@ -222,8 +227,8 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
*/
for (iy = 0; iy < height; iy++)
{
p = (guchar *) source_image->mem + iy*source_image->bpl;
q = (guchar *) mask_image->mem + iy*mask_image->bpl;
p = source_bits + iy*source_bpl;
q = mask_bits + iy*mask_bpl;
for (ix = 0; ix < ((width-1)/8+1); ix++)
if (bg_is_white)
@ -237,7 +242,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
for (iy = 0; iy < height; iy++)
{
p = (guchar *) source_image->mem + iy*source_image->bpl;
p = source_bits + iy*source_bpl;
q = xor_mask + iy*cursor_width/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
@ -255,7 +260,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
for (iy = 0; iy < height; iy++)
{
p = (guchar *) mask_image->mem + iy*mask_image->bpl;
p = mask_bits + iy*mask_bpl;
q = and_mask + iy*cursor_width/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)

View File

@ -1450,13 +1450,13 @@ blit_from_pixmap (gboolean use_fg_bg,
WIN32_GDI_FAILED ("SelectObject");
else
{
if (src->image->depth <= 8)
if (GDK_PIXMAP_OBJECT (src->parent_instance.wrapper)->depth <= 8)
{
/* Blitting from a 1, 4 or 8-bit pixmap */
if ((oldtable_size = GetDIBColorTable (srcdc, 0, 256, oldtable)) == 0)
WIN32_GDI_FAILED ("GetDIBColorTable");
else if (src->image->depth == 1)
else if (GDK_PIXMAP_OBJECT (src->parent_instance.wrapper)->depth == 1)
{
/* Blitting from an 1-bit pixmap */
@ -1472,9 +1472,9 @@ blit_from_pixmap (gboolean use_fg_bg,
bgix = 0;
fgix = 1;
}
if (GDK_IS_PIXMAP_IMPL_WIN32 (dest) &&
((GdkPixmapImplWin32 *) dest)->image->depth <= 8)
GDK_PIXMAP_OBJECT (dest->wrapper)->depth <= 8)
{
/* Destination is also pixmap, get fg and bg from
* its palette. Either use the foreground and

View File

@ -1079,12 +1079,17 @@ _gdk_win32_bitmap_to_hrgn (GdkPixmap *pixmap)
HRGN h;
DWORD maxRects;
RGNDATA *pData;
GdkImage *image;
guchar *bits;
gint width, height, bpl;
guchar *p;
gint x, y;
image = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
g_assert (image->depth == 1);
g_assert (GDK_PIXMAP_OBJECT(pixmap)->depth == 1);
bits = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->bits;
width = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->width;
height = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->height;
bpl = ((width - 1)/32 + 1)*4;
/* For better performances, we will use the ExtCreateRegion()
* function to create the region. This function take a RGNDATA
@ -1100,15 +1105,15 @@ _gdk_win32_bitmap_to_hrgn (GdkPixmap *pixmap)
pData->rdh.nCount = pData->rdh.nRgnSize = 0;
SetRect (&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);
for (y = 0; y < image->height; y++)
for (y = 0; y < height; y++)
{
/* Scan each bitmap row from left to right*/
p = (guchar *) image->mem + y * image->bpl;
for (x = 0; x < image->width; x++)
p = (guchar *) bits + y * bpl;
for (x = 0; x < width; x++)
{
/* Search for a continuous range of "non transparent pixels"*/
gint x0 = x;
while (x < image->width)
while (x < width)
{
if ((((p[x/8])>>(7-(x%8)))&1) == 0)
/* This pixel is "transparent"*/

View File

@ -104,20 +104,24 @@ _gdk_image_exit (void)
}
}
GdkImage *
_gdk_win32_setup_pixmap_image (GdkPixmap *pixmap,
GdkDrawable *drawable,
gint width,
gint height,
gint depth,
guchar *bits)
/*
* Create a GdkImage _without_ an associated GdkPixmap. The caller is
* responsible for creating a GdkPixmap object and making the association.
*/
static GdkImage *
_gdk_win32_new_image (GdkVisual *visual,
gint width,
gint height,
gint depth,
guchar *bits)
{
GdkImage *image;
image = g_object_new (gdk_image_get_type (), NULL);
image->windowing_data = pixmap;
image->windowing_data = NULL;
image->type = GDK_IMAGE_SHARED;
image->visual = gdk_drawable_get_visual (drawable);
image->visual = visual;
image->byte_order = GDK_LSB_FIRST;
image->width = width;
image->height = height;
@ -143,7 +147,7 @@ _gdk_win32_setup_pixmap_image (GdkPixmap *pixmap,
image->bpp = 4;
break;
default:
g_warning ("_gdk_win32_setup_pixmap_image: depth=%d", image->depth);
g_warning ("_gdk_win32_new_image: depth=%d", image->depth);
g_assert_not_reached ();
}
if (depth == 1)
@ -166,6 +170,7 @@ gdk_image_new_bitmap (GdkVisual *visual,
{
GdkPixmap *pixmap;
GdkImage *image;
guchar *bits;
gint data_bpl = (w-1)/8 + 1;
gint i;
@ -174,10 +179,12 @@ gdk_image_new_bitmap (GdkVisual *visual,
if (pixmap == NULL)
return NULL;
image = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
GDK_NOTE (IMAGE, g_print ("gdk_image_new_bitmap: %dx%d=%p\n",
w, h, GDK_PIXMAP_HBITMAP (pixmap)));
bits = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->bits;
image = _gdk_win32_new_image (visual, w, h, 1, bits);
image->windowing_data = pixmap;
if (data_bpl != image->bpl)
{
@ -205,6 +212,8 @@ _gdk_image_new_for_depth (GdkScreen *screen,
gint depth)
{
GdkPixmap *pixmap;
GdkImage *image;
guchar *bits;
g_return_val_if_fail (!visual || GDK_IS_VISUAL (visual), NULL);
g_return_val_if_fail (visual || depth != -1, NULL);
@ -221,7 +230,11 @@ _gdk_image_new_for_depth (GdkScreen *screen,
GDK_NOTE (IMAGE, g_print ("_gdk_image_new_for_depth: %dx%dx%d=%p\n",
width, height, depth, GDK_PIXMAP_HBITMAP (pixmap)));
return GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
bits = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->bits;
image = _gdk_win32_new_image (visual, width, height, depth, bits);
image->windowing_data = pixmap;
return image;
}
GdkImage*

View File

@ -923,17 +923,16 @@ gchar *
_gdk_win32_drawable_description (GdkDrawable *d)
{
GdkVisual *v;
gint width, height;
gint width, height, depth;
gdk_drawable_get_size (d, &width, &height);
depth = gdk_drawable_get_depth (d);
return static_printf
("%s:%p:%dx%dx%d",
G_OBJECT_TYPE_NAME (d),
GDK_DRAWABLE_HANDLE (d),
width, height,
(GDK_IS_PIXMAP (d) ? GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (d)->impl)->image->depth
: ((v = gdk_drawable_get_visual (d)) ? v->depth : gdk_visual_get_system ()->depth)));
width, height, depth);
}
#endif /* G_ENABLE_DEBUG */

View File

@ -103,7 +103,6 @@ gdk_pixmap_impl_win32_finalize (GObject *object)
{
GdkPixmapImplWin32 *impl = GDK_PIXMAP_IMPL_WIN32 (object);
GdkPixmap *wrapper = GDK_PIXMAP (GDK_DRAWABLE_IMPL_WIN32 (impl)->wrapper);
GdkImage *image = impl->image;
GDK_NOTE (PIXMAP, g_print ("gdk_pixmap_impl_win32_finalize: %p\n",
GDK_PIXMAP_HBITMAP (wrapper)));
@ -113,9 +112,6 @@ gdk_pixmap_impl_win32_finalize (GObject *object)
gdk_win32_handle_table_remove (GDK_PIXMAP_HBITMAP (wrapper));
image->windowing_data = NULL;
g_object_unref (image);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -307,9 +303,7 @@ gdk_pixmap_new (GdkDrawable *drawable,
}
drawable_impl->handle = hbitmap;
pixmap_impl->image = _gdk_win32_setup_pixmap_image (pixmap, drawable,
width, height,
depth, bits);
pixmap_impl->bits = bits;
gdk_win32_handle_table_insert (&GDK_PIXMAP_HBITMAP (pixmap), pixmap);
@ -359,7 +353,7 @@ gdk_bitmap_create_from_data (GdkDrawable *drawable,
{
GdkPixmap *pixmap;
GdkPixmapImplWin32 *pixmap_impl;
gint i, j, data_bpl, image_bpl;
gint i, j, data_bpl, pixmap_bpl;
guchar *bits;
g_return_val_if_fail (data != NULL, NULL);
@ -378,13 +372,13 @@ gdk_bitmap_create_from_data (GdkDrawable *drawable,
return NULL;
pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
bits = pixmap_impl->image->mem;
bits = pixmap_impl->bits;
data_bpl = ((width - 1) / 8 + 1);
image_bpl = pixmap_impl->image->bpl;
pixmap_bpl = ((width - 1)/32 + 1)*4;
for (i = 0; i < height; i++)
for (j = 0; j < data_bpl; j++)
bits[i*image_bpl + j] = mirror[(guchar) data[i*data_bpl + j]];
bits[i*pixmap_bpl + j] = mirror[(guchar) data[i*data_bpl + j]];
GDK_NOTE (PIXMAP, g_print ("gdk_bitmap_create_from_data: %dx%d=%p\n",
width, height, GDK_PIXMAP_HBITMAP (pixmap)));
@ -481,11 +475,7 @@ gdk_pixmap_foreign_new (GdkNativeWindow anid)
draw_impl->colormap = NULL;
pix_impl->width = size.cx;
pix_impl->height = size.cy;
pix_impl->image =
_gdk_win32_setup_pixmap_image (pixmap, _gdk_parent_root,
size.cx, size.cy,
gdk_visual_get_system ()->depth,
NULL);
pix_impl->bits = NULL;
gdk_win32_handle_table_insert (&GDK_PIXMAP_HBITMAP (pixmap), pixmap);

View File

@ -53,10 +53,7 @@ struct _GdkPixmapImplWin32
gint width;
gint height;
GdkImage *image; /* A pointer to the GdkImage
* containing the pixels.
*/
guchar *bits;
guint is_foreign : 1;
};

View File

@ -337,13 +337,6 @@ GdkImage *_gdk_win32_copy_to_image (GdkDrawable *drawable,
gint width,
gint height);
GdkImage *_gdk_win32_setup_pixmap_image (GdkPixmap *pixmap,
GdkDrawable *drawable,
gint width,
gint height,
gint depth,
guchar *bits);
void _gdk_win32_blit (gboolean use_fg_bg,
GdkDrawableImplWin32 *drawable,
GdkGC *gc,