Loading libs/gui/tests/EndToEndNativeInputTest.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -391,6 +391,25 @@ TEST_F(InputSurfacesTest, input_respects_cropped_surface_insets) { parentSurface->expectTap(1, 1); } // Ensure a surface whose insets are scaled, handles the touch offset correctly. TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets) { std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); bgSurface->showAt(100, 100); fgSurface->mInputInfo.surfaceInset = 5; fgSurface->showAt(100, 100); fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 4.0); }); // expect = touch / scale - inset injectTap(112, 124); fgSurface->expectTap(1, 1); injectTap(101, 101); bgSurface->expectTap(1, 1); } // Ensure we ignore transparent region when getting screen bounds when positioning input frame. TEST_F(InputSurfacesTest, input_ignores_transparent_region) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); Loading services/surfaceflinger/Layer.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -2004,10 +2004,14 @@ InputWindowInfo Layer::fillInputInfo() { ui::Transform t = getTransform(); const float xScale = t.sx(); const float yScale = t.sy(); float xSurfaceInset = info.surfaceInset; float ySurfaceInset = info.surfaceInset; if (xScale != 1.0f || yScale != 1.0f) { info.windowXScale *= 1.0f / xScale; info.windowYScale *= 1.0f / yScale; info.touchableRegion.scaleSelf(xScale, yScale); xSurfaceInset *= xScale; ySurfaceInset *= yScale; } // Transform layer size to screen space and inset it by surface insets. Loading @@ -2019,7 +2023,7 @@ InputWindowInfo Layer::fillInputInfo() { layerBounds = getCroppedBufferSize(getDrawingState()); } layerBounds = t.transform(layerBounds); layerBounds.inset(info.surfaceInset, info.surfaceInset, info.surfaceInset, info.surfaceInset); layerBounds.inset(xSurfaceInset, ySurfaceInset, xSurfaceInset, ySurfaceInset); // Input coordinate should match the layer bounds. info.frameLeft = layerBounds.left; Loading services/surfaceflinger/RefreshRateOverlay.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -37,9 +37,16 @@ bool RefreshRateOverlay::createLayer() { return false; } Mutex::Autolock _l(mFlinger.mStateLock); mLayer = mClient->getLayerUser(mIBinder); mLayer->setCrop_legacy(Rect(50, 70, 200, 100), true); mLayer->setLayer(INT32_MAX - 2); // setting Layer's Z requires resorting layersSortedByZ ssize_t idx = mFlinger.mCurrentState.layersSortedByZ.indexOf(mLayer); if (mLayer->setLayer(INT32_MAX - 2) && idx >= 0) { mFlinger.mCurrentState.layersSortedByZ.removeAt(idx); mFlinger.mCurrentState.layersSortedByZ.add(mLayer); } return true; } Loading services/surfaceflinger/SurfaceFlinger.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -5432,9 +5432,13 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r // TODO(b/129297325): expose this via developer menu option n = data.readInt32(); if (n && !mRefreshRateOverlay) { RefreshRateType type; { std::lock_guard<std::mutex> lock(mActiveConfigLock); type = mDesiredActiveConfig.type; } mRefreshRateOverlay = std::make_unique<RefreshRateOverlay>(*this); mRefreshRateOverlay->changeRefreshRate(mDesiredActiveConfig.type); mRefreshRateOverlay->changeRefreshRate(type); } else if (!n) { mRefreshRateOverlay.reset(); } Loading Loading
libs/gui/tests/EndToEndNativeInputTest.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -391,6 +391,25 @@ TEST_F(InputSurfacesTest, input_respects_cropped_surface_insets) { parentSurface->expectTap(1, 1); } // Ensure a surface whose insets are scaled, handles the touch offset correctly. TEST_F(InputSurfacesTest, input_respects_scaled_surface_insets) { std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100); std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100); bgSurface->showAt(100, 100); fgSurface->mInputInfo.surfaceInset = 5; fgSurface->showAt(100, 100); fgSurface->doTransaction([&](auto &t, auto &sc) { t.setMatrix(sc, 2.0, 0, 0, 4.0); }); // expect = touch / scale - inset injectTap(112, 124); fgSurface->expectTap(1, 1); injectTap(101, 101); bgSurface->expectTap(1, 1); } // Ensure we ignore transparent region when getting screen bounds when positioning input frame. TEST_F(InputSurfacesTest, input_ignores_transparent_region) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); Loading
services/surfaceflinger/Layer.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -2004,10 +2004,14 @@ InputWindowInfo Layer::fillInputInfo() { ui::Transform t = getTransform(); const float xScale = t.sx(); const float yScale = t.sy(); float xSurfaceInset = info.surfaceInset; float ySurfaceInset = info.surfaceInset; if (xScale != 1.0f || yScale != 1.0f) { info.windowXScale *= 1.0f / xScale; info.windowYScale *= 1.0f / yScale; info.touchableRegion.scaleSelf(xScale, yScale); xSurfaceInset *= xScale; ySurfaceInset *= yScale; } // Transform layer size to screen space and inset it by surface insets. Loading @@ -2019,7 +2023,7 @@ InputWindowInfo Layer::fillInputInfo() { layerBounds = getCroppedBufferSize(getDrawingState()); } layerBounds = t.transform(layerBounds); layerBounds.inset(info.surfaceInset, info.surfaceInset, info.surfaceInset, info.surfaceInset); layerBounds.inset(xSurfaceInset, ySurfaceInset, xSurfaceInset, ySurfaceInset); // Input coordinate should match the layer bounds. info.frameLeft = layerBounds.left; Loading
services/surfaceflinger/RefreshRateOverlay.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -37,9 +37,16 @@ bool RefreshRateOverlay::createLayer() { return false; } Mutex::Autolock _l(mFlinger.mStateLock); mLayer = mClient->getLayerUser(mIBinder); mLayer->setCrop_legacy(Rect(50, 70, 200, 100), true); mLayer->setLayer(INT32_MAX - 2); // setting Layer's Z requires resorting layersSortedByZ ssize_t idx = mFlinger.mCurrentState.layersSortedByZ.indexOf(mLayer); if (mLayer->setLayer(INT32_MAX - 2) && idx >= 0) { mFlinger.mCurrentState.layersSortedByZ.removeAt(idx); mFlinger.mCurrentState.layersSortedByZ.add(mLayer); } return true; } Loading
services/surfaceflinger/SurfaceFlinger.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -5432,9 +5432,13 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r // TODO(b/129297325): expose this via developer menu option n = data.readInt32(); if (n && !mRefreshRateOverlay) { RefreshRateType type; { std::lock_guard<std::mutex> lock(mActiveConfigLock); type = mDesiredActiveConfig.type; } mRefreshRateOverlay = std::make_unique<RefreshRateOverlay>(*this); mRefreshRateOverlay->changeRefreshRate(mDesiredActiveConfig.type); mRefreshRateOverlay->changeRefreshRate(type); } else if (!n) { mRefreshRateOverlay.reset(); } Loading