blob: df2e16c57cd8fcd8df2976bc751422d16e22f4f7 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000010#ifndef GrPathUtils_DEFINED
11#define GrPathUtils_DEFINED
12
bsalomon@google.com181e9bd2011-09-07 18:42:30 +000013#include "GrMatrix.h"
reed@google.com07f3ee12011-05-16 17:21:57 +000014#include "GrPath.h"
bsalomon@google.com69cc6ad2012-01-17 14:25:10 +000015#include "SkTArray.h"
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000016
17/**
18 * Utilities for evaluating paths.
19 */
bsalomon@google.com181e9bd2011-09-07 18:42:30 +000020namespace GrPathUtils {
21 GrScalar scaleToleranceToSrc(GrScalar devTol,
bsalomon@google.com38396322011-09-09 19:32:04 +000022 const GrMatrix& viewM,
23 const GrRect& pathBounds);
tomhudson@google.comc10a8882011-06-28 15:19:32 +000024
bsalomon@google.com181e9bd2011-09-07 18:42:30 +000025 /// Since we divide by tol if we're computing exact worst-case bounds,
26 /// very small tolerances will be increased to gMinCurveTol.
27 int worstCasePointCount(const GrPath&,
28 int* subpaths,
29 GrScalar tol);
30 /// Since we divide by tol if we're computing exact worst-case bounds,
31 /// very small tolerances will be increased to gMinCurveTol.
32 uint32_t quadraticPointCount(const GrPoint points[], GrScalar tol);
33 uint32_t generateQuadraticPoints(const GrPoint& p0,
34 const GrPoint& p1,
35 const GrPoint& p2,
36 GrScalar tolSqd,
37 GrPoint** points,
38 uint32_t pointsLeft);
39 /// Since we divide by tol if we're computing exact worst-case bounds,
40 /// very small tolerances will be increased to gMinCurveTol.
41 uint32_t cubicPointCount(const GrPoint points[], GrScalar tol);
42 uint32_t generateCubicPoints(const GrPoint& p0,
43 const GrPoint& p1,
44 const GrPoint& p2,
45 const GrPoint& p3,
46 GrScalar tolSqd,
47 GrPoint** points,
48 uint32_t pointsLeft);
bsalomon@google.com69cc6ad2012-01-17 14:25:10 +000049 // Compute a matrix that goes from the 2d space coordinates to UV space
50 // where u^2-v = 0 specifies the quad.
51 void quadDesignSpaceToUVCoordsMatrix(const GrPoint qPts[3],
52 GrMatrix* matrix);
53 // Converts a cubic into a sequence of quads. If working in device space
54 // use tolScale = 1, otherwise set based on stretchiness of the matrix. The
55 // result is sets of 3 points in quads (TODO: share endpoints in returned
56 // array)
57 void convertCubicToQuads(const GrPoint p[4],
58 SkScalar tolScale,
59 SkTArray<SkPoint, true>* quads);
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000060};
61#endif