#include <config.h>
-#include <cairo/cairo-quartz.h>
+#include <cairo-quartz.h>
#include "gdkprivate-quartz.h"
static gpointer parent_class;
{
SurfaceInfo *info = data;
- _gdk_quartz_drawable_release_context (info->drawable, info->context);
+ gdk_quartz_drawable_release_context (info->drawable, info->context);
g_free (info);
}
GDK_WINDOW_DESTROYED (impl->wrapper))
return NULL;
- context = _gdk_quartz_drawable_get_context (drawable, TRUE);
+ context = gdk_quartz_drawable_get_context (drawable, TRUE);
if (!context)
return NULL;
static void
gdk_quartz_draw_rectangle (GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height)
+ GdkGC *gc,
+ gboolean filled,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
- CGRect rect = CGRectMake (x + 0.5, y + 0.5, width, height);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
if (!context)
return;
- _gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_update_context_from_gc (context, gc);
if (filled)
{
- _gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ CGRect rect = CGRectMake (x, y, width, height);
+
+ gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
_gdk_gc_get_fg_pixel (gc));
CGContextFillRect (context, rect);
}
else
{
- _gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ CGRect rect = CGRectMake (x + 0.5, y + 0.5, width, height);
+
+ gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
_gdk_gc_get_fg_pixel (gc));
CGContextStrokeRect (context, rect);
}
- _gdk_quartz_drawable_release_context (drawable, context);
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_arc (GdkDrawable *drawable,
- GdkGC *gc,
- gboolean filled,
- gint x,
- gint y,
- gint width,
- gint height,
- gint angle1,
- gint angle2)
+ GdkGC *gc,
+ gboolean filled,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ gint angle1,
+ gint angle2)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
float start_angle, end_angle;
if (!context)
return;
- _gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_update_context_from_gc (context, gc);
CGContextSaveGState (context);
- CGContextTranslateCTM (context,
- x + width / 2 + 0.5,
- y + height / 2 + 0.5);
- CGContextScaleCTM (context, 1.0, (float)height / width);
start_angle = (2 - (angle1 / (180.0 * 64.0))) * G_PI;
end_angle = start_angle - (angle2 / (180.0 * 64.0)) * G_PI;
if (filled)
{
- _gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
_gdk_gc_get_fg_pixel (gc));
+ CGContextTranslateCTM (context,
+ x + width / 2.0,
+ y + height / 2.0);
+ CGContextScaleCTM (context, 1.0, (double)height / (double)width);
+
CGContextMoveToPoint (context, 0, 0);
- CGContextAddArc (context, 0, 0, width / 2,
+ CGContextAddArc (context, 0, 0, width / 2.0,
start_angle, end_angle,
TRUE);
CGContextClosePath (context);
}
else
{
- _gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
_gdk_gc_get_fg_pixel (gc));
- CGContextAddArc (context, 0, 0, width / 2,
+
+ CGContextTranslateCTM (context,
+ x + width / 2.0 + 0.5,
+ y + height / 2.0 + 0.5);
+ CGContextScaleCTM (context, 1.0, (double)height / (double)width);
+
+ CGContextAddArc (context, 0, 0, width / 2.0,
start_angle, end_angle,
TRUE);
CGContextStrokePath (context);
CGContextRestoreGState (context);
- _gdk_quartz_drawable_release_context (drawable, context);
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
GdkPoint *points,
gint npoints)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
int i;
if (!context)
return;
- _gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_update_context_from_gc (context, gc);
if (filled)
- _gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
- _gdk_gc_get_fg_pixel (gc));
- else
- _gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
- _gdk_gc_get_fg_pixel (gc));
-
- CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
- for (i = 1; i < npoints; i++)
- CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
+ {
+ gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ _gdk_gc_get_fg_pixel (gc));
- CGContextClosePath (context);
+ CGContextMoveToPoint (context, points[0].x, points[0].y);
+ for (i = 1; i < npoints; i++)
+ CGContextAddLineToPoint (context, points[i].x, points[i].y);
- if (filled)
- CGContextFillPath (context);
+ CGContextClosePath (context);
+ CGContextFillPath (context);
+ }
else
- CGContextStrokePath (context);
+ {
+ gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ _gdk_gc_get_fg_pixel (gc));
+
+ CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
+ for (i = 1; i < npoints; i++)
+ CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
+
+ CGContextClosePath (context);
+ CGContextStrokePath (context);
+ }
- _gdk_quartz_drawable_release_context (drawable, context);
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
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);
- GdkDrawableImplQuartz *impl;
GdkDrawableImplQuartz *src_impl;
-
- impl = GDK_DRAWABLE_IMPL_QUARTZ (drawable);
if (GDK_IS_DRAWABLE_IMPL_QUARTZ (src))
src_impl = GDK_DRAWABLE_IMPL_QUARTZ (src);
- else
+ else if (GDK_IS_PIXMAP (src))
src_impl = GDK_DRAWABLE_IMPL_QUARTZ (GDK_PIXMAP_OBJECT (src)->impl);
+ else if (GDK_IS_WINDOW (src))
+ {
+ src_impl = GDK_DRAWABLE_IMPL_QUARTZ (GDK_WINDOW_OBJECT (src)->impl);
+ /* FIXME: Implement drawing a window. */
+ return;
+ }
+ else
+ g_assert_not_reached ();
if (src_depth == 1)
{
}
else if (dest_depth != 0 && src_depth == dest_depth)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
if (!context)
return;
- _gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_update_context_from_gc (context, gc);
CGContextSetBlendMode (context, kCGBlendModeNormal);
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);
+ gdk_quartz_drawable_release_context (drawable, context);
}
else
g_warning ("Attempt to draw a drawable with depth %d to a drawable with depth %d",
static void
gdk_quartz_draw_points (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPoint *points,
- gint npoints)
+ GdkGC *gc,
+ GdkPoint *points,
+ gint npoints)
{
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
int i;
+ if (!context)
+ return;
+
+ gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_set_context_fill_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ _gdk_gc_get_fg_pixel (gc));
+
/* Just draw 1x1 rectangles */
for (i = 0; i < npoints; i++)
{
- gdk_draw_rectangle (drawable, gc, TRUE,
- points[i].x, points[i].y,
- 1, 1);
+ CGRect rect = CGRectMake (points[i].x, points[i].y, 1, 1);
+ CGContextFillRect (context, rect);
}
+
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_segments (GdkDrawable *drawable,
- GdkGC *gc,
- GdkSegment *segs,
- gint nsegs)
+ GdkGC *gc,
+ GdkSegment *segs,
+ gint nsegs)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
int i;
if (!context)
return;
- _gdk_quartz_update_context_from_gc (context, gc);
- _gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
_gdk_gc_get_fg_pixel (gc));
for (i = 0; i < nsegs; i++)
CGContextStrokePath (context);
- _gdk_quartz_drawable_release_context (drawable, context);
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
GdkPoint *points,
gint npoints)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
int i;
if (!context)
return;
- _gdk_quartz_update_context_from_gc (context, gc);
- _gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
- _gdk_gc_get_fg_pixel (gc));
+ gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
+ _gdk_gc_get_fg_pixel (gc));
for (i = 1; i < npoints; i++)
{
CGContextStrokePath (context);
- _gdk_quartz_drawable_release_context (drawable, context);
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_pixbuf (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixbuf *pixbuf,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height,
- GdkRgbDither dither,
- gint x_dither,
- gint y_dither)
+ GdkGC *gc,
+ GdkPixbuf *pixbuf,
+ gint src_x,
+ gint src_y,
+ gint dest_x,
+ gint dest_y,
+ gint width,
+ gint height,
+ GdkRgbDither dither,
+ gint x_dither,
+ gint y_dither)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
CGColorSpaceRef colorspace;
CGDataProviderRef data_provider;
CGImageRef image;
CGDataProviderRelease (data_provider);
CGColorSpaceRelease (colorspace);
- _gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_update_context_from_gc (context, gc);
CGContextSetBlendMode (context, kCGBlendModeNormal);
CGContextDrawImage (context, CGRectMake (0, 0, pixbuf_width, pixbuf_height), image);
CGImageRelease (image);
- _gdk_quartz_drawable_release_context (drawable, context);
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
gdk_quartz_draw_image (GdkDrawable *drawable,
- GdkGC *gc,
- GdkImage *image,
- gint xsrc,
- gint ysrc,
- gint xdest,
- gint ydest,
- gint width,
- gint height)
+ GdkGC *gc,
+ GdkImage *image,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height)
{
- CGContextRef context = _gdk_quartz_drawable_get_context (drawable, FALSE);
+ CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
CGColorSpaceRef colorspace;
CGDataProviderRef data_provider;
CGImageRef cgimage;
CGDataProviderRelease (data_provider);
CGColorSpaceRelease (colorspace);
- _gdk_quartz_update_context_from_gc (context, gc);
+ gdk_quartz_update_context_from_gc (context, gc);
CGContextSetBlendMode (context, kCGBlendModeNormal);
CGContextDrawImage (context, CGRectMake (0, 0, image->width, image->height), cgimage);
CGImageRelease (cgimage);
- _gdk_quartz_drawable_release_context (drawable, context);
+ gdk_quartz_drawable_release_context (drawable, context);
}
static void
}
CGContextRef
-_gdk_quartz_drawable_get_context (GdkDrawable *drawable, gboolean antialias)
+gdk_quartz_drawable_get_context (GdkDrawable *drawable,
+ gboolean antialias)
{
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
{
}
void
-_gdk_quartz_drawable_release_context (GdkDrawable *drawable, CGContextRef context)
+gdk_quartz_drawable_release_context (GdkDrawable *drawable,
+ CGContextRef context)
{
if (!context)
return;