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 "base/memory/weak_ptr.h" |
| 12 #include "cc/trees/layer_tree_host_client.h" |
| 13 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 14 #include "cc/trees/layer_tree_settings.h" |
| 15 #include "ui/gfx/geometry/size.h" |
| 16 #include "ui/gfx/native_widget_types.h" |
| 17 |
| 18 namespace base { |
| 19 class CommandLine; |
| 20 class SingleThreadTaskRunner; |
| 21 class Thread; |
| 22 } |
| 23 |
| 24 namespace cc { |
| 25 class LayerTreeHost; |
| 26 } |
| 27 |
| 28 namespace blimp { |
| 29 |
| 30 // BlimpCompositor provides the basic framework and setup to host a |
| 31 // LayerTreeHost (compositor). The rendering surface this compositor draws to |
| 32 // is defined by the gfx::AcceleratedWidget returned by |
| 33 // BlimpCompositor::GetWindow(). |
| 34 class BlimpCompositor : public cc::LayerTreeHostClient, |
| 35 public cc::LayerTreeHostSingleThreadClient { |
| 36 public: |
| 37 ~BlimpCompositor() override; |
| 38 |
| 39 void SetVisible(bool visible); |
| 40 void SetSize(const gfx::Size& size); |
| 41 |
| 42 // LayerTreeHostClient Implementation ---------------------------------------- |
| 43 void WillBeginMainFrame() override {} |
| 44 void DidBeginMainFrame() override {} |
| 45 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} |
| 46 void BeginMainFrameNotExpectedSoon() override {} |
| 47 void Layout() override; |
| 48 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
| 49 const gfx::Vector2dF& outer_delta, |
| 50 const gfx::Vector2dF& elastic_overscroll_delta, |
| 51 float page_scale, |
| 52 float top_controls_delta) override {} |
| 53 void RequestNewOutputSurface() override; |
| 54 void DidInitializeOutputSurface() override; |
| 55 void DidFailToInitializeOutputSurface() override; |
| 56 void WillCommit() override {} |
| 57 void DidCommit() override; |
| 58 void DidCommitAndDrawFrame() override {} |
| 59 void DidCompleteSwapBuffers() override; |
| 60 void DidCompletePageScaleAnimation() override {} |
| 61 void RecordFrameTimingEvents( |
| 62 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, |
| 63 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
| 64 override {} |
| 65 |
| 66 // LayerTreeHostSingleThreadClient Implementation ---------------------------- |
| 67 void ScheduleComposite() override; |
| 68 void ScheduleAnimation() override; |
| 69 void DidPostSwapBuffers() override; |
| 70 void DidAbortSwapBuffers() override; |
| 71 |
| 72 protected: |
| 73 explicit BlimpCompositor(float device_scale_factor); |
| 74 |
| 75 // Used by this class when building the OutputSurface that this compositor |
| 76 // draws to. This needs to return a valid gfx::AcceleratedWidget by the time |
| 77 // BlimpCompositor::SetVisible(true) is called. |
| 78 virtual gfx::AcceleratedWidget GetWindow() = 0; |
| 79 |
| 80 // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost. Can be |
| 81 // overridden to provide custom settings parameters. |
| 82 virtual void GenerateLayerTreeSettings(cc::LayerTreeSettings& settings, |
| 83 const base::CommandLine& cmd); |
| 84 |
| 85 private: |
| 86 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner(); |
| 87 |
| 88 gfx::Size viewport_size_; |
| 89 float device_scale_factor_; |
| 90 scoped_ptr<cc::LayerTreeHost> host_; |
| 91 scoped_ptr<cc::LayerTreeSettings> settings_; |
| 92 scoped_ptr<base::Thread> compositor_thread_; |
| 93 |
| 94 base::WeakPtrFactory<BlimpCompositor> weak_factory_; |
| 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); |
| 97 }; |
| 98 |
| 99 } // namespace blimp |
| 100 |
| 101 #endif // BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
OLD | NEW |