Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_CORE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ | 5 #ifndef BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_MANAGER_H_ |
| 6 #define BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ | 6 #define BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_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/blimp_compositor.h" | 11 #include "blimp/client/core/compositor/blimp_compositor.h" |
| 12 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" | |
| 13 #include "blimp/client/core/render_widget/render_widget_feature.h" | 12 #include "blimp/client/core/render_widget/render_widget_feature.h" |
| 14 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
| 15 #include "cc/trees/layer_tree_settings.h" | 14 #include "cc/trees/layer_tree_settings.h" |
| 16 | 15 |
| 17 namespace blimp { | 16 namespace blimp { |
| 18 namespace client { | 17 namespace client { |
| 19 | 18 |
| 20 // The BlimpCompositorManager manages multiple BlimpCompositor instances, each | 19 class BlimpDocument; |
| 21 // mapped to a render widget on the engine. The compositor corresponding to | 20 |
| 22 // the render widget initialized on the engine will be the |active_compositor_|. | 21 // The BlimpDocumentManager |
|
David Trainor- moved to gerrit
2016/10/04 22:29:02
Suggest:
The BlimpDocumentManager is responsible f
xingliu
2016/10/05 00:40:08
Done.
| |
| 23 // Only the |active_compositor_| holds the accelerated widget and builds the | 22 // 1. Manages multiple BlimpDocument instances, each mapped to a render widget |
| 24 // output surface from this widget to draw to the view. All events from the | 23 // on the engine. The |document_id_| matches the |render_widget_id| of the |
| 25 // native view are forwarded to this compositor. | 24 // render widget messages which are routed to the engine side render widget. |
| 26 class BlimpCompositorManager | 25 // |
| 27 : public RenderWidgetFeature::RenderWidgetFeatureDelegate, | 26 // 2. The compositor corresponding to the render widget initialized on the |
| 28 public BlimpCompositorClient { | 27 // engine will be the |active_document_|. |
| 28 // All events from the native view are forwarded to this compositor. | |
| 29 class BlimpDocumentManager | |
| 30 : public RenderWidgetFeature::RenderWidgetFeatureDelegate { | |
| 29 public: | 31 public: |
| 30 explicit BlimpCompositorManager( | 32 explicit BlimpDocumentManager( |
| 31 int blimp_contents_id, | 33 int blimp_contents_id, |
| 32 RenderWidgetFeature* render_widget_feature, | 34 RenderWidgetFeature* render_widget_feature, |
| 33 BlimpCompositorDependencies* compositor_dependencies); | 35 BlimpCompositorDependencies* compositor_dependencies); |
| 34 ~BlimpCompositorManager() override; | 36 ~BlimpDocumentManager() override; |
| 35 | 37 |
| 36 void SetVisible(bool visible); | 38 void SetVisible(bool visible); |
| 37 bool visible() const { return visible_; } | 39 bool visible() const { return visible_; } |
| 38 | 40 |
| 39 bool OnTouchEvent(const ui::MotionEvent& motion_event); | 41 bool OnTouchEvent(const ui::MotionEvent& motion_event); |
| 40 | 42 |
| 41 // Notifies |callback| when all pending commits on the active BlimpCompositor | 43 // Notifies |callback| when all pending commits on the active BlimpCompositor |
| 42 // have been drawn to the screen. If the active compositor is destroyed or | 44 // have been drawn to the screen. If the active compositor is destroyed or |
| 43 // becomes hidden |callback| will be notified. | 45 // becomes hidden |callback| will be notified. |
| 44 void NotifyWhenDonePendingCommits(base::Closure callback); | 46 void NotifyWhenDonePendingCommits(base::Closure callback); |
| 45 | 47 |
| 48 // Sends input event to the engine, virtual for testing. | |
| 49 virtual void SendWebGestureEvent(int document_id, | |
| 50 const blink::WebGestureEvent& gesture_event); | |
| 51 | |
| 52 // Sends compositor message to the engine, virtual for testing. | |
| 53 virtual void SendCompositorMessage( | |
| 54 int document_id, | |
| 55 const cc::proto::CompositorMessage& message); | |
| 56 | |
| 46 scoped_refptr<cc::Layer> layer() const { return layer_; } | 57 scoped_refptr<cc::Layer> layer() const { return layer_; } |
| 47 | 58 |
| 48 protected: | 59 protected: |
| 49 // virtual for testing. | 60 // Creates a BlimpDocument, virtual for testing. |
| 50 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor( | 61 virtual std::unique_ptr<BlimpDocument> CreateBlimpDocument( |
| 51 int render_widget_id, | 62 int document_id, |
| 52 BlimpCompositorDependencies* compositor_dependencies, | 63 BlimpCompositorDependencies* compositor_dependencies); |
| 53 BlimpCompositorClient* client); | |
| 54 | 64 |
| 55 // Returns the compositor for the |render_widget_id|. Will return nullptr if | 65 // Returns the blimp document from |document_id|, returns nullptr if |
| 56 // no compositor is found. | 66 // the document is not found, protected for testing. |
| 57 // protected for testing. | 67 BlimpDocument* GetDocument(int document_id); |
| 58 BlimpCompositor* GetCompositor(int render_widget_id); | |
| 59 | 68 |
| 60 private: | 69 private: |
| 61 // RenderWidgetFeatureDelegate implementation. | 70 // RenderWidgetFeatureDelegate implementation. |
| 62 void OnRenderWidgetCreated(int render_widget_id) override; | 71 void OnRenderWidgetCreated(int render_widget_id) override; |
| 63 void OnRenderWidgetInitialized(int render_widget_id) override; | 72 void OnRenderWidgetInitialized(int render_widget_id) override; |
| 64 void OnRenderWidgetDeleted(int render_widget_id) override; | 73 void OnRenderWidgetDeleted(int render_widget_id) override; |
| 65 void OnCompositorMessageReceived( | 74 void OnCompositorMessageReceived( |
| 66 int render_widget_id, | 75 int render_widget_id, |
| 67 std::unique_ptr<cc::proto::CompositorMessage> message) override; | 76 std::unique_ptr<cc::proto::CompositorMessage> message) override; |
| 68 | 77 |
| 69 // BlimpCompositorClient implementation. | 78 // The unique id of BlimpContentImpl which owns this document manager. |
| 70 void SendWebGestureEvent( | |
| 71 int render_widget_id, | |
| 72 const blink::WebGestureEvent& gesture_event) override; | |
| 73 void SendCompositorMessage( | |
| 74 int render_widget_id, | |
| 75 const cc::proto::CompositorMessage& message) override; | |
| 76 | |
| 77 int blimp_contents_id_; | 79 int blimp_contents_id_; |
| 78 | 80 |
| 79 // The bridge to the network layer that does the proto/RenderWidget id work. | 81 // The bridge to the network layer that does the proto/RenderWidget id work. |
| 80 // BlimpCompositorManager does not own this and it is expected to outlive this | 82 // BlimpCompositorManager does not own this and it is expected to outlive this |
| 81 // BlimpCompositorManager instance. | 83 // BlimpCompositorManager instance. |
| 82 RenderWidgetFeature* render_widget_feature_; | 84 RenderWidgetFeature* render_widget_feature_; |
| 83 | 85 |
| 84 bool visible_; | 86 bool visible_; |
| 85 | 87 |
| 86 // The layer which holds the content from the active compositor. | 88 // The layer which holds the content from the active compositor. |
| 87 scoped_refptr<cc::Layer> layer_; | 89 scoped_refptr<cc::Layer> layer_; |
| 88 | 90 |
| 89 // A map of render_widget_ids to the BlimpCompositor instance. | 91 // A map of document id to the BlimpDocument instance. |
| 90 using CompositorMap = std::map<int, std::unique_ptr<BlimpCompositor>>; | 92 using DocumentMap = std::map<int, std::unique_ptr<BlimpDocument>>; |
| 91 CompositorMap compositors_; | 93 DocumentMap documents_; |
| 92 | 94 |
| 93 // The |active_compositor_| represents the compositor from the CompositorMap | 95 // The |active_document_| holds the compositor from the that is currently |
| 94 // that is currently visible and has the |window_|. It corresponds to the | 96 // visible. It corresponds to the |
| 95 // render widget currently initialized on the engine. | 97 // render widget currently initialized on the engine. |
| 96 BlimpCompositor* active_compositor_; | 98 BlimpDocument* active_document_; |
| 97 | 99 |
| 98 BlimpCompositorDependencies* compositor_dependencies_; | 100 BlimpCompositorDependencies* compositor_dependencies_; |
| 99 | 101 |
| 100 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager); | 102 DISALLOW_COPY_AND_ASSIGN(BlimpDocumentManager); |
| 101 }; | 103 }; |
| 102 | 104 |
| 103 } // namespace client | 105 } // namespace client |
| 104 } // namespace blimp | 106 } // namespace blimp |
| 105 | 107 |
| 106 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ | 108 #endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_MANAGER_H_ |
| OLD | NEW |