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_SUPPORT_COMPOSITOR_BLIMP_EMBEDDER_COMPOSITOR_H_ | |
6 #define BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_EMBEDDER_COMPOSITOR_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/macros.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "cc/layers/layer.h" | |
12 #include "cc/surfaces/frame_sink_id.h" | |
13 #include "cc/trees/layer_tree_host_client.h" | |
14 #include "cc/trees/layer_tree_host_single_thread_client.h" | |
15 #include "ui/gfx/geometry/size.h" | |
16 | |
17 namespace cc { | |
18 class AnimationHost; | |
19 class BeginFrameSource; | |
20 class ContextProvider; | |
21 class Display; | |
22 class LayerTreeHost; | |
23 } // namespace cc | |
24 | |
25 namespace blimp { | |
26 namespace client { | |
27 class CompositorDependencies; | |
28 | |
29 // The parent compositor that embeds the content from the BlimpCompositor for | |
30 // the current page and draws it to a display. | |
31 class BlimpEmbedderCompositor : public cc::LayerTreeHostClient, | |
32 public cc::LayerTreeHostSingleThreadClient { | |
33 public: | |
34 explicit BlimpEmbedderCompositor( | |
35 CompositorDependencies* compositor_dependencies); | |
36 ~BlimpEmbedderCompositor() override; | |
37 | |
38 // Sets the layer with the content from the renderer compositor. | |
39 void SetContentLayer(scoped_refptr<cc::Layer> content_layer); | |
40 | |
41 // Sets the size for the display. Should be in physical pixels. | |
42 void SetSize(const gfx::Size& size_in_px); | |
43 | |
44 protected: | |
45 void SetContextProvider(scoped_refptr<cc::ContextProvider> context_provider); | |
46 | |
47 scoped_refptr<cc::Layer> root_layer() { return root_layer_; } | |
48 CompositorDependencies* compositor_dependencies() { | |
49 return compositor_dependencies_; | |
50 } | |
51 | |
52 // LayerTreeHostClient implementation. | |
53 void WillBeginMainFrame() override {} | |
54 void DidBeginMainFrame() override {} | |
55 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} | |
56 void BeginMainFrameNotExpectedSoon() override {} | |
57 void UpdateLayerTreeHost() override {} | |
58 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | |
59 const gfx::Vector2dF& outer_delta, | |
60 const gfx::Vector2dF& elastic_overscroll_delta, | |
61 float page_scale, | |
62 float top_controls_delta) override {} | |
63 void RequestNewCompositorFrameSink() override; | |
64 void DidInitializeCompositorFrameSink() override; | |
65 void DidFailToInitializeCompositorFrameSink() override; | |
66 void WillCommit() override {} | |
67 void DidCommit() override {} | |
68 void DidCommitAndDrawFrame() override {} | |
69 void DidReceiveCompositorFrameAck() override {} | |
70 void DidCompletePageScaleAnimation() override {} | |
71 | |
72 // LayerTreeHostSingleThreadClient implementation. | |
73 void DidSubmitCompositorFrame() override {} | |
74 void DidLoseCompositorFrameSink() override {} | |
75 | |
76 private: | |
77 void HandlePendingCompositorFrameSinkRequest(); | |
78 | |
79 CompositorDependencies* compositor_dependencies_; | |
80 | |
81 cc::FrameSinkId frame_sink_id_; | |
82 | |
83 scoped_refptr<cc::ContextProvider> context_provider_; | |
84 | |
85 bool compositor_frame_sink_request_pending_; | |
86 std::unique_ptr<cc::BeginFrameSource> begin_frame_source_; | |
87 std::unique_ptr<cc::Display> display_; | |
88 | |
89 gfx::Size viewport_size_in_px_; | |
90 | |
91 std::unique_ptr<cc::AnimationHost> animation_host_; | |
92 std::unique_ptr<cc::LayerTreeHost> host_; | |
93 scoped_refptr<cc::Layer> root_layer_; | |
94 | |
95 base::Closure did_complete_swap_buffers_; | |
96 | |
97 DISALLOW_COPY_AND_ASSIGN(BlimpEmbedderCompositor); | |
98 }; | |
99 | |
100 } // namespace client | |
101 } // namespace blimp | |
102 | |
103 #endif // BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_EMBEDDER_COMPOSITOR_H_ | |
OLD | NEW |