diff options
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkdraw.c | 2 | ||||
-rw-r--r-- | gdk/gdkpixbuf-drawable.c | 36 | ||||
-rw-r--r-- | gdk/gdkpixbuf-render.c | 1 | ||||
-rw-r--r-- | gdk/makefile.msc | 4 | ||||
-rw-r--r-- | gdk/win32/gdkdrawable-win32.c | 4 | ||||
-rw-r--r-- | gdk/win32/gdkevents-win32.c | 2 | ||||
-rw-r--r-- | gdk/win32/gdkimage-win32.c | 137 | ||||
-rw-r--r-- | gdk/win32/gdkpixmap-win32.c | 20 | ||||
-rw-r--r-- | gdk/win32/gdkprivate-win32.h | 9 | ||||
-rw-r--r-- | gdk/win32/makefile.msc | 3 |
10 files changed, 175 insertions, 43 deletions
diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index c7882c577..cc1299e37 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -1253,7 +1253,7 @@ gdk_drawable_real_draw_pixbuf (GdkDrawable *drawable, width1, height1); (*composite_func) (pixbuf->pixels + (src_y + y0) * pixbuf->rowstride + (src_x + x0) * 4, pixbuf->rowstride, - image->mem + ys0 * image->bpl + xs0 * image->bpp, + (guchar*)image->mem + ys0 * image->bpl + xs0 * image->bpp, image->bpl, visual->byte_order, width1, height1); diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c index bfb0d941d..ce7319acd 100644 --- a/gdk/gdkpixbuf-drawable.c +++ b/gdk/gdkpixbuf-drawable.c @@ -72,7 +72,7 @@ bitmap1 (GdkImage *image, int bpl; register guint8 data; guint8 *o; - guint8 *srow = image->mem + y1 * image->bpl, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl, *orow = pixels; d (printf ("bitmap, no alpha\n")); @@ -128,7 +128,7 @@ bitmap1a (GdkImage *image, int bpl; register guint8 data; guint8 *o; - guint8 *srow = image->mem + y1 * image->bpl, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl, *orow = pixels; d (printf ("bitmap, with alpha\n")); @@ -183,7 +183,7 @@ rgb1 (GdkImage *image, int bpl; register guint8 data; guint8 *o; - guint8 *srow = image->mem + y1 * image->bpl, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl, *orow = pixels; d (printf ("1 bits/pixel\n")); @@ -231,7 +231,7 @@ rgb1a (GdkImage *image, int bpl; register guint8 data; guint8 *o; - guint8 *srow = image->mem + y1 * image->bpl, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl, *orow = pixels; d (printf ("1 bits/pixel\n")); @@ -279,7 +279,7 @@ rgb8 (GdkImage *image, int bpl; guint32 mask; register guint32 data; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; register guint8 *s; register guint8 *o; @@ -326,7 +326,7 @@ rgb8a (GdkImage *image, guint32 remap[256]; register guint8 *s; /* read 2 pixels at once */ register guint32 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -387,7 +387,7 @@ rgb565lsb (GdkImage *image, register guint8 *s; /* read 2 pixels at once */ #endif register guint16 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -490,7 +490,7 @@ rgb565msb (GdkImage *image, register guint32 *s; /* read 2 pixels at once */ #endif register guint16 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -596,7 +596,7 @@ rgb565alsb (GdkImage *image, #endif register guint32 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -659,7 +659,7 @@ rgb565amsb (GdkImage *image, #endif register guint32 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -717,7 +717,7 @@ rgb555lsb (GdkImage *image, register guint8 *s; /* read 2 pixels at once */ #endif register guint16 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -821,7 +821,7 @@ rgb555msb (GdkImage *image, register guint32 *s; /* read 2 pixels at once */ #endif register guint16 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -922,7 +922,7 @@ rgb555alsb (GdkImage *image, #endif register guint32 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -985,7 +985,7 @@ rgb555amsb (GdkImage *image, #endif register guint32 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -1039,7 +1039,7 @@ rgb888alsb (GdkImage *image, guint8 *s; /* for byte order swapping */ guint8 *o; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; bpl = image->bpl; @@ -1076,7 +1076,7 @@ rgb888lsb (GdkImage *image, int xx, yy; int bpl; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; guint8 *o, *s; bpl = image->bpl; @@ -1112,7 +1112,7 @@ rgb888amsb (GdkImage *image, int xx, yy; int bpl; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; #ifdef LITTLE guint32 *o; guint32 *s; @@ -1166,7 +1166,7 @@ rgb888msb (GdkImage *image, int xx, yy; int bpl; - guint8 *srow = image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; + guint8 *srow = (guint8*)image->mem + y1 * image->bpl + x1 * image->bpp, *orow = pixels; guint8 *s; guint8 *o; diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c index daaf6b31b..fdbbbb76e 100644 --- a/gdk/gdkpixbuf-render.c +++ b/gdk/gdkpixbuf-render.c @@ -22,6 +22,7 @@ #include <config.h> #include <gdk/gdk.h> +#include "gdkinternals.h" /* _gdk_draw_pixbuf() */ #include "gdk-pixbuf-private.h" #include "gdkpixbuf.h" diff --git a/gdk/makefile.msc b/gdk/makefile.msc index 544ae1bbd..6ddcb2a7e 100644 --- a/gdk/makefile.msc +++ b/gdk/makefile.msc @@ -40,7 +40,8 @@ GDK_PIXBUF_VER=$(GTK_VER) PERL = perl !ENDIF -CFLAGS = -I . -I .. $(GLIB_CFLAGS) $(PANGO_CFLAGS) -I ../gdk-pixbuf \ +CFLAGS = -FImsvc_recommended_pragmas.h -I . -I .. \ + $(GLIB_CFLAGS) $(PANGO_CFLAGS) -I ../gdk-pixbuf \ $(G_DEBUGGING) -DHAVE_CONFIG_H -DGDK_ENABLE_BROKEN -DGDK_VERSION=\"$(GTK_VER)\" EXTRALIBS = $(WTKIT)\lib\i386\wntab32x.lib $(GLIB_LIBS) \ ..\gdk-pixbuf\gdk_pixbuf-$(GDK_PIXBUF_VER).lib $(PANGOWIN32_LIBS) @@ -88,7 +89,6 @@ gdk_public_h_sources = \ gdk.h \ gdkcolor.h \ gdkcursor.h \ - gdkcursors.h \ gdkdnd.h \ gdkdrawable.h \ gdkevents.h \ diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c index 8350525ea..4f94df329 100644 --- a/gdk/win32/gdkdrawable-win32.c +++ b/gdk/win32/gdkdrawable-win32.c @@ -176,6 +176,8 @@ gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass) drawable_class->get_visual = gdk_win32_get_visual; drawable_class->get_image = _gdk_win32_get_image; + + drawable_class->_copy_to_image = _gdk_win32_copy_to_image; } static void @@ -1026,7 +1028,7 @@ gdk_win32_draw_image (GdkDrawable *drawable, hdc = gdk_win32_hdc_get (drawable, gc, 0); - if (image->visual->type == GDK_VISUAL_PSEUDO_COLOR && + if (image->visual && image->visual->type == GDK_VISUAL_PSEUDO_COLOR && colormap_private && colormap_private->xcolormap->rc_palette) { if (!bmi_inited) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 6ffb91436..3c8a0af8a 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -2559,7 +2559,7 @@ gdk_event_translate (GdkEvent *event, break; } - colormap = GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap; + colormap = gdk_drawable_get_colormap (window); if (colormap) colormap_private = GDK_COLORMAP_PRIVATE_DATA (colormap); hdc = (HDC) msg->wParam; diff --git a/gdk/win32/gdkimage-win32.c b/gdk/win32/gdkimage-win32.c index 0c3b51d4a..8d2bf900a 100644 --- a/gdk/win32/gdkimage-win32.c +++ b/gdk/win32/gdkimage-win32.c @@ -191,14 +191,15 @@ _gdk_windowing_image_init (void) } GdkImage* -gdk_image_new (GdkImageType type, - GdkVisual *visual, - gint width, - gint height) +_gdk_image_new_for_depth (GdkImageType type, + GdkVisual *visual, + gint width, + gint height, + gint depth) { GdkImage *image; GdkImagePrivateWin32 *private; - Visual *xvisual; + Visual *xvisual = NULL; struct { BITMAPINFOHEADER bmiHeader; union { @@ -210,6 +211,12 @@ gdk_image_new (GdkImageType type, UINT iUsage; int i; + g_return_val_if_fail (!visual || GDK_IS_VISUAL (visual), NULL); + g_return_val_if_fail (visual || depth != -1, NULL); + + if (visual) + depth = visual->depth; + if (type == GDK_IMAGE_FASTEST || type == GDK_IMAGE_NORMAL) type = GDK_IMAGE_SHARED; @@ -225,9 +232,10 @@ gdk_image_new (GdkImageType type, image->visual = visual; image->width = width; image->height = height; - image->depth = visual->depth; + image->depth = depth; - xvisual = ((GdkVisualPrivate*) visual)->xvisual; + if (visual) + xvisual = ((GdkVisualPrivate*) visual)->xvisual; bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER); bmi.bmiHeader.biWidth = width; @@ -247,7 +255,8 @@ gdk_image_new (GdkImageType type, bmi.bmiHeader.biClrUsed = 0; bmi.bmiHeader.biClrImportant = 0; - if (image->visual->type == GDK_VISUAL_PSEUDO_COLOR) + if ( (image->visual && image->visual->type == GDK_VISUAL_PSEUDO_COLOR) + || (8 == image->depth)) { iUsage = DIB_PAL_COLORS; for (i = 0; i < 256; i++) @@ -271,9 +280,9 @@ gdk_image_new (GdkImageType type, } else if (image->depth == 16) { - bmi.u.bmiMasks[0] = visual->red_mask; - bmi.u.bmiMasks[1] = visual->green_mask; - bmi.u.bmiMasks[2] = visual->blue_mask; + bmi.u.bmiMasks[0] = visual ? visual->red_mask : 0x0000F800; + bmi.u.bmiMasks[1] = visual ? visual->green_mask : 0x000007E0; + bmi.u.bmiMasks[2] = visual ? visual->blue_mask : 0x0000001F; } } @@ -321,6 +330,16 @@ gdk_image_new (GdkImageType type, } GdkImage* +gdk_image_new (GdkImageType type, + GdkVisual *visual, + gint width, + gint height) +{ + return _gdk_image_new_for_depth (type, visual, width, height, -1); +} + + +GdkImage* _gdk_win32_get_image (GdkDrawable *drawable, gint x, gint y, @@ -401,7 +420,7 @@ _gdk_win32_get_image (GdkDrawable *drawable, return NULL; } image->depth = gdk_visual_get_system ()->depth; - if (image->visual->type == GDK_VISUAL_PSEUDO_COLOR) + if (image->visual && image->visual->type == GDK_VISUAL_PSEUDO_COLOR) { iUsage = DIB_PAL_COLORS; for (i = 0; i < 256; i++) @@ -563,6 +582,87 @@ _gdk_win32_get_image (GdkDrawable *drawable, return image; } +GdkImage* +_gdk_win32_copy_to_image (GdkDrawable *drawable, + GdkImage *image, + gint src_x, + gint src_y, + gint dest_x, + gint dest_y, + gint width, + gint height) +{ + GdkImagePrivateWin32 *private; + GdkDrawableImplWin32 *impl; + GdkVisual *visual; + GdkGC *gc = NULL; + gboolean ok = TRUE, is_window_impl; + HBITMAP holdbmp = NULL; + HDC src_dc = NULL, dest_dc = NULL; + + g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable), NULL); + g_return_val_if_fail (image != NULL || (dest_x == 0 && dest_y == 0), NULL); + + visual = gdk_drawable_get_visual (drawable); + impl = GDK_DRAWABLE_IMPL_WIN32 (drawable); + is_window_impl = GDK_IS_WINDOW_IMPL_WIN32 (drawable); + + if (!image && !is_window_impl) + return _gdk_win32_get_image (drawable, src_x, src_y, width, height); + + if (!image) + image = _gdk_image_new_for_depth (GDK_IMAGE_FASTEST, visual, width, height, -1); + + private = IMAGE_PRIVATE_DATA (image); + + if (is_window_impl) + src_dc = GetDC (impl->handle); + else + { + gc = gdk_gc_new (drawable); + src_dc = gdk_win32_hdc_get (drawable, gc, 0); + } + ok = !!src_dc; + + if (ok) + { + dest_dc = CreateCompatibleDC (NULL); + ok = !!dest_dc; + } + + if (ok) + { + holdbmp = SelectObject (dest_dc, private->hbitmap); + ok = !!holdbmp; + } + + if (ok && !BitBlt (dest_dc, dest_x, dest_y, width, height, + src_dc, src_x, src_y, SRCCOPY)) + WIN32_GDI_FAILED ("BitBlt"); + + if (is_window_impl) + { + if (src_dc && !ReleaseDC (impl->handle, src_dc)) + WIN32_GDI_FAILED ("ReleaseDC"); + } + else + { + gdk_win32_hdc_release (drawable, gc, 0); + g_object_unref (gc); + } + + if (dest_dc) + { + if (holdbmp) + SelectObject (dest_dc, holdbmp); + if (!DeleteDC (dest_dc)) + WIN32_GDI_FAILED ("DeleteDC"); + } + g_return_val_if_fail (ok, image); + + return image; +} + guint32 gdk_image_get_pixel (GdkImage *image, gint x, @@ -677,3 +777,16 @@ gdk_win32_image_destroy (GdkImage *image) image->windowing_data = NULL; } +gint +_gdk_windowing_get_bits_for_depth (gint depth) +{ + if ((1 == depth) || (8 == depth) || (16 == depth) || + (24 == depth) || (32 == depth)) + return depth; + else if (15 == depth) + return 16; + else + g_assert_not_reached (); + + return 0; +} diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c index f23d42b5b..2902383eb 100644 --- a/gdk/win32/gdkpixmap-win32.c +++ b/gdk/win32/gdkpixmap-win32.c @@ -134,6 +134,8 @@ gdk_pixmap_new (GdkWindow *window, GdkDrawableImplWin32 *draw_impl; GdkPixmapImplWin32 *pix_impl; GdkVisual *visual; + GdkColormap *cmap = NULL; + gint window_depth; struct { BITMAPINFOHEADER bmiHeader; @@ -174,8 +176,9 @@ gdk_pixmap_new (GdkWindow *window, visual = gdk_drawable_get_visual (window); + window_depth = gdk_drawable_get_depth (GDK_DRAWABLE (window)); if (depth == -1) - depth = gdk_drawable_get_depth (GDK_DRAWABLE (window)); + depth = window_depth; GDK_NOTE (MISC, g_print ("gdk_pixmap_new: %dx%dx%d\n", width, height, depth)); @@ -228,15 +231,9 @@ gdk_pixmap_new (GdkWindow *window, bmi.u.bmiColors[1].rgbRed = 0xFF; bmi.u.bmiColors[1].rgbReserved = 0x00; draw_impl->colormap = NULL; - GDK_NOTE (MISC, g_print ("... colormap NULL\n")); } else { - draw_impl->colormap = GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap; - if (draw_impl->colormap == NULL) - draw_impl->colormap = gdk_colormap_get_system (); - GDK_NOTE (MISC, g_print ("... colormap %p\n", draw_impl->colormap)); - if (depth == 8) { iUsage = DIB_PAL_COLORS; @@ -267,6 +264,15 @@ gdk_pixmap_new (GdkWindow *window, } ReleaseDC (GDK_WINDOW_HWND (window), hdc); + if (depth == window_depth) + { + cmap = gdk_drawable_get_colormap (window); + if (cmap) + gdk_drawable_set_colormap (pixmap, cmap); + } + + GDK_NOTE (MISC, g_print ("... colormap %p\n", cmap)); + GDK_NOTE (MISC, g_print ("... = %#x\n", (guint) GDK_PIXMAP_HBITMAP (pixmap))); diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index dac35be8d..a23847517 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -365,6 +365,15 @@ GdkImage* _gdk_win32_get_image (GdkDrawable *drawable, gint width, gint height); +GdkImage *_gdk_win32_copy_to_image (GdkDrawable *drawable, + GdkImage *image, + gint src_x, + gint src_y, + gint dest_x, + gint dest_y, + gint width, + gint height); + COLORREF _gdk_win32_colormap_color (GdkColormap *colormap, gulong pixel); diff --git a/gdk/win32/makefile.msc b/gdk/win32/makefile.msc index d1031932c..360790adb 100644 --- a/gdk/win32/makefile.msc +++ b/gdk/win32/makefile.msc @@ -13,7 +13,8 @@ TOP = ../../.. GTK_VER=1.3 -CFLAGS = -I. -I.. -I..\.. $(GLIB_CFLAGS) $(PANGO_CFLAGS) \ +CFLAGS = -FImsvc_recommended_pragmas.h \ + -I. -I.. -I..\.. $(GLIB_CFLAGS) $(PANGO_CFLAGS) \ -I$(WTKIT)\include -I$(GLIB) \ $(G_DEBUGGING) -DHAVE_CONFIG_H -DINSIDE_GDK_WIN32 -DGDK_VERSION=\"$(GTK_VER)\" |