From e808d8a16df697cfe647f55ee273776ac69ecb45 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 22 Sep 2017 16:39:53 -0400 Subject: [PATCH] Bug 1402439 - Add some documentation for the compositor animation code. r=pchang Also removes an unneeded forward-declaration. MozReview-Commit-ID: 8BPGPtkIBui --- gfx/layers/AnimationHelper.h | 43 +++++++++++-------- .../ipc/CrossProcessCompositorBridgeParent.h | 1 - 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/gfx/layers/AnimationHelper.h b/gfx/layers/AnimationHelper.h index b50ddcf69d13..34e26a4540d7 100644 --- a/gfx/layers/AnimationHelper.h +++ b/gfx/layers/AnimationHelper.h @@ -73,8 +73,20 @@ private: AnimatedValue() = delete; }; -// CompositorAnimationStorage stores the layer animations and animated value -// after sampling based on an unique id (CompositorAnimationsId) +// CompositorAnimationStorage stores the animations and animated values +// keyed by a CompositorAnimationsId. The "animations" are a representation of +// an entire animation over time, while the "animated values" are values sampled +// from the animations at a particular point in time. +// +// There is one CompositorAnimationStorage per CompositorBridgeParent (i.e. +// one per browser window), and the CompositorAnimationsId key is unique within +// a particular CompositorAnimationStorage instance. +// +// Each layer which has animations gets a CompositorAnimationsId key, and reuses +// that key during its lifetime. Likewise, in layers-free webrender, a display +// item that is animated (e.g. nsDisplayTransform) gets a CompositorAnimationsId +// key and reuses that key (it persists the key via the frame user-data +// mechanism). class CompositorAnimationStorage final { typedef nsClassHashtable AnimatedValueTable; @@ -162,8 +174,8 @@ public: * Clear AnimatedValues and Animations data */ void Clear(); - void ClearById(const uint64_t& aId); + private: ~CompositorAnimationStorage() { }; @@ -172,16 +184,16 @@ private: AnimationsTable mAnimations; }; +/** + * This utility class allows reusing code between the webrender and + * non-webrender compositor-side implementations. It provides + * utility functions for sampling animations at particular timestamps. + */ class AnimationHelper { public: - - /* - * TODO Bug 1356509 Once we decouple the compositor animations and layers - * in parent side, the API will be called inside SampleAnimations. - * Before this, we expose this API for AsyncCompositionManager. - * + /** * Sample animations based on a given time stamp for a element(layer) with * its animation data. * Returns true if there exists compositor animation, and stores corresponding @@ -193,19 +205,16 @@ public: InfallibleTArray& aAnimationData, StyleAnimationValue& aAnimationValue, bool& aHasInEffectAnimations); - /* - * TODO Bug 1356509 Once we decouple the compositor animations and layers - * in parent side, the API will be called inside SampleAnimations. - * Before this, we expose this API for AsyncCompositionManager. - * - * Populates AnimData stuctures into |aAnimData| based on |aAnimations| + /** + * Populates AnimData stuctures into |aAnimData| and |aBaseAnimationStyle| + * based on |aAnimations|. */ static void SetAnimations(AnimationArray& aAnimations, InfallibleTArray& aAnimData, StyleAnimationValue& aBaseAnimationStyle); - /* + /** * Get a unique id to represent the compositor animation between child * and parent side. This id will be used as a key to store animation * data in the CompositorAnimationStorage per compositor. @@ -214,7 +223,7 @@ public: */ static uint64_t GetNextCompositorAnimationsId(); - /* + /** * Sample animation based a given time stamp |aTime| and the animation * data inside CompositorAnimationStorage |aStorage|. The animated values * after sampling will be stored in CompositorAnimationStorage as well. diff --git a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h index a56564f6a744..c8c085603051 100644 --- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h +++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h @@ -14,7 +14,6 @@ namespace mozilla { namespace layers { class CompositorOptions; -class CompositorAnimationStorage; /** * This class handles layer updates pushed directly from child processes to