2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_HWUI_SPOT_SHADOW_H
18 #define ANDROID_HWUI_SPOT_SHADOW_H
24 namespace uirenderer {
30 static void createSpotShadow(bool isCasterOpaque, const Vector3& lightCenter,
31 float lightSize, const Vector3* poly, int polyLength,
32 const Vector3& polyCentroid, VertexBuffer& retstrips);
35 struct VertexAngleData;
37 static float projectCasterToOutline(Vector2& outline,
38 const Vector3& lightCenter, const Vector3& polyVertex);
40 static void computeLightPolygon(int points, const Vector3& lightCenter,
41 float size, Vector3* ret);
43 static void smoothPolygon(int level, int rays, float* rayDist);
44 static float rayIntersectPoly(const Vector2* poly, int polyLength,
45 const Vector2& point, float dx, float dy);
47 static void xsort(Vector2* points, int pointsLength);
48 static int hull(Vector2* points, int pointsLength, Vector2* retPoly);
49 static bool ccw(float ax, float ay, float bx, float by, float cx, float cy);
50 static void sort(Vector2* poly, int polyLength, const Vector2& center);
52 static void swap(Vector2* points, int i, int j);
53 static void quicksortCirc(Vector2* points, int low, int high, const Vector2& center);
54 static void quicksortX(Vector2* points, int low, int high);
56 static bool testPointInsidePolygon(const Vector2 testPoint, const Vector2* poly, int len);
57 static void makeClockwise(Vector2* polygon, int len);
58 static void reverse(Vector2* polygon, int len);
60 static void generateTriangleStrip(bool isCasterOpaque, float shadowStrengthScale,
61 Vector2* penumbra, int penumbraLength, Vector2* umbra, int umbraLength,
62 const Vector3* poly, int polyLength, VertexBuffer& retstrips, const Vector2& centroid);
65 static bool testConvex(const Vector2* polygon, int polygonLength,
67 static void testIntersection(const Vector2* poly1, int poly1Length,
68 const Vector2* poly2, int poly2Length,
69 const Vector2* intersection, int intersectionLength);
70 static void updateBound(const Vector2 inVector, Vector2& lowerBound, Vector2& upperBound );
71 static void dumpPolygon(const Vector2* poly, int polyLength, const char* polyName);
72 static void dumpPolygon(const Vector3* poly, int polyLength, const char* polyName);
77 }; // namespace uirenderer
78 }; // namespace android
80 #endif // ANDROID_HWUI_SPOT_SHADOW_H