- Revision
- 289160
- Author
- [email protected]
- Date
- 2022-02-05 11:44:48 -0800 (Sat, 05 Feb 2022)
Log Message
Refactor RemoteLayerBackingStoreCollection to have a single backing store traversal function
https://bugs.webkit.org/show_bug.cgi?id=236040
Reviewed by Tim Horton.
Instead of traversing m_liveBackingStore and m_unparentedBackingStore in two places (from the volatilityTimerFired()
and from tryMarkAllBackingStoreVolatile()), factor into a single function with two behavior flags.
Also make VolatilityMarkingFlags an OptionSet<> and add an option to consider last display time.
* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::RemoteLayerBackingStore):
* Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h:
(WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
* Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm:
(WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
(WebKit::RemoteLayerBackingStoreCollection::backingStoreBecameUnreachable):
(WebKit::RemoteLayerBackingStoreCollection::markAllBackingStoreVolatile):
(WebKit::RemoteLayerBackingStoreCollection::tryMarkAllBackingStoreVolatile):
(WebKit::RemoteLayerBackingStoreCollection::volatilityTimerFired):
(WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatileImmediately): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (289159 => 289160)
--- trunk/Source/WebKit/ChangeLog 2022-02-05 18:06:02 UTC (rev 289159)
+++ trunk/Source/WebKit/ChangeLog 2022-02-05 19:44:48 UTC (rev 289160)
@@ -1,3 +1,28 @@
+2022-02-05 Simon Fraser <[email protected]>
+
+ Refactor RemoteLayerBackingStoreCollection to have a single backing store traversal function
+ https://bugs.webkit.org/show_bug.cgi?id=236040
+
+ Reviewed by Tim Horton.
+
+ Instead of traversing m_liveBackingStore and m_unparentedBackingStore in two places (from the volatilityTimerFired()
+ and from tryMarkAllBackingStoreVolatile()), factor into a single function with two behavior flags.
+
+ Also make VolatilityMarkingFlags an OptionSet<> and add an option to consider last display time.
+
+ * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+ * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+ (WebKit::RemoteLayerBackingStore::RemoteLayerBackingStore):
+ * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h:
+ (WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
+ * Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm:
+ (WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatile):
+ (WebKit::RemoteLayerBackingStoreCollection::backingStoreBecameUnreachable):
+ (WebKit::RemoteLayerBackingStoreCollection::markAllBackingStoreVolatile):
+ (WebKit::RemoteLayerBackingStoreCollection::tryMarkAllBackingStoreVolatile):
+ (WebKit::RemoteLayerBackingStoreCollection::volatilityTimerFired):
+ (WebKit::RemoteLayerBackingStoreCollection::markBackingStoreVolatileImmediately): Deleted.
+
2022-02-05 Brady Eidson <[email protected]>
Notification refactoring
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h (289159 => 289160)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h 2022-02-05 18:06:02 UTC (rev 289159)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h 2022-02-05 19:44:48 UTC (rev 289160)
@@ -113,8 +113,8 @@
PlatformCALayerRemote* m_layer;
WebCore::FloatSize m_size;
- float m_scale;
- bool m_isOpaque;
+ float m_scale { 1.0f };
+ bool m_isOpaque { false };
WebCore::Region m_dirtyRegion;
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm (289159 => 289160)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm 2022-02-05 18:06:02 UTC (rev 289159)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm 2022-02-05 19:44:48 UTC (rev 289160)
@@ -57,7 +57,6 @@
RemoteLayerBackingStore::RemoteLayerBackingStore(PlatformCALayerRemote* layer)
: m_layer(layer)
- , m_isOpaque(false)
, m_lastDisplayTime(-MonotonicTime::infinity())
{
if (!m_layer)
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h (289159 => 289160)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h 2022-02-05 18:06:02 UTC (rev 289159)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.h 2022-02-05 19:44:48 UTC (rev 289160)
@@ -57,13 +57,13 @@
void scheduleVolatilityTimer();
private:
- enum VolatilityMarkingFlag {
- MarkBuffersIgnoringReachability = 1 << 0
+ enum class VolatilityMarkingBehavior : uint8_t {
+ IgnoreReachability = 1 << 0,
+ ConsiderTimeSinceLastDisplay = 1 << 1,
};
- typedef unsigned VolatilityMarkingFlags;
- bool markBackingStoreVolatileImmediately(RemoteLayerBackingStore&, VolatilityMarkingFlags = 0);
- bool markBackingStoreVolatile(RemoteLayerBackingStore&, MonotonicTime now);
+ bool markBackingStoreVolatile(RemoteLayerBackingStore&, OptionSet<VolatilityMarkingBehavior> = { }, MonotonicTime = { });
+ bool markAllBackingStoreVolatile(OptionSet<VolatilityMarkingBehavior> liveBackingStoreMarkingBehavior, OptionSet<VolatilityMarkingBehavior> unparentedBackingStoreMarkingBehavior);
void volatilityTimerFired();
HashSet<RemoteLayerBackingStore*> m_liveBackingStore;
Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm (289159 => 289160)
--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm 2022-02-05 18:06:02 UTC (rev 289159)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm 2022-02-05 19:44:48 UTC (rev 289160)
@@ -101,9 +101,20 @@
return true;
}
-bool RemoteLayerBackingStoreCollection::markBackingStoreVolatileImmediately(RemoteLayerBackingStore& backingStore, VolatilityMarkingFlags volatilityMarkingFlags)
+bool RemoteLayerBackingStoreCollection::markBackingStoreVolatile(RemoteLayerBackingStore& backingStore, OptionSet<VolatilityMarkingBehavior> markingBehavior, MonotonicTime now)
{
ASSERT(!m_inLayerFlush);
+
+ if (markingBehavior.contains(VolatilityMarkingBehavior::ConsiderTimeSinceLastDisplay)) {
+ auto timeSinceLastDisplay = now - backingStore.lastDisplayTime();
+ if (timeSinceLastDisplay < volatileBackingStoreAgeThreshold) {
+ if (timeSinceLastDisplay >= volatileSecondaryBackingStoreAgeThreshold)
+ backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true);
+
+ return false;
+ }
+ }
+
bool successfullyMadeBackingStoreVolatile = true;
if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true))
@@ -112,7 +123,7 @@
if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::Back, true))
successfullyMadeBackingStoreVolatile = false;
- if (!m_reachableBackingStoreInLatestFlush.contains(&backingStore) || (volatilityMarkingFlags & MarkBuffersIgnoringReachability)) {
+ if (!m_reachableBackingStoreInLatestFlush.contains(&backingStore) || markingBehavior.contains(VolatilityMarkingBehavior::IgnoreReachability)) {
if (!backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::Front, true))
successfullyMadeBackingStoreVolatile = false;
}
@@ -120,19 +131,6 @@
return successfullyMadeBackingStoreVolatile;
}
-bool RemoteLayerBackingStoreCollection::markBackingStoreVolatile(RemoteLayerBackingStore& backingStore, MonotonicTime now)
-{
- auto timeSinceLastDisplay = now - backingStore.lastDisplayTime();
- if (timeSinceLastDisplay < volatileBackingStoreAgeThreshold) {
- if (timeSinceLastDisplay >= volatileSecondaryBackingStoreAgeThreshold)
- backingStore.setBufferVolatility(RemoteLayerBackingStore::BufferType::SecondaryBack, true);
-
- return false;
- }
-
- return markBackingStoreVolatileImmediately(backingStore);
-}
-
void RemoteLayerBackingStoreCollection::backingStoreBecameUnreachable(RemoteLayerBackingStore& backingStore)
{
ASSERT(backingStore.layer());
@@ -146,33 +144,32 @@
// This will not succeed in marking all buffers as volatile, because the commit unparenting the layer hasn't
// made it to the UI process yet. The volatility timer will finish marking the remaining buffers later.
- markBackingStoreVolatileImmediately(backingStore);
+ markBackingStoreVolatile(backingStore);
}
-void RemoteLayerBackingStoreCollection::tryMarkAllBackingStoreVolatile(CompletionHandler<void(bool)>&& completionHandler)
+bool RemoteLayerBackingStoreCollection::markAllBackingStoreVolatile(OptionSet<VolatilityMarkingBehavior> liveBackingStoreMarkingBehavior, OptionSet<VolatilityMarkingBehavior> unparentedBackingStoreMarkingBehavior)
{
bool successfullyMadeBackingStoreVolatile = true;
+ auto now = MonotonicTime::now();
for (const auto& backingStore : m_liveBackingStore)
- successfullyMadeBackingStoreVolatile &= markBackingStoreVolatileImmediately(*backingStore, MarkBuffersIgnoringReachability);
+ successfullyMadeBackingStoreVolatile &= markBackingStoreVolatile(*backingStore, liveBackingStoreMarkingBehavior, now);
for (const auto& backingStore : m_unparentedBackingStore)
- successfullyMadeBackingStoreVolatile &= markBackingStoreVolatileImmediately(*backingStore, MarkBuffersIgnoringReachability);
+ successfullyMadeBackingStoreVolatile &= markBackingStoreVolatile(*backingStore, unparentedBackingStoreMarkingBehavior, now);
+ return successfullyMadeBackingStoreVolatile;
+}
+
+void RemoteLayerBackingStoreCollection::tryMarkAllBackingStoreVolatile(CompletionHandler<void(bool)>&& completionHandler)
+{
+ bool successfullyMadeBackingStoreVolatile = markAllBackingStoreVolatile(VolatilityMarkingBehavior::IgnoreReachability, VolatilityMarkingBehavior::IgnoreReachability);
completionHandler(successfullyMadeBackingStoreVolatile);
}
void RemoteLayerBackingStoreCollection::volatilityTimerFired()
{
- bool successfullyMadeBackingStoreVolatile = true;
-
- auto now = MonotonicTime::now();
- for (const auto& backingStore : m_liveBackingStore)
- successfullyMadeBackingStoreVolatile &= markBackingStoreVolatile(*backingStore, now);
-
- for (const auto& backingStore : m_unparentedBackingStore)
- successfullyMadeBackingStoreVolatile &= markBackingStoreVolatileImmediately(*backingStore);
-
+ bool successfullyMadeBackingStoreVolatile = markAllBackingStoreVolatile(VolatilityMarkingBehavior::ConsiderTimeSinceLastDisplay, { });
if (successfullyMadeBackingStoreVolatile)
m_volatilityTimer.stop();
}