mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 13:30:19 +00:00
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:
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>
|
||||
|
||||
* 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>
|
||||
|
||||
* gdk/quartz/gdkcolor-quartz.c (gdk_colormap_alloc_colors): Always
|
||||
|
@ -264,14 +264,14 @@ gdk_quartz_draw_text_wc (GdkDrawable *drawable,
|
||||
|
||||
static void
|
||||
gdk_quartz_draw_drawable (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
GdkPixmap *src,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
GdkGC *gc,
|
||||
GdkPixmap *src,
|
||||
gint xsrc,
|
||||
gint ysrc,
|
||||
gint xdest,
|
||||
gint ydest,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
int src_depth = gdk_drawable_get_depth (src);
|
||||
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));
|
||||
CGContextTranslateCTM (context, xdest - xsrc, ydest - ysrc);
|
||||
CGContextDrawImage (context, CGRectMake(0, 0,
|
||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width,
|
||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height),
|
||||
CGContextDrawImage (context,
|
||||
CGRectMake(0, 0,
|
||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->width,
|
||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->height),
|
||||
GDK_PIXMAP_IMPL_QUARTZ (src_impl)->image);
|
||||
|
||||
gdk_quartz_drawable_release_context (drawable, context);
|
||||
|
@ -141,9 +141,12 @@ gdk_window_impl_quartz_begin_paint_region (GdkPaintable *paintable,
|
||||
GdkRegion *region)
|
||||
{
|
||||
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (paintable);
|
||||
CGContextRef context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
|
||||
int i, n_rects;
|
||||
int n_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)
|
||||
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 ++;
|
||||
|
||||
if (bg_pixmap == GDK_NO_BG)
|
||||
return;
|
||||
|
||||
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),
|
||||
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));
|
||||
CGContextRef context = gdk_quartz_drawable_get_context (GDK_DRAWABLE (impl), FALSE);
|
||||
gint 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_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
|
||||
|
Loading…
Reference in New Issue
Block a user