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

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

Issue 2266863003: blimp: Move BlimpCompositor to use delegated rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make gn happy 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/compositor/blimp_gpu_memory_buffer_manager.h"
14 #include "blimp/client/feature/render_widget_feature.h" 13 #include "blimp/client/feature/render_widget_feature.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
17 namespace blimp { 21 namespace blimp {
18 namespace client { 22 namespace client {
19 23 class BlimpGpuMemoryBufferManager;
20 class BlimpCompositorManagerClient {
21 public:
22 virtual void OnSwapBuffersCompleted() = 0;
23 virtual void DidCommitAndDrawFrame() = 0;
24 };
25 24
26 // The BlimpCompositorManager manages multiple BlimpCompositor instances, each 25 // The BlimpCompositorManager manages multiple BlimpCompositor instances, each
27 // mapped to a render widget on the engine. The compositor corresponding to 26 // mapped to a render widget on the engine. The compositor corresponding to
28 // the render widget initialized on the engine will be the |active_compositor_|. 27 // the render widget initialized on the engine will be the |active_compositor_|.
29 // Only the |active_compositor_| holds the accelerated widget and builds the 28 // Only the |active_compositor_| holds the accelerated widget and builds the
30 // output surface from this widget to draw to the view. All events from the 29 // output surface from this widget to draw to the view. All events from the
31 // native view are forwarded to this compositor. 30 // native view are forwarded to this compositor.
32 class BlimpCompositorManager 31 class BlimpCompositorManager
33 : public RenderWidgetFeature::RenderWidgetFeatureDelegate, 32 : public RenderWidgetFeature::RenderWidgetFeatureDelegate,
34 public BlimpCompositorClient { 33 public BlimpCompositorClient {
35 public: 34 public:
36 explicit BlimpCompositorManager(RenderWidgetFeature* render_widget_feature, 35 using SurfaceIdAllocationCallback = base::Callback<uint32_t()>;
37 BlimpCompositorManagerClient* client); 36
37 explicit BlimpCompositorManager(
38 RenderWidgetFeature* render_widget_feature,
39 cc::SurfaceManager* surface_manager,
40 BlimpGpuMemoryBufferManager* gpu_memory_buffer_manager,
41 SurfaceIdAllocationCallback callback);
42
38 ~BlimpCompositorManager() override; 43 ~BlimpCompositorManager() override;
39 44
40 void SetVisible(bool visible); 45 void SetVisible(bool visible);
41 46
42 void SetAcceleratedWidget(gfx::AcceleratedWidget widget); 47 bool OnTouchEvent(const ui::MotionEvent& motion_event);
43 48
44 void ReleaseAcceleratedWidget(); 49 scoped_refptr<cc::Layer> layer() const { return layer_; }
45
46 bool OnTouchEvent(const ui::MotionEvent& motion_event);
47 50
48 protected: 51 protected:
49 // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost of the 52 // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost of the
50 // BlimpCompositors created by this manager. Can be overridden to provide 53 // BlimpCompositors created by this manager. Can be overridden to provide
51 // custom settings parameters. 54 // custom settings parameters.
52 virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings); 55 virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings);
53 56
54 // virtual for testing. 57 // virtual for testing.
55 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor( 58 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor(
56 int render_widget_id, 59 int render_widget_id,
60 cc::SurfaceManager* surface_manager,
61 uint32_t surface_client_id,
57 BlimpCompositorClient* client); 62 BlimpCompositorClient* client);
58 63
59 // Returns the compositor for the |render_widget_id|. Will return nullptr if 64 // Returns the compositor for the |render_widget_id|. Will return nullptr if
60 // no compositor is found. 65 // no compositor is found.
61 // protected for testing. 66 // protected for testing.
62 BlimpCompositor* GetCompositor(int render_widget_id); 67 BlimpCompositor* GetCompositor(int render_widget_id);
63 68
64 private: 69 private:
65 // RenderWidgetFeatureDelegate implementation. 70 // RenderWidgetFeatureDelegate implementation.
66 void OnRenderWidgetCreated(int render_widget_id) override; 71 void OnRenderWidgetCreated(int render_widget_id) override;
67 void OnRenderWidgetInitialized(int render_widget_id) override; 72 void OnRenderWidgetInitialized(int render_widget_id) override;
68 void OnRenderWidgetDeleted(int render_widget_id) override; 73 void OnRenderWidgetDeleted(int render_widget_id) override;
69 void OnCompositorMessageReceived( 74 void OnCompositorMessageReceived(
70 int render_widget_id, 75 int render_widget_id,
71 std::unique_ptr<cc::proto::CompositorMessage> message) override; 76 std::unique_ptr<cc::proto::CompositorMessage> message) override;
72 77
73 // BlimpCompositorClient implementation. 78 // BlimpCompositorClient implementation.
74 void DidCompleteSwapBuffers() override;
75 void DidCommitAndDrawFrame() override;
76 cc::LayerTreeSettings* GetLayerTreeSettings() override; 79 cc::LayerTreeSettings* GetLayerTreeSettings() override;
77 scoped_refptr<base::SingleThreadTaskRunner> 80 scoped_refptr<base::SingleThreadTaskRunner>
78 GetCompositorTaskRunner() override; 81 GetCompositorTaskRunner() override;
79 cc::TaskGraphRunner* GetTaskGraphRunner() override; 82 cc::TaskGraphRunner* GetTaskGraphRunner() override;
80 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; 83 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
81 cc::ImageSerializationProcessor* GetImageSerializationProcessor() override; 84 cc::ImageSerializationProcessor* GetImageSerializationProcessor() override;
82 void SendWebGestureEvent( 85 void SendWebGestureEvent(
83 int render_widget_id, 86 int render_widget_id,
84 const blink::WebGestureEvent& gesture_event) override; 87 const blink::WebGestureEvent& gesture_event) override;
85 void SendCompositorMessage( 88 void SendCompositorMessage(
86 int render_widget_id, 89 int render_widget_id,
87 const cc::proto::CompositorMessage& message) override; 90 const cc::proto::CompositorMessage& message) override;
88 91
92 // 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
94 // BlimpCompositorManager instance.
95 RenderWidgetFeature* render_widget_feature_;
96
97 cc::SurfaceManager* surface_manager_;
98 BlimpGpuMemoryBufferManager* gpu_memory_buffer_manager_;
99 SurfaceIdAllocationCallback surface_id_allocation_callback_;
100
89 bool visible_; 101 bool visible_;
90
91 gfx::AcceleratedWidget window_;
92
93 std::unique_ptr<cc::LayerTreeSettings> settings_; 102 std::unique_ptr<cc::LayerTreeSettings> settings_;
94 103
95 std::unique_ptr<BlimpGpuMemoryBufferManager> gpu_memory_buffer_manager_; 104 // The layer which holds the content from the active compositor.
105 scoped_refptr<cc::Layer> layer_;
96 106
97 // A map of render_widget_ids to the BlimpCompositor instance. 107 // A map of render_widget_ids to the BlimpCompositor instance.
98 typedef std::map<int, std::unique_ptr<BlimpCompositor>> CompositorMap; 108 typedef std::map<int, std::unique_ptr<BlimpCompositor>> CompositorMap;
99 CompositorMap compositors_; 109 CompositorMap compositors_;
100 110
101 // The |active_compositor_| represents the compositor from the CompositorMap 111 // The |active_compositor_| represents the compositor from the CompositorMap
102 // that is currently visible and has the |window_|. It corresponds to the 112 // that is currently visible and has the |window_|. It corresponds to the
103 // render widget currently initialized on the engine. 113 // render widget currently initialized on the engine.
104 BlimpCompositor* active_compositor_; 114 BlimpCompositor* active_compositor_;
105 115
106 // Lazily created thread that will run the compositor rendering tasks and will 116 // Lazily created thread that will run the compositor rendering tasks and will
107 // be shared by all compositor instances. 117 // be shared by all compositor instances.
108 std::unique_ptr<base::Thread> compositor_thread_; 118 std::unique_ptr<base::Thread> compositor_thread_;
109 119
110 // The bridge to the network layer that does the proto/RenderWidget id work.
111 // BlimpCompositorManager does not own this and it is expected to outlive this
112 // BlimpCompositorManager instance.
113 RenderWidgetFeature* render_widget_feature_;
114 BlimpCompositorManagerClient* client_;
115
116 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager); 120 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager);
117 }; 121 };
118 122
119 } // namespace client 123 } // namespace client
120 } // namespace blimp 124 } // namespace blimp
121 125
122 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ 126 #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