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_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_ | 5 #ifndef BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_EMBEDDER_COMPOSITOR_H_ |
6 #define BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_ | 6 #define BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_EMBEDDER_COMPOSITOR_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
8 #include "base/macros.h" | 9 #include "base/macros.h" |
9 #include "base/callback.h" | |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "cc/layers/layer.h" |
11 #include "cc/trees/layer_tree_host_client.h" | 12 #include "cc/trees/layer_tree_host_client.h" |
12 #include "cc/trees/layer_tree_host_single_thread_client.h" | 13 #include "cc/trees/layer_tree_host_single_thread_client.h" |
13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
14 #include "ui/gfx/native_widget_types.h" | |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 class Display; | 17 class Display; |
18 class Layer; | |
19 class LayerTreeHostInterface; | 18 class LayerTreeHostInterface; |
20 class SurfaceIdAllocator; | 19 class SurfaceIdAllocator; |
21 class SurfaceManager; | 20 class SurfaceManager; |
22 } // namespace cc | 21 } // namespace cc |
23 | 22 |
24 namespace blimp { | 23 namespace blimp { |
25 namespace client { | 24 namespace client { |
26 class CompositorDependencies; | 25 class CompositorDependencies; |
27 | 26 |
28 // The parent compositor that embeds the content from the BlimpCompositor for | 27 // The parent compositor that embeds the content from the BlimpCompositor for |
29 // the current page. | 28 // the current page and draws it to a display. |
30 class BrowserCompositor : public cc::LayerTreeHostClient, | 29 class BlimpEmbedderCompositor : public cc::LayerTreeHostClient, |
31 public cc::LayerTreeHostSingleThreadClient { | 30 public cc::LayerTreeHostSingleThreadClient { |
32 public: | 31 public: |
33 explicit BrowserCompositor(CompositorDependencies* compositor_dependencies); | 32 explicit BlimpEmbedderCompositor( |
34 ~BrowserCompositor() override; | 33 CompositorDependencies* compositor_dependencies); |
| 34 ~BlimpEmbedderCompositor() override; |
35 | 35 |
36 // Sets the layer with the content from the renderer compositor. | 36 // Sets the layer with the content from the renderer compositor. |
37 void SetContentLayer(scoped_refptr<cc::Layer> content_layer); | 37 void SetContentLayer(scoped_refptr<cc::Layer> content_layer); |
38 | 38 |
39 // Sets the size for the display. Should be in physical pixels. | 39 // Sets the size for the display. Should be in physical pixels. |
40 void SetSize(const gfx::Size& size_in_px); | 40 void SetSize(const gfx::Size& size_in_px); |
41 | 41 |
42 // Sets the widget that the |cc::Display| draws to. On proving it the widget, | 42 protected: |
43 // the compositor will become visible and start drawing to the widget. When | 43 void SetContextProvider(scoped_refptr<cc::ContextProvider> context_provider); |
44 // the widget goes away, we become invisible and drop all resources being | |
45 // used to draw to the screen. | |
46 void SetAcceleratedWidget(gfx::AcceleratedWidget widget); | |
47 | 44 |
48 // A callback to get notifed when the compositor performs a successful swap. | 45 scoped_refptr<cc::Layer> root_layer() { return root_layer_; } |
49 void set_did_complete_swap_buffers_callback(base::Closure callback) { | 46 CompositorDependencies* compositor_dependencies() { |
50 did_complete_swap_buffers_ = callback; | 47 return compositor_dependencies_; |
51 } | 48 } |
52 | 49 |
53 private: | |
54 // LayerTreeHostClient implementation. | 50 // LayerTreeHostClient implementation. |
55 void WillBeginMainFrame() override {} | 51 void WillBeginMainFrame() override {} |
56 void DidBeginMainFrame() override {} | 52 void DidBeginMainFrame() override {} |
57 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} | 53 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} |
58 void BeginMainFrameNotExpectedSoon() override {} | 54 void BeginMainFrameNotExpectedSoon() override {} |
59 void UpdateLayerTreeHost() override {} | 55 void UpdateLayerTreeHost() override {} |
60 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | 56 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
61 const gfx::Vector2dF& outer_delta, | 57 const gfx::Vector2dF& outer_delta, |
62 const gfx::Vector2dF& elastic_overscroll_delta, | 58 const gfx::Vector2dF& elastic_overscroll_delta, |
63 float page_scale, | 59 float page_scale, |
64 float top_controls_delta) override {} | 60 float top_controls_delta) override {} |
65 void RequestNewOutputSurface() override; | 61 void RequestNewOutputSurface() override; |
66 void DidInitializeOutputSurface() override; | 62 void DidInitializeOutputSurface() override; |
67 void DidFailToInitializeOutputSurface() override; | 63 void DidFailToInitializeOutputSurface() override; |
68 void WillCommit() override {} | 64 void WillCommit() override {} |
69 void DidCommit() override {} | 65 void DidCommit() override {} |
70 void DidCommitAndDrawFrame() override {} | 66 void DidCommitAndDrawFrame() override {} |
71 void DidCompleteSwapBuffers() override; | 67 void DidCompleteSwapBuffers() override {} |
72 void DidCompletePageScaleAnimation() override {} | 68 void DidCompletePageScaleAnimation() override {} |
73 | 69 |
74 // LayerTreeHostSingleThreadClient implementation. | 70 // LayerTreeHostSingleThreadClient implementation. |
75 void DidPostSwapBuffers() override {} | 71 void DidPostSwapBuffers() override {} |
76 void DidAbortSwapBuffers() override {} | 72 void DidAbortSwapBuffers() override {} |
77 | 73 |
| 74 private: |
78 void HandlePendingOutputSurfaceRequest(); | 75 void HandlePendingOutputSurfaceRequest(); |
79 | 76 |
80 CompositorDependencies* compositor_dependencies_; | 77 CompositorDependencies* compositor_dependencies_; |
81 | 78 |
| 79 scoped_refptr<cc::ContextProvider> context_provider_; |
| 80 |
82 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 81 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
83 gfx::AcceleratedWidget widget_; | |
84 bool output_surface_request_pending_; | 82 bool output_surface_request_pending_; |
85 std::unique_ptr<cc::Display> display_; | 83 std::unique_ptr<cc::Display> display_; |
86 | 84 |
87 gfx::Size viewport_size_in_px_; | 85 gfx::Size viewport_size_in_px_; |
88 | 86 |
89 std::unique_ptr<cc::LayerTreeHostInterface> host_; | 87 std::unique_ptr<cc::LayerTreeHostInterface> host_; |
90 scoped_refptr<cc::Layer> root_layer_; | 88 scoped_refptr<cc::Layer> root_layer_; |
91 | 89 |
92 base::Closure did_complete_swap_buffers_; | 90 base::Closure did_complete_swap_buffers_; |
93 | 91 |
94 DISALLOW_COPY_AND_ASSIGN(BrowserCompositor); | 92 DISALLOW_COPY_AND_ASSIGN(BlimpEmbedderCompositor); |
95 }; | 93 }; |
96 | 94 |
97 } // namespace client | 95 } // namespace client |
98 } // namespace blimp | 96 } // namespace blimp |
99 | 97 |
100 #endif // BLIMP_CLIENT_APP_COMPOSITOR_BROWSER_COMPOSITOR_H_ | 98 #endif // BLIMP_CLIENT_SUPPORT_COMPOSITOR_BLIMP_EMBEDDER_COMPOSITOR_H_ |
OLD | NEW |