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