summaryrefslogtreecommitdiffstats
path: root/mojo/examples/compositor_app/compositor_host.h
blob: 2576fdd2162a6ee5d27cb597186af2cb11e94866 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2013 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 MOJO_EXAMPLES_COMPOSITOR_APP_COMPOSITOR_HOST_H_
#define MOJO_EXAMPLES_COMPOSITOR_APP_COMPOSITOR_HOST_H_

#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread.h"
#include "cc/trees/layer_tree_host_client.h"
#include "mojo/public/cpp/system/core.h"
#include "ui/gfx/size.h"

namespace cc {
class Layer;
class LayerTreeHost;
}  // namespace cc

namespace mojo {
namespace examples {
class GLES2ClientImpl;

class CompositorHost : public cc::LayerTreeHostClient {
 public:
  explicit CompositorHost(ScopedMessagePipeHandle command_buffer_handle);
  virtual ~CompositorHost();

  void SetSize(const gfx::Size& viewport_size);

  // cc::LayerTreeHostClient implementation.
  virtual void WillBeginMainFrame(int frame_id) OVERRIDE;
  virtual void DidBeginMainFrame() OVERRIDE;
  virtual void BeginMainFrame(const cc::BeginFrameArgs& args) OVERRIDE;
  virtual void Layout() OVERRIDE;
  virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
                                   float page_scale) OVERRIDE;
  virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback)
      OVERRIDE;
  virtual void DidInitializeOutputSurface() OVERRIDE;
  virtual void WillCommit() OVERRIDE;
  virtual void DidCommit() OVERRIDE;
  virtual void DidCommitAndDrawFrame() OVERRIDE;
  virtual void DidCompleteSwapBuffers() OVERRIDE;

 private:
  void SetupScene();

  ScopedMessagePipeHandle command_buffer_handle_;
  scoped_ptr<cc::LayerTreeHost> tree_;
  scoped_refptr<cc::Layer> child_layer_;
  base::Thread compositor_thread_;
};

}  // namespace examples
}  // namespace mojo

#endif  // MOJO_EXAMPLES_COMPOSITOR_APP_COMPOSITOR_HOST_H_