gfx/skia/trunk/include/core/SkLineClipper.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/core/SkLineClipper.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +#ifndef SkLineClipper_DEFINED
    1.12 +#define SkLineClipper_DEFINED
    1.13 +
    1.14 +#include "SkRect.h"
    1.15 +#include "SkPoint.h"
    1.16 +
    1.17 +class SkLineClipper {
    1.18 +public:
    1.19 +    enum {
    1.20 +        kMaxPoints = 4,
    1.21 +        kMaxClippedLineSegments = kMaxPoints - 1
    1.22 +    };
    1.23 +
    1.24 +    /*  Clip the line pts[0]...pts[1] against clip, ignoring segments that
    1.25 +        lie completely above or below the clip. For portions to the left or
    1.26 +        right, turn those into vertical line segments that are aligned to the
    1.27 +        edge of the clip.
    1.28 +
    1.29 +        Return the number of line segments that result, and store the end-points
    1.30 +        of those segments sequentially in lines as follows:
    1.31 +            1st segment: lines[0]..lines[1]
    1.32 +            2nd segment: lines[1]..lines[2]
    1.33 +            3rd segment: lines[2]..lines[3]
    1.34 +     */
    1.35 +    static int ClipLine(const SkPoint pts[2], const SkRect& clip,
    1.36 +                        SkPoint lines[kMaxPoints]);
    1.37 +
    1.38 +    /*  Intersect the line segment against the rect. If there is a non-empty
    1.39 +        resulting segment, return true and set dst[] to that segment. If not,
    1.40 +        return false and ignore dst[].
    1.41 +
    1.42 +        ClipLine is specialized for scan-conversion, as it adds vertical
    1.43 +        segments on the sides to show where the line extended beyond the
    1.44 +        left or right sides. IntersectLine does not.
    1.45 +     */
    1.46 +    static bool IntersectLine(const SkPoint src[2], const SkRect& clip,
    1.47 +                              SkPoint dst[2]);
    1.48 +};
    1.49 +
    1.50 +#endif

mercurial