From 600fbd3e740f72a010ecf84780b07927f08d743f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 17 Jul 2010 04:50:49 +0200 Subject: [PATCH] API: remove gdk_draw_rectangle() --- docs/reference/gdk/gdk3-sections.txt | 1 - docs/reference/gdk/tmpl/drawing.sgml | 17 -- gdk/directfb/gdkdrawable-directfb.c | 153 ------------- gdk/gdk.symbols | 1 - gdk/gdkdraw.c | 50 ----- gdk/gdkdrawable.h | 14 -- gdk/gdkoffscreenwindow.c | 20 -- gdk/gdkpixmap.c | 24 -- gdk/gdkwindow.c | 26 --- gdk/quartz/gdkdrawable-quartz.c | 38 ---- gdk/win32/gdkdrawable-win32.c | 320 --------------------------- gdk/x11/gdkdrawable-x11.c | 29 --- 12 files changed, 693 deletions(-) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 0fd907b7d2..841fbffcf3 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -334,7 +334,6 @@ gdk_drawable_get_clip_region gdk_drawable_get_visible_region -gdk_draw_rectangle gdk_draw_layout_line gdk_draw_layout_line_with_colors gdk_draw_layout diff --git a/docs/reference/gdk/tmpl/drawing.sgml b/docs/reference/gdk/tmpl/drawing.sgml index fc5c18f5c6..866a7ab36c 100644 --- a/docs/reference/gdk/tmpl/drawing.sgml +++ b/docs/reference/gdk/tmpl/drawing.sgml @@ -127,23 +127,6 @@ or a #GdkWindow. @Returns: - - - - - - - - -@drawable: -@gc: -@filled: -@x: -@y: -@width: -@height: - - diff --git a/gdk/directfb/gdkdrawable-directfb.c b/gdk/directfb/gdkdrawable-directfb.c index 238e92e08e..0879c5b0fb 100644 --- a/gdk/directfb/gdkdrawable-directfb.c +++ b/gdk/directfb/gdkdrawable-directfb.c @@ -397,158 +397,6 @@ gdk_directfb_setup_for_drawing (GdkDrawableImplDirectFB *impl, return TRUE; } -static void -gdk_directfb_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height) -{ - GdkDrawableImplDirectFB *impl; - cairo_region_t clip; - GdkGCDirectFB *gc_private = NULL; - IDirectFBSurface *surface = NULL; - gint i; - - g_return_if_fail (GDK_IS_DRAWABLE (drawable)); - - D_DEBUG_AT( GDKDFB_Drawable, "%s( %p, %p, %s, %4d,%4d - %4dx%4d )\n", G_STRFUNC, - drawable, gc, filled ? " filled" : "outline", x, y, width, height ); - - impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable); - - if (!impl->surface) - return; - - if (gc) - gc_private = GDK_GC_DIRECTFB (gc); - - if (gc_private) - { - if (gdk_directfb_enable_color_keying && - (gc_private->values.foreground.red >> 8) == gdk_directfb_bg_color_key.r && - (gc_private->values.foreground.green >> 8) == gdk_directfb_bg_color_key.g && - (gc_private->values.foreground.blue >> 8) == gdk_directfb_bg_color_key.b) - { - if (DFB_PIXELFORMAT_IS_INDEXED (impl->format)) - impl->surface->SetColorIndex (impl->surface, 255); - else - impl->surface->SetColor (impl->surface, - gdk_directfb_bg_color.r, - gdk_directfb_bg_color.g, - gdk_directfb_bg_color.b, - gdk_directfb_bg_color.a); - } - else - { - if (!gdk_directfb_setup_for_drawing (impl, gc_private)){ - return; - } - } - } - else - { - GdkWindowObject *win = GDK_WINDOW_OBJECT (impl->wrapper); - - if (gdk_directfb_enable_color_keying) - { - if (DFB_PIXELFORMAT_IS_INDEXED (impl->format)) - impl->surface->SetColorIndex (impl->surface, 255); - else - impl->surface->SetColor (impl->surface, - gdk_directfb_bg_color.r, - gdk_directfb_bg_color.b, - gdk_directfb_bg_color.g, - gdk_directfb_bg_color.a); - } - else - { - gdk_directfb_set_color (impl, &win->bg_color, 0xFF); - } - } - - if (filled) - { - GdkRectangle rect = { x, y, width, height }; - - gdk_directfb_clip_region (drawable, gc, &rect, &clip); - - if (gc_private && gc_private->values_mask & GDK_GC_FILL) - { - if (gc_private->values.fill == GDK_STIPPLED && - gc_private->values_mask & GDK_GC_STIPPLE && - gc_private->values.stipple) - { - surface = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (gc_private->values.stipple)->impl)->surface; - - if (surface) - impl->surface->SetBlittingFlags (impl->surface, - (DSBLIT_BLEND_ALPHACHANNEL | - DSBLIT_COLORIZE)); - } - else if (gc_private->values.fill == GDK_TILED && - gc_private->values_mask & GDK_GC_TILE && - gc_private->values.tile) - { - surface = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (gc_private->values.tile)->impl)->surface; - - impl->surface->SetBlittingFlags (impl->surface, DSBLIT_NOFX); - } - } - - if (surface) - { - if (gc_private->values_mask & GDK_GC_TS_X_ORIGIN) - x = gc_private->values.ts_x_origin; - if (gc_private->values_mask & GDK_GC_TS_Y_ORIGIN) - y = gc_private->values.ts_y_origin; - - for (i = 0; i < clip.numRects; i++) - { - DFBRegion reg = { clip.rects[i].x1, clip.rects[i].y1, - clip.rects[i].x2, clip.rects[i].y2 }; - - impl->surface->SetClip (impl->surface, ®); - impl->surface->TileBlit (impl->surface, surface, NULL, x, y); - } - } - else /* normal rectangle filling */ - { - DFBRectangle rects[clip.numRects]; - - impl->surface->SetClip (impl->surface, NULL); - - for (i = 0; i < clip.numRects; i++) - { - cairo_region_tBox *box = &clip.rects[i]; - - rects[i].x = box->x1; - rects[i].y = box->y1; - rects[i].w = box->x2 - box->x1; - rects[i].h = box->y2 - box->y1; - } - - impl->surface->FillRectangles(impl->surface, rects, clip.numRects); - } - - temp_region_deinit( &clip ); - } - else - { - - DFBRegion region = { x, y, x + width, y + height }; - impl->surface->SetClip (impl->surface, ®ion); - - /* DirectFB does not draw rectangles the X way. Using DirectFB, - a filled Rectangle has the same size as a drawn one, while - X draws the rectangle one pixel taller and wider. */ - impl->surface->DrawRectangle (impl->surface, - x, y, width , height); - } -} - static void gdk_directfb_draw_drawable (GdkDrawable *drawable, GdkGC *gc, @@ -701,7 +549,6 @@ gdk_drawable_impl_directfb_class_init (GdkDrawableImplDirectFBClass *klass) object_class->finalize = gdk_drawable_impl_directfb_finalize; drawable_class->create_gc = _gdk_directfb_gc_new; - drawable_class->draw_rectangle = gdk_directfb_draw_rectangle; drawable_class->draw_drawable = gdk_directfb_draw_drawable; drawable_class->ref_cairo_surface = gdk_directfb_ref_cairo_surface; diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 1bc019af6d..ceb9753cd6 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -550,7 +550,6 @@ gdk_drawable_get_visible_region gdk_drawable_get_visual gdk_drawable_set_colormap gdk_draw_drawable -gdk_draw_rectangle #endif #endif diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c index 1051e44d57..90b44ba176 100644 --- a/gdk/gdkdraw.c +++ b/gdk/gdkdraw.c @@ -214,56 +214,6 @@ gdk_drawable_get_colormap (GdkDrawable *drawable) /* Drawing */ -/** - * gdk_draw_rectangle: - * @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap). - * @gc: a #GdkGC. - * @filled: %TRUE if the rectangle should be filled. - * @x: the x coordinate of the left edge of the rectangle. - * @y: the y coordinate of the top edge of the rectangle. - * @width: the width of the rectangle. - * @height: the height of the rectangle. - * - * Draws a rectangular outline or filled rectangle, using the foreground color - * and other attributes of the #GdkGC. - * - * A rectangle drawn filled is 1 pixel smaller in both dimensions than a - * rectangle outlined. Calling - * gdk_draw_rectangle (window, gc, TRUE, 0, 0, 20, 20) - * results in a filled rectangle 20 pixels wide and 20 pixels high. Calling - * gdk_draw_rectangle (window, gc, FALSE, 0, 0, 20, 20) - * results in an outlined rectangle with corners at (0, 0), (0, 20), (20, 20), - * and (20, 0), which makes it 21 pixels wide and 21 pixels high. - **/ -void -gdk_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height) -{ - g_return_if_fail (GDK_IS_DRAWABLE (drawable)); - g_return_if_fail (GDK_IS_GC (gc)); - - if (width < 0 || height < 0) - { - gint real_width; - gint real_height; - - gdk_drawable_get_size (drawable, &real_width, &real_height); - - if (width < 0) - width = real_width; - if (height < 0) - height = real_height; - } - - GDK_DRAWABLE_GET_CLASS (drawable)->draw_rectangle (drawable, gc, filled, x, y, - width, height); -} - /** * gdk_draw_drawable: * @drawable: a #GdkDrawable diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h index de741d3664..690d52effe 100644 --- a/gdk/gdkdrawable.h +++ b/gdk/gdkdrawable.h @@ -60,13 +60,6 @@ struct _GdkDrawableClass GdkGC *(*create_gc) (GdkDrawable *drawable, GdkGCValues *values, GdkGCValuesMask mask); - void (*draw_rectangle) (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height); void (*draw_drawable) (GdkDrawable *drawable, GdkGC *gc, GdkDrawable *src, @@ -150,13 +143,6 @@ GdkDisplay* gdk_drawable_get_display (GdkDrawable *drawable); /* Drawing */ -void gdk_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height); void gdk_draw_drawable (GdkDrawable *drawable, GdkGC *gc, GdkDrawable *src, diff --git a/gdk/gdkoffscreenwindow.c b/gdk/gdkoffscreenwindow.c index d582a08e7a..a21ad163a0 100644 --- a/gdk/gdkoffscreenwindow.c +++ b/gdk/gdkoffscreenwindow.c @@ -304,25 +304,6 @@ gdk_offscreen_window_draw_drawable (GdkDrawable *drawable, add_damage (offscreen, xdest, ydest, width, height, FALSE); } -static void -gdk_offscreen_window_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height) -{ - GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable); - GdkDrawable *real_drawable = get_real_drawable (offscreen); - - gdk_draw_rectangle (real_drawable, - gc, filled, x, y, width, height); - - add_damage (offscreen, x, y, width, height, !filled); - -} - void _gdk_offscreen_window_new (GdkWindow *window, GdkScreen *screen, @@ -947,7 +928,6 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass) drawable_class->get_source_drawable = gdk_offscreen_window_get_source_drawable; drawable_class->get_composite_drawable = gdk_offscreen_window_get_composite_drawable; - drawable_class->draw_rectangle = gdk_offscreen_window_draw_rectangle; drawable_class->draw_drawable_with_src = gdk_offscreen_window_draw_drawable; } diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c index 3d51dad5f1..fdb3d29ec9 100644 --- a/gdk/gdkpixmap.c +++ b/gdk/gdkpixmap.c @@ -34,13 +34,6 @@ static GdkGC *gdk_pixmap_create_gc (GdkDrawable *drawable, GdkGCValues *values, GdkGCValuesMask mask); -static void gdk_pixmap_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height); static void gdk_pixmap_draw_drawable (GdkDrawable *drawable, GdkGC *gc, GdkPixmap *src, @@ -109,7 +102,6 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass) object_class->finalize = gdk_pixmap_finalize; drawable_class->create_gc = gdk_pixmap_create_gc; - drawable_class->draw_rectangle = gdk_pixmap_draw_rectangle; drawable_class->draw_drawable_with_src = gdk_pixmap_draw_drawable; drawable_class->get_depth = gdk_pixmap_real_get_depth; drawable_class->get_screen = gdk_pixmap_real_get_screen; @@ -189,22 +181,6 @@ gdk_pixmap_create_gc (GdkDrawable *drawable, values, mask); } -static void -gdk_pixmap_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height) -{ - GdkPixmapObject *private = (GdkPixmapObject *)drawable; - - _gdk_gc_remove_drawable_clip (gc); - gdk_draw_rectangle (private->impl, gc, filled, - x, y, width, height); -} - static void gdk_pixmap_draw_drawable (GdkDrawable *drawable, GdkGC *gc, diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 0554954d3b..1d0e2206dd 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -229,13 +229,6 @@ typedef struct { static GdkGC *gdk_window_create_gc (GdkDrawable *drawable, GdkGCValues *values, GdkGCValuesMask mask); -static void gdk_window_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height); static void gdk_window_draw_drawable (GdkDrawable *drawable, GdkGC *gc, GdkPixmap *src, @@ -424,7 +417,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass) object_class->get_property = gdk_window_get_property; drawable_class->create_gc = gdk_window_create_gc; - drawable_class->draw_rectangle = gdk_window_draw_rectangle; drawable_class->draw_drawable_with_src = gdk_window_draw_drawable; drawable_class->get_depth = gdk_window_real_get_depth; drawable_class->get_screen = gdk_window_real_get_screen; @@ -3898,24 +3890,6 @@ gdk_window_create_gc (GdkDrawable *drawable, values, mask); } -static void -gdk_window_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height) -{ - if (GDK_WINDOW_DESTROYED (drawable)) - return; - - BEGIN_DRAW; - gdk_draw_rectangle (impl, gc, filled, - x - x_offset, y - y_offset, width, height); - END_DRAW; -} - static GdkDrawable * gdk_window_get_source_drawable (GdkDrawable *drawable) { diff --git a/gdk/quartz/gdkdrawable-quartz.c b/gdk/quartz/gdkdrawable-quartz.c index ec6ed52fb8..8cafe79e3b 100644 --- a/gdk/quartz/gdkdrawable-quartz.c +++ b/gdk/quartz/gdkdrawable-quartz.c @@ -147,43 +147,6 @@ gdk_quartz_get_depth (GdkDrawable *drawable) return gdk_drawable_get_depth (GDK_DRAWABLE_IMPL_QUARTZ (drawable)->wrapper); } -static void -gdk_quartz_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height) -{ - CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE); - - if (!context) - return; - - _gdk_quartz_gc_update_cg_context (gc, - drawable, - context, - filled ? - GDK_QUARTZ_CONTEXT_FILL : - GDK_QUARTZ_CONTEXT_STROKE); - - if (filled) - { - CGRect rect = CGRectMake (x, y, width, height); - - CGContextFillRect (context, rect); - } - else - { - CGRect rect = CGRectMake (x + 0.5, y + 0.5, width, height); - - CGContextStrokeRect (context, rect); - } - - gdk_quartz_drawable_release_context (drawable, context); -} - static void gdk_quartz_draw_drawable (GdkDrawable *drawable, GdkGC *gc, @@ -314,7 +277,6 @@ gdk_drawable_impl_quartz_class_init (GdkDrawableImplQuartzClass *klass) object_class->finalize = gdk_drawable_impl_quartz_finalize; drawable_class->create_gc = _gdk_quartz_gc_new; - drawable_class->draw_rectangle = gdk_quartz_draw_rectangle; drawable_class->draw_drawable_with_src = gdk_quartz_draw_drawable; drawable_class->ref_cairo_surface = gdk_quartz_ref_cairo_surface; diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c index fae749f5e8..b31ccadc89 100644 --- a/gdk/win32/gdkdrawable-win32.c +++ b/gdk/win32/gdkdrawable-win32.c @@ -48,13 +48,6 @@ (gcwin32->line_style == GDK_LINE_DOUBLE_DASH || \ (gcwin32->line_style == GDK_LINE_ON_OFF_DASH && gcwin32->pen_dash_offset)) -static void gdk_win32_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height); static void gdk_win32_draw_drawable (GdkDrawable *drawable, GdkGC *gc, GdkPixmap *src, @@ -95,7 +88,6 @@ _gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass) object_class->finalize = gdk_drawable_impl_win32_finalize; drawable_class->create_gc = _gdk_win32_gc_new; - drawable_class->draw_rectangle = gdk_win32_draw_rectangle; drawable_class->draw_drawable_with_src = gdk_win32_draw_drawable; drawable_class->ref_cairo_surface = gdk_win32_ref_cairo_surface; @@ -424,240 +416,6 @@ draw_tiles (GdkDrawable *drawable, g_object_unref (gc_copy); } -static void -generic_draw (GdkDrawable *drawable, - GdkGC *gc, - GdkGCValuesMask mask, - void (*function) (GdkGCWin32 *, HDC, gint, gint, va_list), - const cairo_region_t *region, - ...) -{ - GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable); - GdkGCWin32 *gcwin32 = GDK_GC_WIN32 (gc); - HDC hdc; - va_list args; - GdkFill fill_style = _gdk_gc_get_fill (gc); - - va_start (args, region); - - /* If tiled or stippled, draw to a temp pixmap and do blitting magic. - */ - - if (gcwin32->values_mask & GDK_GC_FILL && - ((fill_style == GDK_TILED && - gcwin32->values_mask & GDK_GC_TILE && - _gdk_gc_get_tile (gc) != NULL) - || - ((fill_style == GDK_OPAQUE_STIPPLED || - fill_style == GDK_STIPPLED) && - gcwin32->values_mask & GDK_GC_STIPPLE && - _gdk_gc_get_stipple (gc) != NULL))) - { - const GdkGCValuesMask blitting_mask = 0; - GdkGCValuesMask drawing_mask = GDK_GC_FOREGROUND; - gint ts_x_origin = 0, ts_y_origin = 0; - cairo_rectangle_int_t region_extents; - - cairo_region_get_extents (region, ®ion_extents); - - GdkPixmap *mask_pixmap = - gdk_pixmap_new (drawable, region_extents.width, region_extents.height, 1); - GdkPixmap *tile_pixmap = - gdk_pixmap_new (drawable, region_extents.width, region_extents.height, -1); - GdkPixmap *stipple_bitmap = NULL; - GdkColor fg; - - GdkGC *mask_gc = gdk_gc_new (mask_pixmap); - GdkGC *tile_gc = gdk_gc_new (tile_pixmap); - - HDC mask_hdc; - HDC tile_hdc; - - HGDIOBJ old_mask_hbm; - HGDIOBJ old_tile_hbm; - - GdkGCValues gcvalues; - - hdc = gdk_win32_hdc_get (drawable, gc, blitting_mask); - tile_hdc = CreateCompatibleDC (hdc); - - if (gcwin32->values_mask & GDK_GC_TS_X_ORIGIN) - ts_x_origin = gc->ts_x_origin; - if (gcwin32->values_mask & GDK_GC_TS_Y_ORIGIN) - ts_y_origin = gc->ts_y_origin; - - ts_x_origin -= region_extents.x; - ts_y_origin -= region_extents.y; - - /* Fill mask bitmap with zeros */ - gdk_gc_set_function (mask_gc, GDK_CLEAR); - gdk_draw_rectangle (mask_pixmap, mask_gc, TRUE, - 0, 0, region_extents.width, region_extents.height); - - /* Paint into mask bitmap, drawing ones */ - gdk_gc_set_function (mask_gc, GDK_COPY); - fg.pixel = 1; - gdk_gc_set_foreground (mask_gc, &fg); - - /* If the drawing function uses line attributes, set them as in - * the real GC. - */ - if (mask & LINE_ATTRIBUTES) - { - gdk_gc_get_values (gc, &gcvalues); - if (gcvalues.line_width != 0 || - gcvalues.line_style != GDK_LINE_SOLID || - gcvalues.cap_style != GDK_CAP_BUTT || - gcvalues.join_style != GDK_JOIN_MITER) - gdk_gc_set_line_attributes (mask_gc, - gcvalues.line_width, - gcvalues.line_style, - gcvalues.cap_style, - gcvalues.join_style); - drawing_mask |= LINE_ATTRIBUTES; - } - - mask_hdc = gdk_win32_hdc_get (mask_pixmap, mask_gc, drawing_mask); - (*function) (GDK_GC_WIN32 (mask_gc), mask_hdc, - region_extents.x, region_extents.y, args); - gdk_win32_hdc_release (mask_pixmap, mask_gc, drawing_mask); - - if (fill_style == GDK_TILED) - { - /* Tile pixmap with tile */ - draw_tiles (tile_pixmap, tile_gc, SRCCOPY, - _gdk_gc_get_tile (gc), - 0, 0, ts_x_origin, ts_y_origin, - region_extents.width, region_extents.height); - } - else - { - /* Tile with stipple */ - GdkGC *stipple_gc; - - stipple_bitmap = - gdk_pixmap_new (NULL, region_extents.width, region_extents.height, 1); - stipple_gc = gdk_gc_new (stipple_bitmap); - - /* Tile stipple bitmap */ - draw_tiles (stipple_bitmap, stipple_gc, SRCCOPY, - _gdk_gc_get_stipple (gc), - 0, 0, ts_x_origin, ts_y_origin, - region_extents.width, region_extents.height); - - if (fill_style == GDK_OPAQUE_STIPPLED) - { - /* Fill tile pixmap with background */ - fg.pixel = _gdk_gc_get_bg_pixel (gc); - gdk_gc_set_foreground (tile_gc, &fg); - gdk_draw_rectangle (tile_pixmap, tile_gc, TRUE, - 0, 0, - region_extents.width, region_extents.height); - } - g_object_unref (stipple_gc); - } - - g_object_unref (mask_gc); - g_object_unref (tile_gc); - - mask_hdc = CreateCompatibleDC (hdc); - - if ((old_mask_hbm = SelectObject (mask_hdc, GDK_PIXMAP_HBITMAP (mask_pixmap))) == NULL) - WIN32_GDI_FAILED ("SelectObject"); - - if ((old_tile_hbm = SelectObject (tile_hdc, GDK_PIXMAP_HBITMAP (tile_pixmap))) == NULL) - WIN32_GDI_FAILED ("SelectObject"); - - if (fill_style == GDK_STIPPLED || - fill_style == GDK_OPAQUE_STIPPLED) - { - HDC stipple_hdc; - HGDIOBJ old_stipple_hbm; - HBRUSH fg_brush; - HGDIOBJ old_tile_brush; - - if ((stipple_hdc = CreateCompatibleDC (hdc)) == NULL) - WIN32_GDI_FAILED ("CreateCompatibleDC"); - - if ((old_stipple_hbm = - SelectObject (stipple_hdc, - GDK_PIXMAP_HBITMAP (stipple_bitmap))) == NULL) - WIN32_GDI_FAILED ("SelectObject"); - - if ((fg_brush = CreateSolidBrush - (_gdk_win32_colormap_color (impl->colormap, - _gdk_gc_get_fg_pixel (gc)))) == NULL) - WIN32_GDI_FAILED ("CreateSolidBrush"); - - if ((old_tile_brush = SelectObject (tile_hdc, fg_brush)) == NULL) - WIN32_GDI_FAILED ("SelectObject"); - - /* Paint tile with foreround where stipple is one - * - * Desired ternary ROP: (P=foreground, S=stipple, D=destination) - * P S D ? - * 0 0 0 0 - * 0 0 1 1 - * 0 1 0 0 - * 0 1 1 0 - * 1 0 0 0 - * 1 0 1 1 - * 1 1 0 1 - * 1 1 1 1 - * - * Reading bottom-up: 11100010 = 0xE2. PSDK docs say this is - * known as DSPDxax, with hex value 0x00E20746. - */ - GDI_CALL (BitBlt, (tile_hdc, 0, 0, - region_extents.width, region_extents.height, - stipple_hdc, 0, 0, - ROP3_DSPDxax)); - - if (fill_style == GDK_STIPPLED) - { - /* Punch holes in mask where stipple is zero */ - GDI_CALL (BitBlt, (mask_hdc, 0, 0, - region_extents.width, region_extents.height, - stipple_hdc, 0, 0, - SRCAND)); - } - - GDI_CALL (SelectObject, (tile_hdc, old_tile_brush)); - GDI_CALL (DeleteObject, (fg_brush)); - GDI_CALL (SelectObject, (stipple_hdc, old_stipple_hbm)); - GDI_CALL (DeleteDC, (stipple_hdc)); - g_object_unref (stipple_bitmap); - } - - /* Tile pixmap now contains the pattern that we should paint in - * the areas where mask is one. (It is filled with said pattern.) - */ - - GDI_CALL (MaskBlt, (hdc, region_extents.x, region_extents.y, - region_extents.width, region_extents.height, - tile_hdc, 0, 0, - GDK_PIXMAP_HBITMAP (mask_pixmap), 0, 0, - MAKEROP4 (rop2_to_rop3 (gcwin32->rop2), ROP3_D))); - - /* Cleanup */ - GDI_CALL (SelectObject, (mask_hdc, old_mask_hbm)); - GDI_CALL (SelectObject, (tile_hdc, old_tile_hbm)); - GDI_CALL (DeleteDC, (mask_hdc)); - GDI_CALL (DeleteDC, (tile_hdc)); - g_object_unref (mask_pixmap); - g_object_unref (tile_pixmap); - - gdk_win32_hdc_release (drawable, gc, blitting_mask); - } - else - { - hdc = gdk_win32_hdc_get (drawable, gc, mask); - (*function) (gcwin32, hdc, 0, 0, args); - gdk_win32_hdc_release (drawable, gc, mask); - } - va_end (args); -} - static cairo_region_t * widen_bounds (GdkRectangle *bounds, gint pen_width) @@ -673,84 +431,6 @@ widen_bounds (GdkRectangle *bounds, return cairo_region_create_rectangle (bounds); } -static void -draw_rectangle (GdkGCWin32 *gcwin32, - HDC hdc, - gint x_offset, - gint y_offset, - va_list args) -{ - HGDIOBJ old_pen_or_brush; - gboolean filled; - gint x; - gint y; - gint width; - gint height; - - filled = va_arg (args, gboolean); - x = va_arg (args, gint); - y = va_arg (args, gint); - width = va_arg (args, gint); - height = va_arg (args, gint); - - x -= x_offset; - y -= y_offset; - - if (!filled && MUST_RENDER_DASHES_MANUALLY (gcwin32)) - { - render_line_vertical (gcwin32, x, y, y+height+1) && - render_line_horizontal (gcwin32, x, x+width+1, y) && - render_line_vertical (gcwin32, x+width+1, y, y+height+1) && - render_line_horizontal (gcwin32, x, x+width+1, y+height+1); - } - else - { - if (filled) - old_pen_or_brush = SelectObject (hdc, GetStockObject (NULL_PEN)); - else - old_pen_or_brush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH)); - if (old_pen_or_brush == NULL) - WIN32_GDI_FAILED ("SelectObject"); - else - GDI_CALL (Rectangle, (hdc, x, y, x+width+1, y+height+1)); - - if (old_pen_or_brush != NULL) - GDI_CALL (SelectObject, (hdc, old_pen_or_brush)); - } -} - -static void -gdk_win32_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height) -{ - GdkRectangle bounds; - cairo_region_t *region; - - GDK_NOTE (DRAW, g_print ("gdk_win32_draw_rectangle: %s (%p) %s%dx%d@%+d%+d\n", - _gdk_win32_drawable_description (drawable), - gc, - (filled ? "fill " : ""), - width, height, x, y)); - - bounds.x = x; - bounds.y = y; - bounds.width = width; - bounds.height = height; - region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width); - - generic_draw (drawable, gc, - GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | - (filled ? 0 : LINE_ATTRIBUTES), - draw_rectangle, region, filled, x, y, width, height); - - cairo_region_destroy (region); -} - static void gdk_win32_draw_drawable (GdkDrawable *drawable, GdkGC *gc, diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index 53cd107ed2..2a4d9ac7e1 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -48,13 +48,6 @@ #include "gdkdisplay-x11.h" -static void gdk_x11_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height); static void gdk_x11_draw_drawable (GdkDrawable *drawable, GdkGC *gc, GdkPixmap *src, @@ -91,7 +84,6 @@ _gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass) object_class->finalize = gdk_drawable_impl_x11_finalize; drawable_class->create_gc = _gdk_x11_gc_new; - drawable_class->draw_rectangle = gdk_x11_draw_rectangle; drawable_class->draw_drawable_with_src = gdk_x11_draw_drawable; drawable_class->ref_cairo_surface = gdk_x11_ref_cairo_surface; @@ -288,27 +280,6 @@ gdk_x11_set_colormap (GdkDrawable *drawable, /* Drawing */ -static void -gdk_x11_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gboolean filled, - gint x, - gint y, - gint width, - gint height) -{ - GdkDrawableImplX11 *impl; - - impl = GDK_DRAWABLE_IMPL_X11 (drawable); - - if (filled) - XFillRectangle (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid, - GDK_GC_GET_XGC (gc), x, y, width, height); - else - XDrawRectangle (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid, - GDK_GC_GET_XGC (gc), x, y, width, height); -} - static void gdk_x11_draw_drawable (GdkDrawable *drawable, GdkGC *gc,