Bug 743907 - Remove use of WeakMessageHandler/MessageHandler, pending-r=cjones

This commit is contained in:
Michael Wu 2012-04-11 10:59:29 +08:00
Родитель de0fdac7f9
Коммит ebe1e4ea23
4 изменённых файлов: 26 добавлений и 2 удалений

Просмотреть файл

@ -54,7 +54,9 @@ static const nsecs_t POINTER_FADE_DURATION = 500 * 1000000LL; // 500 ms
PointerController::PointerController(const sp<PointerControllerPolicyInterface>& policy,
const sp<Looper>& looper, const sp<SpriteController>& spriteController) :
mPolicy(policy), mLooper(looper), mSpriteController(spriteController) {
#ifdef HAVE_ANDROID_OS
mHandler = new WeakMessageHandler(this);
#endif
AutoMutex _l(mLock);
@ -82,7 +84,9 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>&
}
PointerController::~PointerController() {
#ifdef HAVE_ANDROID_OS
mLooper->removeMessages(mHandler);
#endif
AutoMutex _l(mLock);
@ -461,20 +465,28 @@ void PointerController::startAnimationLocked() {
if (!mLocked.animationPending) {
mLocked.animationPending = true;
mLocked.animationTime = systemTime(SYSTEM_TIME_MONOTONIC);
#ifdef HAVE_ANDROID_OS
mLooper->sendMessageDelayed(ANIMATION_FRAME_INTERVAL, mHandler, Message(MSG_ANIMATE));
#endif
}
}
void PointerController::resetInactivityTimeoutLocked() {
#ifdef HAVE_ANDROID_OS
mLooper->removeMessages(mHandler, MSG_INACTIVITY_TIMEOUT);
#endif
nsecs_t timeout = mLocked.inactivityTimeout == INACTIVITY_TIMEOUT_SHORT
? INACTIVITY_TIMEOUT_DELAY_TIME_SHORT : INACTIVITY_TIMEOUT_DELAY_TIME_NORMAL;
#ifdef HAVE_ANDROID_OS
mLooper->sendMessageDelayed(timeout, mHandler, MSG_INACTIVITY_TIMEOUT);
#endif
}
void PointerController::removeInactivityTimeoutLocked() {
#ifdef HAVE_ANDROID_OS
mLooper->removeMessages(mHandler, MSG_INACTIVITY_TIMEOUT);
#endif
}
void PointerController::updatePointerLocked() {

Просмотреть файл

@ -207,7 +207,9 @@ private:
sp<PointerControllerPolicyInterface> mPolicy;
sp<Looper> mLooper;
sp<SpriteController> mSpriteController;
#ifdef HAVE_ANDROID_OS
sp<WeakMessageHandler> mHandler;
#endif
PointerResources mResources;

Просмотреть файл

@ -35,16 +35,18 @@ namespace android {
SpriteController::SpriteController(const sp<Looper>& looper, int32_t overlayLayer) :
mLooper(looper), mOverlayLayer(overlayLayer) {
#ifdef HAVE_ANDROID_OS
mHandler = new WeakMessageHandler(this);
#endif
mLocked.transactionNestingCount = 0;
mLocked.deferredSpriteUpdate = false;
}
SpriteController::~SpriteController() {
#ifdef HAVE_ANDROID_OS
mLooper->removeMessages(mHandler);
#ifdef HAVE_ANDROID_OS
if (mSurfaceComposerClient != NULL) {
mSurfaceComposerClient->dispose();
mSurfaceComposerClient.clear();
@ -71,7 +73,9 @@ void SpriteController::closeTransaction() {
mLocked.transactionNestingCount -= 1;
if (mLocked.transactionNestingCount == 0 && mLocked.deferredSpriteUpdate) {
mLocked.deferredSpriteUpdate = false;
#ifdef HAVE_ANDROID_OS
mLooper->sendMessage(mHandler, Message(MSG_UPDATE_SPRITES));
#endif
}
}
@ -82,7 +86,9 @@ void SpriteController::invalidateSpriteLocked(const sp<SpriteImpl>& sprite) {
if (mLocked.transactionNestingCount != 0) {
mLocked.deferredSpriteUpdate = true;
} else {
#ifdef HAVE_ANDROID_OS
mLooper->sendMessage(mHandler, Message(MSG_UPDATE_SPRITES));
#endif
}
}
}

Просмотреть файл

@ -151,7 +151,11 @@ public:
*
* Clients are responsible for animating sprites by periodically updating their properties.
*/
#ifdef HAVE_ANDROID_OS
class SpriteController : public MessageHandler {
#else
class SpriteController : public virtual RefBase {
#endif
protected:
virtual ~SpriteController();
@ -286,9 +290,9 @@ private:
sp<Looper> mLooper;
const int32_t mOverlayLayer;
#ifdef HAVE_ANDROID_OS
sp<WeakMessageHandler> mHandler;
#ifdef HAVE_ANDROID_OS
sp<SurfaceComposerClient> mSurfaceComposerClient;
#endif