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