blob: cde560139e9bc2edd713266e61b38e3fec40a44d [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
13#include "GrNoncopyable.h"
reed@google.com7744c202011-05-06 19:26:26 +000014#include "GrPoint.h"
reed@google.com07f3ee12011-05-16 17:21:57 +000015#include "GrPath.h"
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000016
17/**
18 * Utilities for evaluating paths.
19 */
20class GrPathUtils : public GrNoncopyable {
21public:
tomhudson@google.comc10a8882011-06-28 15:19:32 +000022 /// Since we divide by tol if we're computing exact worst-case bounds,
23 /// very small tolerances will be increased to gMinCurveTol.
reed@google.com07f3ee12011-05-16 17:21:57 +000024 static int worstCasePointCount(const GrPath&,
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000025 int* subpaths,
26 GrScalar tol);
tomhudson@google.comc10a8882011-06-28 15:19:32 +000027 /// Since we divide by tol if we're computing exact worst-case bounds,
28 /// very small tolerances will be increased to gMinCurveTol.
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000029 static uint32_t quadraticPointCount(const GrPoint points[], GrScalar tol);
30 static uint32_t generateQuadraticPoints(const GrPoint& p0,
31 const GrPoint& p1,
32 const GrPoint& p2,
33 GrScalar tolSqd,
34 GrPoint** points,
35 uint32_t pointsLeft);
tomhudson@google.comc10a8882011-06-28 15:19:32 +000036 /// Since we divide by tol if we're computing exact worst-case bounds,
37 /// very small tolerances will be increased to gMinCurveTol.
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000038 static uint32_t cubicPointCount(const GrPoint points[], GrScalar tol);
39 static uint32_t generateCubicPoints(const GrPoint& p0,
40 const GrPoint& p1,
41 const GrPoint& p2,
42 const GrPoint& p3,
43 GrScalar tolSqd,
44 GrPoint** points,
45 uint32_t pointsLeft);
tomhudson@google.comc10a8882011-06-28 15:19:32 +000046
47private:
48 static const GrScalar gMinCurveTol;
senorblanco@chromium.org9d18b782011-03-28 20:47:09 +000049};
50#endif