From 5e7fe01b5905863ea348d2715641fe2c78539d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 10 May 2020 02:17:47 +0000 Subject: [PATCH] Bug 1636731 - Use FunctionRef for animation generation enumeration. r=hiro I see the allocation and deallocation of the std::function show up in profiles. Differential Revision: https://phabricator.services.mozilla.com/D74551 --- gfx/layers/AnimationInfo.cpp | 2 +- gfx/layers/AnimationInfo.h | 5 +++-- layout/painting/FrameLayerBuilder.cpp | 2 +- layout/painting/FrameLayerBuilder.h | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gfx/layers/AnimationInfo.cpp b/gfx/layers/AnimationInfo.cpp index 1fd406a4165a..2dbd67b055d0 100644 --- a/gfx/layers/AnimationInfo.cpp +++ b/gfx/layers/AnimationInfo.cpp @@ -182,7 +182,7 @@ Maybe AnimationInfo::GetGenerationFromFrame( void AnimationInfo::EnumerateGenerationOnFrame( const nsIFrame* aFrame, const nsIContent* aContent, const CompositorAnimatableDisplayItemTypes& aDisplayItemTypes, - const AnimationGenerationCallback& aCallback) { + AnimationGenerationCallback aCallback) { if (XRE_IsContentProcess()) { if (nsIWidget* widget = nsContentUtils::WidgetForContent(aContent)) { // In case of child processes, we might not have yet created the layer diff --git a/gfx/layers/AnimationInfo.h b/gfx/layers/AnimationInfo.h index 8e2a59333855..852808bacaba 100644 --- a/gfx/layers/AnimationInfo.h +++ b/gfx/layers/AnimationInfo.h @@ -11,6 +11,7 @@ #include "nsDisplayItemTypes.h" #include "mozilla/Array.h" #include "mozilla/UniquePtr.h" +#include "mozilla/FunctionRef.h" #include "mozilla/layers/LayersMessages.h" // for TransformData struct RawServoAnimationValue; @@ -102,7 +103,7 @@ class AnimationInfo final { using CompositorAnimatableDisplayItemTypes = Array; - using AnimationGenerationCallback = std::function& aGeneration, DisplayItemType aDisplayItemType)>; // Enumerates animation generations on |aFrame| for the given display item // types and calls |aCallback| with the animation generation. @@ -111,7 +112,7 @@ class AnimationInfo final { static void EnumerateGenerationOnFrame( const nsIFrame* aFrame, const nsIContent* aContent, const CompositorAnimatableDisplayItemTypes& aDisplayItemTypes, - const AnimationGenerationCallback& aCallback); + AnimationGenerationCallback); void AddAnimationsForDisplayItem(nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index f24dd1e0523d..1311b229b9eb 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -6420,7 +6420,7 @@ Layer* FrameLayerBuilder::GetDedicatedLayer(nsIFrame* aFrame, /* static */ void FrameLayerBuilder::EnumerateGenerationForDedicatedLayers( - const nsIFrame* aFrame, const AnimationGenerationCallback& aCallback) { + const nsIFrame* aFrame, AnimationGenerationCallback aCallback) { std::bitset(DisplayItemType::TYPE_MAX)> notFoundTypes; for (auto displayItemType : LayerAnimationInfo::sDisplayItemTypes) { notFoundTypes.set(static_cast(displayItemType)); diff --git a/layout/painting/FrameLayerBuilder.h b/layout/painting/FrameLayerBuilder.h index e915a0a94bf2..846975b01c63 100644 --- a/layout/painting/FrameLayerBuilder.h +++ b/layout/painting/FrameLayerBuilder.h @@ -500,7 +500,7 @@ class FrameLayerBuilder : public layers::LayerUserData { static Layer* GetDedicatedLayer(nsIFrame* aFrame, DisplayItemType aDisplayItemType); - using AnimationGenerationCallback = std::function& aGeneration, DisplayItemType aDisplayItemType)>; /** * Enumerates layers for the all display item types that correspond to @@ -512,7 +512,7 @@ class FrameLayerBuilder : public layers::LayerUserData { * The enumeration stops if |aCallback| returns false. */ static void EnumerateGenerationForDedicatedLayers( - const nsIFrame* aFrame, const AnimationGenerationCallback& aCallback); + const nsIFrame* aFrame, AnimationGenerationCallback); /** * This callback must be provided to EndTransaction. The callback data