diff options
| -rw-r--r-- | include/ui/Input.h | 9 | ||||
| -rw-r--r-- | include/ui/InputDispatcher.h | 33 | ||||
| -rw-r--r-- | include/ui/InputTransport.h | 2 | ||||
| -rw-r--r-- | libs/ui/Input.cpp | 2 | ||||
| -rw-r--r-- | libs/ui/InputDispatcher.cpp | 47 | ||||
| -rw-r--r-- | libs/ui/InputReader.cpp | 4 | ||||
| -rw-r--r-- | libs/ui/InputTransport.cpp | 13 | ||||
| -rw-r--r-- | libs/ui/tests/InputPublisherAndConsumer_test.cpp | 18 | ||||
| -rw-r--r-- | libs/utils/Threads.cpp | 39 | ||||
| -rw-r--r-- | opengl/libs/EGL/egl.cpp | 4 | ||||
| -rw-r--r-- | opengl/tests/angeles/app-linux.cpp | 159 |
11 files changed, 199 insertions, 131 deletions
diff --git a/include/ui/Input.h b/include/ui/Input.h index 3fa825f9bf..b587e94db5 100644 --- a/include/ui/Input.h +++ b/include/ui/Input.h @@ -78,6 +78,11 @@ enum { POLICY_FLAG_RAW_MASK = 0x0000ffff, + /* These flags are set by the input dispatcher. */ + + // Indicates that the input event was injected. + POLICY_FLAG_INJECTED = 0x01000000, + /* These flags are set by the input reader policy as it intercepts each event. */ // Indicates that the screen was off when the event was received and the event @@ -225,6 +230,8 @@ public: inline int32_t getAction() const { return mAction; } + inline int32_t getFlags() const { return mFlags; } + inline int32_t getEdgeFlags() const { return mEdgeFlags; } inline int32_t getMetaState() const { return mMetaState; } @@ -343,6 +350,7 @@ public: int32_t deviceId, int32_t source, int32_t action, + int32_t flags, int32_t edgeFlags, int32_t metaState, float xOffset, @@ -370,6 +378,7 @@ public: private: int32_t mAction; + int32_t mFlags; int32_t mEdgeFlags; int32_t mMetaState; float mXOffset; diff --git a/include/ui/InputDispatcher.h b/include/ui/InputDispatcher.h index aed4fa112b..f00f2dbce3 100644 --- a/include/ui/InputDispatcher.h +++ b/include/ui/InputDispatcher.h @@ -84,14 +84,22 @@ struct InputTarget { * current event is delivered to this target or a timeout occurs. */ FLAG_SYNC = 0x01, - /* This flag indicates that a MotionEvent with ACTION_DOWN falls outside of the area of - * this target and so should instead be delivered as an ACTION_OUTSIDE to this target. */ + /* This flag indicates that a MotionEvent with AMOTION_EVENT_ACTION_DOWN falls outside + * of the area of this target and so should instead be delivered as an + * AMOTION_EVENT_ACTION_OUTSIDE to this target. */ FLAG_OUTSIDE = 0x02, /* This flag indicates that a KeyEvent or MotionEvent is being canceled. - * In the case of a key event, it should be delivered with KeyEvent.FLAG_CANCELED set. - * In the case of a motion event, it should be delivered as MotionEvent.ACTION_CANCEL. */ - FLAG_CANCEL = 0x04 + * In the case of a key event, it should be delivered with flag + * AKEY_EVENT_FLAG_CANCELED set. + * In the case of a motion event, it should be delivered with action + * AMOTION_EVENT_ACTION_CANCEL instead. */ + FLAG_CANCEL = 0x04, + + /* This flag indicates that the target of a MotionEvent is partly or wholly + * obscured by another visible window above it. The motion event should be + * delivered with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED. */ + FLAG_WINDOW_IS_OBSCURED = 0x08, }; // The input channel to be targeted. @@ -139,9 +147,12 @@ public: /* Notifies the system that an input channel recovered from ANR. */ virtual void notifyInputChannelRecoveredFromANR(const sp<InputChannel>& inputChannel) = 0; - /* Gets the key repeat timeout or -1 if automatic key repeating is disabled. */ + /* Gets the key repeat initial timeout or -1 if automatic key repeating is disabled. */ virtual nsecs_t getKeyRepeatTimeout() = 0; + /* Gets the key repeat inter-key delay. */ + virtual nsecs_t getKeyRepeatDelay() = 0; + /* Waits for key event input targets to become available. * If the event is being injected, injectorPid and injectorUid should specify the * process id and used id of the injecting application, otherwise they should both @@ -193,7 +204,8 @@ public: uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime) = 0; virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source, - uint32_t policyFlags, int32_t action, int32_t metaState, int32_t edgeFlags, + uint32_t policyFlags, int32_t action, int32_t flags, + int32_t metaState, int32_t edgeFlags, uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords, float xPrecision, float yPrecision, nsecs_t downTime) = 0; @@ -257,7 +269,8 @@ public: uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime); virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source, - uint32_t policyFlags, int32_t action, int32_t metaState, int32_t edgeFlags, + uint32_t policyFlags, int32_t action, int32_t flags, + int32_t metaState, int32_t edgeFlags, uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords, float xPrecision, float yPrecision, nsecs_t downTime); @@ -327,6 +340,7 @@ private: int32_t source; uint32_t policyFlags; int32_t action; + int32_t flags; int32_t metaState; int32_t edgeFlags; float xPrecision; @@ -458,7 +472,8 @@ private: int32_t repeatCount, nsecs_t downTime); MotionEntry* obtainMotionEntry(nsecs_t eventTime, int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action, - int32_t metaState, int32_t edgeFlags, float xPrecision, float yPrecision, + int32_t flags, int32_t metaState, int32_t edgeFlags, + float xPrecision, float yPrecision, nsecs_t downTime, uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords); DispatchEntry* obtainDispatchEntry(EventEntry* eventEntry); diff --git a/include/ui/InputTransport.h b/include/ui/InputTransport.h index 31ec7019a6..82831e29b6 100644 --- a/include/ui/InputTransport.h +++ b/include/ui/InputTransport.h @@ -135,6 +135,7 @@ struct InputMessage { struct { int32_t action; + int32_t flags; int32_t metaState; int32_t edgeFlags; nsecs_t downTime; @@ -218,6 +219,7 @@ public: int32_t deviceId, int32_t source, int32_t action, + int32_t flags, int32_t edgeFlags, int32_t metaState, float xOffset, diff --git a/libs/ui/Input.cpp b/libs/ui/Input.cpp index 4973cd89f2..811edaf8a2 100644 --- a/libs/ui/Input.cpp +++ b/libs/ui/Input.cpp @@ -129,6 +129,7 @@ void MotionEvent::initialize( int32_t deviceId, int32_t source, int32_t action, + int32_t flags, int32_t edgeFlags, int32_t metaState, float xOffset, @@ -142,6 +143,7 @@ void MotionEvent::initialize( const PointerCoords* pointerCoords) { InputEvent::initialize(deviceId, source); mAction = action; + mFlags = flags; mEdgeFlags = edgeFlags; mMetaState = metaState; mXOffset = xOffset; diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp index 886c7856de..df232d425b 100644 --- a/libs/ui/InputDispatcher.cpp +++ b/libs/ui/InputDispatcher.cpp @@ -97,6 +97,7 @@ InputDispatcher::~InputDispatcher() { void InputDispatcher::dispatchOnce() { nsecs_t keyRepeatTimeout = mPolicy->getKeyRepeatTimeout(); + nsecs_t keyRepeatDelay = mPolicy->getKeyRepeatDelay(); bool skipPoll = false; nsecs_t currentTime; @@ -146,7 +147,7 @@ void InputDispatcher::dispatchOnce() { if (mInboundQueue.isEmpty()) { if (mKeyRepeatState.lastKeyEntry) { if (currentTime >= mKeyRepeatState.nextRepeatTime) { - processKeyRepeatLockedInterruptible(currentTime, keyRepeatTimeout); + processKeyRepeatLockedInterruptible(currentTime, keyRepeatDelay); skipPoll = true; } else { if (mKeyRepeatState.nextRepeatTime < nextWakeupTime) { @@ -335,7 +336,7 @@ void InputDispatcher::processKeyLockedInterruptible( } void InputDispatcher::processKeyRepeatLockedInterruptible( - nsecs_t currentTime, nsecs_t keyRepeatTimeout) { + nsecs_t currentTime, nsecs_t keyRepeatDelay) { KeyEntry* entry = mKeyRepeatState.lastKeyEntry; // Search the inbound queue for a key up corresponding to this device. @@ -352,7 +353,7 @@ void InputDispatcher::processKeyRepeatLockedInterruptible( } } - // Synthesize a key repeat after the repeat timeout expired. + // Synthesize a key repeat. // Reuse the repeated key entry if it is otherwise unreferenced. uint32_t policyFlags = entry->policyFlags & POLICY_FLAG_RAW_MASK; if (entry->refCount == 1) { @@ -375,7 +376,7 @@ void InputDispatcher::processKeyRepeatLockedInterruptible( entry->flags |= AKEY_EVENT_FLAG_LONG_PRESS; } - mKeyRepeatState.nextRepeatTime = currentTime + keyRepeatTimeout; + mKeyRepeatState.nextRepeatTime = currentTime + keyRepeatDelay; #if DEBUG_OUTBOUND_EVENT_DETAILS LOGD("processKeyRepeat - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, " @@ -392,9 +393,11 @@ void InputDispatcher::processKeyRepeatLockedInterruptible( void InputDispatcher::processMotionLockedInterruptible( nsecs_t currentTime, MotionEntry* entry) { #if DEBUG_OUTBOUND_EVENT_DETAILS - LOGD("processMotion - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, action=0x%x, " + LOGD("processMotion - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, " + "action=0x%x, flags=0x%x, " "metaState=0x%x, edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, downTime=%lld", - entry->eventTime, entry->deviceId, entry->source, entry->policyFlags, entry->action, + entry->eventTime, entry->deviceId, entry->source, entry->policyFlags, + entry->action, entry->flags, entry->metaState, entry->edgeFlags, entry->xPrecision, entry->yPrecision, entry->downTime); @@ -406,7 +409,7 @@ void InputDispatcher::processMotionLockedInterruptible( } for (uint32_t i = 0; i < entry->pointerCount; i++) { LOGD(" Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f, " - "touchMajor=%f, touchMinor=%d, toolMajor=%f, toolMinor=%f, " + "touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, " "orientation=%f", i, entry->pointerIds[i], sample->pointerCoords[i].x, sample->pointerCoords[i].y, @@ -465,7 +468,7 @@ void InputDispatcher::identifyInputTargetsAndDispatchMotionLockedInterruptible( mCurrentInputTargetsValid = false; mLock.unlock(); - mReusableMotionEvent.initialize(entry->deviceId, entry->source, entry->action, + mReusableMotionEvent.initialize(entry->deviceId, entry->source, entry->action, entry->flags, entry->edgeFlags, entry->metaState, 0, 0, entry->xPrecision, entry->yPrecision, entry->downTime, entry->eventTime, entry->pointerCount, entry->pointerIds, @@ -698,12 +701,16 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, // Apply target flags. int32_t action = motionEntry->action; + int32_t flags = motionEntry->flags; if (dispatchEntry->targetFlags & InputTarget::FLAG_OUTSIDE) { action = AMOTION_EVENT_ACTION_OUTSIDE; } if (dispatchEntry->targetFlags & InputTarget::FLAG_CANCEL) { action = AMOTION_EVENT_ACTION_CANCEL; } + if (dispatchEntry->targetFlags & InputTarget::FLAG_WINDOW_IS_OBSCURED) { + flags |= AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED; + } // If headMotionSample is non-NULL, then it points to the first new sample that we // were unable to dispatch during the previous cycle so we resume dispatching from @@ -726,7 +733,7 @@ void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime, // Publish the motion event and the first motion sample. status = connection->inputPublisher.publishMotionEvent(motionEntry->deviceId, - motionEntry->source, action, motionEntry->edgeFlags, motionEntry->metaState, + motionEntry->source, action, flags, motionEntry->edgeFlags, motionEntry->metaState, xOffset, yOffset, motionEntry->xPrecision, motionEntry->yPrecision, motionEntry->downTime, firstMotionSample->eventTime, @@ -1073,18 +1080,18 @@ void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t sou } void InputDispatcher::notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source, - uint32_t policyFlags, int32_t action, int32_t metaState, int32_t edgeFlags, + uint32_t policyFlags, int32_t action, int32_t flags, int32_t metaState, int32_t edgeFlags, uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords, float xPrecision, float yPrecision, nsecs_t downTime) { #if DEBUG_INBOUND_EVENT_DETAILS LOGD("notifyMotion - eventTime=%lld, deviceId=0x%x, source=0x%x, policyFlags=0x%x, " - "action=0x%x, metaState=0x%x, edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, " - "downTime=%lld", - eventTime, deviceId, source, policyFlags, action, metaState, edgeFlags, + "action=0x%x, flags=0x%x, metaState=0x%x, edgeFlags=0x%x, " + "xPrecision=%f, yPrecision=%f, downTime=%lld", + eventTime, deviceId, source, policyFlags, action, flags, metaState, edgeFlags, xPrecision, yPrecision, downTime); for (uint32_t i = 0; i < pointerCount; i++) { LOGD(" Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f, " - "touchMajor=%f, touchMinor=%d, toolMajor=%f, toolMinor=%f, " + "touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, " "orientation=%f", i, pointerIds[i], pointerCoords[i].x, pointerCoords[i].y, pointerCoords[i].pressure, pointerCoords[i].size, @@ -1209,7 +1216,7 @@ NoBatchingOrStreaming:; // Just enqueue a new motion event. MotionEntry* newEntry = mAllocator.obtainMotionEntry(eventTime, - deviceId, source, policyFlags, action, metaState, edgeFlags, + deviceId, source, policyFlags, action, flags, metaState, edgeFlags, xPrecision, yPrecision, downTime, pointerCount, pointerIds, pointerCoords); @@ -1359,7 +1366,7 @@ InputDispatcher::EventEntry* InputDispatcher::createEntryFromInputEventLocked( switch (event->getType()) { case AINPUT_EVENT_TYPE_KEY: { const KeyEvent* keyEvent = static_cast<const KeyEvent*>(event); - uint32_t policyFlags = 0; // XXX consider adding a policy flag to track injected events + uint32_t policyFlags = POLICY_FLAG_INJECTED; KeyEntry* keyEntry = mAllocator.obtainKeyEntry(keyEvent->getEventTime(), keyEvent->getDeviceId(), keyEvent->getSource(), policyFlags, @@ -1371,7 +1378,7 @@ InputDispatcher::EventEntry* InputDispatcher::createEntryFromInputEventLocked( case AINPUT_EVENT_TYPE_MOTION: { const MotionEvent* motionEvent = static_cast<const MotionEvent*>(event); - uint32_t policyFlags = 0; // XXX consider adding a policy flag to track injected events + uint32_t policyFlags = POLICY_FLAG_INJECTED; const nsecs_t* sampleEventTimes = motionEvent->getSampleEventTimes(); const PointerCoords* samplePointerCoords = motionEvent->getSamplePointerCoords(); @@ -1379,7 +1386,8 @@ InputDispatcher::EventEntry* InputDispatcher::createEntryFromInputEventLocked( MotionEntry* motionEntry = mAllocator.obtainMotionEntry(*sampleEventTimes, motionEvent->getDeviceId(), motionEvent->getSource(), policyFlags, - motionEvent->getAction(), motionEvent->getMetaState(), motionEvent->getEdgeFlags(), + motionEvent->getAction(), motionEvent->getFlags(), + motionEvent->getMetaState(), motionEvent->getEdgeFlags(), motionEvent->getXPrecision(), motionEvent->getYPrecision(), motionEvent->getDownTime(), uint32_t(pointerCount), motionEvent->getPointerIds(), samplePointerCoords); @@ -1664,7 +1672,7 @@ InputDispatcher::KeyEntry* InputDispatcher::Allocator::obtainKeyEntry(nsecs_t ev } InputDispatcher::MotionEntry* InputDispatcher::Allocator::obtainMotionEntry(nsecs_t eventTime, - int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action, + int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action, int32_t flags, int32_t metaState, int32_t edgeFlags, float xPrecision, float yPrecision, nsecs_t downTime, uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords) { @@ -1676,6 +1684,7 @@ InputDispatcher::MotionEntry* InputDispatcher::Allocator::obtainMotionEntry(nsec entry->source = source; entry->policyFlags = policyFlags; entry->action = action; + entry->flags = flags; entry->metaState = metaState; entry->edgeFlags = edgeFlags; entry->xPrecision = xPrecision; diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp index 8ffb48debe..d57b38c2e2 100644 --- a/libs/ui/InputReader.cpp +++ b/libs/ui/InputReader.cpp @@ -1153,7 +1153,7 @@ void TrackballInputMapper::applyPolicyAndDispatch(nsecs_t when, int32_t motionEv int32_t pointerId = 0; getDispatcher()->notifyMotion(when, getDeviceId(), AINPUT_SOURCE_TRACKBALL, policyFlags, - motionEventAction, metaState, AMOTION_EVENT_EDGE_FLAG_NONE, + motionEventAction, 0, metaState, AMOTION_EVENT_EDGE_FLAG_NONE, 1, & pointerId, pointerCoords, mXPrecision, mYPrecision, downTime); } @@ -2324,7 +2324,7 @@ void TouchInputMapper::dispatchTouch(nsecs_t when, uint32_t policyFlags, } // release lock getDispatcher()->notifyMotion(when, getDeviceId(), AINPUT_SOURCE_TOUCHSCREEN, policyFlags, - motionEventAction, getContext()->getGlobalMetaState(), motionEventEdgeFlags, + motionEventAction, 0, getContext()->getGlobalMetaState(), motionEventEdgeFlags, pointerCount, pointerIds, pointerCoords, xPrecision, yPrecision, mDownTime); } diff --git a/libs/ui/InputTransport.cpp b/libs/ui/InputTransport.cpp index cf0f63e247..4c402dc020 100644 --- a/libs/ui/InputTransport.cpp +++ b/libs/ui/InputTransport.cpp @@ -318,8 +318,8 @@ status_t InputPublisher::publishKeyEvent( nsecs_t downTime, nsecs_t eventTime) { #if DEBUG_TRANSPORT_ACTIONS - LOGD("channel '%s' publisher ~ publishKeyEvent: deviceId=%d, source=%d, " - "action=%d, flags=%d, keyCode=%d, scanCode=%d, metaState=%d, repeatCount=%d," + LOGD("channel '%s' publisher ~ publishKeyEvent: deviceId=%d, source=0x%x, " + "action=0x%x, flags=0x%x, keyCode=%d, scanCode=%d, metaState=0x%x, repeatCount=%d," "downTime=%lld, eventTime=%lld", mChannel->getName().string(), deviceId, source, action, flags, keyCode, scanCode, metaState, repeatCount, @@ -346,6 +346,7 @@ status_t InputPublisher::publishMotionEvent( int32_t deviceId, int32_t source, int32_t action, + int32_t flags, int32_t edgeFlags, int32_t metaState, float xOffset, @@ -358,12 +359,12 @@ status_t InputPublisher::publishMotionEvent( const int32_t* pointerIds, const PointerCoords* pointerCoords) { #if DEBUG_TRANSPORT_ACTIONS - LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, source=%d, " - "action=%d, edgeFlags=%d, metaState=%d, xOffset=%f, yOffset=%f, " + LOGD("channel '%s' publisher ~ publishMotionEvent: deviceId=%d, source=0x%x, " + "action=0x%x, flags=0x%x, edgeFlags=0x%x, metaState=0x%x, xOffset=%f, yOffset=%f, " "xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, " "pointerCount=%d", mChannel->getName().string(), - deviceId, source, action, edgeFlags, metaState, xOffset, yOffset, + deviceId, source, action, flags, edgeFlags, metaState, xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount); #endif @@ -379,6 +380,7 @@ status_t InputPublisher::publishMotionEvent( } mSharedMessage->motion.action = action; + mSharedMessage->motion.flags = flags; mSharedMessage->motion.edgeFlags = edgeFlags; mSharedMessage->motion.metaState = metaState; mSharedMessage->motion.xOffset = xOffset; @@ -664,6 +666,7 @@ void InputConsumer::populateMotionEvent(MotionEvent* motionEvent) const { mSharedMessage->deviceId, mSharedMessage->source, mSharedMessage->motion.action, + mSharedMessage->motion.flags, mSharedMessage->motion.edgeFlags, mSharedMessage->motion.metaState, mSharedMessage->motion.xOffset, diff --git a/libs/ui/tests/InputPublisherAndConsumer_test.cpp b/libs/ui/tests/InputPublisherAndConsumer_test.cpp index 3bc21fa296..952b974769 100644 --- a/libs/ui/tests/InputPublisherAndConsumer_test.cpp +++ b/libs/ui/tests/InputPublisherAndConsumer_test.cpp @@ -138,6 +138,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent( const int32_t deviceId = 1; const int32_t source = AINPUT_SOURCE_TOUCHSCREEN; const int32_t action = AMOTION_EVENT_ACTION_MOVE; + const int32_t flags = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED; const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP; const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON; const float xOffset = -10; @@ -167,7 +168,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent( } } - status = mPublisher->publishMotionEvent(deviceId, source, action, edgeFlags, + status = mPublisher->publishMotionEvent(deviceId, source, action, flags, edgeFlags, metaState, xOffset, yOffset, xPrecision, yPrecision, downTime, sampleEventTimes[0], pointerCount, pointerIds, samplePointerCoords.array()); ASSERT_EQ(OK, status) @@ -213,6 +214,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent( EXPECT_EQ(deviceId, motionEvent->getDeviceId()); EXPECT_EQ(source, motionEvent->getSource()); EXPECT_EQ(action, motionEvent->getAction()); + EXPECT_EQ(flags, motionEvent->getFlags()); EXPECT_EQ(edgeFlags, motionEvent->getEdgeFlags()); EXPECT_EQ(metaState, motionEvent->getMetaState()); EXPECT_EQ(xPrecision, motionEvent->getXPrecision()); @@ -322,12 +324,12 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenNotReset_ReturnsErr int32_t pointerIds[pointerCount] = { 0 }; PointerCoords pointerCoords[pointerCount] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; - status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); ASSERT_EQ(OK, status) << "publisher publishMotionEvent should return OK"; - status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); ASSERT_EQ(INVALID_OPERATION, status) << "publisher publishMotionEvent should return INVALID_OPERATION because "; @@ -342,7 +344,7 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenPointerCountLessTha int32_t pointerIds[pointerCount]; PointerCoords pointerCoords[pointerCount]; - status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; @@ -356,7 +358,7 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenPointerCountGreater int32_t pointerIds[pointerCount]; PointerCoords pointerCoords[pointerCount]; - status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + status = mPublisher->publishMotionEvent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE"; @@ -402,7 +404,7 @@ TEST_F(InputPublisherAndConsumerTest, AppendMotionSample_WhenPublishedMotionEven PointerCoords pointerCoords[pointerCount]; status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_DOWN, - 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); + 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); ASSERT_EQ(OK, status); status = mPublisher->appendMotionSample(0, pointerCoords); @@ -419,7 +421,7 @@ TEST_F(InputPublisherAndConsumerTest, AppendMotionSample_WhenAlreadyConsumed_Ret PointerCoords pointerCoords[pointerCount]; status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_MOVE, - 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); + 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); ASSERT_EQ(OK, status); status = mPublisher->sendDispatchSignal(); @@ -446,7 +448,7 @@ TEST_F(InputPublisherAndConsumerTest, AppendMotionSample_WhenBufferFull_ReturnsE PointerCoords pointerCoords[pointerCount]; status = mPublisher->publishMotionEvent(0, 0, AMOTION_EVENT_ACTION_MOVE, - 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); + 0, 0, 0, 0, 0, 0, 0, 0, 0, pointerCount, pointerIds, pointerCoords); ASSERT_EQ(OK, status); for (int count = 1;; count++) { diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp index e5ece8e8a2..f6c55e4d89 100644 --- a/libs/utils/Threads.cpp +++ b/libs/utils/Threads.cpp @@ -65,6 +65,20 @@ using namespace android; typedef void* (*android_pthread_entry)(void*); +static pthread_once_t gDoSchedulingGroupOnce = PTHREAD_ONCE_INIT; +static bool gDoSchedulingGroup = true; + +static void checkDoSchedulingGroup(void) { + char buf[PROPERTY_VALUE_MAX]; + int len = property_get("debug.sys.noschedgroups", buf, ""); + if (len > 0) { + int temp; + if (sscanf(buf, "%d", &temp) == 1) { + gDoSchedulingGroup = temp == 0; + } + } +} + struct thread_data_t { thread_func_t entryFunction; void* userData; @@ -80,6 +94,15 @@ struct thread_data_t { char * name = t->threadName; delete t; setpriority(PRIO_PROCESS, 0, prio); + pthread_once(&gDoSchedulingGroupOnce, checkDoSchedulingGroup); + if (gDoSchedulingGroup) { + if (prio >= ANDROID_PRIORITY_BACKGROUND) { + set_sched_policy(androidGetTid(), SP_BACKGROUND); + } else { + set_sched_policy(androidGetTid(), SP_FOREGROUND); + } + } + if (name) { #if defined(HAVE_PRCTL) // Mac OS doesn't have this, and we build libutil for the host too @@ -281,22 +304,6 @@ pid_t androidGetTid() #endif } -#if defined(HAVE_PTHREADS) -static pthread_once_t gDoSchedulingGroupOnce = PTHREAD_ONCE_INIT; -static bool gDoSchedulingGroup = true; - -static void checkDoSchedulingGroup(void) { - char buf[PROPERTY_VALUE_MAX]; - int len = property_get("debug.sys.noschedgroups", buf, ""); - if (len > 0) { - int temp; - if (sscanf(buf, "%d", &temp) == 1) { - gDoSchedulingGroup = temp == 0; - } - } -} -#endif - int androidSetThreadSchedulingGroup(pid_t tid, int grp) { if (grp > ANDROID_TGROUP_MAX || grp < 0) { diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp index 5e61607da8..df21358dc7 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp @@ -239,7 +239,7 @@ struct egl_image_t : public egl_object_t memset(images, 0, sizeof(images)); } EGLDisplay dpy; - EGLConfig context; + EGLContext context; EGLImageKHR images[IMPL_NUM_IMPLEMENTATIONS]; }; @@ -1769,7 +1769,7 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) egl_connection_t* const cnx = &gEGLImpl[i]; if (image->images[i] != EGL_NO_IMAGE_KHR) { if (cnx->dso) { - if (cnx->egl.eglCreateImageKHR) { + if (cnx->egl.eglDestroyImageKHR) { if (cnx->egl.eglDestroyImageKHR( dp->disp[i].dpy, image->images[i])) { success = true; diff --git a/opengl/tests/angeles/app-linux.cpp b/opengl/tests/angeles/app-linux.cpp index 06fa0c2bd7..4d10ee5099 100644 --- a/opengl/tests/angeles/app-linux.cpp +++ b/opengl/tests/angeles/app-linux.cpp @@ -63,7 +63,7 @@ using namespace android; int gAppAlive = 1; static const char sAppName[] = - "San Angeles Observation OpenGL ES version example (Linux)"; + "San Angeles Observation OpenGL ES version example (Linux)"; static int sWindowWidth = WINDOW_DEFAULT_WIDTH; static int sWindowHeight = WINDOW_DEFAULT_HEIGHT; @@ -74,22 +74,22 @@ static EGLSurface sEglSurface = EGL_NO_SURFACE; const char *egl_strerror(unsigned err) { switch(err){ - case EGL_SUCCESS: return "SUCCESS"; - case EGL_NOT_INITIALIZED: return "NOT INITIALIZED"; - case EGL_BAD_ACCESS: return "BAD ACCESS"; - case EGL_BAD_ALLOC: return "BAD ALLOC"; - case EGL_BAD_ATTRIBUTE: return "BAD_ATTRIBUTE"; - case EGL_BAD_CONFIG: return "BAD CONFIG"; - case EGL_BAD_CONTEXT: return "BAD CONTEXT"; - case EGL_BAD_CURRENT_SURFACE: return "BAD CURRENT SURFACE"; - case EGL_BAD_DISPLAY: return "BAD DISPLAY"; - case EGL_BAD_MATCH: return "BAD MATCH"; - case EGL_BAD_NATIVE_PIXMAP: return "BAD NATIVE PIXMAP"; - case EGL_BAD_NATIVE_WINDOW: return "BAD NATIVE WINDOW"; - case EGL_BAD_PARAMETER: return "BAD PARAMETER"; - case EGL_BAD_SURFACE: return "BAD_SURFACE"; -// case EGL_CONTEXT_LOST: return "CONTEXT LOST"; - default: return "UNKNOWN"; + case EGL_SUCCESS: return "SUCCESS"; + case EGL_NOT_INITIALIZED: return "NOT INITIALIZED"; + case EGL_BAD_ACCESS: return "BAD ACCESS"; + case EGL_BAD_ALLOC: return "BAD ALLOC"; + case EGL_BAD_ATTRIBUTE: return "BAD_ATTRIBUTE"; + case EGL_BAD_CONFIG: return "BAD CONFIG"; + case EGL_BAD_CONTEXT: return "BAD CONTEXT"; + case EGL_BAD_CURRENT_SURFACE: return "BAD CURRENT SURFACE"; + case EGL_BAD_DISPLAY: return "BAD DISPLAY"; + case EGL_BAD_MATCH: return "BAD MATCH"; + case EGL_BAD_NATIVE_PIXMAP: return "BAD NATIVE PIXMAP"; + case EGL_BAD_NATIVE_WINDOW: return "BAD NATIVE WINDOW"; + case EGL_BAD_PARAMETER: return "BAD PARAMETER"; + case EGL_BAD_SURFACE: return "BAD_SURFACE"; + // case EGL_CONTEXT_LOST: return "CONTEXT LOST"; + default: return "UNKNOWN"; } } @@ -118,52 +118,59 @@ static void checkEGLErrors() fprintf(stderr, "EGL Error: 0x%04x\n", (int)error); } -static int initGraphics() +static int initGraphics(unsigned samples) { EGLint configAttribs[] = { - EGL_DEPTH_SIZE, 16, - EGL_NONE - }; - - EGLint majorVersion; - EGLint minorVersion; - EGLContext context; - EGLConfig config; - EGLSurface surface; - EGLint w, h; - EGLDisplay dpy; - - EGLNativeWindowType window = android_createDisplaySurface(); - - dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - eglInitialize(dpy, &majorVersion, &minorVersion); - - status_t err = EGLUtils::selectConfigForNativeWindow( - dpy, configAttribs, window, &config); - if (err) { - fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n"); - return 0; - } - - surface = eglCreateWindowSurface(dpy, config, window, NULL); - egl_error("eglCreateWindowSurface"); - - fprintf(stderr,"surface = %p\n", surface); - - context = eglCreateContext(dpy, config, NULL, NULL); - egl_error("eglCreateContext"); - fprintf(stderr,"context = %p\n", context); - - eglMakeCurrent(dpy, surface, surface, context); - egl_error("eglMakeCurrent"); - - eglQuerySurface(dpy, surface, EGL_WIDTH, &sWindowWidth); - eglQuerySurface(dpy, surface, EGL_HEIGHT, &sWindowHeight); + EGL_DEPTH_SIZE, 16, + EGL_SAMPLE_BUFFERS, samples ? 1 : 0, + EGL_SAMPLES, samples, + EGL_NONE + }; + + EGLint majorVersion; + EGLint minorVersion; + EGLContext context; + EGLConfig config; + EGLSurface surface; + EGLint w, h; + EGLDisplay dpy; + + EGLNativeWindowType window = android_createDisplaySurface(); + + dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + eglInitialize(dpy, &majorVersion, &minorVersion); + + status_t err = EGLUtils::selectConfigForNativeWindow( + dpy, configAttribs, window, &config); + if (err) { + fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n"); + return 0; + } + + surface = eglCreateWindowSurface(dpy, config, window, NULL); + egl_error("eglCreateWindowSurface"); + + fprintf(stderr,"surface = %p\n", surface); + + context = eglCreateContext(dpy, config, NULL, NULL); + egl_error("eglCreateContext"); + fprintf(stderr,"context = %p\n", context); + + eglMakeCurrent(dpy, surface, surface, context); + egl_error("eglMakeCurrent"); + + eglQuerySurface(dpy, surface, EGL_WIDTH, &sWindowWidth); + eglQuerySurface(dpy, surface, EGL_HEIGHT, &sWindowHeight); sEglDisplay = dpy; sEglSurface = surface; sEglContext = context; + if (samples == 0) { + // GL_MULTISAMPLE is enabled by default + glDisable(GL_MULTISAMPLE); + } + return EGL_TRUE; } @@ -179,35 +186,47 @@ static void deinitGraphics() int main(int argc, char *argv[]) { - // not referenced: - argc = argc; - argv = argv; + unsigned samples = 0; + printf("usage: %s [samples]\n", argv[0]); + if (argc == 2) { + samples = atoi( argv[1] ); + printf("Multisample enabled: GL_SAMPLES = %u\n", samples); + } - if (!initGraphics()) + if (!initGraphics(samples)) { fprintf(stderr, "Graphics initialization failed.\n"); return EXIT_FAILURE; } appInit(); - + + struct timeval timeTemp; + int frameCount = 0; + gettimeofday(&timeTemp, NULL); + double totalTime = timeTemp.tv_usec/1000000.0 + timeTemp.tv_sec; + while (gAppAlive) { struct timeval timeNow; - if (gAppAlive) - { - gettimeofday(&timeNow, NULL); - appRender(timeNow.tv_sec * 1000 + timeNow.tv_usec / 1000, - sWindowWidth, sWindowHeight); - checkGLErrors(); - eglSwapBuffers(sEglDisplay, sEglSurface); - checkEGLErrors(); - } + gettimeofday(&timeNow, NULL); + appRender(timeNow.tv_sec * 1000 + timeNow.tv_usec / 1000, + sWindowWidth, sWindowHeight); + checkGLErrors(); + eglSwapBuffers(sEglDisplay, sEglSurface); + checkEGLErrors(); + frameCount++; } + gettimeofday(&timeTemp, NULL); + appDeinit(); deinitGraphics(); + totalTime = (timeTemp.tv_usec/1000000.0 + timeTemp.tv_sec) - totalTime; + printf("totalTime=%f s, frameCount=%d, %.2f fps\n", + totalTime, frameCount, frameCount/totalTime); + return EXIT_SUCCESS; } |