Bug 1554499 - Store WebRenderAnimationData using display item type as key r=jrmuizel
authorMiko Mynttinen <mikokm@gmail.com>
Tue, 05 Nov 2019 15:10:40 +0000
changeset 500639 3a49bec953389927936256a24c99bcde4ea13bd1
parent 500638 c802ab8cc73058de7f422c8f450d3f0cd9546df9
child 500640 af5556dcd6bb19e49fff2b0d732f01262146b870
push id36768
push usershindli@mozilla.com
push dateTue, 05 Nov 2019 22:07:34 +0000
treeherdermozilla-central@e96c1ca93d25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1554499
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1554499 - Store WebRenderAnimationData using display item type as key r=jrmuizel Depends on D50186 Differential Revision: https://phabricator.services.mozilla.com/D50187
gfx/layers/wr/WebRenderCommandBuilder.h
gfx/layers/wr/WebRenderUserData.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.h
+++ b/gfx/layers/wr/WebRenderCommandBuilder.h
@@ -187,18 +187,27 @@ class WebRenderCommandBuilder final {
     WebRenderUserDataTable* userDataTable =
         frame->GetProperty(WebRenderUserDataProperty::Key());
 
     if (!userDataTable) {
       userDataTable = new WebRenderUserDataTable();
       frame->AddProperty(WebRenderUserDataProperty::Key(), userDataTable);
     }
 
-    RefPtr<WebRenderUserData>& data = userDataTable->GetOrInsert(
-        WebRenderUserDataKey(aItem->GetPerFrameKey(), T::Type()));
+    // TODO (miko): This is a slight hack. For OMTA, WebRenderAnimationData
+    // needs to be accessible with just (frame, display item type) -key,
+    // so a more specific per frame key cannot be used.
+    const uint32_t key =
+        T::Type() == WebRenderUserData::UserDataType::eAnimation
+            ? static_cast<uint32_t>(aItem->GetType())
+            : aItem->GetPerFrameKey();
+
+    RefPtr<WebRenderUserData>& data =
+        userDataTable->GetOrInsert(WebRenderUserDataKey(key, T::Type()));
+
     if (!data) {
       data = new T(GetRenderRootStateManager(aRenderRoot), aItem);
       mWebRenderUserDatas.PutEntry(data);
       if (aOutIsRecycled) {
         *aOutIsRecycled = false;
       }
     }
 
--- a/gfx/layers/wr/WebRenderUserData.cpp
+++ b/gfx/layers/wr/WebRenderUserData.cpp
@@ -333,17 +333,18 @@ WebRenderImageData* WebRenderFallbackDat
   mImageData = MakeAndAddRef<WebRenderImageData>(mManager.get(),
                                                  mDisplayItemKey, mFrame);
 
   return mImageData.get();
 }
 
 WebRenderAnimationData::WebRenderAnimationData(RenderRootStateManager* aManager,
                                                nsDisplayItem* aItem)
-    : WebRenderUserData(aManager, aItem) {}
+    : WebRenderUserData(aManager, static_cast<uint32_t>(aItem->GetType()),
+                        aItem->Frame()) {}
 
 WebRenderAnimationData::~WebRenderAnimationData() {
   // It may be the case that nsDisplayItem that created this WebRenderUserData
   // gets destroyed without getting a chance to discard the compositor animation
   // id, so we should do it as part of cleanup here.
   uint64_t animationId = mAnimationInfo.GetCompositorAnimationsId();
   // animationId might be 0 if mAnimationInfo never held any active animations.
   if (animationId) {