From af60c6419331f5450b301c58460d551fa3711f98 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Wed, 20 Feb 2013 10:43:35 -0800 Subject: Fix system library search path. Bug: 8162719 Change-Id: I87421fdbafcc9f05692dc9e09ae5474fbb8bb02d --- renderscript/v8/rs_support/cpu_ref/rsCpuScript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/renderscript/v8/rs_support/cpu_ref/rsCpuScript.cpp b/renderscript/v8/rs_support/cpu_ref/rsCpuScript.cpp index 29ed1c2446..78d4a73e76 100644 --- a/renderscript/v8/rs_support/cpu_ref/rsCpuScript.cpp +++ b/renderscript/v8/rs_support/cpu_ref/rsCpuScript.cpp @@ -181,7 +181,7 @@ bool RsdCpuScriptImpl::init(char const *resName, char const *cacheDir, // We do this to allow bundled applications to use the compatibility // library fallback path. Those applications don't have a private // library path, so they need to install to the system directly. - String8 scriptSONameSystem("/system/lib/lib"); + String8 scriptSONameSystem("/system/lib/librs."); scriptSONameSystem.append(resName); scriptSONameSystem.append(".so"); mScriptSO = dlopen(scriptSONameSystem.string(), RTLD_NOW | RTLD_LOCAL); -- cgit v1.2.3 From 385d67ee9d065ec77d3485aa2ae5679dc77d57bb Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Wed, 3 Apr 2013 14:19:15 -0700 Subject: am c93e8d03: am 5a50b1ce: am 1732720a: Add a short delay for drawer peeking in DrawerLayout * commit 'c93e8d03544f903de80d7c77bd35450c98670cd6': Add a short delay for drawer peeking in DrawerLayout --- .../android/support/v4/widget/DrawerLayout.java | 64 +++++++-- .../android/support/v4/widget/ViewDragHelper.java | 144 ++++++++++++++++++++- 2 files changed, 192 insertions(+), 16 deletions(-) diff --git a/v4/java/android/support/v4/widget/DrawerLayout.java b/v4/java/android/support/v4/widget/DrawerLayout.java index 1cf5e5cbe2..fe58c04fbd 100644 --- a/v4/java/android/support/v4/widget/DrawerLayout.java +++ b/v4/java/android/support/v4/widget/DrawerLayout.java @@ -88,6 +88,11 @@ public class DrawerLayout extends ViewGroup { private static final int DEFAULT_SCRIM_COLOR = 0x99000000; + /** + * Length of time to delay before peeking the drawer. + */ + private static final int PEEK_DELAY = 160; // ms + /** * Experimental feature. */ @@ -105,11 +110,14 @@ public class DrawerLayout extends ViewGroup { private final ViewDragHelper mLeftDragger; private final ViewDragHelper mRightDragger; + private final ViewDragCallback mLeftCallback; + private final ViewDragCallback mRightCallback; private int mDrawerState; private boolean mInLayout; private boolean mFirstLayout = true; private int mLockModeLeft; private int mLockModeRight; + private boolean mDisallowInterceptRequested; private DrawerListener mListener; @@ -190,16 +198,16 @@ public class DrawerLayout extends ViewGroup { final float density = getResources().getDisplayMetrics().density; mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f); - final ViewDragCallback leftCallback = new ViewDragCallback(Gravity.LEFT); - final ViewDragCallback rightCallback = new ViewDragCallback(Gravity.RIGHT); + mLeftCallback = new ViewDragCallback(Gravity.LEFT); + mRightCallback = new ViewDragCallback(Gravity.RIGHT); - mLeftDragger = ViewDragHelper.create(this, 0.5f, leftCallback); + mLeftDragger = ViewDragHelper.create(this, 0.5f, mLeftCallback); mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); - leftCallback.setDragger(mLeftDragger); + mLeftCallback.setDragger(mLeftDragger); - mRightDragger = ViewDragHelper.create(this, 0.5f, rightCallback); + mRightDragger = ViewDragHelper.create(this, 0.5f, mRightCallback); mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT); - rightCallback.setDragger(mRightDragger); + mRightCallback.setDragger(mRightDragger); // So that we can catch the back button setFocusableInTouchMode(true); @@ -781,14 +789,26 @@ public class DrawerLayout extends ViewGroup { isContentView(mLeftDragger.findTopChildUnder((int) x, (int) y))) { interceptForTap = true; } + mDisallowInterceptRequested = false; + break; + } + + case MotionEvent.ACTION_MOVE: { + // If we cross the touch slop, don't perform the delayed peek for an edge touch. + if (mLeftDragger.checkTouchSlop(ViewDragHelper.DIRECTION_ALL)) { + mLeftCallback.removeCallbacks(); + mRightCallback.removeCallbacks(); + } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { closeDrawers(true); + mDisallowInterceptRequested = false; } } + return interceptForDrag || interceptForTap || hasPeekingDrawer(); } @@ -806,6 +826,7 @@ public class DrawerLayout extends ViewGroup { final float y = ev.getY(); mInitialMotionX = x; mInitialMotionY = y; + mDisallowInterceptRequested = false; break; } @@ -827,11 +848,13 @@ public class DrawerLayout extends ViewGroup { } } closeDrawers(peekingOnly); + mDisallowInterceptRequested = false; break; } case MotionEvent.ACTION_CANCEL: { closeDrawers(true); + mDisallowInterceptRequested = false; break; } } @@ -840,7 +863,12 @@ public class DrawerLayout extends ViewGroup { } public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { - super.requestDisallowInterceptTouchEvent(disallowIntercept); + if (!mLeftDragger.isEdgeTouched(ViewDragHelper.EDGE_LEFT) && + !mRightDragger.isEdgeTouched(ViewDragHelper.EDGE_RIGHT)) { + // If we have an edge touch we want to skip this and track it for later instead. + super.requestDisallowInterceptTouchEvent(disallowIntercept); + } + mDisallowInterceptRequested = disallowIntercept; if (disallowIntercept) { closeDrawers(true); } @@ -877,6 +905,9 @@ public class DrawerLayout extends ViewGroup { lp.isPeeking = false; } + mLeftCallback.removeCallbacks(); + mRightCallback.removeCallbacks(); + if (needsInvalidate) { invalidate(); } @@ -1152,10 +1183,15 @@ public class DrawerLayout extends ViewGroup { } private class ViewDragCallback extends ViewDragHelper.Callback { - private final int mGravity; private ViewDragHelper mDragger; + private final Runnable mPeekRunnable = new Runnable() { + @Override public void run() { + peekDrawer(); + } + }; + public ViewDragCallback(int gravity) { mGravity = gravity; } @@ -1164,6 +1200,10 @@ public class DrawerLayout extends ViewGroup { mDragger = dragger; } + public void removeCallbacks() { + DrawerLayout.this.removeCallbacks(mPeekRunnable); + } + @Override public boolean tryCaptureView(View child, int pointerId) { // Only capture views where the gravity matches what we're looking for. @@ -1231,11 +1271,14 @@ public class DrawerLayout extends ViewGroup { @Override public void onEdgeTouched(int edgeFlags, int pointerId) { + postDelayed(mPeekRunnable, PEEK_DELAY); + } + + private void peekDrawer() { final View toCapture; final int childLeft; - final boolean leftEdge = - (edgeFlags & ViewDragHelper.EDGE_LEFT) == ViewDragHelper.EDGE_LEFT; final int peekDistance = mDragger.getEdgeSize(); + final boolean leftEdge = mGravity == Gravity.LEFT; if (leftEdge) { toCapture = findDrawerWithGravity(Gravity.LEFT); childLeft = (toCapture != null ? -toCapture.getWidth() : 0) + peekDistance; @@ -1243,7 +1286,6 @@ public class DrawerLayout extends ViewGroup { toCapture = findDrawerWithGravity(Gravity.RIGHT); childLeft = getWidth() - peekDistance; } - // Only peek if it would mean making the drawer more visible and the drawer isn't locked if (toCapture != null && ((leftEdge && toCapture.getLeft() < childLeft) || (!leftEdge && toCapture.getLeft() > childLeft)) && diff --git a/v4/java/android/support/v4/widget/ViewDragHelper.java b/v4/java/android/support/v4/widget/ViewDragHelper.java index bdb42a7a8f..9c68509b24 100644 --- a/v4/java/android/support/v4/widget/ViewDragHelper.java +++ b/v4/java/android/support/v4/widget/ViewDragHelper.java @@ -80,6 +80,26 @@ public class ViewDragHelper { */ public static final int EDGE_BOTTOM = 1 << 3; + /** + * Edge flag set indicating all edges should be affected. + */ + public static final int EDGE_ALL = EDGE_LEFT | EDGE_TOP | EDGE_RIGHT | EDGE_BOTTOM; + + /** + * Indicates that a check should occur along the horizontal axis + */ + public static final int DIRECTION_HORIZONTAL = 1 << 0; + + /** + * Indicates that a check should occur along the vertical axis + */ + public static final int DIRECTION_VERTICAL = 1 << 1; + + /** + * Indicates that a check should occur along all axes + */ + public static final int DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL; + private static final int EDGE_SIZE = 24; // dp private static final int BASE_SETTLE_DURATION = 256; // ms @@ -100,6 +120,7 @@ public class ViewDragHelper { private int[] mInitialEdgesTouched; private int[] mEdgeDragsInProgress; private int[] mEdgeDragsLocked; + private int mPointersDown; private VelocityTracker mVelocityTracker; private float mMaxVelocity; @@ -718,6 +739,7 @@ public class ViewDragHelper { Arrays.fill(mInitialEdgesTouched, 0); Arrays.fill(mEdgeDragsInProgress, 0); Arrays.fill(mEdgeDragsLocked, 0); + mPointersDown = 0; } private void clearMotionHistory(int pointerId) { @@ -731,6 +753,7 @@ public class ViewDragHelper { mInitialEdgesTouched[pointerId] = 0; mEdgeDragsInProgress[pointerId] = 0; mEdgeDragsLocked[pointerId] = 0; + mPointersDown &= ~(1 << pointerId); } private void ensureMotionHistorySizeForId(int pointerId) { @@ -768,6 +791,7 @@ public class ViewDragHelper { mInitialMotionX[pointerId] = mLastMotionX[pointerId] = x; mInitialMotionY[pointerId] = mLastMotionY[pointerId] = y; mInitialEdgesTouched[pointerId] = getEdgesTouched((int) x, (int) y); + mPointersDown |= 1 << pointerId; } private void saveLastMotion(MotionEvent ev) { @@ -781,6 +805,23 @@ public class ViewDragHelper { } } + /** + * Check if the given pointer ID represents a pointer that is currently down (to the best + * of the ViewDragHelper's knowledge). + * + *

The state used to report this information is populated by the methods + * {@link #shouldInterceptTouchEvent(android.view.MotionEvent)} or + * {@link #processTouchEvent(android.view.MotionEvent)}. If one of these methods has not + * been called for all relevant MotionEvents to track, the information reported + * by this method may be stale or incorrect.

+ * + * @param pointerId pointer ID to check; corresponds to IDs provided by MotionEvent + * @return true if the pointer with the given ID is still down + */ + public boolean isPointerDown(int pointerId) { + return (mPointersDown & 1 << pointerId) != 0; + } + void setDragState(int state) { if (mDragState != state) { mDragState = state; @@ -932,7 +973,7 @@ public class ViewDragHelper { } final View toCapture = findTopChildUnder((int) x, (int) y); - if (toCapture != null && slopCheck(toCapture, dx, dy) && + if (toCapture != null && checkTouchSlop(toCapture, dx, dy) && tryCaptureViewForDrag(toCapture, pointerId)) { break; } @@ -1055,7 +1096,7 @@ public class ViewDragHelper { } final View toCapture = findTopChildUnder((int) x, (int) y); - if (slopCheck(toCapture, dx, dy) && + if (checkTouchSlop(toCapture, dx, dy) && tryCaptureViewForDrag(toCapture, pointerId)) { break; } @@ -1142,14 +1183,14 @@ public class ViewDragHelper { if ((mInitialEdgesTouched[pointerId] & edge) != edge || (mTrackingEdges & edge) == 0 || (mEdgeDragsLocked[pointerId] & edge) == edge || (mEdgeDragsInProgress[pointerId] & edge) == edge || - (absDelta < mTouchSlop && absODelta < mTouchSlop)) { + (absDelta <= mTouchSlop && absODelta <= mTouchSlop)) { return false; } if (absDelta < absODelta * 0.5f && mCallback.onEdgeLock(edge)) { mEdgeDragsLocked[pointerId] |= edge; return false; } - return (mEdgeDragsInProgress[pointerId] & edge) == 0; + return (mEdgeDragsInProgress[pointerId] & edge) == 0 && absDelta > mTouchSlop; } /** @@ -1162,7 +1203,7 @@ public class ViewDragHelper { * @param dy Motion since initial position along Y axis * @return true if the touch slop has been crossed */ - private boolean slopCheck(View child, float dx, float dy) { + private boolean checkTouchSlop(View child, float dx, float dy) { if (child == null) { return false; } @@ -1179,6 +1220,99 @@ public class ViewDragHelper { return false; } + /** + * Check if any pointer tracked in the current gesture has crossed + * the required slop threshold. + * + *

This depends on internal state populated by + * {@link #shouldInterceptTouchEvent(android.view.MotionEvent)} or + * {@link #processTouchEvent(android.view.MotionEvent)}. You should only rely on + * the results of this method after all currently available touch data + * has been provided to one of these two methods.

+ * + * @param directions Combination of direction flags, see {@link #DIRECTION_HORIZONTAL}, + * {@link #DIRECTION_VERTICAL}, {@link #DIRECTION_ALL} + * @return true if the slop threshold has been crossed, false otherwise + */ + public boolean checkTouchSlop(int directions) { + final int count = mInitialMotionX.length; + for (int i = 0; i < count; i++) { + if (checkTouchSlop(directions, i)) { + return true; + } + } + return false; + } + + /** + * Check if the specified pointer tracked in the current gesture has crossed + * the required slop threshold. + * + *

This depends on internal state populated by + * {@link #shouldInterceptTouchEvent(android.view.MotionEvent)} or + * {@link #processTouchEvent(android.view.MotionEvent)}. You should only rely on + * the results of this method after all currently available touch data + * has been provided to one of these two methods.

+ * + * @param directions Combination of direction flags, see {@link #DIRECTION_HORIZONTAL}, + * {@link #DIRECTION_VERTICAL}, {@link #DIRECTION_ALL} + * @param pointerId ID of the pointer to slop check as specified by MotionEvent + * @return true if the slop threshold has been crossed, false otherwise + */ + public boolean checkTouchSlop(int directions, int pointerId) { + if (!isPointerDown(pointerId)) { + return false; + } + + final boolean checkHorizontal = (directions & DIRECTION_HORIZONTAL) == DIRECTION_HORIZONTAL; + final boolean checkVertical = (directions & DIRECTION_VERTICAL) == DIRECTION_VERTICAL; + + final float dx = mLastMotionX[pointerId] - mInitialMotionX[pointerId]; + final float dy = mLastMotionY[pointerId] - mInitialMotionY[pointerId]; + + if (checkHorizontal && checkVertical) { + return dx * dx + dy * dy > mTouchSlop * mTouchSlop; + } else if (checkHorizontal) { + return Math.abs(dx) > mTouchSlop; + } else if (checkVertical) { + return Math.abs(dy) > mTouchSlop; + } + return false; + } + + /** + * Check if any of the edges specified were initially touched in the currently active gesture. + * If there is no currently active gesture this method will return false. + * + * @param edges Edges to check for an initial edge touch. See {@link #EDGE_LEFT}, + * {@link #EDGE_TOP}, {@link #EDGE_RIGHT}, {@link #EDGE_BOTTOM} and + * {@link #EDGE_ALL} + * @return true if any of the edges specified were initially touched in the current gesture + */ + public boolean isEdgeTouched(int edges) { + final int count = mInitialEdgesTouched.length; + for (int i = 0; i < count; i++) { + if (isEdgeTouched(edges, i)) { + return true; + } + } + return false; + } + + /** + * Check if any of the edges specified were initially touched by the pointer with + * the specified ID. If there is no currently active gesture or if there is no pointer with + * the given ID currently down this method will return false. + * + * @param edges Edges to check for an initial edge touch. See {@link #EDGE_LEFT}, + * {@link #EDGE_TOP}, {@link #EDGE_RIGHT}, {@link #EDGE_BOTTOM} and + * {@link #EDGE_ALL} + * @return true if any of the edges specified were initially touched in the current gesture + */ + public boolean isEdgeTouched(int edges, int pointerId) { + return isPointerDown(pointerId) && (mInitialEdgesTouched[pointerId] & edges) != 0; + } + private void releaseViewForPointerUp() { mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity); dispatchViewReleased(VelocityTrackerCompat.getXVelocity(mVelocityTracker, mActivePointerId), -- cgit v1.2.3 From 78a83c09e5f3e8b8c729cdab7dde4b4afa59af9a Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Wed, 24 Apr 2013 18:17:59 -0700 Subject: RS compatlib is not thunking LaunchOptions correctly bug 8680826 Change-Id: I22af3a5f5bc583beaff9c96c086a2deee0369443 --- .../android/support/v8/renderscript/Script.java | 5 +++++ .../support/v8/renderscript/ScriptCThunker.java | 25 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/Script.java b/renderscript/v8/java/src/android/support/v8/renderscript/Script.java index 33dd4ed9b2..596c387603 100644 --- a/renderscript/v8/java/src/android/support/v8/renderscript/Script.java +++ b/renderscript/v8/java/src/android/support/v8/renderscript/Script.java @@ -249,6 +249,11 @@ public class Script extends BaseObj { } protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) { + if (mT != null) { + mT.thunkForEach(slot, ain, aout, v, sc); + return; + } + if (ain == null && aout == null) { throw new RSIllegalArgumentException( "At least one of ain or aout is required to be non-null."); diff --git a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptCThunker.java b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptCThunker.java index 50b7904438..130e408ea1 100644 --- a/renderscript/v8/java/src/android/support/v8/renderscript/ScriptCThunker.java +++ b/renderscript/v8/java/src/android/support/v8/renderscript/ScriptCThunker.java @@ -92,6 +92,31 @@ class ScriptCThunker extends android.renderscript.ScriptC { forEach(slot, nin, nout, nfp); } + void thunkForEach(int slot, Allocation ain, Allocation aout, FieldPacker v, + android.support.v8.renderscript.Script.LaunchOptions sc) { + android.renderscript.Script.LaunchOptions lo = null; + if (sc != null) { + lo = new android.renderscript.Script.LaunchOptions(); + if (sc.getXEnd() > 0) lo.setX(sc.getXStart(), sc.getXEnd()); + if (sc.getYEnd() > 0) lo.setY(sc.getYStart(), sc.getYEnd()); + if (sc.getZEnd() > 0) lo.setZ(sc.getZStart(), sc.getZEnd()); + } + + android.renderscript.Allocation nin = null; + android.renderscript.Allocation nout = null; + android.renderscript.FieldPacker nfp = null; + if (ain != null) { + nin = ((AllocationThunker)ain).mN; + } + if (aout != null) { + nout = ((AllocationThunker)aout).mN; + } + if (v != null) { + nfp = new android.renderscript.FieldPacker(v.getData()); + } + forEach(slot, nin, nout, nfp, lo); + } + void thunkSetVar(int index, float v) { setVar(index, v); } -- cgit v1.2.3