180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkCullPoints_DEFINED 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkCullPoints_DEFINED 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkRect.h" 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkCullPoints { 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkCullPoints(); 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkCullPoints(const SkIRect& r); 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void reset(const SkIRect& r); 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Start a contour at (x,y). Follow this with call(s) to lineTo(...) 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void moveTo(int x, int y); 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru enum LineToResult { 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kNo_Result, //!< line segment was completely clipped out 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kLineTo_Result, //!< path.lineTo(pts[1]); 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]); 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru /** Connect a line to the previous call to lineTo (or moveTo). 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru LineToResult lineTo(int x, int y, SkIPoint pts[2]); 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkIRect fR; // the caller's rectangle 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkIPoint fAsQuad[4]; // cache of fR as 4 points 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkIPoint fPrevPt; // private state 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru LineToResult fPrevResult; // private state 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool sect_test(int x0, int y0, int x1, int y1) const; 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru///////////////////////////////////////////////////////////////////////////////// 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPath; 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** \class SkCullPointsPath 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru Similar to SkCullPoints, but this class handles the return values 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru from lineTo, and automatically builds a SkPath with the result(s). 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru*/ 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkCullPointsPath { 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkCullPointsPath(); 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkCullPointsPath(const SkIRect& r, SkPath* dst); 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void reset(const SkIRect& r, SkPath* dst); 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void moveTo(int x, int y); 6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru void lineTo(int x, int y); 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkCullPoints fCP; 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkPath* fPath; 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querubool SkHitTestPath(const SkPath&, SkRect& target, bool hires); 6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querubool SkHitTestPath(const SkPath&, SkScalar x, SkScalar y, bool hires); 7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 72