blob: e43b10133b993aa83734485859a745714348cf8d [file] [log] [blame]
Chris Craik65cd6122012-12-10 17:56:27 -08001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HWUI_PATH_TESSELLATOR_H
18#define ANDROID_HWUI_PATH_TESSELLATOR_H
19
20#include <utils/Vector.h>
21
22#include "Matrix.h"
23#include "Rect.h"
24#include "Vertex.h"
ztenghui55bfb4e2013-12-03 10:38:55 -080025#include "VertexBuffer.h"
Chris Craik65cd6122012-12-10 17:56:27 -080026
27namespace android {
28namespace uirenderer {
29
Chris Craik65cd6122012-12-10 17:56:27 -080030class PathTessellator {
31public:
Chris Craikf0a59072013-11-19 18:00:46 -080032 static void expandBoundsForStroke(SkRect& bounds, const SkPaint* paint);
Chris Craik65cd6122012-12-10 17:56:27 -080033
34 static void tessellatePath(const SkPath& path, const SkPaint* paint,
Chris Craikd6b65f62014-01-01 14:45:21 -080035 const mat4& transform, VertexBuffer& vertexBuffer);
Chris Craik65cd6122012-12-10 17:56:27 -080036
Chris Craikd218a922014-01-02 17:13:34 -080037 static void tessellatePoints(const float* points, int count, const SkPaint* paint,
Chris Craikd6b65f62014-01-01 14:45:21 -080038 const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer);
Chris Craik6d29c8d2013-05-08 18:35:44 -070039
Chris Craikd218a922014-01-02 17:13:34 -080040 static void tessellateLines(const float* points, int count, const SkPaint* paint,
Chris Craikd6b65f62014-01-01 14:45:21 -080041 const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer);
Chris Craik65cd6122012-12-10 17:56:27 -080042
43private:
44 static bool approximatePathOutlineVertices(const SkPath &path, bool forceClose,
45 float sqrInvScaleX, float sqrInvScaleY, Vector<Vertex> &outputVertices);
46
47/*
48 endpoints a & b,
49 control c
50 */
51 static void recursiveQuadraticBezierVertices(
52 float ax, float ay,
53 float bx, float by,
54 float cx, float cy,
55 float sqrInvScaleX, float sqrInvScaleY,
56 Vector<Vertex> &outputVertices);
57
58/*
59 endpoints p1, p2
60 control c1, c2
61 */
62 static void recursiveCubicBezierVertices(
63 float p1x, float p1y,
64 float c1x, float c1y,
65 float p2x, float p2y,
66 float c2x, float c2y,
67 float sqrInvScaleX, float sqrInvScaleY,
68 Vector<Vertex> &outputVertices);
69};
70
71}; // namespace uirenderer
72}; // namespace android
73
74#endif // ANDROID_HWUI_PATH_TESSELLATOR_H