1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/utils/SkCullPoints.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 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 + 1.12 + 1.13 +#ifndef SkCullPoints_DEFINED 1.14 +#define SkCullPoints_DEFINED 1.15 + 1.16 +#include "SkRect.h" 1.17 + 1.18 +class SkCullPoints { 1.19 +public: 1.20 + SkCullPoints(); 1.21 + SkCullPoints(const SkIRect& r); 1.22 + 1.23 + void reset(const SkIRect& r); 1.24 + 1.25 + /** Start a contour at (x,y). Follow this with call(s) to lineTo(...) 1.26 + */ 1.27 + void moveTo(int x, int y); 1.28 + 1.29 + enum LineToResult { 1.30 + kNo_Result, //!< line segment was completely clipped out 1.31 + kLineTo_Result, //!< path.lineTo(pts[1]); 1.32 + kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]); 1.33 + }; 1.34 + /** Connect a line to the previous call to lineTo (or moveTo). 1.35 + */ 1.36 + LineToResult lineTo(int x, int y, SkIPoint pts[2]); 1.37 + 1.38 +private: 1.39 + SkIRect fR; // the caller's rectangle 1.40 + SkIPoint fAsQuad[4]; // cache of fR as 4 points 1.41 + SkIPoint fPrevPt; // private state 1.42 + LineToResult fPrevResult; // private state 1.43 + 1.44 + bool sect_test(int x0, int y0, int x1, int y1) const; 1.45 +}; 1.46 + 1.47 +///////////////////////////////////////////////////////////////////////////////// 1.48 + 1.49 +class SkPath; 1.50 + 1.51 +/** \class SkCullPointsPath 1.52 + 1.53 + Similar to SkCullPoints, but this class handles the return values 1.54 + from lineTo, and automatically builds a SkPath with the result(s). 1.55 +*/ 1.56 +class SkCullPointsPath { 1.57 +public: 1.58 + SkCullPointsPath(); 1.59 + SkCullPointsPath(const SkIRect& r, SkPath* dst); 1.60 + 1.61 + void reset(const SkIRect& r, SkPath* dst); 1.62 + 1.63 + void moveTo(int x, int y); 1.64 + void lineTo(int x, int y); 1.65 + 1.66 +private: 1.67 + SkCullPoints fCP; 1.68 + SkPath* fPath; 1.69 +}; 1.70 + 1.71 +bool SkHitTestPath(const SkPath&, SkRect& target, bool hires); 1.72 +bool SkHitTestPath(const SkPath&, SkScalar x, SkScalar y, bool hires); 1.73 + 1.74 +#endif