some whitespace and indentation cleanup.
2006-08-08 Michael Natterer <mitch@imendio.com> * gdk/quartz/gdkdrawable-quartz.c: some whitespace and indentation cleanup. (gdk_quartz_draw_rectangle) (gdk_quartz_draw_arc) (gdk_quartz_draw_polygon) (gdk_quartz_draw_points): for pixel-prefect drawing, stroked coordinates need to go through pixel centers, while filled ones need to go along pixel boundaries. Moved +0.5 adjusting to the if(!filled) branches and added/removed some adjustments where they were wrong.
This commit is contained in:
committed by
Michael Natterer
parent
f11a4bc30a
commit
f2faaf2fd8
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
2006-08-08 Michael Natterer <mitch@imendio.com>
|
||||||
|
|
||||||
|
* gdk/quartz/gdkdrawable-quartz.c: some whitespace and indentation
|
||||||
|
cleanup.
|
||||||
|
|
||||||
|
(gdk_quartz_draw_rectangle)
|
||||||
|
(gdk_quartz_draw_arc)
|
||||||
|
(gdk_quartz_draw_polygon)
|
||||||
|
(gdk_quartz_draw_points): for pixel-prefect drawing, stroked
|
||||||
|
coordinates need to go through pixel centers, while filled ones
|
||||||
|
need to go along pixel boundaries. Moved +0.5 adjusting to the
|
||||||
|
if(!filled) branches and added/removed some adjustments where they
|
||||||
|
were wrong.
|
||||||
|
|
||||||
2006-08-07 Richard Hult <richard@imendio.com>
|
2006-08-07 Richard Hult <richard@imendio.com>
|
||||||
|
|
||||||
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
|
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
|
||||||
|
|||||||
@ -1,3 +1,17 @@
|
|||||||
|
2006-08-08 Michael Natterer <mitch@imendio.com>
|
||||||
|
|
||||||
|
* gdk/quartz/gdkdrawable-quartz.c: some whitespace and indentation
|
||||||
|
cleanup.
|
||||||
|
|
||||||
|
(gdk_quartz_draw_rectangle)
|
||||||
|
(gdk_quartz_draw_arc)
|
||||||
|
(gdk_quartz_draw_polygon)
|
||||||
|
(gdk_quartz_draw_points): for pixel-prefect drawing, stroked
|
||||||
|
coordinates need to go through pixel centers, while filled ones
|
||||||
|
need to go along pixel boundaries. Moved +0.5 adjusting to the
|
||||||
|
if(!filled) branches and added/removed some adjustments where they
|
||||||
|
were wrong.
|
||||||
|
|
||||||
2006-08-07 Richard Hult <richard@imendio.com>
|
2006-08-07 Richard Hult <richard@imendio.com>
|
||||||
|
|
||||||
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
|
* gdk/quartz/gdkdrawable-quartz.c (gdk_quartz_draw_points): Don't
|
||||||
|
|||||||
@ -124,7 +124,6 @@ gdk_quartz_draw_rectangle (GdkDrawable *drawable,
|
|||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
|
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
|
||||||
CGRect rect = CGRectMake (x + 0.5, y + 0.5, width, height);
|
|
||||||
|
|
||||||
if (!context)
|
if (!context)
|
||||||
return;
|
return;
|
||||||
@ -133,12 +132,16 @@ gdk_quartz_draw_rectangle (GdkDrawable *drawable,
|
|||||||
|
|
||||||
if (filled)
|
if (filled)
|
||||||
{
|
{
|
||||||
|
CGRect rect = CGRectMake (x, y, width, height);
|
||||||
|
|
||||||
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));
|
_gdk_gc_get_fg_pixel (gc));
|
||||||
CGContextFillRect (context, rect);
|
CGContextFillRect (context, rect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
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_quartz_set_context_stroke_color_from_pixel (context, gdk_drawable_get_colormap (drawable),
|
||||||
_gdk_gc_get_fg_pixel (gc));
|
_gdk_gc_get_fg_pixel (gc));
|
||||||
CGContextStrokeRect (context, rect);
|
CGContextStrokeRect (context, rect);
|
||||||
@ -168,10 +171,6 @@ gdk_quartz_draw_arc (GdkDrawable *drawable,
|
|||||||
|
|
||||||
CGContextSaveGState (context);
|
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;
|
start_angle = (2 - (angle1 / (180.0 * 64.0))) * G_PI;
|
||||||
end_angle = start_angle - (angle2 / (180.0 * 64.0)) * G_PI;
|
end_angle = start_angle - (angle2 / (180.0 * 64.0)) * G_PI;
|
||||||
|
|
||||||
@ -180,8 +179,13 @@ gdk_quartz_draw_arc (GdkDrawable *drawable,
|
|||||||
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));
|
_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);
|
CGContextMoveToPoint (context, 0, 0);
|
||||||
CGContextAddArc (context, 0, 0, width / 2,
|
CGContextAddArc (context, 0, 0, width / 2.0,
|
||||||
start_angle, end_angle,
|
start_angle, end_angle,
|
||||||
TRUE);
|
TRUE);
|
||||||
CGContextClosePath (context);
|
CGContextClosePath (context);
|
||||||
@ -191,7 +195,13 @@ gdk_quartz_draw_arc (GdkDrawable *drawable,
|
|||||||
{
|
{
|
||||||
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));
|
_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,
|
start_angle, end_angle,
|
||||||
TRUE);
|
TRUE);
|
||||||
CGContextStrokePath (context);
|
CGContextStrokePath (context);
|
||||||
@ -218,9 +228,19 @@ gdk_quartz_draw_polygon (GdkDrawable *drawable,
|
|||||||
gdk_quartz_update_context_from_gc (context, gc);
|
gdk_quartz_update_context_from_gc (context, gc);
|
||||||
|
|
||||||
if (filled)
|
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));
|
_gdk_gc_get_fg_pixel (gc));
|
||||||
|
|
||||||
|
CGContextMoveToPoint (context, points[0].x, points[0].y);
|
||||||
|
for (i = 1; i < npoints; i++)
|
||||||
|
CGContextAddLineToPoint (context, points[i].x, points[i].y);
|
||||||
|
|
||||||
|
CGContextClosePath (context);
|
||||||
|
CGContextFillPath (context);
|
||||||
|
}
|
||||||
else
|
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));
|
_gdk_gc_get_fg_pixel (gc));
|
||||||
|
|
||||||
@ -229,11 +249,8 @@ gdk_quartz_draw_polygon (GdkDrawable *drawable,
|
|||||||
CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
|
CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
|
||||||
|
|
||||||
CGContextClosePath (context);
|
CGContextClosePath (context);
|
||||||
|
|
||||||
if (filled)
|
|
||||||
CGContextFillPath (context);
|
|
||||||
else
|
|
||||||
CGContextStrokePath (context);
|
CGContextStrokePath (context);
|
||||||
|
}
|
||||||
|
|
||||||
gdk_quartz_drawable_release_context (drawable, context);
|
gdk_quartz_drawable_release_context (drawable, context);
|
||||||
}
|
}
|
||||||
@ -339,7 +356,7 @@ gdk_quartz_draw_points (GdkDrawable *drawable,
|
|||||||
/* Just draw 1x1 rectangles */
|
/* Just draw 1x1 rectangles */
|
||||||
for (i = 0; i < npoints; i++)
|
for (i = 0; i < npoints; i++)
|
||||||
{
|
{
|
||||||
CGRect rect = CGRectMake (points[i].x + 0.5, points[i].y + 0.5, 1, 1);
|
CGRect rect = CGRectMake (points[i].x, points[i].y, 1, 1);
|
||||||
CGContextFillRect (context, rect);
|
CGContextFillRect (context, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +598,8 @@ gdk_drawable_impl_quartz_get_type (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CGContextRef
|
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))
|
if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
|
||||||
{
|
{
|
||||||
@ -657,7 +675,8 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable, gboolean antialias)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gdk_quartz_drawable_release_context (GdkDrawable *drawable, CGContextRef context)
|
gdk_quartz_drawable_release_context (GdkDrawable *drawable,
|
||||||
|
CGContextRef context)
|
||||||
{
|
{
|
||||||
if (!context)
|
if (!context)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user