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:
committed by
Richard Hult
parent
f04a51a7b4
commit
0cb61e8a48
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -307,7 +307,8 @@ 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,
|
||||||
|
CGRectMake(0, 0,
|
||||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width,
|
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width,
|
||||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height),
|
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height),
|
||||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->image);
|
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->image);
|
||||||
|
|||||||
@ -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);
|
||||||
|
|
||||||
|
if (bg_pixmap == NULL)
|
||||||
|
{
|
||||||
|
CGContextRef context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
|
||||||
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < n_rects; i++)
|
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_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);
|
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));
|
CGContextFillRect (context, CGRectMake (rects[i].x, rects[i].y, rects[i].width, rects[i].height));
|
||||||
|
|
||||||
}
|
}
|
||||||
g_free (rects);
|
|
||||||
|
|
||||||
gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), context);
|
gdk_quartz_drawable_release_context (GDK_DRAWABLE (impl), context);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
|||||||
Reference in New Issue
Block a user