summaryrefslogtreecommitdiffstats
path: root/libs/hwui/ShadowTessellator.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/ShadowTessellator.h')
-rw-r--r--libs/hwui/ShadowTessellator.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/libs/hwui/ShadowTessellator.h b/libs/hwui/ShadowTessellator.h
index ef95609..c49fdcb 100644
--- a/libs/hwui/ShadowTessellator.h
+++ b/libs/hwui/ShadowTessellator.h
@@ -20,18 +20,57 @@
#include "Debug.h"
#include "Matrix.h"
+#include "VertexBuffer.h"
namespace android {
namespace uirenderer {
+// All SHADOW_* are used to define all the geometry property of shadows.
+// Use a simplified example to illustrate the geometry setup here.
+// Assuming we use 6 rays and only 1 layer, Then we will have 2 hexagons, which
+// are 0 to 5 and 6 to 11. The area between them will be the penumbra area, and
+// the area inside the 2nd hexagon is the umbra.
+// Also, we need to add the centroid "12" to draw the umbra area as triangle fans.
+//
+// Triange strip indices for penumbra area: (0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 0, 6)
+// Triange strip indices for numbra area: (6, 12, 7, 12, 8, 12, 9, 12, 10, 12, 11, 12, 6)
+// 0
+//
+// 5 6 1
+// 11 7
+// 12
+// 10 8
+// 4 9 2
+//
+// 3
+
+// The total number of rays starting from the centroid of shadow area, in order
+// to generate the shadow geometry.
+#define SHADOW_RAY_COUNT 256
+
+// The total number of layers in the outer shadow area, 1 being the minimum.
+#define SHADOW_LAYER_COUNT 2
+
+// The total number of all the vertices representing the shadow.
+#define SHADOW_VERTEX_COUNT ((SHADOW_LAYER_COUNT + 1) * SHADOW_RAY_COUNT + 1)
+
+// The total number of indices used for drawing the shadow geometry as triangle strips.
+#define SHADOW_INDEX_COUNT (2 * SHADOW_RAY_COUNT + 1 + 2 * (SHADOW_RAY_COUNT + 1) * \
+ SHADOW_LAYER_COUNT)
+
class ShadowTessellator {
public:
- static void tessellateAmbientShadow(const Vector3* casterPolygon, int casterVertexCount,
+ static void tessellateAmbientShadow(const Vector3* casterPolygon,
+ int casterVertexCount, const Vector3& centroid3d,
VertexBuffer& shadowVertexBuffer);
static void tessellateSpotShadow(const Vector3* casterPolygon, int casterVertexCount,
const Vector3& lightPosScale, const mat4& receiverTransform,
int screenWidth, int screenHeight, VertexBuffer& shadowVertexBuffer);
+
+ static void generateShadowIndices(uint16_t* shadowIndices);
+
+ static Vector2 centroid2d(const Vector2* poly, int polyLength);
}; // ShadowTessellator
}; // namespace uirenderer