WebKit Bugzilla
Attachment 370891 Details for
Bug 198353
: Move some HistoricalVelocityData code into the cpp file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198353-20190529154922.patch (text/plain), 6.06 KB, created by
Simon Fraser (smfr)
on 2019-05-29 15:49:22 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Simon Fraser (smfr)
Created:
2019-05-29 15:49:22 PDT
Size:
6.06 KB
patch
obsolete
>Subversion Revision: 245863 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b9caceeec616f0f7836228566437c414f6c6a518..f762257ae833c92289fc3726b29919854f4f0916 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-05-29 Simon Fraser <simon.fraser@apple.com> >+ >+ Move some HistoricalVelocityData code into the cpp file >+ https://bugs.webkit.org/show_bug.cgi?id=198353 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Now that we have VelocityData.cpp put the non-trivial HistoricalVelocityData::velocityForNewData() >+ into it. append() can become a lambda function. >+ >+ * platform/graphics/VelocityData.cpp: >+ (WebCore::HistoricalVelocityData::velocityForNewData): >+ * platform/graphics/VelocityData.h: >+ (WebCore::HistoricalVelocityData::velocityForNewData): Deleted. >+ (WebCore::HistoricalVelocityData::append): Deleted. >+ > 2019-05-29 Ryan Haddad <ryanhaddad@apple.com> > > Unreviewed, rolling out r245857. >diff --git a/Source/WebCore/platform/graphics/VelocityData.cpp b/Source/WebCore/platform/graphics/VelocityData.cpp >index b20529df850cd3cdd4c17ab1425ad76d5919c510..3a6b09367c677003fca34e4062685c597f01530f 100644 >--- a/Source/WebCore/platform/graphics/VelocityData.cpp >+++ b/Source/WebCore/platform/graphics/VelocityData.cpp >@@ -30,6 +30,45 @@ > > namespace WebCore { > >+VelocityData HistoricalVelocityData::velocityForNewData(FloatPoint newPosition, double scale, MonotonicTime timestamp) >+{ >+ auto append = [&](FloatPoint newPosition, double scale, MonotonicTime timestamp) >+ { >+ m_latestDataIndex = (m_latestDataIndex + 1) % maxHistoryDepth; >+ m_positionHistory[m_latestDataIndex] = { timestamp, newPosition, scale }; >+ m_historySize = std::min(m_historySize + 1, maxHistoryDepth); >+ m_lastAppendTimestamp = timestamp; >+ }; >+ >+ // Due to all the source of rect update, the input is very noisy. To smooth the output, we accumulate all changes >+ // within 1 frame as a single update. No speed computation is ever done on data within the same frame. >+ const Seconds filteringThreshold(1.0 / 60); >+ >+ VelocityData velocityData; >+ if (m_historySize > 0) { >+ unsigned oldestDataIndex; >+ unsigned distanceToLastHistoricalData = m_historySize - 1; >+ if (distanceToLastHistoricalData <= m_latestDataIndex) >+ oldestDataIndex = m_latestDataIndex - distanceToLastHistoricalData; >+ else >+ oldestDataIndex = m_historySize - (distanceToLastHistoricalData - m_latestDataIndex); >+ >+ Seconds timeDelta = timestamp - m_positionHistory[oldestDataIndex].timestamp; >+ if (timeDelta > filteringThreshold) { >+ Data& oldestData = m_positionHistory[oldestDataIndex]; >+ velocityData = VelocityData((newPosition.x() - oldestData.position.x()) / timeDelta.seconds(), (newPosition.y() - oldestData.position.y()) / timeDelta.seconds(), (scale - oldestData.scale) / timeDelta.seconds(), timestamp); >+ } >+ } >+ >+ Seconds timeSinceLastAppend = timestamp - m_lastAppendTimestamp; >+ if (timeSinceLastAppend > filteringThreshold) >+ append(newPosition, scale, timestamp); >+ else >+ m_positionHistory[m_latestDataIndex] = { timestamp, newPosition, scale }; >+ >+ return velocityData; >+} >+ > TextStream& operator<<(TextStream& ts, const VelocityData& velocityData) > { > ts.dumpProperty("timestamp", velocityData.lastUpdateTime.secondsSinceEpoch().value()); >diff --git a/Source/WebCore/platform/graphics/VelocityData.h b/Source/WebCore/platform/graphics/VelocityData.h >index 4bbe29ad15718376721a7e07d357a610c4755a07..5276c7c4c7d96133bdace536babcc9efe2a70062 100644 >--- a/Source/WebCore/platform/graphics/VelocityData.h >+++ b/Source/WebCore/platform/graphics/VelocityData.h >@@ -68,48 +68,10 @@ class HistoricalVelocityData { > public: > HistoricalVelocityData() = default; > >- VelocityData velocityForNewData(FloatPoint newPosition, double scale, MonotonicTime timestamp) >- { >- // Due to all the source of rect update, the input is very noisy. To smooth the output, we accumulate all changes >- // within 1 frame as a single update. No speed computation is ever done on data within the same frame. >- const Seconds filteringThreshold(1.0 / 60); >- >- VelocityData velocityData; >- if (m_historySize > 0) { >- unsigned oldestDataIndex; >- unsigned distanceToLastHistoricalData = m_historySize - 1; >- if (distanceToLastHistoricalData <= m_latestDataIndex) >- oldestDataIndex = m_latestDataIndex - distanceToLastHistoricalData; >- else >- oldestDataIndex = m_historySize - (distanceToLastHistoricalData - m_latestDataIndex); >- >- Seconds timeDelta = timestamp - m_positionHistory[oldestDataIndex].timestamp; >- if (timeDelta > filteringThreshold) { >- Data& oldestData = m_positionHistory[oldestDataIndex]; >- velocityData = VelocityData((newPosition.x() - oldestData.position.x()) / timeDelta.seconds(), (newPosition.y() - oldestData.position.y()) / timeDelta.seconds(), (scale - oldestData.scale) / timeDelta.seconds(), timestamp); >- } >- } >- >- Seconds timeSinceLastAppend = timestamp - m_lastAppendTimestamp; >- if (timeSinceLastAppend > filteringThreshold) >- append(newPosition, scale, timestamp); >- else >- m_positionHistory[m_latestDataIndex] = { timestamp, newPosition, scale }; >- >- return velocityData; >- } >- >+ VelocityData velocityForNewData(FloatPoint newPosition, double scale, MonotonicTime); > void clear() { m_historySize = 0; } > > private: >- void append(FloatPoint newPosition, double scale, MonotonicTime timestamp) >- { >- m_latestDataIndex = (m_latestDataIndex + 1) % maxHistoryDepth; >- m_positionHistory[m_latestDataIndex] = { timestamp, newPosition, scale }; >- m_historySize = std::min(m_historySize + 1, maxHistoryDepth); >- m_lastAppendTimestamp = timestamp; >- } >- > static constexpr unsigned maxHistoryDepth = 3; > > unsigned m_historySize { 0 };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
thorton
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198353
: 370891