| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ | |
| 6 #define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" | |
| 12 #include "blimp/client/feature/compositor/blimp_compositor.h" | |
| 13 #include "blimp/client/feature/render_widget_feature.h" | |
| 14 #include "cc/layers/layer.h" | |
| 15 #include "cc/trees/layer_tree_settings.h" | |
| 16 | |
| 17 namespace blimp { | |
| 18 namespace client { | |
| 19 | |
| 20 // The BlimpCompositorManager manages multiple BlimpCompositor instances, each | |
| 21 // mapped to a render widget on the engine. The compositor corresponding to | |
| 22 // the render widget initialized on the engine will be the |active_compositor_|. | |
| 23 // Only the |active_compositor_| holds the accelerated widget and builds the | |
| 24 // output surface from this widget to draw to the view. All events from the | |
| 25 // native view are forwarded to this compositor. | |
| 26 class BlimpCompositorManager | |
| 27 : public RenderWidgetFeature::RenderWidgetFeatureDelegate, | |
| 28 public BlimpCompositorClient { | |
| 29 public: | |
| 30 explicit BlimpCompositorManager( | |
| 31 RenderWidgetFeature* render_widget_feature, | |
| 32 BlimpCompositorDependencies* compositor_dependencies); | |
| 33 ~BlimpCompositorManager() override; | |
| 34 | |
| 35 void SetVisible(bool visible); | |
| 36 | |
| 37 bool OnTouchEvent(const ui::MotionEvent& motion_event); | |
| 38 | |
| 39 scoped_refptr<cc::Layer> layer() const { return layer_; } | |
| 40 | |
| 41 protected: | |
| 42 // virtual for testing. | |
| 43 virtual std::unique_ptr<BlimpCompositor> CreateBlimpCompositor( | |
| 44 int render_widget_id, | |
| 45 BlimpCompositorDependencies* compositor_dependencies, | |
| 46 BlimpCompositorClient* client); | |
| 47 | |
| 48 // Returns the compositor for the |render_widget_id|. Will return nullptr if | |
| 49 // no compositor is found. | |
| 50 // protected for testing. | |
| 51 BlimpCompositor* GetCompositor(int render_widget_id); | |
| 52 | |
| 53 private: | |
| 54 // RenderWidgetFeatureDelegate implementation. | |
| 55 void OnRenderWidgetCreated(int render_widget_id) override; | |
| 56 void OnRenderWidgetInitialized(int render_widget_id) override; | |
| 57 void OnRenderWidgetDeleted(int render_widget_id) override; | |
| 58 void OnCompositorMessageReceived( | |
| 59 int render_widget_id, | |
| 60 std::unique_ptr<cc::proto::CompositorMessage> message) override; | |
| 61 | |
| 62 // BlimpCompositorClient implementation. | |
| 63 void SendWebGestureEvent( | |
| 64 int render_widget_id, | |
| 65 const blink::WebGestureEvent& gesture_event) override; | |
| 66 void SendCompositorMessage( | |
| 67 int render_widget_id, | |
| 68 const cc::proto::CompositorMessage& message) override; | |
| 69 | |
| 70 // The bridge to the network layer that does the proto/RenderWidget id work. | |
| 71 // BlimpCompositorManager does not own this and it is expected to outlive this | |
| 72 // BlimpCompositorManager instance. | |
| 73 RenderWidgetFeature* render_widget_feature_; | |
| 74 | |
| 75 bool visible_; | |
| 76 | |
| 77 // The layer which holds the content from the active compositor. | |
| 78 scoped_refptr<cc::Layer> layer_; | |
| 79 | |
| 80 // A map of render_widget_ids to the BlimpCompositor instance. | |
| 81 using CompositorMap = std::map<int, std::unique_ptr<BlimpCompositor>>; | |
| 82 CompositorMap compositors_; | |
| 83 | |
| 84 // The |active_compositor_| represents the compositor from the CompositorMap | |
| 85 // that is currently visible and has the |window_|. It corresponds to the | |
| 86 // render widget currently initialized on the engine. | |
| 87 BlimpCompositor* active_compositor_; | |
| 88 | |
| 89 BlimpCompositorDependencies* compositor_dependencies_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(BlimpCompositorManager); | |
| 92 }; | |
| 93 | |
| 94 } // namespace client | |
| 95 } // namespace blimp | |
| 96 | |
| 97 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_MANAGER_H_ | |
| OLD | NEW |