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