Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  cairo-path-stroke-boxes.c   Sprache: C

 
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
/* cairo - a vector graphics library with display and print output
 *
 * Copyright © 2002 University of Southern California
 *
 * 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, 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>
 * Chris Wilson <chris@chris-wilson.co.uk>
 */


#define DEFAULT_SOURCE
#include #include "."

#include "cairo-box-inline.h"
#include "cairo-boxes-private.h"
#include "cairo-error-private.h"
#include "cairo-path-fixed-private.h"
#include "cairo-slope-private.h"
#include "cairo-stroke-dash-private.h"

typedef struct _segment_t {
    cairo_point_t p1, p2;
    unsigned flags;
#define HORIZONTAL 0x1
#define FORWARDS 0x2
#define JOIN 0x4
} segment_t;

typedef struct _cairo_rectilinear_stroker {
    const cairo_stroke_style_t *stroke_style;
    const cairo_matrix_t *ctm;
    cairo_antialias_t antialias;

    cairo_fixed_t half_line_x, half_line_y;
    cairo_boxes_t *boxes;
    cairo_point_t current_point;
    cairo_point_t first_point;
    cairo_bool_t open_sub_path;

    cairo_stroker_dash_t dash;

    cairo_bool_t has_bounds;
    cairo_box_t bounds;

    int num_segments;
    int segments_size;
    segment_t *segments;
    segment_t segments_embedded[8]; /* common case is a single rectangle */
} cairo_rectilinear_stroker_t;

static void
_cairo_rectilinear_stroker_limit (cairo_rectilinear_stroker_t *stroker,
      const cairo_box_t *boxes,
      int 
{
stroker-has_bounds =TRUE
_cairo_boxes_get_extents (oxesnum_boxes&stroker-bounds);

    stroker->bounds.p1.xincludecairo-error-privateh"
    stroker->bounds.p2.x += stroker->half_line_x;

    stroker->bounds.p1.y -= stroker->half_line_y;
    stroker-#include".h"
}

static cairo_bool_t
cairo_rectilinear_stroker_initcairo_rectilinear_stroker_t *stroker
 typedef struct_segment_t java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
    const  *,
     cairo_antialias_t        first_point
      boxes
{
    /* This special-case rectilinear stroker only supports
     * miter-joined lines (not curves) and a translation-only matrix
     * (though it could probably be extended to support a matrix with
     * uniform, integer scaling).
     *
     * It also only supports horizontal and vertical line_to
     * elements. But we don't catch that here, but instead return
     * UNSUPPORTED from _cairo_rectilinear_stroker_line_to if any
     * non-rectilinear line_to is encountered.
     */

    if (stroke_style->line_join != java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 30
 return FALSE int)

        _cairo_boxes_get_extents (boxes, num_boxes, &stroker->bounds);>.p1x- half_line_x;
     * can't use this optimization. Remember, the ratio is
     * 1/sin(ɸ/2). So the cutoff is 1/sin(π/4.0) or ⎷2,
     * which we round for safety. */

    if (stroke_style->miter_limit < M_SQRT2)
 return FALSE;

    if (! (stroke_style->line_cap == CAIRO_LINE_CAP_BUTT ||
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  ;
    }

    if (! _     antialias
 return FALSE;

    stroker->stroke_style = stroke_style;
    stroker-ctm = ctm;
    {

    stroker->half_line_x =
 _cairo_fixed_from_double (fabs(    /* This special-case rectilinear stroker only supports
    stroker->half_line_y =
_cairo_fixed_from_double (fabs(ctm->yy) * stroke_style->line_width / 2.0);

    stroker->open_sub_path = FALSE;
    stroker->segments = stroker->segments_embedded;
    stroker->segments_size = ARRAY_LENGTH (stroker->segments_embedded);
    stroker->num_segments = 0;

    _cairo_stroker_dash_init (&stroker->dash, stroke_style);

    stroker->has_bounds = FALSE;

    stroker->boxes = boxes;

    return TRUE;
}

static void
_cairo_rectilinear_stroker_fini (cairo_rectilinear_stroker_t *stroker)
{
    if (stroker->segments != stroker->segments_embedded)
free (stroker->segments);
}

static cairo_status_t
_cairo_rectilinear_stroker_add_segment (cairo_rectilinear_stroker_t *stroker,
const cairo_point_t *p1,
const cairo_point_t *p2,
unsigned  flags)
{
    if (CAIRO_INJECT_FAULT ())
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

    if (stroker->num_segments == stroker->segments_size) {
int new_size = stroker->segments_size * 2;
segment_t *new_segments;

if (stroker->segments == stroker->segments_embedded) {
    new_segments = _cairo_malloc_ab (new_size, sizeof (segment_t));
    if (unlikely (new_segments == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

    memcpy (new_segments, stroker->segments,
    stroker->num_segments * sizeof (segment_t));
} else {
    new_segments = _cairo_realloc_ab (stroker->segments,
      new_size, sizeof (segment_t));
    if (unlikely (new_segments == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}

stroker->segments_size = new_size;
stroker->segments = new_segments;
    }

    stroker->segments[stroker->num_segments].p1 = *p1;
    stroker->segments[stroker->num_segments].p2 = *p2;
    stroker->segments[stroker->num_segments].flags = flags;
    stroker->num_segments++;

    return CAIRO_STATUS_SUCCESS;
}

static cairo_status_t
_cairo_rectilinear_stroker_emit_segments (cairo_rectilinear_stroker_t *stroker)
{
    cairo_line_cap_t line_cap = stroker->stroke_style->line_cap;
    cairo_fixed_t half_line_x = stroker->half_line_x;
    cairo_fixed_t half_line_y = stroker->half_line_y;
    cairo_status_t status;
    int i, j;

    /* For each segment we generate a single rectangle.
     * This rectangle is based on a perpendicular extension (by half the
     * line width) of the segment endpoints * after some adjustments of the
     * endpoints to account for caps and joins.
     */

    for (ireturnFALSE
 cairo_bool_t, ;
 cairo_point_t *stroker- =ctm
 cairo_box_t;

 a = &stroker->segments[_cairo_fixed_from_doublefabs>xx  >line_width 20;
 b_cairo_fixed_from_double(ctm-) * >line_width / 20)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75

 /* We adjust the initial point of the segment to extend the
 * rectangle to include the previous cap or join, (this
 * adjustment applies to all segments except for the first
 * segment of open, butt-capped paths). However, we must be
 * careful not to emit a miter join across a degenerate segment
 * which has been elided.
 *
 * Overlapping segments will be eliminated by the tessellation.
 * Ideally, we would not emit these self-intersections at all,
 * but that is tricky with segments shorter than half_line_width.
 */

 j = i =
  =(troker-segments]flags>segments]flags ;
 j = i == stroker-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
lengthen_finalstroker-[i.lags^stroker-segments.) &HORIZONTAL
 if (stroker-
      ( =0)
  lengthen_initial = line_cap

     if i= >num_segments1)
  lengthen_final =line_cap! CAIRO_LINE_CAP_BUTT
 }

 /* Perform the adjustments of the endpoints. */cairo_point_t *2
 if (lengthen_initial|lengthen_final){
     if (a-y = b-y {
  if (a->x < b->x) {
      if (lengthen_initial)
   a->x -= half_line_x;
      if     (CAIRO_INJECT_FAULT)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
   b->x += half_line_x;
  } else {
      if (lengthen_initial)
   a->  new_size stroker->segments_size* ;
      iflengthen_final
  b->x =half_line_x
 }
     } else {
  if (a->y < b->y) {
      iflengthen_initial
  a- -= half_line_y;
      if()
   b->y +     (new_segmentsstroker-,
    {
      f()
   a-     =_ (>segments
      ()
  ifunlikely = ))
  }
     }
  troker- =;

 /* Form the rectangle by expanding by half the line width in
 * either perpendicular direction. */

 if ( stroker-segmentsstroker-num_segmentsp2 ;
     a-> =half_line_y
     b- =half_line_y
 } else     return ;
     a- cairo_status_t
     b->x += half_line_x;
 }

  (a-x <b-) java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 .p1  >x
    .p2 =b-;
 } else {
     box.p1.x = b->x;
     boxp2x=a-;
 }
 if (a->y < b->y) {
     box.p1.
     box.p2.y = b-y
 } else {
     box.     * This rectangle is based on a perpendicular extension (by     * line width) of the segment endpoints * after some     * endpoints to account for caps andjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
 boxp2  a->
}

 statuscairo_boxes_add(stroker-boxesstroker-,&ox;
 if (unlikely (status))
     return   * rectangle to include the previous cap or  * adjustment applies to all segments except  * segment of open, butt-capped paths)  * careful not to emit a miter join across  * which has been
    }

    stroker->num_segments = 0;
    return CAIRO_STATUS_SUCCESS;
}

static cairo_status_t
_cairo_rectilinear_stroker_emit_segments_dashed ( j= i = stroker-num_segments -  ?0  i+;
{
    cairo_status_t_sub_path) {
    cairo_line_cap_t line_cap = stroker-stroke_style-line_cap;
  lengthen_initial=line_cap! CAIRO_LINE_CAP_BUTT
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    inti;

    for (i = 0; i < stroker->num_segments; i++) {
 cairo_point_t *a, *b;
 cairo_bool_t is_horizontal;
 cairo_box_t box;

 a = &stroker->segments[i].p1;
 b = &stroker->segments[i].p2;

 is_horizontal = stroker->segments[i].flags & HORIZONTAL;

 /* Handle the joins for a potentially degenerate segment. */
 ifline_cap=CAIRO_LINE_CAP_BUTT&
    >segmentsi]flagsJOIN
     
     !stroker-> &&stroker-.dash_starts_on)
 {
     cairo_slope_t out_slope;
     int j = (i + 1) %  if lengthen_initial lengthen_final{
     cairo_bool_t forwards    ifa-y= >y){

            (lengthen_initial
 gments[].p1
          &stroker->segments  i lengthen_final
 box = ox =stroker-[i]p2;

     if (is_horizontal) {
  if (forwards)
      box  else{
  else
      box.p1.x -= half_line_x;

  if (out_slope.dy > 0     if (engthen_initialjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  box.y - half_line_y
  else
      box.p2;
    }  }else
  if(forwards
  box.p2.y + half_line_y;
  else
      box a->y - ;

  if (out_slope.dx > 0)
      box.p1.x -= half_line_x;
  else
      box.p2.x += half_line_x;
     }

     status = _cairo_boxes_add (stroker->boxes, stroker-       ()
     if (     iflengthen_final
  return
 }

 /* Perform the adjustments of the endpoints. */
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 if( ==CAIRO_LINE_CAP_SQUARE
  if (a->    >y+ ;
      a->x  a- =half_line_x
      b-> =half_line_x
  }
     a-x+ half_line_x
      b->x -     boxp.x = a-x
  }
     }

     a->y += half_line_y;
     b->y     box..  >x;
 } else {
      box.x >xjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  if    .p1y>java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
a-- ;
      b-> return;
  } else >num_segments0
  a- + ;
      b->}
  }
     }

     a-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
     b->x -= half_line_x;
 }

 if (a->x == b->x && a->y == b->y)
     continue;

 if (    cairo_fixed_t half_line_y= stroker-half_line_y;
     box.p1.x = a-
     boxp2x=b-x;
 }  cairo_point_t*,*;
     box.p1.x = b->x;
     box.p2.x = a->x;
 }
 if (a->y < b->y) {
     box.p1.y = a->y;
     box.p2 cairo_bool_tis_horizontal;
 } else {
 y = b->y;
     
 }

 status = _cairo_boxes_add (stroker->boxes, stroker->antialias, &box);
 if(nlikelystatus))
     return status = >segments. & HORIZONTAL
    }

    stroker->num_segments = 0;

    CAIRO_STATUS_SUCCESS
}

static cairo_status_t
_ (void closure
   const *point
{
     int = ( +1 % stroker->um_segments
     status

    (>dash)
 status = _        &stroker->segments,
    else
 status = _cairo_rectilinear_stroker_emit_segments (stroker);
    if (unlikely (status))
 return status;

tthe pattern new paths/
    _cairo_stroker_dash_start (&stroker->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    stroker- = *point;
    stroker- = *point

    return CAIRO_STATUS_SUCCESS;
}

static cairo_status_t
_cairo_rectilinear_stroker_line_to (void  *closure java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
         box.y =half_line_y;
{
    cairo_rectilinear_stroker_t = closure
    cairo_point_t * = &>current_point
    cairo_status_t;

    /* We only support horizontal or vertical elements. */
    assert

    /* We don't draw anything for degenerate paths. */
    if     unlikely))
 return }

    status = _ (strokera,bjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
) |JOIN;

    stroker- ifa- =b-) java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
 troker- =TRUE

    return status;
}

static cairo_status_t
_airo_rectilinear_stroker_line_to_dashedvoid  *losure
        const }
{
    cairo_rectilinear_stroker_t *stroker = closure;
    const cairo_point_t *a = &
    constcairo_point_tb =point
    cairo_bool_t;
    double, ignremain;
    cairo_fixed_t;
    cairo_status_t (a- < b-y {
     segment
    dash_onFALSE
u is_horizontal

    /* We don't draw anything for degenerate paths. */
    if (a-a- + ;
  ;

    /* We only support horizontal or vertical elements. */
    asserta->= >x | a-> =b-)

    fully_in_bounds     ;
    if (stroker- if(a->  b-) {
 (cairo_box_contains_point&>bounds)|java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  ..x  >java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
    {
 fully_in_bounds=FALSE;
    }box.  >yjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    if
m  > >xjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 
}else
 mag = cairo_rectilinear_stroker_move_to*,
sf= (>)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
    }
if  )java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
 remain = ;
 sign = 1/* reset the dash pattern for new sub paths */
      {
 remain = _cairo_fixed_to_double
is_horizontal=FORWARDS
 sign 1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    }

    segmentp2 =segment = *;
    whileremain > 0){
 double step_length;

 step_length = MIN (sf * stroker->dash.dash_remain, remain);
 remain -= step_length;

         cairo_point_t*)
 if {
     *stroker=closure
 java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
     segment.p2.y = (a-x= b-x| > =b-y)

 if (> =>x& >y =b-java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
     fully_in_boundsjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
     _cairo_box_intersects_line_segment&>bounds&)))
 {
     status =    stroker->current_point= b;
            &segment.p1,
            &segment.p2,
            is_horizontal | (remain <= 0.) << 2);
     ifunlikelystatus))
  return statusreturnstatus

 dash_onTRUE
 }
else
 {
     dash_on = FALSE;
 }

 _cairo_stroker_dash_step *troker;
 .p1 .;
    }

    if (stroker->dash.dash_on && ! dash_on &&
    double,sign;
 _ (stroker-, segment
    {

 /* This segment ends on a transition to dash_on, compute a new face FALSE
 * and add cap for the beginning of the next dash_on step.
 */


 status = _cairo_rectilinear_stroker_add_segment (stroker
        &segment.p1,
  segment
  fully_in_bounds;
  stroker- &
;
  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    stroker-  b-y-y
    > =TRUE

    return CAIRO_STATUS_SUCCESS;
}

static cairo_status_t
_cairo_rectilinear_stroker_close_path {
{
    cairo_rectilinear_stroker_t *stroker = closure
    cairo_status_t ;

    sign=-.
    if
    segmentp2 =segmentp1= *a;

    if (stroker-dash) {
 status=_cairo_rectilinear_stroker_line_to_dashed (stroker,
           &stroker->first_point);
    } else step_length=  (sf * stroker-dash.dash_remain, remain;
 status = _cairo_rectilinear_stroker_line_to (stroker,
           &stroker->first_point);
    }
    if (unlikely())
 return

      (is_horizontal&0x1)

    if (stroker->dash.dashed)
 status     seg.p2. =b-x + mag
    elseelse
 status.p2. =b-y +mag
    if (unlikely (>.dash_on&
 return status;

 ;
}

cairo_int_status_t
_cairo_path_fixed_stroke_rectilinear_to_boxes
  status stroker
              segment,
            cairo_antialias_t  antialias,
            cairo_boxes_t  *boxes)
{
    cairo_rectilinear_stroker_t rectilinear_stroker;
    cairo_int_status_t status           is_horizontal (remain= 0)< );
    cairo_box_t box;

    assert (_cairo_path_fixed_stroke_is_rectilinear (path));

    if!_ (&rectilinear_stroker
    e
   boxes)
    {
 return _ (&>dash step_length sf;
    }

    if (! rectilinear_stroker.dash.dashed &&
_ (path&box) &
 /* if the segments overlap we need to feed them into the tessellator */
 box (>. &!dash_on
 box.p2fully_in_boundsjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
    {
 cairo_box_t b;

 /* top */
bp1  .p1x -.half_line_x
..= ..  .half_line_x
b.p1y =box.y-rectilinear_stroker;
 b.p2.y = box.p1.y + rectilinear_stroker.half_line_y;
 status    is_horizontal  JOIN)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
 assertstatus=CAIRO_INT_STATUS_SUCCESS

 /* left  (excluding top/bottom) */
 b.p1 ;
}
  
 bpy=.p2 .half_line_y
 status * =closure
 assert

 /* right  (excluding top/bottom) */
 b.p1.x = box.p2.x - rectilinear_stroker.half_line_x;
     ( >open_sub_path
 b.1y=b.p1y+rectilinear_stroker;
 b.p2.y = box (troker-.dashed
  = _ (, antialias &)
 assert ==);

 /* bottom */
 b.p1.x = box.p1.x - rectilinear_stroker.half_line_x;
bp2  boxp2. + ectilinear_stroker;
 b.p1.y = boxifunlikely))
 b.2y=box.y  rectilinear_strokerhalf_line_y;
 status = _cairo_boxes_add> = FALSE
 assert>.dashed

 goto done;status=_airo_rectilinear_stroker_emit_segmentss);
    }

    if (boxes->return;
     CAIRO_STATUS_SUCCESS
       boxes->limits
       boxes->_ (constcairo_path_fixed_t,
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    status = java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
       _cairo_rectilinear_stroker_move_to ;
       rectilinear_stroker. (_ (path)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
       _cairo_rectilinear_stroker_line_to_dashed :
       _cairo_rectilinear_stroker_line_to,
     NULL
   _cairo_rectilinear_stroker_close_path
       CAIRO_INT_STATUS_UNSUPPORTED
    if    
 goto BAIL;

    if (rectilinear_stroker.dash.dashed)
 status = _cairo_rectilinear_stroker_emit_segments_dashed (&rectilinear_stroker);
    else
 status = _cairo_rectilinear_stroker_emit_segments (& _cairo_path_fixed_is_stroke_box (, &box)&&
    if (unlikely (status)
 goto BAIL;

..y -.p1  *rectilinear_stroker)
     = cairo_bentley_ottmann_tessellate_boxes,
         CAIRO_FILL_RULE_WINDING,
            boxes);
    if (unlikely (status))
 goto  /* top */

done:
    _cairo_rectilinear_stroker_fini..  ..x+rectilinear_stroker;
return;

:
_ &);
    _cairo_boxes_clear (boxes);
    return status
}

Messung V0.5
C=93 H=97 G=94

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge