LCOV - code coverage report
Current view: directory - gfx/cairo/cairo/src - cairo-path-fixed-private.h (source / functions) Found Hit Coverage
Test: app.info Lines: 9 2 22.2 %
Date: 2012-06-02 Functions: 2 1 50.0 %

       1                 : /* cairo - a vector graphics library with display and print output
       2                 :  *
       3                 :  * Copyright © 2005 Red Hat, Inc.
       4                 :  *
       5                 :  * This library is free software; you can redistribute it and/or
       6                 :  * modify it either under the terms of the GNU Lesser General Public
       7                 :  * License version 2.1 as published by the Free Software Foundation
       8                 :  * (the "LGPL") or, at your option, under the terms of the Mozilla
       9                 :  * Public License Version 1.1 (the "MPL"). If you do not alter this
      10                 :  * notice, a recipient may use your version of this file under either
      11                 :  * the MPL or the LGPL.
      12                 :  *
      13                 :  * You should have received a copy of the LGPL along with this library
      14                 :  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
      15                 :  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
      16                 :  * You should have received a copy of the MPL along with this library
      17                 :  * in the file COPYING-MPL-1.1
      18                 :  *
      19                 :  * The contents of this file are subject to the Mozilla Public License
      20                 :  * Version 1.1 (the "License"); you may not use this file except in
      21                 :  * compliance with the License. You may obtain a copy of the License at
      22                 :  * http://www.mozilla.org/MPL/
      23                 :  *
      24                 :  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
      25                 :  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
      26                 :  * the specific language governing rights and limitations.
      27                 :  *
      28                 :  * The Original Code is the cairo graphics library.
      29                 :  *
      30                 :  * The Initial Developer of the Original Code is Red Hat, Inc.
      31                 :  *
      32                 :  * Contributor(s):
      33                 :  *      Carl D. Worth <cworth@redhat.com>
      34                 :  */
      35                 : 
      36                 : #ifndef CAIRO_PATH_FIXED_PRIVATE_H
      37                 : #define CAIRO_PATH_FIXED_PRIVATE_H
      38                 : 
      39                 : #include "cairo-types-private.h"
      40                 : #include "cairo-compiler-private.h"
      41                 : #include "cairo-list-private.h"
      42                 : 
      43                 : #define WATCH_PATH 0
      44                 : #if WATCH_PATH
      45                 : #include <stdio.h>
      46                 : #endif
      47                 : 
      48                 : enum cairo_path_op {
      49                 :     CAIRO_PATH_OP_MOVE_TO = 0,
      50                 :     CAIRO_PATH_OP_LINE_TO = 1,
      51                 :     CAIRO_PATH_OP_CURVE_TO = 2,
      52                 :     CAIRO_PATH_OP_CLOSE_PATH = 3
      53                 : };
      54                 : 
      55                 : /* we want to make sure a single byte is used for the enum */
      56                 : typedef char cairo_path_op_t;
      57                 : 
      58                 : /* make _cairo_path_fixed fit into ~512 bytes -- about 50 items */
      59                 : #define CAIRO_PATH_BUF_SIZE ((512 - sizeof (cairo_path_buf_t)) \
      60                 :                            / (2 * sizeof (cairo_point_t) + sizeof (cairo_path_op_t)))
      61                 : 
      62                 : typedef struct _cairo_path_buf {
      63                 :     cairo_list_t link;
      64                 :     unsigned int num_ops;
      65                 :     unsigned int size_ops;
      66                 :     unsigned int num_points;
      67                 :     unsigned int size_points;
      68                 : 
      69                 :     cairo_path_op_t *op;
      70                 :     cairo_point_t *points;
      71                 : } cairo_path_buf_t;
      72                 : 
      73                 : typedef struct _cairo_path_buf_fixed {
      74                 :     cairo_path_buf_t base;
      75                 : 
      76                 :     cairo_path_op_t op[CAIRO_PATH_BUF_SIZE];
      77                 :     cairo_point_t points[2 * CAIRO_PATH_BUF_SIZE];
      78                 : } cairo_path_buf_fixed_t;
      79                 : 
      80                 : struct _cairo_path_fixed {
      81                 :     cairo_point_t last_move_point;
      82                 :     cairo_point_t current_point;
      83                 :     unsigned int has_current_point      : 1;
      84                 :     unsigned int has_last_move_point    : 1;
      85                 :     unsigned int has_curve_to           : 1;
      86                 :     unsigned int is_rectilinear         : 1;
      87                 :     unsigned int maybe_fill_region      : 1;
      88                 :     unsigned int is_empty_fill          : 1;
      89                 : 
      90                 :     cairo_box_t extents;
      91                 : 
      92                 :     cairo_path_buf_fixed_t  buf;
      93                 : };
      94                 : 
      95                 : cairo_private void
      96                 : _cairo_path_fixed_translate (cairo_path_fixed_t *path,
      97                 :                              cairo_fixed_t offx,
      98                 :                              cairo_fixed_t offy);
      99                 : 
     100                 : cairo_private cairo_status_t
     101                 : _cairo_path_fixed_append (cairo_path_fixed_t                *path,
     102                 :                           const cairo_path_fixed_t          *other,
     103                 :                           cairo_direction_t                  dir,
     104                 :                           cairo_fixed_t                      tx,
     105                 :                           cairo_fixed_t                      ty);
     106                 : 
     107                 : cairo_private unsigned long
     108                 : _cairo_path_fixed_hash (const cairo_path_fixed_t *path);
     109                 : 
     110                 : cairo_private unsigned long
     111                 : _cairo_path_fixed_size (const cairo_path_fixed_t *path);
     112                 : 
     113                 : cairo_private cairo_bool_t
     114                 : _cairo_path_fixed_equal (const cairo_path_fixed_t *a,
     115                 :                          const cairo_path_fixed_t *b);
     116                 : 
     117                 : typedef struct _cairo_path_fixed_iter {
     118                 :     const cairo_path_buf_t *first;
     119                 :     const cairo_path_buf_t *buf;
     120                 :     unsigned int n_op;
     121                 :     unsigned int n_point;
     122                 : } cairo_path_fixed_iter_t;
     123                 : 
     124                 : cairo_private void
     125                 : _cairo_path_fixed_iter_init (cairo_path_fixed_iter_t *iter,
     126                 :                              const cairo_path_fixed_t *path);
     127                 : 
     128                 : cairo_private cairo_bool_t
     129                 : _cairo_path_fixed_iter_is_fill_box (cairo_path_fixed_iter_t *_iter,
     130                 :                                     cairo_box_t *box);
     131                 : 
     132                 : cairo_private cairo_bool_t
     133                 : _cairo_path_fixed_iter_at_end (const cairo_path_fixed_iter_t *iter);
     134                 : 
     135                 : static inline cairo_bool_t
     136              21 : _cairo_path_fixed_fill_is_empty (const cairo_path_fixed_t *path)
     137                 : {
     138              21 :     return path->is_empty_fill;
     139                 : }
     140                 : 
     141                 : static inline cairo_bool_t
     142               0 : _cairo_path_fixed_is_rectilinear_fill (const cairo_path_fixed_t *path)
     143                 : {
     144               0 :     if (! path->is_rectilinear)
     145               0 :         return 0;
     146                 : 
     147               0 :     if (! path->has_current_point)
     148               0 :         return 1;
     149                 : 
     150                 :     /* check whether the implicit close preserves the rectilinear property */
     151               0 :     return path->current_point.x == path->last_move_point.x ||
     152               0 :            path->current_point.y == path->last_move_point.y;
     153                 : }
     154                 : 
     155                 : static inline cairo_bool_t
     156                 : _cairo_path_fixed_maybe_fill_region (const cairo_path_fixed_t *path)
     157                 : {
     158                 : #if WATCH_PATH
     159                 :     fprintf (stderr, "_cairo_path_fixed_maybe_fill_region () = %s\n",
     160                 :              path->maybe_fill_region ? "true" : "false");
     161                 : #endif
     162                 :     return path->maybe_fill_region;
     163                 : }
     164                 : 
     165                 : #endif /* CAIRO_PATH_FIXED_PRIVATE_H */

Generated by: LCOV version 1.7