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 ---------------------------------------- |
+ void WillBeginMainFrame() override {} |
+ 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 |
+ // 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, |
+ const base::CommandLine& cmd); |
+ |
+ private: |
+ scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner(); |
+ |
+ gfx::Size viewport_size_; |
+ float device_scale_factor_; |
+ scoped_ptr<cc::LayerTreeHost> host_; |
+ scoped_ptr<cc::LayerTreeSettings> settings_; |
+ 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_ |