void VelocityTracker::addMovement(const MotionEvent* event) { int32_t actionMasked = event->getActionMasked(); switch (actionMasked) { case AMOTION_EVENT_ACTION_DOWN: case AMOTION_EVENT_ACTION_HOVER_ENTER: // Clear all pointers on down before adding the new movement. clear(); break; case AMOTION_EVENT_ACTION_POINTER_DOWN: { // Start a new movement trace for a pointer that just went down. // We do this on down instead of on up because the client may want to query the // final velocity for a pointer that just went up. BitSet32 downIdBits; downIdBits.markBit(event->getPointerId(event->getActionIndex())); clearPointers(downIdBits); break; } case AMOTION_EVENT_ACTION_MOVE: case AMOTION_EVENT_ACTION_HOVER_MOVE: break; default: // Ignore all other actions because they do not convey any new information about // pointer movement. We also want to preserve the last known velocity of the pointers. // Note that ACTION_UP and ACTION_POINTER_UP always report the last known position // of the pointers that went up. ACTION_POINTER_UP does include the new position of // pointers that remained down but we will also receive an ACTION_MOVE with this // information if any of them actually moved. Since we don't know how many pointers // will be going up at once it makes sense to just wait for the following ACTION_MOVE // before adding the movement. return; } size_t pointerCount = event->getPointerCount(); if (pointerCount > MAX_POINTERS) { pointerCount = MAX_POINTERS; } BitSet32 idBits; for (size_t i = 0; i < pointerCount; i++) { idBits.markBit(event->getPointerId(i)); } uint32_t pointerIndex[MAX_POINTERS]; for (size_t i = 0; i < pointerCount; i++) { pointerIndex[i] = idBits.getIndexOfBit(event->getPointerId(i)); } nsecs_t eventTime; Position positions[pointerCount]; size_t historySize = event->getHistorySize(); for (size_t h = 0; h < historySize; h++) { eventTime = event->getHistoricalEventTime(h); for (size_t i = 0; i < pointerCount; i++) { uint32_t index = pointerIndex[i]; positions[index].x = event->getHistoricalX(i, h); positions[index].y = event->getHistoricalY(i, h); } addMovement(eventTime, idBits, positions); } eventTime = event->getEventTime(); for (size_t i = 0; i < pointerCount; i++) { uint32_t index = pointerIndex[i]; positions[index].x = event->getX(i); positions[index].y = event->getY(i); } addMovement(eventTime, idBits, positions); }
MVOID MAIN_CLASS_NAME:: applyRelease(UserId_T userId) { NodeId_T const nodeId = userId; sp<IAppCallback> pAppCallback; List<MyListener> listeners; BitSet32 nodeStatusUpdated; NodeStatusUpdater updater(getFrameNo(), mLogLevel); // String8 const logTag = String8::format("frameNo:%u nodeId:%#"PRIxPTR, getFrameNo(), nodeId); MY_LOG1("%s +", logTag.string()); // { RWLock::AutoWLock _lRWLock(mRWLock); Mutex::Autolock _lMapLock(mItemMapLock); // // Update MBOOL isAnyUpdate = updater.run(nodeId, mNodeStatusMap, nodeStatusUpdated); // // Is the entire frame released? if ( isAnyUpdate && 0 == mNodeStatusMap.mInFlightNodeCount ) { nodeStatusUpdated.markBit(IPipelineFrameListener::eMSG_FRAME_RELEASED); // mTimestampFrameDone = ::elapsedRealtimeNano(); // #if 1 // mpPipelineNodeMap = 0; // mpPipelineDAG = 0; mpStreamInfoSet = 0; #endif MY_LOG1( "Done frameNo:%u @ nodeId:%#"PRIxPTR" - timestamp:%"PRIu64"=%"PRIu64"-%"PRIu64, getFrameNo(), nodeId, (mTimestampFrameDone-mTimestampFrameCreated), mTimestampFrameDone, mTimestampFrameCreated ); } // if ( ! nodeStatusUpdated.isEmpty() ) { listeners = mListeners; } // pAppCallback = mpAppCallback.promote(); } // // Release (Hal) Buffers. updater.handleResult(); // // Callback to App. if ( pAppCallback == 0 ) { MY_LOGW("Caonnot promote AppCallback for frameNo:%u, userId:%#"PRIxPTR, getFrameNo(), userId); } else { pAppCallback->updateFrame(getFrameNo(), userId); } // // Callback to listeners if needed. if ( ! nodeStatusUpdated.isEmpty() ) { NSCam::Utils::CamProfile profile(__FUNCTION__, logTag.string()); // List<MyListener>::iterator it = listeners.begin(); for (; it != listeners.end(); ++it) { sp<MyListener::IListener> p = it->mpListener.promote(); if ( p == 0 ) { continue; } // if ( nodeStatusUpdated.hasBit(IPipelineFrameListener::eMSG_ALL_OUT_META_BUFFERS_RELEASED) ) { MY_LOG2("%s O Meta Buffers Released", logTag.string()); p->onPipelineFrame( getFrameNo(), nodeId, IPipelineFrameListener::eMSG_ALL_OUT_META_BUFFERS_RELEASED, it->mpCookie ); } // if ( nodeStatusUpdated.hasBit(IPipelineFrameListener::eMSG_ALL_OUT_IMAGE_BUFFERS_RELEASED) ) { MY_LOG2("%s O Image Buffers Released", logTag.string()); p->onPipelineFrame( getFrameNo(), nodeId, IPipelineFrameListener::eMSG_ALL_OUT_IMAGE_BUFFERS_RELEASED, it->mpCookie ); } // if ( nodeStatusUpdated.hasBit(IPipelineFrameListener::eMSG_FRAME_RELEASED) ) { MY_LOG2("%s Frame Done", logTag.string()); p->onPipelineFrame( getFrameNo(), IPipelineFrameListener::eMSG_FRAME_RELEASED, it->mpCookie ); } } // profile.print_overtime(3, "notify listeners (nodeStatusUpdated:%#x)", nodeStatusUpdated.value); } // MY_LOG1("%s -", logTag.string()); }