Loading libs/hwui/AmbientShadow.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, const Vector3* vertices, int vertexCount, const Vector3& centroid3d, float heightFactor, float geomFactor, VertexBuffer& shadowVertexBuffer) { const int rays = SHADOW_RAY_COUNT; VertexBuffer::Mode mode = VertexBuffer::kOnePolyRingShadow; // Validate the inputs. if (vertexCount < 3 || heightFactor <= 0 || rays <= 0 || geomFactor <= 0) { Loading Loading @@ -124,19 +123,23 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, opacity); } if (isCasterOpaque) { // skip inner ring, calc bounds over filled portion of buffer shadowVertexBuffer.computeBounds<AlphaVertex>(2 * rays); shadowVertexBuffer.setMode(VertexBuffer::kOnePolyRingShadow); } else { // If caster isn't opaque, we need to to fill the umbra by storing the umbra's // centroid in the innermost ring of vertices. if (!isCasterOpaque) { mode = VertexBuffer::kTwoPolyRingShadow; float centroidAlpha = 1.0 / (1 + centroid3d.z * heightFactor); AlphaVertex centroidXYA; AlphaVertex::set(¢roidXYA, centroid2d.x, centroid2d.y, centroidAlpha); for (int rayIndex = 0; rayIndex < rays; rayIndex++) { shadowVertices[2 * rays + rayIndex] = centroidXYA; } } shadowVertexBuffer.setMode(mode); // calc bounds over entire buffer shadowVertexBuffer.computeBounds<AlphaVertex>(); shadowVertexBuffer.setMode(VertexBuffer::kTwoPolyRingShadow); } #if DEBUG_SHADOW for (int i = 0; i < SHADOW_VERTEX_COUNT; i++) { Loading libs/hwui/SpotShadow.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -507,8 +507,6 @@ void SpotShadow::createSpotShadow(bool isCasterOpaque, const Vector3* poly, computeLightPolygon(lightVertexCount, lightCenter, lightSize, light); computeSpotShadow(isCasterOpaque, light, lightVertexCount, lightCenter, poly, polyLength, retStrips); retStrips.setMode(VertexBuffer::kTwoPolyRingShadow); retStrips.computeBounds<AlphaVertex>(); } /** Loading Loading @@ -785,6 +783,9 @@ void SpotShadow::generateTriangleStrip(bool isCasterOpaque, const Vector2* penum shadowVertices[2 * rays + rayIndex] = centroidXYA; } } shadowTriangleStrip.setMode(VertexBuffer::kTwoPolyRingShadow); shadowTriangleStrip.computeBounds<AlphaVertex>(); } /** Loading libs/hwui/VertexBuffer.h +6 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ public: mVertexCount = vertexCount; mByteCount = mVertexCount * sizeof(TYPE); mReallocBuffer = mBuffer = (void*)new TYPE[vertexCount]; memset(mBuffer, 0, sizeof(TYPE) * vertexCount); mCleanupMethod = &(cleanup<TYPE>); Loading @@ -86,13 +85,17 @@ public: * vertex buffer can't determine bounds more simply/efficiently */ template <class TYPE> void computeBounds() { void computeBounds(int vertexCount = 0) { if (!mVertexCount) { mBounds.setEmpty(); return; } // default: compute over every vertex if (vertexCount == 0) vertexCount = mVertexCount; TYPE* current = (TYPE*)mBuffer; TYPE* end = current + mVertexCount; TYPE* end = current + vertexCount; mBounds.set(current->x, current->y, current->x, current->y); for (; current < end; current++) { mBounds.expandToCoverVertex(current->x, current->y); Loading Loading
libs/hwui/AmbientShadow.cpp +10 −7 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, const Vector3* vertices, int vertexCount, const Vector3& centroid3d, float heightFactor, float geomFactor, VertexBuffer& shadowVertexBuffer) { const int rays = SHADOW_RAY_COUNT; VertexBuffer::Mode mode = VertexBuffer::kOnePolyRingShadow; // Validate the inputs. if (vertexCount < 3 || heightFactor <= 0 || rays <= 0 || geomFactor <= 0) { Loading Loading @@ -124,19 +123,23 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, opacity); } if (isCasterOpaque) { // skip inner ring, calc bounds over filled portion of buffer shadowVertexBuffer.computeBounds<AlphaVertex>(2 * rays); shadowVertexBuffer.setMode(VertexBuffer::kOnePolyRingShadow); } else { // If caster isn't opaque, we need to to fill the umbra by storing the umbra's // centroid in the innermost ring of vertices. if (!isCasterOpaque) { mode = VertexBuffer::kTwoPolyRingShadow; float centroidAlpha = 1.0 / (1 + centroid3d.z * heightFactor); AlphaVertex centroidXYA; AlphaVertex::set(¢roidXYA, centroid2d.x, centroid2d.y, centroidAlpha); for (int rayIndex = 0; rayIndex < rays; rayIndex++) { shadowVertices[2 * rays + rayIndex] = centroidXYA; } } shadowVertexBuffer.setMode(mode); // calc bounds over entire buffer shadowVertexBuffer.computeBounds<AlphaVertex>(); shadowVertexBuffer.setMode(VertexBuffer::kTwoPolyRingShadow); } #if DEBUG_SHADOW for (int i = 0; i < SHADOW_VERTEX_COUNT; i++) { Loading
libs/hwui/SpotShadow.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -507,8 +507,6 @@ void SpotShadow::createSpotShadow(bool isCasterOpaque, const Vector3* poly, computeLightPolygon(lightVertexCount, lightCenter, lightSize, light); computeSpotShadow(isCasterOpaque, light, lightVertexCount, lightCenter, poly, polyLength, retStrips); retStrips.setMode(VertexBuffer::kTwoPolyRingShadow); retStrips.computeBounds<AlphaVertex>(); } /** Loading Loading @@ -785,6 +783,9 @@ void SpotShadow::generateTriangleStrip(bool isCasterOpaque, const Vector2* penum shadowVertices[2 * rays + rayIndex] = centroidXYA; } } shadowTriangleStrip.setMode(VertexBuffer::kTwoPolyRingShadow); shadowTriangleStrip.computeBounds<AlphaVertex>(); } /** Loading
libs/hwui/VertexBuffer.h +6 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ public: mVertexCount = vertexCount; mByteCount = mVertexCount * sizeof(TYPE); mReallocBuffer = mBuffer = (void*)new TYPE[vertexCount]; memset(mBuffer, 0, sizeof(TYPE) * vertexCount); mCleanupMethod = &(cleanup<TYPE>); Loading @@ -86,13 +85,17 @@ public: * vertex buffer can't determine bounds more simply/efficiently */ template <class TYPE> void computeBounds() { void computeBounds(int vertexCount = 0) { if (!mVertexCount) { mBounds.setEmpty(); return; } // default: compute over every vertex if (vertexCount == 0) vertexCount = mVertexCount; TYPE* current = (TYPE*)mBuffer; TYPE* end = current + mVertexCount; TYPE* end = current + vertexCount; mBounds.set(current->x, current->y, current->x, current->y); for (; current < end; current++) { mBounds.expandToCoverVertex(current->x, current->y); Loading