diff options
| author | 2013-12-03 10:38:55 -0800 | |
|---|---|---|
| committer | 2013-12-13 17:25:47 -0800 | |
| commit | 55bfb4e728fe1db619af5d2c287f4abe711b3343 (patch) | |
| tree | 3b9c9eb0902fdb0f8991259a04c342f89f65bcaa /libs/hwui/OpenGLRenderer.cpp | |
| parent | d08eadd287991ec18eafe620b24e2b1bf0ce1f2d (diff) | |
Calculate and show Ambient shadow.
Basically we compute the shadow as a strip of triangles, whose alpha value
is the strength of the shadow.
We use the normal to extend the geometry.
And we use static function and try to avoid new/malloc in the computation.
Change-Id: I382286f1cad351bd5ff983f76f446c075819dcaf
Diffstat (limited to 'libs/hwui/OpenGLRenderer.cpp')
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 79df5201f62c..578a2517105d 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -36,7 +36,9 @@ #include "Fence.h" #include "PathTessellator.h" #include "Properties.h" +#include "ShadowTessellator.h" #include "Vector.h" +#include "VertexBuffer.h" namespace android { namespace uirenderer { @@ -2579,7 +2581,7 @@ status_t OpenGLRenderer::drawVertexBuffer(const VertexBuffer& vertexBuffer, SkPa setupDrawColorFilterUniforms(); setupDrawShaderUniforms(); - void* vertices = vertexBuffer.getBuffer(); + const void* vertices = vertexBuffer.getBuffer(); bool force = mCaches.unbindMeshBuffer(); mCaches.bindPositionVertexPointer(true, vertices, isAA ? gAlphaVertexStride : gVertexStride); mCaches.resetTexCoordsVertexPointer(); @@ -3393,22 +3395,13 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransform, float casterAlp SkPaint paint; paint.setColor(0x3f000000); + // Force the draw to use alpha values. paint.setAntiAlias(true); - VertexBuffer vertexBuffer; - { - //TODO: populate vertex buffer with better shadow geometry. - Vector3 pivot(width/2, height/2, 0.0f); - casterTransform.mapPoint3d(pivot); - - float zScaleFactor = 0.5 + 0.0005f * pivot.z; - - SkPath path; - path.addRect(pivot.x - width * zScaleFactor, pivot.y - height * zScaleFactor, - pivot.x + width * zScaleFactor, pivot.y + height * zScaleFactor); - PathTessellator::tessellatePath(path, &paint, mSnapshot->transform, vertexBuffer); - } - return drawVertexBuffer(vertexBuffer, &paint); + VertexBuffer shadowVertexBuffer; + ShadowTessellator::tessellateAmbientShadow(width, height, casterTransform, + shadowVertexBuffer); + return drawVertexBuffer(shadowVertexBuffer, &paint); } status_t OpenGLRenderer::drawColorRects(const float* rects, int count, int color, |