Index: cc/surfaces/framesink_manager.h |
diff --git a/cc/surfaces/framesink_manager.h b/cc/surfaces/framesink_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..308bc0cca6f01e6dd88b696908b67f562458e11c |
--- /dev/null |
+++ b/cc/surfaces/framesink_manager.h |
@@ -0,0 +1,123 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CC_SURFACES_FRAMESINK_MANAGER_H_ |
+#define CC_SURFACES_FRAMESINK_MANAGER_H_ |
+ |
+#include <stdint.h> |
+ |
+#include <list> |
+#include <memory> |
+#include <unordered_map> |
+#include <unordered_set> |
+#include <vector> |
+ |
+#include "base/logging.h" |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/threading/thread_checker.h" |
+#include "cc/surfaces/frame_sink_id.h" |
+#include "cc/surfaces/surface_factory_client.h" |
+#include "cc/surfaces/surfaces_export.h" |
+ |
+#if DCHECK_IS_ON() |
+#include <iosfwd> |
+#include <string> |
+#endif |
+ |
+namespace cc { |
+class BeginFrameSource; |
+class SurfaceFactoryClient; |
+ |
+class CC_SURFACES_EXPORT FrameSinkManager { |
+ public: |
+ FrameSinkManager(); |
+ ~FrameSinkManager(); |
+ |
+ void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); |
Fady Samuel
2017/02/12 19:04:07
Ahh I see you've moved this here. I think you left
k.devara
2017/02/13 07:00:52
Yes, I will remove it from surface_manager.h, look
|
+ |
+ // Invalidate a frame_sink_id that might still have associated sequences, |
+ // possibly because a renderer process has crashed. |
+ void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); |
+ |
+ // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered |
+ // and unregistered in any order with respect to each other. |
+ // |
+ // This happens in practice, e.g. 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. |
+ |
+ // Associates a SurfaceFactoryClient with the surface id frame_sink_id it |
+ // uses. |
+ // SurfaceFactoryClient and surface namespaces/allocators have a 1:1 mapping. |
+ // Caller guarantees the client is alive between register/unregister. |
+ // Reregistering the same namespace when a previous client is active is not |
+ // valid. |
+ void RegisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id, |
+ SurfaceFactoryClient* client); |
+ void UnregisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id); |
+ |
+ // Associates a |source| with a particular namespace. That namespace and |
+ // any children of that namespace with valid clients can potentially use |
+ // that |source|. |
+ void RegisterBeginFrameSource(BeginFrameSource* source, |
+ const FrameSinkId& frame_sink_id); |
+ void UnregisterBeginFrameSource(BeginFrameSource* source); |
+ |
+ // Register a relationship between two namespaces. This relationship means |
+ // that surfaces from the child namespace will be displayed in the parent. |
+ // Children are allowed to use any begin frame source that their parent can |
+ // use. |
+ void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, |
+ const FrameSinkId& child_frame_sink_id); |
+ void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, |
+ const FrameSinkId& child_frame_sink_id); |
+ |
+ private: |
+ void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, |
+ BeginFrameSource* source); |
+ void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, |
+ BeginFrameSource* source); |
+ |
+ // Returns true if |child namespace| is or has |search_frame_sink_id| as a |
+ // child. |
+ bool ChildContains(const FrameSinkId& child_frame_sink_id, |
+ const FrameSinkId& search_frame_sink_id) const; |
+ |
+ // Set of valid surface ID namespaces. When a namespace is removed from |
+ // this set, any remaining sequences with that namespace are considered |
+ // satisfied. |
+ std::unordered_set<FrameSinkId, FrameSinkIdHash> valid_frame_sink_ids_; |
+ |
+ // Begin frame source routing. Both BeginFrameSource and SurfaceFactoryClient |
+ // pointers guaranteed alive by callers until unregistered. |
+ struct FrameSinkSourceMapping { |
+ FrameSinkSourceMapping(); |
+ FrameSinkSourceMapping(const FrameSinkSourceMapping& other); |
+ ~FrameSinkSourceMapping(); |
+ bool is_empty() const { return !client && children.empty(); } |
+ // 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<FrameSinkId> children; |
+ }; |
+ std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> |
+ frame_sink_source_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*, FrameSinkId> registered_sources_; |
+ |
+ base::ThreadChecker thread_checker_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FrameSinkManager); |
+}; |
+ |
+} // namespace cc |
+ |
+#endif // CC_SURFACES_FRAMESINK_MANAGER_H_ |