summaryrefslogtreecommitdiffstats
path: root/mojo/examples/sample_app/gles2_client_impl.h
blob: 300557addb1365517ffc205540792d14a2d3a96e (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
// 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_SAMPLE_APP_GLES2_CLIENT_IMPL_H_
#define MOJO_EXAMPLES_SAMPLE_APP_GLES2_CLIENT_IMPL_H_

#include "base/time/time.h"
#include "base/timer/timer.h"
#include "mojo/examples/sample_app/spinning_cube.h"
#include "mojo/public/bindings/lib/remote_ptr.h"
#include "mojom/gles2.h"
#include "mojom/native_viewport.h"
#include "ui/gfx/point_f.h"

namespace mojo {
namespace examples {

class GLES2ClientImpl : public GLES2ClientStub {
 public:
  explicit GLES2ClientImpl(ScopedMessagePipeHandle pipe);
  virtual ~GLES2ClientImpl();

  void HandleInputEvent(const Event& event);

 private:
  virtual void DidCreateContext(uint64_t encoded,
                                uint32_t width,
                                uint32_t height) MOJO_OVERRIDE;
  virtual void ContextLost() MOJO_OVERRIDE;

  void Draw();
  void StartTimer();

  base::Time last_time_;
  base::RepeatingTimer<GLES2ClientImpl> timer_;
  SpinningCube cube_;
  gfx::PointF capture_point_;
  gfx::PointF last_drag_point_;
  base::Time drag_start_time_;

  RemotePtr<GLES2> service_;

  MOJO_DISALLOW_COPY_AND_ASSIGN(GLES2ClientImpl);
};

}  // namespace examples
}  // namespace mojo

#endif  // MOJO_EXAMPLES_SAMPLE_APP_GLES2_CLIENT_IMPL_H_