OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
| 6 #define BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/trees/layer_tree_host_client.h" |
| 12 #include "cc/trees/layer_tree_settings.h" |
| 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/gfx/native_widget_types.h" |
| 15 |
| 16 namespace base { |
| 17 class SingleThreadTaskRunner; |
| 18 class Thread; |
| 19 } |
| 20 |
| 21 namespace cc { |
| 22 class LayerTreeHost; |
| 23 } |
| 24 |
| 25 namespace blimp { |
| 26 |
| 27 // BlimpCompositor provides the basic framework and setup to host a |
| 28 // LayerTreeHost (compositor). The rendering surface this compositor draws to |
| 29 // is defined by the gfx::AcceleratedWidget returned by |
| 30 // BlimpCompositor::GetWindow(). |
| 31 class BlimpCompositor : public cc::LayerTreeHostClient { |
| 32 public: |
| 33 ~BlimpCompositor() override; |
| 34 |
| 35 void SetVisible(bool visible); |
| 36 void SetSize(const gfx::Size& size); |
| 37 |
| 38 // LayerTreeHostClient implementation. |
| 39 void WillBeginMainFrame() override; |
| 40 void DidBeginMainFrame() override; |
| 41 void BeginMainFrame(const cc::BeginFrameArgs& args) override; |
| 42 void BeginMainFrameNotExpectedSoon() override; |
| 43 void Layout() override; |
| 44 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
| 45 const gfx::Vector2dF& outer_delta, |
| 46 const gfx::Vector2dF& elastic_overscroll_delta, |
| 47 float page_scale, |
| 48 float top_controls_delta) override; |
| 49 void RequestNewOutputSurface() override; |
| 50 void DidInitializeOutputSurface() override; |
| 51 void DidFailToInitializeOutputSurface() override; |
| 52 void WillCommit() override; |
| 53 void DidCommit() override; |
| 54 void DidCommitAndDrawFrame() override; |
| 55 void DidCompleteSwapBuffers() override; |
| 56 void DidCompletePageScaleAnimation() override; |
| 57 void RecordFrameTimingEvents( |
| 58 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, |
| 59 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
| 60 override; |
| 61 |
| 62 protected: |
| 63 explicit BlimpCompositor(float device_scale_factor); |
| 64 |
| 65 // Returns a widget for use in constructing this compositor's OutputSurface. |
| 66 // Will only ever be called while this compositor is visible. |
| 67 virtual gfx::AcceleratedWidget GetWindow() = 0; |
| 68 |
| 69 // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost. Can be |
| 70 // overridden to provide custom settings parameters. |
| 71 virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings* settings); |
| 72 |
| 73 private: |
| 74 // Creates (if necessary) and returns a TaskRunner for a thread meant to run |
| 75 // compositor rendering. |
| 76 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner(); |
| 77 |
| 78 gfx::Size viewport_size_; |
| 79 |
| 80 // The scale factor used to convert dp units (device independent pixels) to |
| 81 // pixels. |
| 82 float device_scale_factor_; |
| 83 scoped_ptr<cc::LayerTreeHost> host_; |
| 84 scoped_ptr<cc::LayerTreeSettings> settings_; |
| 85 |
| 86 // Lazily created thread that will run the compositor rendering tasks. |
| 87 scoped_ptr<base::Thread> compositor_thread_; |
| 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); |
| 90 }; |
| 91 |
| 92 } // namespace blimp |
| 93 |
| 94 #endif // BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
OLD | NEW |