diff --git a/frameworks/core/gestures/velocity_tracker.cpp b/frameworks/core/gestures/velocity_tracker.cpp index 44406599cce62fa6cab340905f9cb40daff1a763..e066bcb0341e5cb8c015fb054eb19a8ad245f9aa 100644 --- a/frameworks/core/gestures/velocity_tracker.cpp +++ b/frameworks/core/gestures/velocity_tracker.cpp @@ -103,6 +103,14 @@ double UpdateAxisVelocity(LeastSquareImpl& axis) } return velocity; } + +inline void DumpHistoryTrack(const std::vector& vals) +{ + LOGI("Dump when velocity is zero."); + for (double val : vals) { + LOGI("History position of zero velocity track:%{public}f", val); + } +} } // namespace void VelocityTracker::UpdateTouchPoint(const TouchEvent& event, bool end) @@ -181,6 +189,12 @@ void VelocityTracker::UpdateVelocity() double yVelocity = UpdateAxisVelocity(yAxis_); velocity_.SetOffsetPerSecond({ xVelocity, yVelocity }); isVelocityDone_ = true; + + if (mainAxis_ == Axis::HORIZONTAL && NearZero(xVelocity)) { + DumpHistoryTrack(xAxis_.GetYVals()); + } else if (mainAxis_ == Axis::VERTICAL && NearZero(yVelocity)) { + DumpHistoryTrack(yAxis_.GetYVals()); + } } } // namespace OHOS::Ace diff --git a/frameworks/core/pipeline_ng/pipeline_context.cpp b/frameworks/core/pipeline_ng/pipeline_context.cpp index 91296d2f9983fcc0dc810601ad3d07f077fc5e22..ab8d3d0a067e1f6c5a458788a7ff0a7ddcb94dec 100755 --- a/frameworks/core/pipeline_ng/pipeline_context.cpp +++ b/frameworks/core/pipeline_ng/pipeline_context.cpp @@ -2074,6 +2074,14 @@ void PipelineContext::FlushTouchEvents() if (needInterpolation) { auto targetTimeStamp = resampleTimeStamp_; for (const auto& idIter : idToTouchPoints) { + auto stamp = + std::chrono::duration_cast(idIter.second.time.time_since_epoch()).count(); + if (targetTimeStamp > static_cast(stamp)) { + LOGI("Skip interpolation when there is no touch event after interpolation time point. " + "(last stamp:%{public}" PRIu64 ", target stamp:%{public}" PRIu64 ")", + static_cast(stamp), targetTimeStamp); + continue; + } TouchEvent newTouchEvent = GetResampleTouchEvent(historyPointsById_[idIter.first], idIter.second.history, targetTimeStamp); if (newTouchEvent.x != 0 && newTouchEvent.y != 0) {