| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef CC_SURFACES_FRAMESINK_MANAGER_H_ | 5 #ifndef CC_SURFACES_FRAMESINK_MANAGER_H_ | 
| 6 #define CC_SURFACES_FRAMESINK_MANAGER_H_ | 6 #define CC_SURFACES_FRAMESINK_MANAGER_H_ | 
| 7 | 7 | 
| 8 #include <stdint.h> | 8 #include <stdint.h> | 
| 9 | 9 | 
| 10 #include <unordered_map> | 10 #include <unordered_map> | 
| 11 #include <unordered_set> | 11 #include <unordered_set> | 
| 12 #include <vector> | 12 #include <vector> | 
| 13 | 13 | 
| 14 #include "base/logging.h" | 14 #include "base/logging.h" | 
| 15 #include "base/macros.h" | 15 #include "base/macros.h" | 
| 16 #include "cc/surfaces/frame_sink_id.h" | 16 #include "cc/surfaces/frame_sink_id.h" | 
| 17 #include "cc/surfaces/surfaces_export.h" | 17 #include "cc/surfaces/surfaces_export.h" | 
| 18 | 18 | 
| 19 namespace cc { | 19 namespace cc { | 
| 20 class BeginFrameSource; | 20 class BeginFrameSource; | 
| 21 class SurfaceFactoryClient; | 21 class CompositorFrameSinkSupport; | 
| 22 | 22 | 
| 23 namespace test { | 23 namespace test { | 
| 24 class CompositorFrameSinkSupportTest; | 24 class CompositorFrameSinkSupportTest; | 
| 25 } | 25 } | 
| 26 | 26 | 
| 27 class CC_SURFACES_EXPORT FrameSinkManager { | 27 class CC_SURFACES_EXPORT FrameSinkManager { | 
| 28  public: | 28  public: | 
| 29   FrameSinkManager(); | 29   FrameSinkManager(); | 
| 30   ~FrameSinkManager(); | 30   ~FrameSinkManager(); | 
| 31 | 31 | 
| 32   void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); | 32   void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); | 
| 33 | 33 | 
| 34   // Invalidate a frame_sink_id that might still have associated sequences, | 34   // Invalidate a frame_sink_id that might still have associated sequences, | 
| 35   // possibly because a renderer process has crashed. | 35   // possibly because a renderer process has crashed. | 
| 36   void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); | 36   void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); | 
| 37 | 37 | 
| 38   // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered | 38   // CompositorFrameSinkSupport, hierarchy, and BeginFrameSource can be | 
| 39   // and unregistered in any order with respect to each other. | 39   // registered and unregistered in any order with respect to each other. | 
| 40   // | 40   // | 
| 41   // This happens in practice, e.g. the relationship to between ui::Compositor / | 41   // This happens in practice, e.g. the relationship to between ui::Compositor / | 
| 42   // DelegatedFrameHost is known before ui::Compositor has a surface/client). | 42   // DelegatedFrameHost is known before ui::Compositor has a surface/client). | 
| 43   // However, DelegatedFrameHost can register itself as a client before its | 43   // However, DelegatedFrameHost can register itself as a client before its | 
| 44   // relationship with the ui::Compositor is known. | 44   // relationship with the ui::Compositor is known. | 
| 45 | 45 | 
| 46   // Associates a SurfaceFactoryClient with the  frame_sink_id it  uses. | 46   // Associates a CompositorFrameSinkSupport with the  frame_sink_id it  uses. | 
| 47   // SurfaceFactoryClient and framesink allocators have a 1:1 mapping. | 47   // CompositorFrameSinkSupport and framesink allocators have a 1:1 mapping. | 
| 48   // Caller guarantees the client is alive between register/unregister. | 48   // Caller guarantees |support| is alive between register/unregister. | 
| 49   void RegisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id, | 49   void RegisterCompositorFrameSinkSupport(const FrameSinkId& frame_sink_id, | 
| 50                                     SurfaceFactoryClient* client); | 50                                           CompositorFrameSinkSupport* support); | 
| 51   void UnregisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id); | 51   void UnregisterCompositorFrameSinkSupport(const FrameSinkId& frame_sink_id); | 
| 52 | 52 | 
| 53   // Associates a |source| with a particular framesink.  That framesink and | 53   // Associates a |source| with a particular framesink.  That framesink and | 
| 54   // any children of that framesink with valid clients can potentially use | 54   // any children of that framesink with valid clients can potentially use | 
| 55   // that |source|. | 55   // that |source|. | 
| 56   void RegisterBeginFrameSource(BeginFrameSource* source, | 56   void RegisterBeginFrameSource(BeginFrameSource* source, | 
| 57                                 const FrameSinkId& frame_sink_id); | 57                                 const FrameSinkId& frame_sink_id); | 
| 58   void UnregisterBeginFrameSource(BeginFrameSource* source); | 58   void UnregisterBeginFrameSource(BeginFrameSource* source); | 
| 59 | 59 | 
| 60   // Register a relationship between two framesinks.  This relationship means | 60   // Register a relationship between two framesinks.  This relationship means | 
| 61   // that surfaces from the child framesik will be displayed in the parent. | 61   // that surfaces from the child framesik will be displayed in the parent. | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 83   // Returns true if |child framesink| is or has |search_frame_sink_id| as a | 83   // Returns true if |child framesink| is or has |search_frame_sink_id| as a | 
| 84   // child. | 84   // child. | 
| 85   bool ChildContains(const FrameSinkId& child_frame_sink_id, | 85   bool ChildContains(const FrameSinkId& child_frame_sink_id, | 
| 86                      const FrameSinkId& search_frame_sink_id) const; | 86                      const FrameSinkId& search_frame_sink_id) const; | 
| 87 | 87 | 
| 88   // Set of valid framesink Ids. When a framesink Id  is removed from | 88   // Set of valid framesink Ids. When a framesink Id  is removed from | 
| 89   // this set, any remaining (surface) sequences with that framesink are | 89   // this set, any remaining (surface) sequences with that framesink are | 
| 90   // considered satisfied. | 90   // considered satisfied. | 
| 91   std::unordered_set<FrameSinkId, FrameSinkIdHash> valid_frame_sink_ids_; | 91   std::unordered_set<FrameSinkId, FrameSinkIdHash> valid_frame_sink_ids_; | 
| 92 | 92 | 
| 93   // Begin frame source routing. Both BeginFrameSource and SurfaceFactoryClient | 93   // Begin frame source routing. Both BeginFrameSource and | 
| 94   // pointers guaranteed alive by callers until unregistered. | 94   // CompositorFrameSinkSupport pointers guaranteed alive by callers until | 
|  | 95   // unregistered. | 
| 95   struct FrameSinkSourceMapping { | 96   struct FrameSinkSourceMapping { | 
| 96     FrameSinkSourceMapping(); | 97     FrameSinkSourceMapping(); | 
| 97     FrameSinkSourceMapping(const FrameSinkSourceMapping& other); | 98     FrameSinkSourceMapping(const FrameSinkSourceMapping& other); | 
| 98     ~FrameSinkSourceMapping(); | 99     ~FrameSinkSourceMapping(); | 
| 99     bool has_children() const { return !children.empty(); } | 100     bool has_children() const { return !children.empty(); } | 
| 100     // The currently assigned begin frame source for this client. | 101     // The currently assigned begin frame source for this client. | 
| 101     BeginFrameSource* source; | 102     BeginFrameSource* source; | 
| 102     // This represents a dag of parent -> children mapping. | 103     // This represents a dag of parent -> children mapping. | 
| 103     std::vector<FrameSinkId> children; | 104     std::vector<FrameSinkId> children; | 
| 104   }; | 105   }; | 
| 105 | 106 | 
| 106   std::unordered_map<FrameSinkId, SurfaceFactoryClient*, FrameSinkIdHash> | 107   std::unordered_map<FrameSinkId, CompositorFrameSinkSupport*, FrameSinkIdHash> | 
| 107       clients_; | 108       clients_; | 
| 108 | 109 | 
| 109   std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> | 110   std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> | 
| 110       frame_sink_source_map_; | 111       frame_sink_source_map_; | 
| 111 | 112 | 
| 112   // Set of which sources are registered to which frmesinks.  Any child | 113   // Set of which sources are registered to which frmesinks.  Any child | 
| 113   // that is implicitly using this framesink must be reachable by the | 114   // that is implicitly using this framesink must be reachable by the | 
| 114   // parent in the dag. | 115   // parent in the dag. | 
| 115   std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; | 116   std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; | 
| 116 | 117 | 
| 117   DISALLOW_COPY_AND_ASSIGN(FrameSinkManager); | 118   DISALLOW_COPY_AND_ASSIGN(FrameSinkManager); | 
| 118 }; | 119 }; | 
| 119 | 120 | 
| 120 }  // namespace cc | 121 }  // namespace cc | 
| 121 | 122 | 
| 122 #endif  // CC_SURFACES_FRAMESINK_MANAGER_H_ | 123 #endif  // CC_SURFACES_FRAMESINK_MANAGER_H_ | 
| OLD | NEW | 
|---|