LCOV - code coverage report
Current view: top level - gfx/cairo/cairo/src - cairo-surface-clipper.c (source / functions) Hit Total Coverage
Test: output.info Lines: 0 39 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* cairo - a vector graphics library with display and print output
       2             :  *
       3             :  * Copyright © 2009 Chris Wilson
       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             :  *      Chris Wilson <chris@chris-wilson.co.uk>
      34             :  */
      35             : 
      36             : #include "cairoint.h"
      37             : 
      38             : #include "cairo-surface-clipper-private.h"
      39             : 
      40             : /* A collection of routines to facilitate vector surface clipping */
      41             : 
      42             : static cairo_status_t
      43           0 : _cairo_surface_clipper_intersect_clip_path_recursive (cairo_surface_clipper_t *clipper,
      44             :                                                       cairo_clip_path_t *clip_path)
      45             : {
      46             :     cairo_status_t status;
      47             : 
      48           0 :     if (clip_path->prev != NULL) {
      49           0 :         status =
      50           0 :             _cairo_surface_clipper_intersect_clip_path_recursive (clipper,
      51             :                                                                   clip_path->prev);
      52           0 :         if (unlikely (status))
      53           0 :             return status;
      54             :     }
      55             : 
      56           0 :     return clipper->intersect_clip_path (clipper,
      57             :                                          &clip_path->path,
      58             :                                          clip_path->fill_rule,
      59             :                                          clip_path->tolerance,
      60             :                                          clip_path->antialias);
      61             : }
      62             : 
      63             : cairo_status_t
      64           0 : _cairo_surface_clipper_set_clip (cairo_surface_clipper_t *clipper,
      65             :                                  cairo_clip_t *clip)
      66             : {
      67             :     cairo_status_t status;
      68             :     cairo_bool_t clear;
      69             : 
      70             :     /* XXX as we cache a reference to the path, and compare every time,
      71             :      * we may in future need to install a notification if the clip->path
      72             :      * is every modified (e.g. cairo_clip_translate).
      73             :      */
      74             : 
      75           0 :     if (clip == NULL && clipper->clip.path == NULL)
      76           0 :         return CAIRO_STATUS_SUCCESS;
      77             : 
      78           0 :     if (clip != NULL && clipper->clip.path != NULL &&
      79           0 :         _cairo_clip_equal (clip, &clipper->clip))
      80             :     {
      81           0 :         return CAIRO_STATUS_SUCCESS;
      82             :     }
      83             : 
      84             :     /* all clipped out state should never propagate this far */
      85           0 :     assert (clip == NULL || clip->path != NULL);
      86             : 
      87             :     /* Check whether this clip is a continuation of the previous.
      88             :      * If not, we have to remove the current clip and rebuild.
      89             :      */
      90           0 :     clear = clip == NULL || clip->path->prev != clipper->clip.path;
      91             : 
      92           0 :     _cairo_clip_reset (&clipper->clip);
      93           0 :     _cairo_clip_init_copy (&clipper->clip, clip);
      94             : 
      95           0 :     if (clear) {
      96           0 :         clipper->is_clipped = FALSE;
      97           0 :         status = clipper->intersect_clip_path (clipper, NULL, 0, 0, 0);
      98           0 :         if (unlikely (status))
      99           0 :             return status;
     100             : 
     101           0 :         if (clip != NULL && clip->path != NULL) {
     102           0 :             status =
     103           0 :                 _cairo_surface_clipper_intersect_clip_path_recursive (clipper,
     104             :                                                                       clip->path);
     105           0 :             clipper->is_clipped = TRUE;
     106             :         }
     107             :     } else {
     108           0 :         cairo_clip_path_t *path = clip->path;
     109             : 
     110           0 :         clipper->is_clipped = TRUE;
     111           0 :         status = clipper->intersect_clip_path (clipper,
     112             :                                                &path->path,
     113             :                                                path->fill_rule,
     114             :                                                path->tolerance,
     115             :                                                path->antialias);
     116             :     }
     117             : 
     118           0 :     return status;
     119             : }
     120             : 
     121             : void
     122           0 : _cairo_surface_clipper_init (cairo_surface_clipper_t *clipper,
     123             :                              cairo_surface_clipper_intersect_clip_path_func_t func)
     124             : {
     125           0 :     _cairo_clip_init (&clipper->clip);
     126           0 :     clipper->is_clipped = FALSE;
     127           0 :     clipper->intersect_clip_path = func;
     128           0 : }
     129             : 
     130             : void
     131           0 : _cairo_surface_clipper_reset (cairo_surface_clipper_t *clipper)
     132             : {
     133           0 :     _cairo_clip_reset (&clipper->clip);
     134           0 :     clipper->is_clipped = FALSE;
     135           0 : }

Generated by: LCOV version 1.13