gfx/skia/trunk/include/utils/SkCullPoints.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkCullPoints_DEFINED
michael@0 11 #define SkCullPoints_DEFINED
michael@0 12
michael@0 13 #include "SkRect.h"
michael@0 14
michael@0 15 class SkCullPoints {
michael@0 16 public:
michael@0 17 SkCullPoints();
michael@0 18 SkCullPoints(const SkIRect& r);
michael@0 19
michael@0 20 void reset(const SkIRect& r);
michael@0 21
michael@0 22 /** Start a contour at (x,y). Follow this with call(s) to lineTo(...)
michael@0 23 */
michael@0 24 void moveTo(int x, int y);
michael@0 25
michael@0 26 enum LineToResult {
michael@0 27 kNo_Result, //!< line segment was completely clipped out
michael@0 28 kLineTo_Result, //!< path.lineTo(pts[1]);
michael@0 29 kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]);
michael@0 30 };
michael@0 31 /** Connect a line to the previous call to lineTo (or moveTo).
michael@0 32 */
michael@0 33 LineToResult lineTo(int x, int y, SkIPoint pts[2]);
michael@0 34
michael@0 35 private:
michael@0 36 SkIRect fR; // the caller's rectangle
michael@0 37 SkIPoint fAsQuad[4]; // cache of fR as 4 points
michael@0 38 SkIPoint fPrevPt; // private state
michael@0 39 LineToResult fPrevResult; // private state
michael@0 40
michael@0 41 bool sect_test(int x0, int y0, int x1, int y1) const;
michael@0 42 };
michael@0 43
michael@0 44 /////////////////////////////////////////////////////////////////////////////////
michael@0 45
michael@0 46 class SkPath;
michael@0 47
michael@0 48 /** \class SkCullPointsPath
michael@0 49
michael@0 50 Similar to SkCullPoints, but this class handles the return values
michael@0 51 from lineTo, and automatically builds a SkPath with the result(s).
michael@0 52 */
michael@0 53 class SkCullPointsPath {
michael@0 54 public:
michael@0 55 SkCullPointsPath();
michael@0 56 SkCullPointsPath(const SkIRect& r, SkPath* dst);
michael@0 57
michael@0 58 void reset(const SkIRect& r, SkPath* dst);
michael@0 59
michael@0 60 void moveTo(int x, int y);
michael@0 61 void lineTo(int x, int y);
michael@0 62
michael@0 63 private:
michael@0 64 SkCullPoints fCP;
michael@0 65 SkPath* fPath;
michael@0 66 };
michael@0 67
michael@0 68 bool SkHitTestPath(const SkPath&, SkRect& target, bool hires);
michael@0 69 bool SkHitTestPath(const SkPath&, SkScalar x, SkScalar y, bool hires);
michael@0 70
michael@0 71 #endif

mercurial