Loading libs/input/PointerController.cpp +71 −64 Original line number Diff line number Diff line Loading @@ -89,10 +89,6 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& mLocked.animationPending = false; mLocked.displayWidth = -1; mLocked.displayHeight = -1; mLocked.displayOrientation = DISPLAY_ORIENTATION_0; mLocked.presentation = PRESENTATION_POINTER; mLocked.presentationChanged = false; Loading @@ -110,15 +106,6 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& mLocked.lastFrameUpdatedTime = 0; mLocked.buttonState = 0; mPolicy->loadPointerIcon(&mLocked.pointerIcon); loadResources(); if (mLocked.pointerIcon.isValid()) { mLocked.pointerIconChanged = true; updatePointerLocked(); } } PointerController::~PointerController() { Loading @@ -144,23 +131,15 @@ bool PointerController::getBounds(float* outMinX, float* outMinY, bool PointerController::getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const { if (mLocked.displayWidth <= 0 || mLocked.displayHeight <= 0) { if (!mLocked.viewport.isValid()) { return false; } *outMinX = 0; *outMinY = 0; switch (mLocked.displayOrientation) { case DISPLAY_ORIENTATION_90: case DISPLAY_ORIENTATION_270: *outMaxX = mLocked.displayHeight - 1; *outMaxY = mLocked.displayWidth - 1; break; default: *outMaxX = mLocked.displayWidth - 1; *outMaxY = mLocked.displayHeight - 1; break; } *outMinX = mLocked.viewport.logicalLeft; *outMinY = mLocked.viewport.logicalTop; *outMaxX = mLocked.viewport.logicalRight - 1; *outMaxY = mLocked.viewport.logicalBottom - 1; return true; } Loading Loading @@ -231,6 +210,12 @@ void PointerController::getPosition(float* outX, float* outY) const { *outY = mLocked.pointerY; } int32_t PointerController::getDisplayId() const { AutoMutex _l(mLock); return mLocked.viewport.displayId; } void PointerController::fade(Transition transition) { AutoMutex _l(mLock); Loading Loading @@ -355,48 +340,56 @@ void PointerController::setInactivityTimeout(InactivityTimeout inactivityTimeout void PointerController::reloadPointerResources() { AutoMutex _l(mLock); loadResources(); if (mLocked.presentation == PRESENTATION_POINTER) { mLocked.additionalMouseResources.clear(); mLocked.animationResources.clear(); mPolicy->loadPointerIcon(&mLocked.pointerIcon); mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources, &mLocked.animationResources); loadResourcesLocked(); updatePointerLocked(); } mLocked.presentationChanged = true; updatePointerLocked(); /** * The viewport values for deviceHeight and deviceWidth have already been adjusted for rotation, * so here we are getting the dimensions in the original, unrotated orientation (orientation 0). */ static void getNonRotatedSize(const DisplayViewport& viewport, int32_t& width, int32_t& height) { width = viewport.deviceWidth; height = viewport.deviceHeight; if (viewport.orientation == DISPLAY_ORIENTATION_90 || viewport.orientation == DISPLAY_ORIENTATION_270) { std::swap(width, height); } } void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_t orientation) { void PointerController::setDisplayViewport(const DisplayViewport& viewport) { AutoMutex _l(mLock); // Adjust to use the display's unrotated coordinate frame. if (orientation == DISPLAY_ORIENTATION_90 || orientation == DISPLAY_ORIENTATION_270) { int32_t temp = height; height = width; width = temp; if (viewport == mLocked.viewport) { return; } if (mLocked.displayWidth != width || mLocked.displayHeight != height) { mLocked.displayWidth = width; mLocked.displayHeight = height; const DisplayViewport oldViewport = mLocked.viewport; mLocked.viewport = viewport; int32_t oldDisplayWidth, oldDisplayHeight; getNonRotatedSize(oldViewport, oldDisplayWidth, oldDisplayHeight); int32_t newDisplayWidth, newDisplayHeight; getNonRotatedSize(viewport, newDisplayWidth, newDisplayHeight); // Reset cursor position to center if size or display changed. if (oldViewport.displayId != viewport.displayId || oldDisplayWidth != newDisplayWidth || oldDisplayHeight != newDisplayHeight) { float minX, minY, maxX, maxY; if (getBoundsLocked(&minX, &minY, &maxX, &maxY)) { mLocked.pointerX = (minX + maxX) * 0.5f; mLocked.pointerY = (minY + maxY) * 0.5f; // Reload icon resources for density may be changed. loadResourcesLocked(); } else { mLocked.pointerX = 0; mLocked.pointerY = 0; } fadeOutAndReleaseAllSpotsLocked(); } if (mLocked.displayOrientation != orientation) { } else if (oldViewport.orientation != viewport.orientation) { // Apply offsets to convert from the pixel top-left corner position to the pixel center. // This creates an invariant frame of reference that we can easily rotate when // taking into account that the pointer may be located at fractional pixel offsets. Loading @@ -405,37 +398,37 @@ void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_ float temp; // Undo the previous rotation. switch (mLocked.displayOrientation) { switch (oldViewport.orientation) { case DISPLAY_ORIENTATION_90: temp = x; x = mLocked.displayWidth - y; x = oldViewport.deviceHeight - y; y = temp; break; case DISPLAY_ORIENTATION_180: x = mLocked.displayWidth - x; y = mLocked.displayHeight - y; x = oldViewport.deviceWidth - x; y = oldViewport.deviceHeight - y; break; case DISPLAY_ORIENTATION_270: temp = x; x = y; y = mLocked.displayHeight - temp; y = oldViewport.deviceWidth - temp; break; } // Perform the new rotation. switch (orientation) { switch (viewport.orientation) { case DISPLAY_ORIENTATION_90: temp = x; x = y; y = mLocked.displayWidth - temp; y = viewport.deviceHeight - temp; break; case DISPLAY_ORIENTATION_180: x = mLocked.displayWidth - x; y = mLocked.displayHeight - y; x = viewport.deviceWidth - x; y = viewport.deviceHeight - y; break; case DISPLAY_ORIENTATION_270: temp = x; x = mLocked.displayHeight - y; x = viewport.deviceWidth - y; y = temp; break; } Loading @@ -444,7 +437,6 @@ void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_ // and save the results. mLocked.pointerX = x - 0.5f; mLocked.pointerY = y - 0.5f; mLocked.displayOrientation = orientation; } updatePointerLocked(); Loading Loading @@ -614,11 +606,16 @@ void PointerController::removeInactivityTimeoutLocked() { mLooper->removeMessages(mHandler, MSG_INACTIVITY_TIMEOUT); } void PointerController::updatePointerLocked() { void PointerController::updatePointerLocked() REQUIRES(mLock) { if (!mLocked.viewport.isValid()) { return; } mSpriteController->openTransaction(); mLocked.pointerSprite->setLayer(Sprite::BASE_LAYER_POINTER); mLocked.pointerSprite->setPosition(mLocked.pointerX, mLocked.pointerY); mLocked.pointerSprite->setDisplayId(mLocked.viewport.displayId); if (mLocked.pointerAlpha > 0) { mLocked.pointerSprite->setAlpha(mLocked.pointerAlpha); Loading Loading @@ -729,8 +726,18 @@ void PointerController::fadeOutAndReleaseAllSpotsLocked() { } } void PointerController::loadResources() { void PointerController::loadResourcesLocked() REQUIRES(mLock) { mPolicy->loadPointerResources(&mResources); if (mLocked.presentation == PRESENTATION_POINTER) { mLocked.additionalMouseResources.clear(); mLocked.animationResources.clear(); mPolicy->loadPointerIcon(&mLocked.pointerIcon); mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources, &mLocked.animationResources); } mLocked.pointerIconChanged = true; } Loading libs/input/PointerController.h +6 −6 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <vector> #include <ui/DisplayInfo.h> #include <input/DisplayViewport.h> #include <input/Input.h> #include <PointerControllerInterface.h> #include <utils/BitSet.h> Loading Loading @@ -96,6 +97,7 @@ public: virtual int32_t getButtonState() const; virtual void setPosition(float x, float y); virtual void getPosition(float* outX, float* outY) const; virtual int32_t getDisplayId() const; virtual void fade(Transition transition); virtual void unfade(Transition transition); Loading @@ -106,7 +108,7 @@ public: void updatePointerIcon(int32_t iconId); void setCustomPointerIcon(const SpriteIcon& icon); void setDisplayViewport(int32_t width, int32_t height, int32_t orientation); void setDisplayViewport(const DisplayViewport& viewport); void setInactivityTimeout(InactivityTimeout inactivityTimeout); void reloadPointerResources(); Loading Loading @@ -156,9 +158,7 @@ private: size_t animationFrameIndex; nsecs_t lastFrameUpdatedTime; int32_t displayWidth; int32_t displayHeight; int32_t displayOrientation; DisplayViewport viewport; InactivityTimeout inactivityTimeout; Loading @@ -182,7 +182,7 @@ private: Vector<Spot*> spots; Vector<sp<Sprite> > recycledSprites; } mLocked; } mLocked GUARDED_BY(mLock); bool getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const; void setPositionLocked(float x, float y); Loading @@ -207,7 +207,7 @@ private: void fadeOutAndReleaseSpotLocked(Spot* spot); void fadeOutAndReleaseAllSpotsLocked(); void loadResources(); void loadResourcesLocked(); }; } // namespace android Loading libs/input/SpriteController.cpp +21 −3 Original line number Diff line number Diff line Loading @@ -144,13 +144,16 @@ void SpriteController::doUpdateSprites() { } } // Resize sprites if needed. // Resize and/or reparent sprites if needed. SurfaceComposerClient::Transaction t; bool needApplyTransaction = false; for (size_t i = 0; i < numSprites; i++) { SpriteUpdate& update = updates.editItemAt(i); if (update.state.surfaceControl == nullptr) { continue; } if (update.state.surfaceControl != NULL && update.state.wantSurfaceVisible()) { if (update.state.wantSurfaceVisible()) { int32_t desiredWidth = update.state.icon.bitmap.width(); int32_t desiredHeight = update.state.icon.bitmap.height(); if (update.state.surfaceWidth < desiredWidth Loading @@ -170,6 +173,12 @@ void SpriteController::doUpdateSprites() { } } } // If surface is a new one, we have to set right layer stack. if (update.surfaceChanged || update.state.dirty & DIRTY_DISPLAY_ID) { t.setLayerStack(update.state.surfaceControl, update.state.displayId); needApplyTransaction = true; } } if (needApplyTransaction) { t.apply(); Loading Loading @@ -236,7 +245,7 @@ void SpriteController::doUpdateSprites() { if (update.state.surfaceControl != NULL && (becomingVisible || becomingHidden || (wantSurfaceVisibleAndDrawn && (update.state.dirty & (DIRTY_ALPHA | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER | DIRTY_VISIBILITY | DIRTY_HOTSPOT))))) { | DIRTY_VISIBILITY | DIRTY_HOTSPOT | DIRTY_DISPLAY_ID))))) { needApplyTransaction = true; if (wantSurfaceVisibleAndDrawn Loading Loading @@ -445,6 +454,15 @@ void SpriteController::SpriteImpl::setTransformationMatrix( } } void SpriteController::SpriteImpl::setDisplayId(int32_t displayId) { AutoMutex _l(mController->mLock); if (mLocked.state.displayId != displayId) { mLocked.state.displayId = displayId; invalidateLocked(DIRTY_DISPLAY_ID); } } void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) { bool wasDirty = mLocked.state.dirty; mLocked.state.dirty |= dirty; Loading libs/input/SpriteController.h +7 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ public: /* Sets the sprite transformation matrix. */ virtual void setTransformationMatrix(const SpriteTransformationMatrix& matrix) = 0; /* Sets the id of the display where the sprite should be shown. */ virtual void setDisplayId(int32_t displayId) = 0; }; /* Loading Loading @@ -170,6 +173,7 @@ private: DIRTY_LAYER = 1 << 4, DIRTY_VISIBILITY = 1 << 5, DIRTY_HOTSPOT = 1 << 6, DIRTY_DISPLAY_ID = 1 << 7, }; /* Describes the state of a sprite. Loading @@ -180,7 +184,7 @@ private: struct SpriteState { inline SpriteState() : dirty(0), visible(false), positionX(0), positionY(0), layer(0), alpha(1.0f), positionX(0), positionY(0), layer(0), alpha(1.0f), displayId(ADISPLAY_ID_DEFAULT), surfaceWidth(0), surfaceHeight(0), surfaceDrawn(false), surfaceVisible(false) { } Loading @@ -193,6 +197,7 @@ private: int32_t layer; float alpha; SpriteTransformationMatrix transformationMatrix; int32_t displayId; sp<SurfaceControl> surfaceControl; int32_t surfaceWidth; Loading Loading @@ -225,6 +230,7 @@ private: virtual void setLayer(int32_t layer); virtual void setAlpha(float alpha); virtual void setTransformationMatrix(const SpriteTransformationMatrix& matrix); virtual void setDisplayId(int32_t displayId); inline const SpriteState& getStateLocked() const { return mLocked.state; Loading services/core/java/com/android/server/input/InputManagerService.java +7 −0 Original line number Diff line number Diff line Loading @@ -1950,6 +1950,11 @@ public class InputManagerService extends IInputManager.Stub return PointerIcon.getDefaultIcon(mContext); } // Native callback. private int getPointerDisplayId() { return mWindowManagerCallbacks.getPointerDisplayId(); } // Native callback. private String[] getKeyboardLayoutOverlay(InputDeviceIdentifier identifier) { if (!mSystemReady) { Loading Loading @@ -2017,6 +2022,8 @@ public class InputManagerService extends IInputManager.Stub KeyEvent event, int policyFlags); public int getPointerLayer(); public int getPointerDisplayId(); } /** Loading Loading
libs/input/PointerController.cpp +71 −64 Original line number Diff line number Diff line Loading @@ -89,10 +89,6 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& mLocked.animationPending = false; mLocked.displayWidth = -1; mLocked.displayHeight = -1; mLocked.displayOrientation = DISPLAY_ORIENTATION_0; mLocked.presentation = PRESENTATION_POINTER; mLocked.presentationChanged = false; Loading @@ -110,15 +106,6 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& mLocked.lastFrameUpdatedTime = 0; mLocked.buttonState = 0; mPolicy->loadPointerIcon(&mLocked.pointerIcon); loadResources(); if (mLocked.pointerIcon.isValid()) { mLocked.pointerIconChanged = true; updatePointerLocked(); } } PointerController::~PointerController() { Loading @@ -144,23 +131,15 @@ bool PointerController::getBounds(float* outMinX, float* outMinY, bool PointerController::getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const { if (mLocked.displayWidth <= 0 || mLocked.displayHeight <= 0) { if (!mLocked.viewport.isValid()) { return false; } *outMinX = 0; *outMinY = 0; switch (mLocked.displayOrientation) { case DISPLAY_ORIENTATION_90: case DISPLAY_ORIENTATION_270: *outMaxX = mLocked.displayHeight - 1; *outMaxY = mLocked.displayWidth - 1; break; default: *outMaxX = mLocked.displayWidth - 1; *outMaxY = mLocked.displayHeight - 1; break; } *outMinX = mLocked.viewport.logicalLeft; *outMinY = mLocked.viewport.logicalTop; *outMaxX = mLocked.viewport.logicalRight - 1; *outMaxY = mLocked.viewport.logicalBottom - 1; return true; } Loading Loading @@ -231,6 +210,12 @@ void PointerController::getPosition(float* outX, float* outY) const { *outY = mLocked.pointerY; } int32_t PointerController::getDisplayId() const { AutoMutex _l(mLock); return mLocked.viewport.displayId; } void PointerController::fade(Transition transition) { AutoMutex _l(mLock); Loading Loading @@ -355,48 +340,56 @@ void PointerController::setInactivityTimeout(InactivityTimeout inactivityTimeout void PointerController::reloadPointerResources() { AutoMutex _l(mLock); loadResources(); if (mLocked.presentation == PRESENTATION_POINTER) { mLocked.additionalMouseResources.clear(); mLocked.animationResources.clear(); mPolicy->loadPointerIcon(&mLocked.pointerIcon); mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources, &mLocked.animationResources); loadResourcesLocked(); updatePointerLocked(); } mLocked.presentationChanged = true; updatePointerLocked(); /** * The viewport values for deviceHeight and deviceWidth have already been adjusted for rotation, * so here we are getting the dimensions in the original, unrotated orientation (orientation 0). */ static void getNonRotatedSize(const DisplayViewport& viewport, int32_t& width, int32_t& height) { width = viewport.deviceWidth; height = viewport.deviceHeight; if (viewport.orientation == DISPLAY_ORIENTATION_90 || viewport.orientation == DISPLAY_ORIENTATION_270) { std::swap(width, height); } } void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_t orientation) { void PointerController::setDisplayViewport(const DisplayViewport& viewport) { AutoMutex _l(mLock); // Adjust to use the display's unrotated coordinate frame. if (orientation == DISPLAY_ORIENTATION_90 || orientation == DISPLAY_ORIENTATION_270) { int32_t temp = height; height = width; width = temp; if (viewport == mLocked.viewport) { return; } if (mLocked.displayWidth != width || mLocked.displayHeight != height) { mLocked.displayWidth = width; mLocked.displayHeight = height; const DisplayViewport oldViewport = mLocked.viewport; mLocked.viewport = viewport; int32_t oldDisplayWidth, oldDisplayHeight; getNonRotatedSize(oldViewport, oldDisplayWidth, oldDisplayHeight); int32_t newDisplayWidth, newDisplayHeight; getNonRotatedSize(viewport, newDisplayWidth, newDisplayHeight); // Reset cursor position to center if size or display changed. if (oldViewport.displayId != viewport.displayId || oldDisplayWidth != newDisplayWidth || oldDisplayHeight != newDisplayHeight) { float minX, minY, maxX, maxY; if (getBoundsLocked(&minX, &minY, &maxX, &maxY)) { mLocked.pointerX = (minX + maxX) * 0.5f; mLocked.pointerY = (minY + maxY) * 0.5f; // Reload icon resources for density may be changed. loadResourcesLocked(); } else { mLocked.pointerX = 0; mLocked.pointerY = 0; } fadeOutAndReleaseAllSpotsLocked(); } if (mLocked.displayOrientation != orientation) { } else if (oldViewport.orientation != viewport.orientation) { // Apply offsets to convert from the pixel top-left corner position to the pixel center. // This creates an invariant frame of reference that we can easily rotate when // taking into account that the pointer may be located at fractional pixel offsets. Loading @@ -405,37 +398,37 @@ void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_ float temp; // Undo the previous rotation. switch (mLocked.displayOrientation) { switch (oldViewport.orientation) { case DISPLAY_ORIENTATION_90: temp = x; x = mLocked.displayWidth - y; x = oldViewport.deviceHeight - y; y = temp; break; case DISPLAY_ORIENTATION_180: x = mLocked.displayWidth - x; y = mLocked.displayHeight - y; x = oldViewport.deviceWidth - x; y = oldViewport.deviceHeight - y; break; case DISPLAY_ORIENTATION_270: temp = x; x = y; y = mLocked.displayHeight - temp; y = oldViewport.deviceWidth - temp; break; } // Perform the new rotation. switch (orientation) { switch (viewport.orientation) { case DISPLAY_ORIENTATION_90: temp = x; x = y; y = mLocked.displayWidth - temp; y = viewport.deviceHeight - temp; break; case DISPLAY_ORIENTATION_180: x = mLocked.displayWidth - x; y = mLocked.displayHeight - y; x = viewport.deviceWidth - x; y = viewport.deviceHeight - y; break; case DISPLAY_ORIENTATION_270: temp = x; x = mLocked.displayHeight - y; x = viewport.deviceWidth - y; y = temp; break; } Loading @@ -444,7 +437,6 @@ void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_ // and save the results. mLocked.pointerX = x - 0.5f; mLocked.pointerY = y - 0.5f; mLocked.displayOrientation = orientation; } updatePointerLocked(); Loading Loading @@ -614,11 +606,16 @@ void PointerController::removeInactivityTimeoutLocked() { mLooper->removeMessages(mHandler, MSG_INACTIVITY_TIMEOUT); } void PointerController::updatePointerLocked() { void PointerController::updatePointerLocked() REQUIRES(mLock) { if (!mLocked.viewport.isValid()) { return; } mSpriteController->openTransaction(); mLocked.pointerSprite->setLayer(Sprite::BASE_LAYER_POINTER); mLocked.pointerSprite->setPosition(mLocked.pointerX, mLocked.pointerY); mLocked.pointerSprite->setDisplayId(mLocked.viewport.displayId); if (mLocked.pointerAlpha > 0) { mLocked.pointerSprite->setAlpha(mLocked.pointerAlpha); Loading Loading @@ -729,8 +726,18 @@ void PointerController::fadeOutAndReleaseAllSpotsLocked() { } } void PointerController::loadResources() { void PointerController::loadResourcesLocked() REQUIRES(mLock) { mPolicy->loadPointerResources(&mResources); if (mLocked.presentation == PRESENTATION_POINTER) { mLocked.additionalMouseResources.clear(); mLocked.animationResources.clear(); mPolicy->loadPointerIcon(&mLocked.pointerIcon); mPolicy->loadAdditionalMouseResources(&mLocked.additionalMouseResources, &mLocked.animationResources); } mLocked.pointerIconChanged = true; } Loading
libs/input/PointerController.h +6 −6 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <vector> #include <ui/DisplayInfo.h> #include <input/DisplayViewport.h> #include <input/Input.h> #include <PointerControllerInterface.h> #include <utils/BitSet.h> Loading Loading @@ -96,6 +97,7 @@ public: virtual int32_t getButtonState() const; virtual void setPosition(float x, float y); virtual void getPosition(float* outX, float* outY) const; virtual int32_t getDisplayId() const; virtual void fade(Transition transition); virtual void unfade(Transition transition); Loading @@ -106,7 +108,7 @@ public: void updatePointerIcon(int32_t iconId); void setCustomPointerIcon(const SpriteIcon& icon); void setDisplayViewport(int32_t width, int32_t height, int32_t orientation); void setDisplayViewport(const DisplayViewport& viewport); void setInactivityTimeout(InactivityTimeout inactivityTimeout); void reloadPointerResources(); Loading Loading @@ -156,9 +158,7 @@ private: size_t animationFrameIndex; nsecs_t lastFrameUpdatedTime; int32_t displayWidth; int32_t displayHeight; int32_t displayOrientation; DisplayViewport viewport; InactivityTimeout inactivityTimeout; Loading @@ -182,7 +182,7 @@ private: Vector<Spot*> spots; Vector<sp<Sprite> > recycledSprites; } mLocked; } mLocked GUARDED_BY(mLock); bool getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const; void setPositionLocked(float x, float y); Loading @@ -207,7 +207,7 @@ private: void fadeOutAndReleaseSpotLocked(Spot* spot); void fadeOutAndReleaseAllSpotsLocked(); void loadResources(); void loadResourcesLocked(); }; } // namespace android Loading
libs/input/SpriteController.cpp +21 −3 Original line number Diff line number Diff line Loading @@ -144,13 +144,16 @@ void SpriteController::doUpdateSprites() { } } // Resize sprites if needed. // Resize and/or reparent sprites if needed. SurfaceComposerClient::Transaction t; bool needApplyTransaction = false; for (size_t i = 0; i < numSprites; i++) { SpriteUpdate& update = updates.editItemAt(i); if (update.state.surfaceControl == nullptr) { continue; } if (update.state.surfaceControl != NULL && update.state.wantSurfaceVisible()) { if (update.state.wantSurfaceVisible()) { int32_t desiredWidth = update.state.icon.bitmap.width(); int32_t desiredHeight = update.state.icon.bitmap.height(); if (update.state.surfaceWidth < desiredWidth Loading @@ -170,6 +173,12 @@ void SpriteController::doUpdateSprites() { } } } // If surface is a new one, we have to set right layer stack. if (update.surfaceChanged || update.state.dirty & DIRTY_DISPLAY_ID) { t.setLayerStack(update.state.surfaceControl, update.state.displayId); needApplyTransaction = true; } } if (needApplyTransaction) { t.apply(); Loading Loading @@ -236,7 +245,7 @@ void SpriteController::doUpdateSprites() { if (update.state.surfaceControl != NULL && (becomingVisible || becomingHidden || (wantSurfaceVisibleAndDrawn && (update.state.dirty & (DIRTY_ALPHA | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER | DIRTY_VISIBILITY | DIRTY_HOTSPOT))))) { | DIRTY_VISIBILITY | DIRTY_HOTSPOT | DIRTY_DISPLAY_ID))))) { needApplyTransaction = true; if (wantSurfaceVisibleAndDrawn Loading Loading @@ -445,6 +454,15 @@ void SpriteController::SpriteImpl::setTransformationMatrix( } } void SpriteController::SpriteImpl::setDisplayId(int32_t displayId) { AutoMutex _l(mController->mLock); if (mLocked.state.displayId != displayId) { mLocked.state.displayId = displayId; invalidateLocked(DIRTY_DISPLAY_ID); } } void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) { bool wasDirty = mLocked.state.dirty; mLocked.state.dirty |= dirty; Loading
libs/input/SpriteController.h +7 −1 Original line number Diff line number Diff line Loading @@ -125,6 +125,9 @@ public: /* Sets the sprite transformation matrix. */ virtual void setTransformationMatrix(const SpriteTransformationMatrix& matrix) = 0; /* Sets the id of the display where the sprite should be shown. */ virtual void setDisplayId(int32_t displayId) = 0; }; /* Loading Loading @@ -170,6 +173,7 @@ private: DIRTY_LAYER = 1 << 4, DIRTY_VISIBILITY = 1 << 5, DIRTY_HOTSPOT = 1 << 6, DIRTY_DISPLAY_ID = 1 << 7, }; /* Describes the state of a sprite. Loading @@ -180,7 +184,7 @@ private: struct SpriteState { inline SpriteState() : dirty(0), visible(false), positionX(0), positionY(0), layer(0), alpha(1.0f), positionX(0), positionY(0), layer(0), alpha(1.0f), displayId(ADISPLAY_ID_DEFAULT), surfaceWidth(0), surfaceHeight(0), surfaceDrawn(false), surfaceVisible(false) { } Loading @@ -193,6 +197,7 @@ private: int32_t layer; float alpha; SpriteTransformationMatrix transformationMatrix; int32_t displayId; sp<SurfaceControl> surfaceControl; int32_t surfaceWidth; Loading Loading @@ -225,6 +230,7 @@ private: virtual void setLayer(int32_t layer); virtual void setAlpha(float alpha); virtual void setTransformationMatrix(const SpriteTransformationMatrix& matrix); virtual void setDisplayId(int32_t displayId); inline const SpriteState& getStateLocked() const { return mLocked.state; Loading
services/core/java/com/android/server/input/InputManagerService.java +7 −0 Original line number Diff line number Diff line Loading @@ -1950,6 +1950,11 @@ public class InputManagerService extends IInputManager.Stub return PointerIcon.getDefaultIcon(mContext); } // Native callback. private int getPointerDisplayId() { return mWindowManagerCallbacks.getPointerDisplayId(); } // Native callback. private String[] getKeyboardLayoutOverlay(InputDeviceIdentifier identifier) { if (!mSystemReady) { Loading Loading @@ -2017,6 +2022,8 @@ public class InputManagerService extends IInputManager.Stub KeyEvent event, int policyFlags); public int getPointerLayer(); public int getPointerDisplayId(); } /** Loading