diff options
author | Chris Craik <ccraik@google.com> | 2014-04-25 18:34:11 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2014-04-28 14:33:33 -0700 |
commit | cc39e16cb98855f35079941b5e7e6eac2b7bc388 (patch) | |
tree | f37cb0ce9da11a018446adfb83c756f5e76e77f1 /libs | |
parent | 802667b20b2170ddce94d70a022b68b64b9a7493 (diff) | |
download | frameworks_base-cc39e16cb98855f35079941b5e7e6eac2b7bc388.zip frameworks_base-cc39e16cb98855f35079941b5e7e6eac2b7bc388.tar.gz frameworks_base-cc39e16cb98855f35079941b5e7e6eac2b7bc388.tar.bz2 |
Add elevation, Z properties to View
Change-Id: I3dd3b683a66e248a0fdf2ca69d1e962615b0daf9
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/RenderNode.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/RenderProperties.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/RenderProperties.h | 21 | ||||
-rw-r--r-- | libs/hwui/utils/MathUtils.h | 4 |
4 files changed, 35 insertions, 9 deletions
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 2008f02..838e5ac 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -219,11 +219,11 @@ void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) matrix.multiply(anim); } - bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getTranslationZ()); + bool applyTranslationZ = true3dTransform && !MathUtils::isZero(properties().getZ()); if (properties().hasTransformMatrix() || applyTranslationZ) { if (properties().isTransformTranslateOnly()) { matrix.translate(properties().getTranslationX(), properties().getTranslationY(), - true3dTransform ? properties().getTranslationZ() : 0.0f); + true3dTransform ? properties().getZ() : 0.0f); } else { if (!true3dTransform) { matrix.multiply(*properties().getTransformMatrix()); @@ -232,7 +232,7 @@ void RenderNode::applyViewPropertyTransforms(mat4& matrix, bool true3dTransform) true3dMat.loadTranslate( properties().getPivotX() + properties().getTranslationX(), properties().getPivotY() + properties().getTranslationY(), - properties().getTranslationZ()); + properties().getZ()); true3dMat.rotate(properties().getRotationX(), 1, 0, 0); true3dMat.rotate(properties().getRotationY(), 0, 1, 0); true3dMat.rotate(properties().getRotation(), 0, 0, 1); @@ -344,7 +344,9 @@ private: void RenderNode::deferNodeTree(DeferStateStruct& deferStruct) { DeferOperationHandler handler(deferStruct, 0); - if (properties().getTranslationZ() > 0.0f) issueDrawShadowOperation(Matrix4::identity(), handler); + if (MathUtils::isPositive(properties().getZ())) { + issueDrawShadowOperation(Matrix4::identity(), handler); + } issueOperations<DeferOperationHandler>(deferStruct.mRenderer, handler); } @@ -380,7 +382,9 @@ private: void RenderNode::replayNodeTree(ReplayStateStruct& replayStruct) { ReplayOperationHandler handler(replayStruct, 0); - if (properties().getTranslationZ() > 0.0f) issueDrawShadowOperation(Matrix4::identity(), handler); + if (MathUtils::isPositive(properties().getZ())) { + issueDrawShadowOperation(Matrix4::identity(), handler); + } issueOperations<ReplayOperationHandler>(replayStruct.mRenderer, handler); } @@ -395,7 +399,7 @@ void RenderNode::buildZSortedChildList(Vector<ZDrawDisplayListOpPair>& zTranslat for (unsigned int i = 0; i < mDisplayListData->children().size(); i++) { DrawDisplayListOp* childOp = mDisplayListData->children()[i]; RenderNode* child = childOp->mDisplayList; - float childZ = child->properties().getTranslationZ(); + float childZ = child->properties().getZ(); if (!MathUtils::isZero(childZ)) { zTranslatedNodes.add(ZDrawDisplayListOpPair(childZ, childOp)); diff --git a/libs/hwui/RenderProperties.cpp b/libs/hwui/RenderProperties.cpp index a922db8..9ec7297 100644 --- a/libs/hwui/RenderProperties.cpp +++ b/libs/hwui/RenderProperties.cpp @@ -37,6 +37,7 @@ RenderProperties::PrimitiveFields::PrimitiveFields() , mProjectionReceiver(false) , mAlpha(1) , mHasOverlappingRendering(true) + , mElevation(0) , mTranslationX(0), mTranslationY(0), mTranslationZ(0) , mRotation(0), mRotationX(0), mRotationY(0) , mScaleX(1), mScaleY(1) @@ -100,7 +101,7 @@ void RenderProperties::debugOutputProperties(const int level) const { if (hasTransformMatrix()) { if (isTransformTranslateOnly()) { ALOGD("%*sTranslate %.2f, %.2f, %.2f", - level * 2, "", mPrimitiveFields.mTranslationX, mPrimitiveFields.mTranslationY, mPrimitiveFields.mTranslationZ); + level * 2, "", getTranslationX(), getTranslationY(), getZ()); } else { ALOGD("%*sConcatMatrix %p: " SK_MATRIX_STRING, level * 2, "", mComputedFields.mTransformMatrix, SK_MATRIX_ARGS(mComputedFields.mTransformMatrix)); diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h index 4270da2..8fc2dd0 100644 --- a/libs/hwui/RenderProperties.h +++ b/libs/hwui/RenderProperties.h @@ -105,6 +105,17 @@ public: return mPrimitiveFields.mHasOverlappingRendering; } + void setElevation(float elevation) { + if (elevation != mPrimitiveFields.mElevation) { + mPrimitiveFields.mElevation = elevation; + // mMatrixOrPivotDirty not set, since matrix doesn't respect Z + } + } + + float getElevation() const { + return mPrimitiveFields.mElevation; + } + void setTranslationX(float translationX) { if (translationX != mPrimitiveFields.mTranslationX) { mPrimitiveFields.mTranslationX = translationX; @@ -130,7 +141,7 @@ public: void setTranslationZ(float translationZ) { if (translationZ != mPrimitiveFields.mTranslationZ) { mPrimitiveFields.mTranslationZ = translationZ; - mPrimitiveFields.mMatrixOrPivotDirty = true; + // mMatrixOrPivotDirty not set, since matrix doesn't respect Z } } @@ -138,6 +149,10 @@ public: return mPrimitiveFields.mTranslationZ; } + float getZ() const { + return getElevation() + getTranslationZ(); + } + void setRotation(float rotation) { if (rotation != mPrimitiveFields.mRotation) { mPrimitiveFields.mRotation = rotation; @@ -302,7 +317,8 @@ public: } void setLeftTopRightBottom(int left, int top, int right, int bottom) { - if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop || right != mPrimitiveFields.mRight || bottom != mPrimitiveFields.mBottom) { + if (left != mPrimitiveFields.mLeft || top != mPrimitiveFields.mTop + || right != mPrimitiveFields.mRight || bottom != mPrimitiveFields.mBottom) { mPrimitiveFields.mLeft = left; mPrimitiveFields.mTop = top; mPrimitiveFields.mRight = right; @@ -429,6 +445,7 @@ private: bool mProjectionReceiver; float mAlpha; bool mHasOverlappingRendering; + float mElevation; float mTranslationX, mTranslationY, mTranslationZ; float mRotation, mRotationX, mRotationY; float mScaleX, mScaleY; diff --git a/libs/hwui/utils/MathUtils.h b/libs/hwui/utils/MathUtils.h index 57ba8fa..7deabe9 100644 --- a/libs/hwui/utils/MathUtils.h +++ b/libs/hwui/utils/MathUtils.h @@ -29,6 +29,10 @@ public: inline static bool isZero(float value) { return (value >= -gNonZeroEpsilon) && (value <= gNonZeroEpsilon); } + + inline static bool isPositive(float value) { + return value >= gNonZeroEpsilon; + } }; // class MathUtils } /* namespace uirenderer */ |