Chromium Code Reviews| 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 ---------------------------------------- | |
|
Wez
2015/08/27 02:01:51
n00b nit: See my comment in the .java re trailing
David Trainor- moved to gerrit
2015/08/28 01:23:46
Be gone ---! I was looking at the cc files and th
Wez
2015/09/03 00:49:27
Sadly the C++ is not very consistent; typically in
David Trainor- moved to gerrit
2015/09/03 06:33:21
Crap! Adding . to all "X implementation" lines.
| |
| 43 void WillBeginMainFrame() override {} | |
|
Wez
2015/08/27 02:01:51
Chromium style guide requires that virtual functio
David Trainor- moved to gerrit
2015/08/28 01:23:46
Ah my bad! I saw this in ui/compositor/compositor
Wez
2015/09/03 00:49:27
Strictly speaking, yes; I'm pretty sure the guidan
David Trainor- moved to gerrit
2015/09/03 06:33:21
Moved these all to the cc file. I'm fine with tha
| |
| 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 | |
|
Wez
2015/08/27 02:01:51
"by this class" seems redundant?
Suggest wording
David Trainor- moved to gerrit
2015/08/28 01:23:46
Much better thanks :).
| |
| 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, | |
|
Wez
2015/08/27 02:01:51
If this is an out-parameter then it should be cc::
David Trainor- moved to gerrit
2015/08/28 01:23:46
I changed it to LayerTreeSettings*.
Wez
2015/09/03 00:49:27
Acknowledged.
| |
| 83 const base::CommandLine& cmd); | |
| 84 | |
| 85 private: | |
| 86 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner(); | |
|
Wez
2015/08/27 02:01:51
nit: Comment to clarify what this does - what is t
David Trainor- moved to gerrit
2015/08/28 01:23:46
Done.
| |
| 87 | |
| 88 gfx::Size viewport_size_; | |
|
Wez
2015/08/27 02:01:51
nit: Comments to explain the less obvious members,
David Trainor- moved to gerrit
2015/08/28 01:23:46
Done.
| |
| 89 float device_scale_factor_; | |
| 90 scoped_ptr<cc::LayerTreeHost> host_; | |
| 91 scoped_ptr<cc::LayerTreeSettings> settings_; | |
|
Wez
2015/08/27 02:01:51
nit: Does this need to be a scoped_ptr<>, rather t
David Trainor- moved to gerrit
2015/08/28 01:23:46
I wanted to easily know when it wasn't initialized
| |
| 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 |