diff options
author | jbauman <jbauman@chromium.org> | 2014-10-09 17:22:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-10 00:23:11 +0000 |
commit | fdc3baa3f2ae1554292165b53189196acd7418e4 (patch) | |
tree | d18943bb63a7be1fcaf04ccdfc3389b99604d8a0 /cc/surfaces/surface_manager.h | |
parent | f41800135c80bd45b9ddedf3e09316bfb0d5fa21 (diff) | |
download | chromium_src-fdc3baa3f2ae1554292165b53189196acd7418e4.zip chromium_src-fdc3baa3f2ae1554292165b53189196acd7418e4.tar.gz chromium_src-fdc3baa3f2ae1554292165b53189196acd7418e4.tar.bz2 |
Avoid destroying surface before the parent surface stops referencing it.
Add surface sequence numbers, which are used to schedule the
destruction of surfaces. The child surface's destruction can
wait on a set of sequence numbers, and the parent surface can
later queue a frame that satisfies those numbers, causing the
former child surface to be destroyed.
Also move ownership of the SurfaceIdAllocator to the
ui::Compositor, so that the surface id namespace for a
compositor will stay the same across all output surfaces it
ever uses.
BUG=411118
Review URL: https://codereview.chromium.org/553213003
Cr-Commit-Position: refs/heads/master@{#299022}
Diffstat (limited to 'cc/surfaces/surface_manager.h')
-rw-r--r-- | cc/surfaces/surface_manager.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h index 7515be5..66db9d9 100644 --- a/cc/surfaces/surface_manager.h +++ b/cc/surfaces/surface_manager.h @@ -5,12 +5,17 @@ #ifndef CC_SURFACES_SURFACE_MANAGER_H_ #define CC_SURFACES_SURFACE_MANAGER_H_ +#include <list> +#include <set> +#include <vector> + #include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/observer_list.h" #include "base/threading/thread_checker.h" #include "cc/surfaces/surface_damage_observer.h" #include "cc/surfaces/surface_id.h" +#include "cc/surfaces/surface_sequence.h" #include "cc/surfaces/surfaces_export.h" namespace cc { @@ -25,6 +30,10 @@ class CC_SURFACES_EXPORT SurfaceManager { void RegisterSurface(Surface* surface); void DeregisterSurface(SurfaceId surface_id); + // Destroy the Surface once a set of sequence numbers has been satisfied. + void DestroyOnSequence(scoped_ptr<Surface> surface, + const std::set<SurfaceSequence>& dependency_set); + Surface* GetSurfaceForId(SurfaceId surface_id); void AddObserver(SurfaceDamageObserver* obs) { @@ -37,12 +46,27 @@ class CC_SURFACES_EXPORT SurfaceManager { void SurfaceModified(SurfaceId surface_id); + // A frame for a surface satisfies a set of sequence numbers. + void DidSatisfySequences(SurfaceId id, std::vector<uint32_t>* sequence); + private: + void SearchForSatisfaction(); + typedef base::hash_map<SurfaceId, Surface*> SurfaceMap; SurfaceMap surface_map_; ObserverList<SurfaceDamageObserver> observer_list_; base::ThreadChecker thread_checker_; + // List of surfaces to be destroyed, along with what sequences they're still + // waiting on. + typedef std::list<std::pair<Surface*, std::set<SurfaceSequence>>> + SurfaceDestroyList; + SurfaceDestroyList surfaces_to_destroy_; + + // Set of SurfaceSequences that have been satisfied by a frame but not yet + // waited on. + std::set<SurfaceSequence> satisfied_sequences_; + DISALLOW_COPY_AND_ASSIGN(SurfaceManager); }; |