TEST_F(BitSet32Test, BitWiseAnd_Disjoint) { b1.markBit(2); b1.markBit(4); b1.markBit(6); BitSet32 tmp = b1 & b2; EXPECT_TRUE(tmp.isEmpty()); // Check that the operator is symmetric EXPECT_TRUE((b2 & b1) == (b1 & b2)); b2 &= b1; EXPECT_TRUE(b2.isEmpty()); EXPECT_EQ(b1.count(), 3u); EXPECT_TRUE(b1.hasBit(2) && b1.hasBit(4) && b1.hasBit(6)); }
void VelocityTracker::addMovement(nsecs_t eventTime, BitSet32 idBits, const Position* positions) { while (idBits.count() > MAX_POINTERS) { idBits.clearLastMarkedBit(); } if ((mCurrentPointerIdBits.value & idBits.value) && eventTime >= mLastEventTime + ASSUME_POINTER_STOPPED_TIME) { #if DEBUG_VELOCITY ALOGD("VelocityTracker: stopped for %0.3f ms, clearing state.", (eventTime - mLastEventTime) * 0.000001f); #endif // We have not received any movements for too long. Assume that all pointers // have stopped. mStrategy->clear(); } mLastEventTime = eventTime; mCurrentPointerIdBits = idBits; if (mActivePointerId < 0 || !idBits.hasBit(mActivePointerId)) { mActivePointerId = idBits.isEmpty() ? -1 : idBits.firstMarkedBit(); } mStrategy->addMovement(eventTime, idBits, positions); #if DEBUG_VELOCITY ALOGD("VelocityTracker: addMovement eventTime=%" PRId64 ", idBits=0x%08x, activePointerId=%d", eventTime, idBits.value, mActivePointerId); for (BitSet32 iterBits(idBits); !iterBits.isEmpty(); ) { uint32_t id = iterBits.firstMarkedBit(); uint32_t index = idBits.getIndexOfBit(id); iterBits.clearBit(id); Estimator estimator; getEstimator(id, &estimator); ALOGD(" %d: position (%0.3f, %0.3f), " "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)", id, positions[index].x, positions[index].y, int(estimator.degree), vectorToString(estimator.xCoeff, estimator.degree + 1).c_str(), vectorToString(estimator.yCoeff, estimator.degree + 1).c_str(), estimator.confidence); } #endif }
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()); }