Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: blimp/client/feature/compositor/blimp_compositor_manager.h

Issue 2274323002: Expose Blimp dependencies to the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@khushal_baseline_1
Patch Set: Addressed Khushal's initial comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ 5 #ifndef BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_
6 #define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ 6 #define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" 11 #include "blimp/client/core/compositor/blob_image_serialization_processor.h"
12 #include "blimp/client/feature/compositor/blimp_compositor.h" 12 #include "blimp/client/feature/compositor/blimp_compositor.h"
13 #include "blimp/client/feature/render_widget_feature.h" 13 #include "blimp/client/feature/render_widget_feature.h"
14 #include "cc/layers/layer.h" 14 #include "cc/layers/layer.h"
15 #include "cc/trees/layer_tree_settings.h" 15 #include "cc/trees/layer_tree_settings.h"
16 16
17 namespace cc {
18 class SurfaceManager;
19 } // namespace cc
20
21 namespace blimp { 17 namespace blimp {
22 namespace client { 18 namespace client {
23 class BlimpGpuMemoryBufferManager;
24 19
25 // The BlimpCompositorManager manages multiple BlimpCompositor instances, each 20 // The BlimpCompositorManager manages multiple BlimpCompositor instances, each
26 // mapped to a render widget on the engine. The compositor corresponding to 21 // mapped to a render widget on the engine. The compositor corresponding to
27 // the render widget initialized on the engine will be the |active_compositor_|. 22 // the render widget initialized on the engine will be the |active_compositor_|.
28 // Only the |active_compositor_| holds the accelerated widget and builds the 23 // Only the |active_compositor_| holds the accelerated widget and builds the
29 // output surface from this widget to draw to the view. All events from the 24 // output surface from this widget to draw to the view. All events from the
30 // native view are forwarded to this compositor. 25 // native view are forwarded to this compositor.
31 class BlimpCompositorManager 26 class BlimpCompositorManager
32 : public RenderWidgetFeature::RenderWidgetFeatureDelegate, 27 : public RenderWidgetFeature::RenderWidgetFeatureDelegate,
33 public BlimpCompositorClient { 28 public BlimpCompositorClient {
34 public: 29 public:
35 using SurfaceIdAllocationCallback = base::Callback<uint32_t()>;
36
37 explicit BlimpCompositorManager( 30 explicit BlimpCompositorManager(
38 RenderWidgetFeature* render_widget_feature, 31 RenderWidgetFeature* render_widget_feature,
39 cc::SurfaceManager* surface_manager, 32 BlimpCompositorDependencies* compositor_dependencies);
40 BlimpGpuMemoryBufferManager* gpu_memory_buffer_manager,
41 SurfaceIdAllocationCallback callback);
42
43 ~BlimpCompositorManager() override; 33 ~BlimpCompositorManager() override;
44 34
45 void SetVisible(bool visible); 35 void SetVisible(bool visible);
46 36
47 bool OnTouchEvent(const ui::MotionEvent& motion_event); 37 bool OnTouchEvent(const ui::MotionEvent& motion_event);
48 38
49 scoped_refptr<cc::Layer> layer() const { return layer_; } 39 scoped_refptr<cc::Layer> layer() const { return layer_; }
50 40
51 protected: 41 protected:
52 // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost of the 42 // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost of the
53 // BlimpCompositors created by this manager. Can be overridden to provide 43 // BlimpCompositors created by this manager. Can be overridden to provide
54 // custom settings parameters. 44 // custom settings parameters.
55 virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings); 45 // virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings);
Khushal 2016/08/25 05:02:54 This is going to go away right? :P
David Trainor- moved to gerrit 2016/08/26 17:15:54 Done.
56 46
57 // virtual for testing. 47 // virtual for testing.
58 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor( 48 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor(
59 int render_widget_id, 49 int render_widget_id,
60 cc::SurfaceManager* surface_manager, 50 BlimpCompositorDependencies* compositor_dependencies,
61 uint32_t surface_client_id,
62 BlimpCompositorClient* client); 51 BlimpCompositorClient* client);
63 52
64 // Returns the compositor for the |render_widget_id|. Will return nullptr if 53 // Returns the compositor for the |render_widget_id|. Will return nullptr if
65 // no compositor is found. 54 // no compositor is found.
66 // protected for testing. 55 // protected for testing.
67 BlimpCompositor* GetCompositor(int render_widget_id); 56 BlimpCompositor* GetCompositor(int render_widget_id);
68 57
69 private: 58 private:
70 // RenderWidgetFeatureDelegate implementation. 59 // RenderWidgetFeatureDelegate implementation.
71 void OnRenderWidgetCreated(int render_widget_id) override; 60 void OnRenderWidgetCreated(int render_widget_id) override;
72 void OnRenderWidgetInitialized(int render_widget_id) override; 61 void OnRenderWidgetInitialized(int render_widget_id) override;
73 void OnRenderWidgetDeleted(int render_widget_id) override; 62 void OnRenderWidgetDeleted(int render_widget_id) override;
74 void OnCompositorMessageReceived( 63 void OnCompositorMessageReceived(
75 int render_widget_id, 64 int render_widget_id,
76 std::unique_ptr<cc::proto::CompositorMessage> message) override; 65 std::unique_ptr<cc::proto::CompositorMessage> message) override;
77 66
78 // BlimpCompositorClient implementation. 67 // BlimpCompositorClient implementation.
79 cc::LayerTreeSettings* GetLayerTreeSettings() override;
80 scoped_refptr<base::SingleThreadTaskRunner>
81 GetCompositorTaskRunner() override;
82 cc::TaskGraphRunner* GetTaskGraphRunner() override;
83 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
84 cc::ImageSerializationProcessor* GetImageSerializationProcessor() override;
85 void SendWebGestureEvent( 68 void SendWebGestureEvent(
86 int render_widget_id, 69 int render_widget_id,
87 const blink::WebGestureEvent& gesture_event) override; 70 const blink::WebGestureEvent& gesture_event) override;
88 void SendCompositorMessage( 71 void SendCompositorMessage(
89 int render_widget_id, 72 int render_widget_id,
90 const cc::proto::CompositorMessage& message) override; 73 const cc::proto::CompositorMessage& message) override;
91 74
92 // The bridge to the network layer that does the proto/RenderWidget id work. 75 // The bridge to the network layer that does the proto/RenderWidget id work.
93 // BlimpCompositorManager does not own this and it is expected to outlive this 76 // BlimpCompositorManager does not own this and it is expected to outlive this
94 // BlimpCompositorManager instance. 77 // BlimpCompositorManager instance.
95 RenderWidgetFeature* render_widget_feature_; 78 RenderWidgetFeature* render_widget_feature_;
96 79
97 cc::SurfaceManager* surface_manager_;
98 BlimpGpuMemoryBufferManager* gpu_memory_buffer_manager_;
99 SurfaceIdAllocationCallback surface_id_allocation_callback_;
100
101 bool visible_; 80 bool visible_;
102 std::unique_ptr<cc::LayerTreeSettings> settings_;
103 81
104 // The layer which holds the content from the active compositor. 82 // The layer which holds the content from the active compositor.
105 scoped_refptr<cc::Layer> layer_; 83 scoped_refptr<cc::Layer> layer_;
106 84
107 // A map of render_widget_ids to the BlimpCompositor instance. 85 // A map of render_widget_ids to the BlimpCompositor instance.
108 typedef std::map<int, std::unique_ptr<BlimpCompositor>> CompositorMap; 86 using CompositorMap = std::map<int, std::unique_ptr<BlimpCompositor>>;
109 CompositorMap compositors_; 87 CompositorMap compositors_;
110 88
111 // The |active_compositor_| represents the compositor from the CompositorMap 89 // The |active_compositor_| represents the compositor from the CompositorMap
112 // that is currently visible and has the |window_|. It corresponds to the 90 // that is currently visible and has the |window_|. It corresponds to the
113 // render widget currently initialized on the engine. 91 // render widget currently initialized on the engine.
114 BlimpCompositor* active_compositor_; 92 BlimpCompositor* active_compositor_;
115 93
116 // Lazily created thread that will run the compositor rendering tasks and will 94 BlimpCompositorDependencies* compositor_dependencies_;
117 // be shared by all compositor instances.
118 std::unique_ptr<base::Thread> compositor_thread_;
119 95
120 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager); 96 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager);
121 }; 97 };
122 98
123 } // namespace client 99 } // namespace client
124 } // namespace blimp 100 } // namespace blimp
125 101
126 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ 102 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698