Loading libs/hwui/.clang-format 0 → 100644 +10 −0 Original line number Original line Diff line number Diff line BasedOnStyle: Google DerivePointerAlignment: false IndentWidth: 4 ConstructorInitializerIndentWidth: 8 ContinuationIndentWidth: 8 ColumnLimit: 100 AllowShortFunctionsOnASingleLine: Inline AccessModifierOffset: -4 #BreakConstructorInitializers: BeforeComma BreakConstructorInitializersBeforeComma: true libs/hwui/AmbientShadow.cpp +47 −52 Original line number Original line Diff line number Diff line Loading @@ -56,8 +56,8 @@ #include "Vertex.h" #include "Vertex.h" #include "VertexBuffer.h" #include "VertexBuffer.h" #include <algorithm> #include <utils/Log.h> #include <utils/Log.h> #include <algorithm> namespace android { namespace android { namespace uirenderer { namespace uirenderer { Loading @@ -79,8 +79,8 @@ inline float getAlphaFromFactoredZ(float factoredZ) { return 1.0 / (1 + std::max(factoredZ, 0.0f)); return 1.0 / (1 + std::max(factoredZ, 0.0f)); } } inline int getEdgeExtraAndUpdateSpike(Vector2* currentSpike, inline int getEdgeExtraAndUpdateSpike(Vector2* currentSpike, const Vector3& secondVertex, const Vector3& secondVertex, const Vector3& centroid) { const Vector3& centroid) { Vector2 secondSpike = {secondVertex.x - centroid.x, secondVertex.y - centroid.y}; Vector2 secondSpike = {secondVertex.x - centroid.x, secondVertex.y - centroid.y}; secondSpike.normalize(); secondSpike.normalize(); Loading @@ -92,11 +92,11 @@ inline int getEdgeExtraAndUpdateSpike(Vector2* currentSpike, // Given the caster's vertex count, compute all the buffers size depending on // Given the caster's vertex count, compute all the buffers size depending on // whether or not the caster is opaque. // whether or not the caster is opaque. inline void computeBufferSize(int* totalVertexCount, int* totalIndexCount, inline void computeBufferSize(int* totalVertexCount, int* totalIndexCount, int* totalUmbraCount, int* totalUmbraCount, int casterVertexCount, bool isCasterOpaque) { int casterVertexCount, bool isCasterOpaque) { // Compute the size of the vertex buffer. // Compute the size of the vertex buffer. int outerVertexCount = casterVertexCount * 2 + MAX_EXTRA_CORNER_VERTEX_NUMBER + int outerVertexCount = MAX_EXTRA_EDGE_VERTEX_NUMBER; casterVertexCount * 2 + MAX_EXTRA_CORNER_VERTEX_NUMBER + MAX_EXTRA_EDGE_VERTEX_NUMBER; int innerVertexCount = casterVertexCount + MAX_EXTRA_EDGE_VERTEX_NUMBER; int innerVertexCount = casterVertexCount + MAX_EXTRA_EDGE_VERTEX_NUMBER; *totalVertexCount = outerVertexCount + innerVertexCount; *totalVertexCount = outerVertexCount + innerVertexCount; Loading Loading @@ -163,27 +163,25 @@ inline bool needsExtraForEdge(float firstAlpha, float secondAlpha) { * | | * | | * (V3)-----------------------------------(V2) * (V3)-----------------------------------(V2) */ */ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, void AmbientShadow::createAmbientShadow(bool isCasterOpaque, const Vector3* casterVertices, const Vector3* casterVertices, int casterVertexCount, const Vector3& centroid3d, int casterVertexCount, const Vector3& centroid3d, float heightFactor, float geomFactor, VertexBuffer& shadowVertexBuffer) { float heightFactor, float geomFactor, VertexBuffer& shadowVertexBuffer) { shadowVertexBuffer.setMeshFeatureFlags(VertexBuffer::kAlpha | VertexBuffer::kIndices); shadowVertexBuffer.setMeshFeatureFlags(VertexBuffer::kAlpha | VertexBuffer::kIndices); // In order to computer the outer vertices in one loop, we need pre-compute // In order to computer the outer vertices in one loop, we need pre-compute // the normal by the vertex (n - 1) to vertex 0, and the spike and alpha value // the normal by the vertex (n - 1) to vertex 0, and the spike and alpha value // for vertex 0. // for vertex 0. Vector2 previousNormal = getNormalFromVertices(casterVertices, Vector2 previousNormal = getNormalFromVertices(casterVertices, casterVertexCount - 1, 0); casterVertexCount - 1 , 0); Vector2 currentSpike = {casterVertices[0].x - centroid3d.x, casterVertices[0].y - centroid3d.y}; Vector2 currentSpike = {casterVertices[0].x - centroid3d.x, casterVertices[0].y - centroid3d.y}; currentSpike.normalize(); currentSpike.normalize(); float currentAlpha = getAlphaFromFactoredZ(casterVertices[0].z * heightFactor); float currentAlpha = getAlphaFromFactoredZ(casterVertices[0].z * heightFactor); // Preparing all the output data. // Preparing all the output data. int totalVertexCount, totalIndexCount, totalUmbraCount; int totalVertexCount, totalIndexCount, totalUmbraCount; computeBufferSize(&totalVertexCount, &totalIndexCount, &totalUmbraCount, computeBufferSize(&totalVertexCount, &totalIndexCount, &totalUmbraCount, casterVertexCount, casterVertexCount, isCasterOpaque); isCasterOpaque); AlphaVertex* shadowVertices = AlphaVertex* shadowVertices = shadowVertexBuffer.alloc<AlphaVertex>(totalVertexCount); shadowVertexBuffer.alloc<AlphaVertex>(totalVertexCount); int vertexBufferIndex = 0; int vertexBufferIndex = 0; uint16_t* indexBuffer = shadowVertexBuffer.allocIndices<uint16_t>(totalIndexCount); uint16_t* indexBuffer = shadowVertexBuffer.allocIndices<uint16_t>(totalIndexCount); int indexBufferIndex = 0; int indexBufferIndex = 0; Loading @@ -193,11 +191,11 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, for (int i = 0; i < casterVertexCount; i++) { for (int i = 0; i < casterVertexCount; i++) { // Corner: first figure out the extra vertices we need for the corner. // Corner: first figure out the extra vertices we need for the corner. const Vector3& innerVertex = casterVertices[i]; const Vector3& innerVertex = casterVertices[i]; Vector2 currentNormal = getNormalFromVertices(casterVertices, i, Vector2 currentNormal = (i + 1) % casterVertexCount); getNormalFromVertices(casterVertices, i, (i + 1) % casterVertexCount); int extraVerticesNumber = ShadowTessellator::getExtraVertexNumber(currentNormal, int extraVerticesNumber = ShadowTessellator::getExtraVertexNumber( previousNormal, CORNER_RADIANS_DIVISOR); currentNormal, previousNormal, CORNER_RADIANS_DIVISOR); float expansionDist = innerVertex.z * heightFactor * geomFactor; float expansionDist = innerVertex.z * heightFactor * geomFactor; const int cornerSlicesNumber = extraVerticesNumber + 1; // Minimal as 1. const int cornerSlicesNumber = extraVerticesNumber + 1; // Minimal as 1. Loading @@ -212,9 +210,8 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, if (!isCasterOpaque) { if (!isCasterOpaque) { umbraVertices[umbraIndex++] = vertexBufferIndex; umbraVertices[umbraIndex++] = vertexBufferIndex; } } AlphaVertex::set(&shadowVertices[vertexBufferIndex++], AlphaVertex::set(&shadowVertices[vertexBufferIndex++], casterVertices[i].x, casterVertices[i].x, casterVertices[i].y, casterVertices[i].y, currentAlpha); currentAlpha); const Vector3& innerStart = casterVertices[i]; const Vector3& innerStart = casterVertices[i]; Loading @@ -225,8 +222,7 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, // This will create vertices from [0, cornerSlicesNumber] inclusively, // This will create vertices from [0, cornerSlicesNumber] inclusively, // which means minimally 2 vertices even without the extra ones. // which means minimally 2 vertices even without the extra ones. for (int j = 0; j <= cornerSlicesNumber; j++) { for (int j = 0; j <= cornerSlicesNumber; j++) { Vector2 averageNormal = Vector2 averageNormal = previousNormal * (cornerSlicesNumber - j) + currentNormal * j; previousNormal * (cornerSlicesNumber - j) + currentNormal * j; averageNormal /= cornerSlicesNumber; averageNormal /= cornerSlicesNumber; averageNormal.normalize(); averageNormal.normalize(); Vector2 outerVertex; Vector2 outerVertex; Loading @@ -235,8 +231,8 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, indexBuffer[indexBufferIndex++] = vertexBufferIndex; indexBuffer[indexBufferIndex++] = vertexBufferIndex; indexBuffer[indexBufferIndex++] = currentInnerVertexIndex; indexBuffer[indexBufferIndex++] = currentInnerVertexIndex; AlphaVertex::set(&shadowVertices[vertexBufferIndex++], outerVertex.x, AlphaVertex::set(&shadowVertices[vertexBufferIndex++], outerVertex.x, outerVertex.y, outerVertex.y, OUTER_ALPHA); OUTER_ALPHA); if (j == 0) { if (j == 0) { outerStart = outerVertex; outerStart = outerVertex; Loading @@ -257,8 +253,8 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, outerNext.y = innerNext.y + currentNormal.y * expansionDist; outerNext.y = innerNext.y + currentNormal.y * expansionDist; // Compute the angle and see how many extra points we need. // Compute the angle and see how many extra points we need. int extraVerticesNumber = getEdgeExtraAndUpdateSpike(¤tSpike, int extraVerticesNumber = innerNext, centroid3d); getEdgeExtraAndUpdateSpike(¤tSpike, innerNext, centroid3d); #if DEBUG_SHADOW #if DEBUG_SHADOW ALOGD("extraVerticesNumber %d for edge %d", extraVerticesNumber, i); ALOGD("extraVerticesNumber %d for edge %d", extraVerticesNumber, i); #endif #endif Loading Loading @@ -293,11 +289,10 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, if (!isCasterOpaque) { if (!isCasterOpaque) { // Add the centroid as the last one in the vertex buffer. // Add the centroid as the last one in the vertex buffer. float centroidOpacity = float centroidOpacity = getAlphaFromFactoredZ(centroid3d.z * heightFactor); getAlphaFromFactoredZ(centroid3d.z * heightFactor); int centroidIndex = vertexBufferIndex; int centroidIndex = vertexBufferIndex; AlphaVertex::set(&shadowVertices[vertexBufferIndex++], centroid3d.x, AlphaVertex::set(&shadowVertices[vertexBufferIndex++], centroid3d.x, centroid3d.y, centroid3d.y, centroidOpacity); centroidOpacity); for (int i = 0; i < umbraIndex; i++) { for (int i = 0; i < umbraIndex; i++) { // Note that umbraVertices[0] is always 0. // Note that umbraVertices[0] is always 0. Loading libs/hwui/AmbientShadow.h +7 −7 Original line number Original line Diff line number Diff line Loading @@ -31,9 +31,9 @@ class VertexBuffer; */ */ class AmbientShadow { class AmbientShadow { public: public: static void createAmbientShadow(bool isCasterOpaque, const Vector3* poly, static void createAmbientShadow(bool isCasterOpaque, const Vector3* poly, int polyLength, int polyLength, const Vector3& centroid3d, float heightFactor, const Vector3& centroid3d, float heightFactor, float geomFactor, float geomFactor, VertexBuffer& shadowVertexBuffer); VertexBuffer& shadowVertexBuffer); }; // AmbientShadow }; // AmbientShadow }; // namespace uirenderer }; // namespace uirenderer Loading libs/hwui/AnimationContext.cpp +9 −14 Original line number Original line Diff line number Diff line Loading @@ -26,11 +26,9 @@ AnimationContext::AnimationContext(renderthread::TimeLord& clock) : mClock(clock) : mClock(clock) , mCurrentFrameAnimations(*this) , mCurrentFrameAnimations(*this) , mNextFrameAnimations(*this) , mNextFrameAnimations(*this) , mFrameTimeMs(0) { , mFrameTimeMs(0) {} } AnimationContext::~AnimationContext() { AnimationContext::~AnimationContext() {} } void AnimationContext::destroy() { void AnimationContext::destroy() { startFrame(TreeInfo::MODE_RT_ONLY); startFrame(TreeInfo::MODE_RT_ONLY); Loading Loading @@ -83,10 +81,7 @@ void AnimationContext::callOnFinished(BaseRenderNodeAnimator* animator, } } AnimationHandle::AnimationHandle(AnimationContext& context) AnimationHandle::AnimationHandle(AnimationContext& context) : mContext(context) : mContext(context), mPreviousHandle(nullptr), mNextHandle(nullptr) {} , mPreviousHandle(nullptr) , mNextHandle(nullptr) { } AnimationHandle::AnimationHandle(RenderNode& animatingNode, AnimationContext& context) AnimationHandle::AnimationHandle(RenderNode& animatingNode, AnimationContext& context) : mRenderNode(&animatingNode) : mRenderNode(&animatingNode) Loading libs/hwui/AnimationContext.h +5 −3 Original line number Original line Diff line number Diff line Loading @@ -43,6 +43,7 @@ class RenderNode; */ */ class AnimationHandle { class AnimationHandle { PREVENT_COPY_AND_ASSIGN(AnimationHandle); PREVENT_COPY_AND_ASSIGN(AnimationHandle); public: public: AnimationContext& context() { return mContext; } AnimationContext& context() { return mContext; } Loading Loading @@ -74,14 +75,14 @@ private: class AnimationContext { class AnimationContext { PREVENT_COPY_AND_ASSIGN(AnimationContext); PREVENT_COPY_AND_ASSIGN(AnimationContext); public: public: ANDROID_API explicit AnimationContext(renderthread::TimeLord& clock); ANDROID_API explicit AnimationContext(renderthread::TimeLord& clock); ANDROID_API virtual ~AnimationContext(); ANDROID_API virtual ~AnimationContext(); nsecs_t frameTimeMs() { return mFrameTimeMs; } nsecs_t frameTimeMs() { return mFrameTimeMs; } bool hasAnimations() { bool hasAnimations() { return mCurrentFrameAnimations.mNextHandle return mCurrentFrameAnimations.mNextHandle || mNextFrameAnimations.mNextHandle; || mNextFrameAnimations.mNextHandle; } } // Will always add to the next frame list, which is swapped when // Will always add to the next frame list, which is swapped when Loading @@ -96,7 +97,8 @@ public: // as part of the standard RenderNode:prepareTree pass. // as part of the standard RenderNode:prepareTree pass. ANDROID_API virtual void runRemainingAnimations(TreeInfo& info); ANDROID_API virtual void runRemainingAnimations(TreeInfo& info); ANDROID_API virtual void callOnFinished(BaseRenderNodeAnimator* animator, AnimationListener* listener); ANDROID_API virtual void callOnFinished(BaseRenderNodeAnimator* animator, AnimationListener* listener); ANDROID_API virtual void destroy(); ANDROID_API virtual void destroy(); Loading Loading
libs/hwui/.clang-format 0 → 100644 +10 −0 Original line number Original line Diff line number Diff line BasedOnStyle: Google DerivePointerAlignment: false IndentWidth: 4 ConstructorInitializerIndentWidth: 8 ContinuationIndentWidth: 8 ColumnLimit: 100 AllowShortFunctionsOnASingleLine: Inline AccessModifierOffset: -4 #BreakConstructorInitializers: BeforeComma BreakConstructorInitializersBeforeComma: true
libs/hwui/AmbientShadow.cpp +47 −52 Original line number Original line Diff line number Diff line Loading @@ -56,8 +56,8 @@ #include "Vertex.h" #include "Vertex.h" #include "VertexBuffer.h" #include "VertexBuffer.h" #include <algorithm> #include <utils/Log.h> #include <utils/Log.h> #include <algorithm> namespace android { namespace android { namespace uirenderer { namespace uirenderer { Loading @@ -79,8 +79,8 @@ inline float getAlphaFromFactoredZ(float factoredZ) { return 1.0 / (1 + std::max(factoredZ, 0.0f)); return 1.0 / (1 + std::max(factoredZ, 0.0f)); } } inline int getEdgeExtraAndUpdateSpike(Vector2* currentSpike, inline int getEdgeExtraAndUpdateSpike(Vector2* currentSpike, const Vector3& secondVertex, const Vector3& secondVertex, const Vector3& centroid) { const Vector3& centroid) { Vector2 secondSpike = {secondVertex.x - centroid.x, secondVertex.y - centroid.y}; Vector2 secondSpike = {secondVertex.x - centroid.x, secondVertex.y - centroid.y}; secondSpike.normalize(); secondSpike.normalize(); Loading @@ -92,11 +92,11 @@ inline int getEdgeExtraAndUpdateSpike(Vector2* currentSpike, // Given the caster's vertex count, compute all the buffers size depending on // Given the caster's vertex count, compute all the buffers size depending on // whether or not the caster is opaque. // whether or not the caster is opaque. inline void computeBufferSize(int* totalVertexCount, int* totalIndexCount, inline void computeBufferSize(int* totalVertexCount, int* totalIndexCount, int* totalUmbraCount, int* totalUmbraCount, int casterVertexCount, bool isCasterOpaque) { int casterVertexCount, bool isCasterOpaque) { // Compute the size of the vertex buffer. // Compute the size of the vertex buffer. int outerVertexCount = casterVertexCount * 2 + MAX_EXTRA_CORNER_VERTEX_NUMBER + int outerVertexCount = MAX_EXTRA_EDGE_VERTEX_NUMBER; casterVertexCount * 2 + MAX_EXTRA_CORNER_VERTEX_NUMBER + MAX_EXTRA_EDGE_VERTEX_NUMBER; int innerVertexCount = casterVertexCount + MAX_EXTRA_EDGE_VERTEX_NUMBER; int innerVertexCount = casterVertexCount + MAX_EXTRA_EDGE_VERTEX_NUMBER; *totalVertexCount = outerVertexCount + innerVertexCount; *totalVertexCount = outerVertexCount + innerVertexCount; Loading Loading @@ -163,27 +163,25 @@ inline bool needsExtraForEdge(float firstAlpha, float secondAlpha) { * | | * | | * (V3)-----------------------------------(V2) * (V3)-----------------------------------(V2) */ */ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, void AmbientShadow::createAmbientShadow(bool isCasterOpaque, const Vector3* casterVertices, const Vector3* casterVertices, int casterVertexCount, const Vector3& centroid3d, int casterVertexCount, const Vector3& centroid3d, float heightFactor, float geomFactor, VertexBuffer& shadowVertexBuffer) { float heightFactor, float geomFactor, VertexBuffer& shadowVertexBuffer) { shadowVertexBuffer.setMeshFeatureFlags(VertexBuffer::kAlpha | VertexBuffer::kIndices); shadowVertexBuffer.setMeshFeatureFlags(VertexBuffer::kAlpha | VertexBuffer::kIndices); // In order to computer the outer vertices in one loop, we need pre-compute // In order to computer the outer vertices in one loop, we need pre-compute // the normal by the vertex (n - 1) to vertex 0, and the spike and alpha value // the normal by the vertex (n - 1) to vertex 0, and the spike and alpha value // for vertex 0. // for vertex 0. Vector2 previousNormal = getNormalFromVertices(casterVertices, Vector2 previousNormal = getNormalFromVertices(casterVertices, casterVertexCount - 1, 0); casterVertexCount - 1 , 0); Vector2 currentSpike = {casterVertices[0].x - centroid3d.x, casterVertices[0].y - centroid3d.y}; Vector2 currentSpike = {casterVertices[0].x - centroid3d.x, casterVertices[0].y - centroid3d.y}; currentSpike.normalize(); currentSpike.normalize(); float currentAlpha = getAlphaFromFactoredZ(casterVertices[0].z * heightFactor); float currentAlpha = getAlphaFromFactoredZ(casterVertices[0].z * heightFactor); // Preparing all the output data. // Preparing all the output data. int totalVertexCount, totalIndexCount, totalUmbraCount; int totalVertexCount, totalIndexCount, totalUmbraCount; computeBufferSize(&totalVertexCount, &totalIndexCount, &totalUmbraCount, computeBufferSize(&totalVertexCount, &totalIndexCount, &totalUmbraCount, casterVertexCount, casterVertexCount, isCasterOpaque); isCasterOpaque); AlphaVertex* shadowVertices = AlphaVertex* shadowVertices = shadowVertexBuffer.alloc<AlphaVertex>(totalVertexCount); shadowVertexBuffer.alloc<AlphaVertex>(totalVertexCount); int vertexBufferIndex = 0; int vertexBufferIndex = 0; uint16_t* indexBuffer = shadowVertexBuffer.allocIndices<uint16_t>(totalIndexCount); uint16_t* indexBuffer = shadowVertexBuffer.allocIndices<uint16_t>(totalIndexCount); int indexBufferIndex = 0; int indexBufferIndex = 0; Loading @@ -193,11 +191,11 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, for (int i = 0; i < casterVertexCount; i++) { for (int i = 0; i < casterVertexCount; i++) { // Corner: first figure out the extra vertices we need for the corner. // Corner: first figure out the extra vertices we need for the corner. const Vector3& innerVertex = casterVertices[i]; const Vector3& innerVertex = casterVertices[i]; Vector2 currentNormal = getNormalFromVertices(casterVertices, i, Vector2 currentNormal = (i + 1) % casterVertexCount); getNormalFromVertices(casterVertices, i, (i + 1) % casterVertexCount); int extraVerticesNumber = ShadowTessellator::getExtraVertexNumber(currentNormal, int extraVerticesNumber = ShadowTessellator::getExtraVertexNumber( previousNormal, CORNER_RADIANS_DIVISOR); currentNormal, previousNormal, CORNER_RADIANS_DIVISOR); float expansionDist = innerVertex.z * heightFactor * geomFactor; float expansionDist = innerVertex.z * heightFactor * geomFactor; const int cornerSlicesNumber = extraVerticesNumber + 1; // Minimal as 1. const int cornerSlicesNumber = extraVerticesNumber + 1; // Minimal as 1. Loading @@ -212,9 +210,8 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, if (!isCasterOpaque) { if (!isCasterOpaque) { umbraVertices[umbraIndex++] = vertexBufferIndex; umbraVertices[umbraIndex++] = vertexBufferIndex; } } AlphaVertex::set(&shadowVertices[vertexBufferIndex++], AlphaVertex::set(&shadowVertices[vertexBufferIndex++], casterVertices[i].x, casterVertices[i].x, casterVertices[i].y, casterVertices[i].y, currentAlpha); currentAlpha); const Vector3& innerStart = casterVertices[i]; const Vector3& innerStart = casterVertices[i]; Loading @@ -225,8 +222,7 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, // This will create vertices from [0, cornerSlicesNumber] inclusively, // This will create vertices from [0, cornerSlicesNumber] inclusively, // which means minimally 2 vertices even without the extra ones. // which means minimally 2 vertices even without the extra ones. for (int j = 0; j <= cornerSlicesNumber; j++) { for (int j = 0; j <= cornerSlicesNumber; j++) { Vector2 averageNormal = Vector2 averageNormal = previousNormal * (cornerSlicesNumber - j) + currentNormal * j; previousNormal * (cornerSlicesNumber - j) + currentNormal * j; averageNormal /= cornerSlicesNumber; averageNormal /= cornerSlicesNumber; averageNormal.normalize(); averageNormal.normalize(); Vector2 outerVertex; Vector2 outerVertex; Loading @@ -235,8 +231,8 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, indexBuffer[indexBufferIndex++] = vertexBufferIndex; indexBuffer[indexBufferIndex++] = vertexBufferIndex; indexBuffer[indexBufferIndex++] = currentInnerVertexIndex; indexBuffer[indexBufferIndex++] = currentInnerVertexIndex; AlphaVertex::set(&shadowVertices[vertexBufferIndex++], outerVertex.x, AlphaVertex::set(&shadowVertices[vertexBufferIndex++], outerVertex.x, outerVertex.y, outerVertex.y, OUTER_ALPHA); OUTER_ALPHA); if (j == 0) { if (j == 0) { outerStart = outerVertex; outerStart = outerVertex; Loading @@ -257,8 +253,8 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, outerNext.y = innerNext.y + currentNormal.y * expansionDist; outerNext.y = innerNext.y + currentNormal.y * expansionDist; // Compute the angle and see how many extra points we need. // Compute the angle and see how many extra points we need. int extraVerticesNumber = getEdgeExtraAndUpdateSpike(¤tSpike, int extraVerticesNumber = innerNext, centroid3d); getEdgeExtraAndUpdateSpike(¤tSpike, innerNext, centroid3d); #if DEBUG_SHADOW #if DEBUG_SHADOW ALOGD("extraVerticesNumber %d for edge %d", extraVerticesNumber, i); ALOGD("extraVerticesNumber %d for edge %d", extraVerticesNumber, i); #endif #endif Loading Loading @@ -293,11 +289,10 @@ void AmbientShadow::createAmbientShadow(bool isCasterOpaque, if (!isCasterOpaque) { if (!isCasterOpaque) { // Add the centroid as the last one in the vertex buffer. // Add the centroid as the last one in the vertex buffer. float centroidOpacity = float centroidOpacity = getAlphaFromFactoredZ(centroid3d.z * heightFactor); getAlphaFromFactoredZ(centroid3d.z * heightFactor); int centroidIndex = vertexBufferIndex; int centroidIndex = vertexBufferIndex; AlphaVertex::set(&shadowVertices[vertexBufferIndex++], centroid3d.x, AlphaVertex::set(&shadowVertices[vertexBufferIndex++], centroid3d.x, centroid3d.y, centroid3d.y, centroidOpacity); centroidOpacity); for (int i = 0; i < umbraIndex; i++) { for (int i = 0; i < umbraIndex; i++) { // Note that umbraVertices[0] is always 0. // Note that umbraVertices[0] is always 0. Loading
libs/hwui/AmbientShadow.h +7 −7 Original line number Original line Diff line number Diff line Loading @@ -31,9 +31,9 @@ class VertexBuffer; */ */ class AmbientShadow { class AmbientShadow { public: public: static void createAmbientShadow(bool isCasterOpaque, const Vector3* poly, static void createAmbientShadow(bool isCasterOpaque, const Vector3* poly, int polyLength, int polyLength, const Vector3& centroid3d, float heightFactor, const Vector3& centroid3d, float heightFactor, float geomFactor, float geomFactor, VertexBuffer& shadowVertexBuffer); VertexBuffer& shadowVertexBuffer); }; // AmbientShadow }; // AmbientShadow }; // namespace uirenderer }; // namespace uirenderer Loading
libs/hwui/AnimationContext.cpp +9 −14 Original line number Original line Diff line number Diff line Loading @@ -26,11 +26,9 @@ AnimationContext::AnimationContext(renderthread::TimeLord& clock) : mClock(clock) : mClock(clock) , mCurrentFrameAnimations(*this) , mCurrentFrameAnimations(*this) , mNextFrameAnimations(*this) , mNextFrameAnimations(*this) , mFrameTimeMs(0) { , mFrameTimeMs(0) {} } AnimationContext::~AnimationContext() { AnimationContext::~AnimationContext() {} } void AnimationContext::destroy() { void AnimationContext::destroy() { startFrame(TreeInfo::MODE_RT_ONLY); startFrame(TreeInfo::MODE_RT_ONLY); Loading Loading @@ -83,10 +81,7 @@ void AnimationContext::callOnFinished(BaseRenderNodeAnimator* animator, } } AnimationHandle::AnimationHandle(AnimationContext& context) AnimationHandle::AnimationHandle(AnimationContext& context) : mContext(context) : mContext(context), mPreviousHandle(nullptr), mNextHandle(nullptr) {} , mPreviousHandle(nullptr) , mNextHandle(nullptr) { } AnimationHandle::AnimationHandle(RenderNode& animatingNode, AnimationContext& context) AnimationHandle::AnimationHandle(RenderNode& animatingNode, AnimationContext& context) : mRenderNode(&animatingNode) : mRenderNode(&animatingNode) Loading
libs/hwui/AnimationContext.h +5 −3 Original line number Original line Diff line number Diff line Loading @@ -43,6 +43,7 @@ class RenderNode; */ */ class AnimationHandle { class AnimationHandle { PREVENT_COPY_AND_ASSIGN(AnimationHandle); PREVENT_COPY_AND_ASSIGN(AnimationHandle); public: public: AnimationContext& context() { return mContext; } AnimationContext& context() { return mContext; } Loading Loading @@ -74,14 +75,14 @@ private: class AnimationContext { class AnimationContext { PREVENT_COPY_AND_ASSIGN(AnimationContext); PREVENT_COPY_AND_ASSIGN(AnimationContext); public: public: ANDROID_API explicit AnimationContext(renderthread::TimeLord& clock); ANDROID_API explicit AnimationContext(renderthread::TimeLord& clock); ANDROID_API virtual ~AnimationContext(); ANDROID_API virtual ~AnimationContext(); nsecs_t frameTimeMs() { return mFrameTimeMs; } nsecs_t frameTimeMs() { return mFrameTimeMs; } bool hasAnimations() { bool hasAnimations() { return mCurrentFrameAnimations.mNextHandle return mCurrentFrameAnimations.mNextHandle || mNextFrameAnimations.mNextHandle; || mNextFrameAnimations.mNextHandle; } } // Will always add to the next frame list, which is swapped when // Will always add to the next frame list, which is swapped when Loading @@ -96,7 +97,8 @@ public: // as part of the standard RenderNode:prepareTree pass. // as part of the standard RenderNode:prepareTree pass. ANDROID_API virtual void runRemainingAnimations(TreeInfo& info); ANDROID_API virtual void runRemainingAnimations(TreeInfo& info); ANDROID_API virtual void callOnFinished(BaseRenderNodeAnimator* animator, AnimationListener* listener); ANDROID_API virtual void callOnFinished(BaseRenderNodeAnimator* animator, AnimationListener* listener); ANDROID_API virtual void destroy(); ANDROID_API virtual void destroy(); Loading