15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file.
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef MOJO_EXAMPLES_COMPOSITOR_APP_COMPOSITOR_HOST_H_
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MOJO_EXAMPLES_COMPOSITOR_APP_COMPOSITOR_HOST_H_
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/compiler_specific.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/threading/thread.h"
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "cc/trees/layer_tree_host_client.h"
12effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "mojo/public/cpp/system/core.h"
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/size.h"
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace cc {
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class Layer;
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class LayerTreeHost;
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace cc
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace mojo {
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace examples {
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class GLES2ClientImpl;
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CompositorHost : public cc::LayerTreeHostClient {
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public:
26cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  explicit CompositorHost(ScopedMessagePipeHandle command_buffer_handle);
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual ~CompositorHost();
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
29cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  void SetSize(const gfx::Size& viewport_size);
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // cc::LayerTreeHostClient implementation.
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void WillBeginMainFrame(int frame_id) OVERRIDE;
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidBeginMainFrame() OVERRIDE;
3403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  virtual void BeginMainFrame(const cc::BeginFrameArgs& args) OVERRIDE;
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void Layout() OVERRIDE;
361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                   float page_scale,
381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                                   float top_controls_delta) OVERRIDE;
391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual void RequestNewOutputSurface(bool fallback) OVERRIDE;
405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual void DidInitializeOutputSurface() OVERRIDE;
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void WillCommit() OVERRIDE;
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidCommit() OVERRIDE;
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidCommitAndDrawFrame() OVERRIDE;
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DidCompleteSwapBuffers() OVERRIDE;
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private:
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetupScene();
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
49cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  ScopedMessagePipeHandle command_buffer_handle_;
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<cc::LayerTreeHost> tree_;
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_refptr<cc::Layer> child_layer_;
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::Thread compositor_thread_;
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)};
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace examples
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace mojo
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // MOJO_EXAMPLES_COMPOSITOR_APP_COMPOSITOR_HOST_H_
59