API: remove gdk_draw_rectangle()
This commit is contained in:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user