Patch from Erik van Pienbroek to implement drawing bg_pixmaps (#348145).

2006-07-31  Richard Hult  <richard@imendio.com>

	* gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable):
	* gdk/quartz/gdkwindow-quartz.c:
	(gdk_window_impl_quartz_begin_paint_region): Patch from Erik van
	Pienbroek to implement drawing bg_pixmaps (#348145).
This commit is contained in:
Richard Hult
2006-07-31 21:05:12 +00:00
committed by Richard Hult
parent f04a51a7b4
commit 0cb61e8a48
4 changed files with 96 additions and 20 deletions

View File

@ -1,3 +1,10 @@
2006-07-31 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable):
* gdk/quartz/gdkwindow-quartz.c:
(gdk_window_impl_quartz_begin_paint_region): Patch from Erik van
Pienbroek to implement drawing bg_pixmaps (#348145).
2006-07-29 Richard Hult <richard@imendio.com> 2006-07-29 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always * gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always

View File

@ -1,3 +1,10 @@
2006-07-31 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c: (gdk_quartz_draw_drawable):
* gdk/quartz/gdkwindow-quartz.c:
(gdk_window_impl_quartz_begin_paint_region): Patch from Erik van
Pienbroek to implement drawing bg_pixmaps (#348145).
2006-07-29 Richard Hult <richard@imendio.com> 2006-07-29 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always * gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always

View File

@ -264,14 +264,14 @@ gdk_quartz_draw_text_wc (GdkDrawable *drawable,
static void static void
gdk_quartz_draw_drawable (GdkDrawable *drawable, gdk_quartz_draw_drawable (GdkDrawable *drawable,
GdkGC *gc, GdkGC *gc,
GdkPixmap *src, GdkPixmap *src,
gint xsrc, gint xsrc,
gint ysrc, gint ysrc,
gint xdest, gint xdest,
gint ydest, gint ydest,
gint width, gint width,
gint height) gint height)
{ {
int src_depth = gdk_drawable_get_depth (src); int src_depth = gdk_drawable_get_depth (src);
int dest_depth = gdk_drawable_get_depth (drawable); int dest_depth = gdk_drawable_get_depth (drawable);
@ -307,9 +307,10 @@ gdk_quartz_draw_drawable (GdkDrawable *drawable,
CGContextClipToRect (context, CGRectMake (xdest, ydest, width, height)); CGContextClipToRect (context, CGRectMake (xdest, ydest, width, height));
CGContextTranslateCTM (context, xdest - xsrc, ydest - ysrc); CGContextTranslateCTM (context, xdest - xsrc, ydest - ysrc);
CGContextDrawImage (context, CGRectMake(0, 0, CGContextDrawImage (context,
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width, CGRectMake(0, 0,
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height), GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width,
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height),
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->image); GDK_PIXMAP_IMPL_QUARTZ (src_impl)->image);
gdk_quartz_drawable_release_context (drawable, context); gdk_quartz_drawable_release_context (drawable, context);

View File

@ -141,9 +141,12 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
GdkRegion *region) GdkRegion *region)
{ {
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable); GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
CGContextRef context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE); int n_rects;
int i, n_rects;
GdkRectangle *rects; GdkRectangle *rects;
GdkPixmap *bg_pixmap;
GdkWindow *window;
bg_pixmap = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper)->bg_pixmap;
if (impl->begin_paint_count == 0) if (impl->begin_paint_count == 0)
impl->paint_clip_region = gdk_region_copy (region); impl->paint_clip_region = gdk_region_copy (region);
@ -152,18 +155,76 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
impl->begin_paint_count ++; impl->begin_paint_count ++;
if (bg_pixmap == GDK_NO_BG)
return;
gdk_region_get_rectangles (region, &rects, &n_rects); gdk_region_get_rectangles (region, &rects, &n_rects);
for (i = 0; i < n_rects; i++)
if (bg_pixmap == NULL)
{ {
gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper), CGContextRef context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper)->bg_color.pixel); gint i;
CGContextFillRect (context, CGRectMake (rects[i].x, rects[i].y, rects[i].width, rects[i].height)); for (i = 0; i < n_rects; i++)
{
gdk_quartz_set_context_fill_color_from_pixel
(context, gdk_drawable_get_colormap (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper),
GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_QUARTZ (impl)->wrapper)->bg_color.pixel);
CGContextFillRect (context, CGRectMake (rects[i].x, rects[i].y, rects[i].width, rects[i].height));
}
gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), context);
} }
g_free (rects); else
{
int x, y;
int x_offset, y_offset;
int width, height;
GdkGC *gc;
x_offset = y_offset = 0;
window = GDK_WINDOW (GDK_DRAWABLE_IMPL_QUARTZ (impl));
while (window && ((GdkWindowObject *) window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
{
/* If this window should have the same background as the parent,
* fetch the parent. (And if the same goes for the parent, fetch
* the grandparent, etc.)
*/
x_offset += ((GdkWindowObject *) window)->x;
y_offset += ((GdkWindowObject *) window)->y;
window = GDK_WINDOW (((GdkWindowObject *) window)->parent);
}
gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), context); /* Note: There should be a CG API to draw tiled images, we might
* want to look into that for this.
*/
gc = gdk_gc_new (GDK_DRAWABLE (impl));
gdk_drawable_get_size (GDK_DRAWABLE (bg_pixmap), &width, &height);
x = -x_offset;
while (x < (rects[0].x + rects[0].width))
{
if (x + width >= rects[0].x)
{
y = -y_offset;
while (y < (rects[0].y + rects[0].height))
{
if (y + height >= rects[0].y)
gdk_draw_drawable (GDK_DRAWABLE (impl), gc, bg_pixmap, 0, 0, x, y, width, height);
y += height;
}
}
x += width;
}
g_object_unref (G_OBJECT (gc));
}
g_free (rects);
} }
static void static void