From f57776b2d195f0937906eb88b777bb55ccc36967 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Fri, 25 Oct 2013 18:30:17 -0700 Subject: 3d view system! True 3d transformations are now supported by DisplayLists and the renderer, initially with the translationZ property on view. Renderer operations used directly by DisplayList (formerly, clip/save/restore/saveLayer) are now more simply managed by allocating them temporarily on the handler's allocator, which exists for a single frame. This is much simpler than continuing to expand the pool of pre-allocated DisplayListOps now that more operations are called directly by DisplayList, especially with z ordered drawing. Still TODO: -APIs for camera positioning, shadows -Make Z apis public, and expose through XML -Make invalidation / input 3d aware Change-Id: I95fe6fa03f9b6ddd34a7e0c6ec8dd9fe47c6c6eb --- core/java/android/view/View.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'core/java/android/view/View.java') diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 5d264b6..4b97c40 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2981,6 +2981,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @ViewDebug.ExportedProperty float mTranslationY = 0f; + @ViewDebug.ExportedProperty + float mTranslationZ = 0f; + /** * The amount of scale in the x direction around the pivot point. A * value of 1 means no scaling is applied. @@ -10484,6 +10487,35 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** + * @hide + */ + @ViewDebug.ExportedProperty(category = "drawing") + public float getTranslationZ() { + return mTransformationInfo != null ? mTransformationInfo.mTranslationZ : 0; + } + + /** + * @hide + */ + public void setTranslationZ(float translationZ) { + ensureTransformationInfo(); + final TransformationInfo info = mTransformationInfo; + if (info.mTranslationZ != translationZ) { + invalidateViewProperty(true, false); + info.mTranslationZ = translationZ; + info.mMatrixDirty = true; + invalidateViewProperty(false, true); + if (mDisplayList != null) { + mDisplayList.setTranslationZ(translationZ); + } + if ((mPrivateFlags2 & PFLAG2_VIEW_QUICK_REJECTED) == PFLAG2_VIEW_QUICK_REJECTED) { + // View was rejected last time it was drawn by its parent; this may have changed + invalidateParentIfNeeded(); + } + } + } + + /** * Hit rectangle in parent's coordinates * * @param outRect The hit rectangle of the view. @@ -14142,6 +14174,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } displayList.setTransformationInfo(alpha, mTransformationInfo.mTranslationX, mTransformationInfo.mTranslationY, + mTransformationInfo.mTranslationZ, mTransformationInfo.mRotation, mTransformationInfo.mRotationX, mTransformationInfo.mRotationY, mTransformationInfo.mScaleX, mTransformationInfo.mScaleY); -- cgit v1.1