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

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: Fix linux build break Created 4 years, 3 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
53 // BlimpCompositors created by this manager. Can be overridden to provide
54 // custom settings parameters.
55 virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings);
56
57 // virtual for testing. 42 // virtual for testing.
58 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor( 43 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor(
59 int render_widget_id, 44 int render_widget_id,
60 cc::SurfaceManager* surface_manager, 45 BlimpCompositorDependencies* compositor_dependencies,
61 uint32_t surface_client_id,
62 BlimpCompositorClient* client); 46 BlimpCompositorClient* client);
63 47
64 // Returns the compositor for the |render_widget_id|. Will return nullptr if 48 // Returns the compositor for the |render_widget_id|. Will return nullptr if
65 // no compositor is found. 49 // no compositor is found.
66 // protected for testing. 50 // protected for testing.
67 BlimpCompositor* GetCompositor(int render_widget_id); 51 BlimpCompositor* GetCompositor(int render_widget_id);
68 52
69 private: 53 private:
70 // RenderWidgetFeatureDelegate implementation. 54 // RenderWidgetFeatureDelegate implementation.
71 void OnRenderWidgetCreated(int render_widget_id) override; 55 void OnRenderWidgetCreated(int render_widget_id) override;
72 void OnRenderWidgetInitialized(int render_widget_id) override; 56 void OnRenderWidgetInitialized(int render_widget_id) override;
73 void OnRenderWidgetDeleted(int render_widget_id) override; 57 void OnRenderWidgetDeleted(int render_widget_id) override;
74 void OnCompositorMessageReceived( 58 void OnCompositorMessageReceived(
75 int render_widget_id, 59 int render_widget_id,
76 std::unique_ptr<cc::proto::CompositorMessage> message) override; 60 std::unique_ptr<cc::proto::CompositorMessage> message) override;
77 61
78 // BlimpCompositorClient implementation. 62 // 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( 63 void SendWebGestureEvent(
86 int render_widget_id, 64 int render_widget_id,
87 const blink::WebGestureEvent& gesture_event) override; 65 const blink::WebGestureEvent& gesture_event) override;
88 void SendCompositorMessage( 66 void SendCompositorMessage(
89 int render_widget_id, 67 int render_widget_id,
90 const cc::proto::CompositorMessage& message) override; 68 const cc::proto::CompositorMessage& message) override;
91 69
92 // The bridge to the network layer that does the proto/RenderWidget id work. 70 // 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 71 // BlimpCompositorManager does not own this and it is expected to outlive this
94 // BlimpCompositorManager instance. 72 // BlimpCompositorManager instance.
95 RenderWidgetFeature* render_widget_feature_; 73 RenderWidgetFeature* render_widget_feature_;
96 74
97 cc::SurfaceManager* surface_manager_;
98 BlimpGpuMemoryBufferManager* gpu_memory_buffer_manager_;
99 SurfaceIdAllocationCallback surface_id_allocation_callback_;
100
101 bool visible_; 75 bool visible_;
102 std::unique_ptr<cc::LayerTreeSettings> settings_;
103 76
104 // The layer which holds the content from the active compositor. 77 // The layer which holds the content from the active compositor.
105 scoped_refptr<cc::Layer> layer_; 78 scoped_refptr<cc::Layer> layer_;
106 79
107 // A map of render_widget_ids to the BlimpCompositor instance. 80 // A map of render_widget_ids to the BlimpCompositor instance.
108 typedef std::map<int, std::unique_ptr<BlimpCompositor>> CompositorMap; 81 using CompositorMap = std::map<int, std::unique_ptr<BlimpCompositor>>;
109 CompositorMap compositors_; 82 CompositorMap compositors_;
110 83
111 // The |active_compositor_| represents the compositor from the CompositorMap 84 // The |active_compositor_| represents the compositor from the CompositorMap
112 // that is currently visible and has the |window_|. It corresponds to the 85 // that is currently visible and has the |window_|. It corresponds to the
113 // render widget currently initialized on the engine. 86 // render widget currently initialized on the engine.
114 BlimpCompositor* active_compositor_; 87 BlimpCompositor* active_compositor_;
115 88
116 // Lazily created thread that will run the compositor rendering tasks and will 89 BlimpCompositorDependencies* compositor_dependencies_;
117 // be shared by all compositor instances.
118 std::unique_ptr<base::Thread> compositor_thread_;
119 90
120 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager); 91 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager);
121 }; 92 };
122 93
123 } // namespace client 94 } // namespace client
124 } // namespace blimp 95 } // namespace blimp
125 96
126 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ 97 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_
OLDNEW
« no previous file with comments | « blimp/client/feature/compositor/blimp_compositor.cc ('k') | blimp/client/feature/compositor/blimp_compositor_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698