summaryrefslogtreecommitdiffstats
path: root/libs/hwui/ShadowTessellator.h
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2014-03-11 16:52:30 -0700
committerztenghui <ztenghui@google.com>2014-03-17 10:10:02 -0700
commit50ecf849cb7ccc3482517b74d2214b347927791e (patch)
treeae48db1ce35bf2d35b5bd126dc78fd5cca0a5d4e /libs/hwui/ShadowTessellator.h
parentde69575dd1bdafabda8afda8b4251b830ba0c551 (diff)
downloadframeworks_base-50ecf849cb7ccc3482517b74d2214b347927791e.zip
frameworks_base-50ecf849cb7ccc3482517b74d2214b347927791e.tar.gz
frameworks_base-50ecf849cb7ccc3482517b74d2214b347927791e.tar.bz2
Create one hole inside the umbra area to avoid overdraw.
bug:13439450 Change-Id: I859575196bd5a3029f447883025a6ec3a1f1face
Diffstat (limited to 'libs/hwui/ShadowTessellator.h')
-rw-r--r--libs/hwui/ShadowTessellator.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/libs/hwui/ShadowTessellator.h b/libs/hwui/ShadowTessellator.h
index c558460..ab039fa 100644
--- a/libs/hwui/ShadowTessellator.h
+++ b/libs/hwui/ShadowTessellator.h
@@ -20,6 +20,7 @@
#include "Debug.h"
#include "Matrix.h"
+#include "OpenGLRenderer.h"
#include "VertexBuffer.h"
namespace android {
@@ -30,15 +31,14 @@ namespace uirenderer {
// 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.
-//
+// Ambient shadow is using only 1 layer for opaque caster, otherwise, spot
+// shadow and ambient shadow are using 2 layers.
// 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
//
@@ -49,20 +49,27 @@ namespace uirenderer {
#define SHADOW_RAY_COUNT 128
// The total number of all the vertices representing the shadow.
-#define SHADOW_VERTEX_COUNT (2 * SHADOW_RAY_COUNT + 1)
+// For the case we only have 1 layer, then we will just fill only 2/3 of it.
+#define SHADOW_VERTEX_COUNT (3 * SHADOW_RAY_COUNT)
// 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))
+// Depending on the mode we are drawing, we can have 1 layer or 2 layers.
+// Therefore, we only build the longer index buffer.
+#define TWO_POLY_RING_SHADOW_INDEX_COUNT (4 * (SHADOW_RAY_COUNT + 1))
+#define ONE_POLY_RING_SHADOW_INDEX_COUNT (2 * (SHADOW_RAY_COUNT + 1))
+
+#define MAX_SHADOW_INDEX_COUNT TWO_POLY_RING_SHADOW_INDEX_COUNT
#define SHADOW_MIN_CASTER_Z 0.001f
class ShadowTessellator {
public:
- static void tessellateAmbientShadow(const Vector3* casterPolygon,
- int casterVertexCount, const Vector3& centroid3d,
- VertexBuffer& shadowVertexBuffer);
+ static VertexBufferMode tessellateAmbientShadow(bool isCasterOpaque,
+ const Vector3* casterPolygon, int casterVertexCount,
+ const Vector3& centroid3d, VertexBuffer& shadowVertexBuffer);
- static void tessellateSpotShadow(const Vector3* casterPolygon, int casterVertexCount,
+ static VertexBufferMode tessellateSpotShadow(bool isCasterOpaque,
+ const Vector3* casterPolygon, int casterVertexCount,
const Vector3& lightPosScale, const mat4& receiverTransform,
int screenWidth, int screenHeight, VertexBuffer& shadowVertexBuffer);