[slope] Inline _cairo_slope_init()

Move the definition to a separate header file and allow callers to inline
the simple function.
This commit is contained in:
Chris Wilson 2009-08-11 13:43:32 +01:00
parent a1e0c4b309
commit 3fcac1ef21
11 changed files with 79 additions and 25 deletions

View file

@ -82,6 +82,7 @@ cairo_private = \
cairo-region-private.h \
cairo-rtree-private.h \
cairo-scaled-font-private.h \
cairo-slope-private.h \
cairo-spans-private.h \
cairo-surface-fallback-private.h \
cairo-surface-private.h \

View file

@ -36,6 +36,8 @@
#include "cairoint.h"
#include "cairo-slope-private.h"
typedef struct cairo_hull {
cairo_point_t point;
cairo_slope_t slope;

View file

@ -39,6 +39,7 @@
#include "cairoint.h"
#include "cairo-path-fixed-private.h"
#include "cairo-slope-private.h"
static cairo_status_t
_cairo_path_fixed_add (cairo_path_fixed_t *path,

View file

@ -38,7 +38,9 @@
#define _BSD_SOURCE /* for hypot() */
#include "cairoint.h"
#include "cairo-path-fixed-private.h"
#include "cairo-slope-private.h"
typedef struct _cairo_stroker_dash {
cairo_bool_t dashed;

View file

@ -38,6 +38,8 @@
#include "cairoint.h"
#include "cairo-slope-private.h"
static int
_cairo_pen_vertices_needed (double tolerance,
double radius,

View file

@ -36,6 +36,8 @@
#include "cairoint.h"
#include "cairo-slope-private.h"
void
_cairo_polygon_init (cairo_polygon_t *polygon)
{

65
src/cairo-slope-private.h Normal file
View file

@ -0,0 +1,65 @@
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2002 University of Southern California
* Copyright © 2005 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
* The Original Code is the cairo graphics library.
*
* The Initial Developer of the Original Code is University of Southern
* California.
*
* Contributor(s):
* Carl D. Worth <cworth@cworth.org>
*/
#ifndef _CAIRO_SLOPE_PRIVATE_H
#define _CAIRO_SLOPE_PRIVATE_H
#include "cairo-types-private.h"
#include "cairo-fixed-private.h"
static inline void
_cairo_slope_init (cairo_slope_t *slope,
const cairo_point_t *a,
const cairo_point_t *b)
{
slope->dx = b->x - a->x;
slope->dy = b->y - a->y;
}
static inline cairo_bool_t
_cairo_slope_equal (const cairo_slope_t *a, const cairo_slope_t *b)
{
return _cairo_int64_eq (_cairo_int32x32_64_mul (a->dy, b->dx),
_cairo_int32x32_64_mul (b->dy, a->dx));
}
cairo_private int
_cairo_slope_compare (const cairo_slope_t *a,
const cairo_slope_t *b) cairo_pure;
#endif /* _CAIRO_SLOPE_PRIVATE_H */

View file

@ -36,14 +36,7 @@
#include "cairoint.h"
void
_cairo_slope_init (cairo_slope_t *slope,
const cairo_point_t *a,
const cairo_point_t *b)
{
slope->dx = b->x - a->x;
slope->dy = b->y - a->y;
}
#include "cairo-slope-private.h"
/* Compare two slopes. Slope angles begin at 0 in the direction of the
positive X axis and increase in the direction of the positive Y

View file

@ -36,6 +36,8 @@
#include "cairoint.h"
#include "cairo-slope-private.h"
cairo_bool_t
_cairo_spline_init (cairo_spline_t *spline,
cairo_spline_add_point_func_t add_point_func,

View file

@ -40,6 +40,7 @@
#include "cairoint.h"
#include "cairo-region-private.h"
#include "cairo-slope-private.h"
/* private functions */

View file

@ -2427,16 +2427,6 @@ _cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
double tx, double ty,
double sx, double sy);
/* cairo-slope.c */
cairo_private void
_cairo_slope_init (cairo_slope_t *slope,
const cairo_point_t *a,
const cairo_point_t *b);
cairo_private int
_cairo_slope_compare (const cairo_slope_t *a,
const cairo_slope_t *b) cairo_pure;
/* cairo-pattern.c */
cairo_private cairo_pattern_t *
@ -2758,13 +2748,6 @@ CAIRO_END_DECLS
#include "cairo-malloc-private.h"
#include "cairo-hash-private.h"
static inline cairo_bool_t
_cairo_slope_equal (const cairo_slope_t *a, const cairo_slope_t *b)
{
return _cairo_int64_eq (_cairo_int32x32_64_mul (a->dy, b->dx),
_cairo_int32x32_64_mul (b->dy, a->dx));
}
#if HAVE_VALGRIND
#include <memcheck.h>