diff --git a/widget/gonk/libui/PointerController.cpp b/widget/gonk/libui/PointerController.cpp index fc828a6afee7..26f467c3eabd 100644 --- a/widget/gonk/libui/PointerController.cpp +++ b/widget/gonk/libui/PointerController.cpp @@ -54,7 +54,9 @@ static const nsecs_t POINTER_FADE_DURATION = 500 * 1000000LL; // 500 ms PointerController::PointerController(const sp& policy, const sp& looper, const sp& 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& } 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() { diff --git a/widget/gonk/libui/PointerController.h b/widget/gonk/libui/PointerController.h index 98c44c2cf293..7c2d5f1ebca4 100644 --- a/widget/gonk/libui/PointerController.h +++ b/widget/gonk/libui/PointerController.h @@ -207,7 +207,9 @@ private: sp mPolicy; sp mLooper; sp mSpriteController; +#ifdef HAVE_ANDROID_OS sp mHandler; +#endif PointerResources mResources; diff --git a/widget/gonk/libui/SpriteController.cpp b/widget/gonk/libui/SpriteController.cpp index 860450182203..dce672605f61 100644 --- a/widget/gonk/libui/SpriteController.cpp +++ b/widget/gonk/libui/SpriteController.cpp @@ -35,16 +35,18 @@ namespace android { SpriteController::SpriteController(const sp& 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& sprite) { if (mLocked.transactionNestingCount != 0) { mLocked.deferredSpriteUpdate = true; } else { +#ifdef HAVE_ANDROID_OS mLooper->sendMessage(mHandler, Message(MSG_UPDATE_SPRITES)); +#endif } } } diff --git a/widget/gonk/libui/SpriteController.h b/widget/gonk/libui/SpriteController.h index 4502f4e3739c..e04fc33ba6be 100644 --- a/widget/gonk/libui/SpriteController.h +++ b/widget/gonk/libui/SpriteController.h @@ -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 mLooper; const int32_t mOverlayLayer; +#ifdef HAVE_ANDROID_OS sp mHandler; -#ifdef HAVE_ANDROID_OS sp mSurfaceComposerClient; #endif