Chris Craik | 65cd612 | 2012-12-10 17:56:27 -0800 | [diff] [blame] | 1 | /* |
| 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" |
ztenghui | 55bfb4e | 2013-12-03 10:38:55 -0800 | [diff] [blame] | 25 | #include "VertexBuffer.h" |
Chris Craik | 65cd612 | 2012-12-10 17:56:27 -0800 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | namespace uirenderer { |
| 29 | |
Chris Craik | 65cd612 | 2012-12-10 17:56:27 -0800 | [diff] [blame] | 30 | class PathTessellator { |
| 31 | public: |
Chris Craik | f0a5907 | 2013-11-19 18:00:46 -0800 | [diff] [blame] | 32 | static void expandBoundsForStroke(SkRect& bounds, const SkPaint* paint); |
Chris Craik | 65cd612 | 2012-12-10 17:56:27 -0800 | [diff] [blame] | 33 | |
| 34 | static void tessellatePath(const SkPath& path, const SkPaint* paint, |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 35 | const mat4& transform, VertexBuffer& vertexBuffer); |
Chris Craik | 65cd612 | 2012-12-10 17:56:27 -0800 | [diff] [blame] | 36 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame^] | 37 | static void tessellatePoints(const float* points, int count, const SkPaint* paint, |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 38 | const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer); |
Chris Craik | 6d29c8d | 2013-05-08 18:35:44 -0700 | [diff] [blame] | 39 | |
Chris Craik | d218a92 | 2014-01-02 17:13:34 -0800 | [diff] [blame^] | 40 | static void tessellateLines(const float* points, int count, const SkPaint* paint, |
Chris Craik | d6b65f6 | 2014-01-01 14:45:21 -0800 | [diff] [blame] | 41 | const mat4& transform, SkRect& bounds, VertexBuffer& vertexBuffer); |
Chris Craik | 65cd612 | 2012-12-10 17:56:27 -0800 | [diff] [blame] | 42 | |
| 43 | private: |
| 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 |