Index: cc/surfaces/surface_manager.h |
diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h |
index a3f7b9b19ff8cc0b466fac599d13499c9ff4d3bd..d756baae7620746461746a77b589949d8bbf015a 100644 |
--- a/cc/surfaces/surface_manager.h |
+++ b/cc/surfaces/surface_manager.h |
@@ -21,8 +21,10 @@ |
#include "cc/surfaces/surfaces_export.h" |
namespace cc { |
+class BeginFrameSource; |
class CompositorFrame; |
class Surface; |
+class SurfaceFactoryClient; |
class CC_SURFACES_EXPORT SurfaceManager { |
public: |
@@ -58,7 +60,43 @@ class CC_SURFACES_EXPORT SurfaceManager { |
// possibly because a renderer process has crashed. |
void InvalidateSurfaceIdNamespace(uint32_t id_namespace); |
+ // SurfaceFactoryClient and namespace hierarchy may be registered in |
+ // either order. (The relationship to between ui::Compositor / |
+ // DelegatedFrameHost is known before ui::Compositor has a surface/client). |
+ // However, DelegatedFrameHost can register itself as a client before |
+ // its relationship with the ui::Compositor is known.) |
+ // |
+ // SurfaceFactoryClient registration for a namespace should outlive |
+ // the BeginFrameSource registration. |
+ // |
+ // Associates a SurfaceFactoryClient with the surface id namespace it uses. |
+ // SurfaceFactoryClient and surface namespaces/allocators have a 1:1 mapping. |
+ // A nullptr client implies unregistering the client from the namespace. |
+ // Caller guarantees the client is alive between register/unregister. |
+ // Reregistering the same namespace when a previous client is active is not |
+ // valid. |
+ void RegisterSurfaceFactoryClient(uint32_t id_namespace, |
brianderson
2016/02/18 23:01:07
Is it possible to fold this into RegisterSurfaceId
enne (OOO)
2016/02/19 21:26:57
Sadly, no. SurfaceIdNamespace is about the alloca
|
+ SurfaceFactoryClient* client); |
+ |
+ void RegisterBeginFrameSource(BeginFrameSource* source, |
+ uint32_t id_namespace); |
+ void UnregisterBeginFrameSource(BeginFrameSource* source); |
+ |
+ // TODO(enne): Call this in the right spots. |
+ // Children should always register/unregister with their parents. |
+ // Unregistration of child namespaces should happen before |
+ // unregistering surface factory clients. |
+ void RegisterSurfaceNamespaceHierarchy(uint32_t parent_namespace, |
+ uint32_t child_namespace); |
+ void UnregisterSurfaceNamespaceHierarchy(uint32_t parent_namespace, |
+ uint32_t child_namespace); |
+ |
private: |
+ void RecursivelyAttachBeginFrameSource(uint32_t id_namespace, |
+ BeginFrameSource* source); |
+ void RecursivelyDetachBeginFrameSource(uint32_t id_namespace, |
+ BeginFrameSource* source); |
+ |
void GarbageCollectSurfaces(); |
using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; |
@@ -80,6 +118,25 @@ class CC_SURFACES_EXPORT SurfaceManager { |
// satisfied. |
std::unordered_set<uint32_t> valid_surface_id_namespaces_; |
+ // Begin frame source routing. Both BeginFrameSource and SurfaceFactoryClient |
+ // pointers guaranteed alive by callers until unregistered. |
+ struct ClientSourceMapping { |
+ ClientSourceMapping(); |
+ ~ClientSourceMapping(); |
+ bool is_empty() const { return !client && !children.size(); } |
+ // The client that's responsible for creating this namespace. Never null. |
+ SurfaceFactoryClient* client; |
+ // The currently assigned begin frame source for this client. |
+ BeginFrameSource* source; |
+ // This represents a dag of parent -> children mapping. |
+ std::vector<uint32_t> children; |
+ }; |
+ std::unordered_map<uint32_t, ClientSourceMapping> namespace_client_map_; |
+ // Set of which sources are registered to which namespace. Any child |
+ // that is implicitly using this namespace must be reachable by the |
+ // parent in the dag. |
+ std::unordered_map<BeginFrameSource*, uint32_t> registered_sources_; |
+ |
DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
}; |