Chromium Code Reviews| Index: blimp/client/compositor/blimp_compositor.h |
| diff --git a/blimp/client/compositor/blimp_compositor.h b/blimp/client/compositor/blimp_compositor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a78630bd87b1003d3965a6b3a67457f05f3c6b51 |
| --- /dev/null |
| +++ b/blimp/client/compositor/blimp_compositor.h |
| @@ -0,0 +1,101 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
| +#define BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "cc/trees/layer_tree_host_client.h" |
| +#include "cc/trees/layer_tree_host_single_thread_client.h" |
| +#include "cc/trees/layer_tree_settings.h" |
| +#include "ui/gfx/geometry/size.h" |
| +#include "ui/gfx/native_widget_types.h" |
| + |
| +namespace base { |
| +class CommandLine; |
| +class SingleThreadTaskRunner; |
| +class Thread; |
| +} |
| + |
| +namespace cc { |
| +class LayerTreeHost; |
| +} |
| + |
| +namespace blimp { |
| + |
| +// BlimpCompositor provides the basic framework and setup to host a |
| +// LayerTreeHost (compositor). The rendering surface this compositor draws to |
| +// is defined by the gfx::AcceleratedWidget returned by |
| +// BlimpCompositor::GetWindow(). |
| +class BlimpCompositor : public cc::LayerTreeHostClient, |
| + public cc::LayerTreeHostSingleThreadClient { |
| + public: |
| + ~BlimpCompositor() override; |
| + |
| + void SetVisible(bool visible); |
| + void SetSize(const gfx::Size& size); |
| + |
| + // 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.
|
| + 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
|
| + void DidBeginMainFrame() override {} |
| + void BeginMainFrame(const cc::BeginFrameArgs& args) override {} |
| + void BeginMainFrameNotExpectedSoon() override {} |
| + void Layout() override; |
| + void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
| + const gfx::Vector2dF& outer_delta, |
| + const gfx::Vector2dF& elastic_overscroll_delta, |
| + float page_scale, |
| + float top_controls_delta) override {} |
| + void RequestNewOutputSurface() override; |
| + void DidInitializeOutputSurface() override; |
| + void DidFailToInitializeOutputSurface() override; |
| + void WillCommit() override {} |
| + void DidCommit() override; |
| + void DidCommitAndDrawFrame() override {} |
| + void DidCompleteSwapBuffers() override; |
| + void DidCompletePageScaleAnimation() override {} |
| + void RecordFrameTimingEvents( |
| + scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, |
| + scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) |
| + override {} |
| + |
| + // LayerTreeHostSingleThreadClient Implementation ---------------------------- |
| + void ScheduleComposite() override; |
| + void ScheduleAnimation() override; |
| + void DidPostSwapBuffers() override; |
| + void DidAbortSwapBuffers() override; |
| + |
| + protected: |
| + explicit BlimpCompositor(float device_scale_factor); |
| + |
| + // 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 :).
|
| + // draws to. This needs to return a valid gfx::AcceleratedWidget by the time |
| + // BlimpCompositor::SetVisible(true) is called. |
| + virtual gfx::AcceleratedWidget GetWindow() = 0; |
| + |
| + // Populates the cc::LayerTreeSettings used by the cc::LayerTreeHost. Can be |
| + // overridden to provide custom settings parameters. |
| + 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.
|
| + const base::CommandLine& cmd); |
| + |
| + private: |
| + 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.
|
| + |
| + 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.
|
| + float device_scale_factor_; |
| + scoped_ptr<cc::LayerTreeHost> host_; |
| + 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
|
| + scoped_ptr<base::Thread> compositor_thread_; |
| + |
| + base::WeakPtrFactory<BlimpCompositor> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); |
| +}; |
| + |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_CLIENT_COMPOSITOR_BLIMP_COMPOSITOR_H_ |