summaryrefslogtreecommitdiffstats
path: root/mojo/services/gles2/command_buffer_impl.h
blob: e76a3d2fc5208dc61c45a7882a2d047fa8b6b7e3 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// 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_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
#define MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_

#include "base/memory/scoped_ptr.h"
#include "base/timer/timer.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/services/gles2/command_buffer.mojom.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"

namespace gpu {
class CommandBufferService;
class GpuScheduler;
class GpuControlService;
namespace gles2 {
class GLES2Decoder;
}
}

namespace mojo {
namespace services {

class CommandBufferImpl : public InterfaceImpl<CommandBuffer> {
 public:
  CommandBufferImpl(gfx::AcceleratedWidget widget,
                    const gfx::Size& size);
  virtual ~CommandBufferImpl();

  virtual void OnConnectionError() OVERRIDE;
  virtual void SetClient(CommandBufferClient* client) OVERRIDE;
  virtual void Initialize(CommandBufferSyncClientPtr sync_client,
                          mojo::ScopedSharedBufferHandle shared_state) OVERRIDE;
  virtual void SetGetBuffer(int32_t buffer) OVERRIDE;
  virtual void Flush(int32_t put_offset) OVERRIDE;
  virtual void MakeProgress(int32_t last_get_offset) OVERRIDE;
  virtual void RegisterTransferBuffer(
      int32_t id,
      mojo::ScopedSharedBufferHandle transfer_buffer,
      uint32_t size) OVERRIDE;
  virtual void DestroyTransferBuffer(int32_t id) OVERRIDE;
  virtual void Echo(const Callback<void()>& callback) OVERRIDE;

  virtual void RequestAnimationFrames() OVERRIDE;
  virtual void CancelAnimationFrames() OVERRIDE;

 private:
  bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state);

  void OnParseError();

  void DrawAnimationFrame();

  CommandBufferClient* client_;
  CommandBufferSyncClientPtr sync_client_;

  gfx::AcceleratedWidget widget_;
  gfx::Size size_;
  scoped_ptr<gpu::CommandBufferService> command_buffer_;
  scoped_ptr<gpu::gles2::GLES2Decoder> decoder_;
  scoped_ptr<gpu::GpuScheduler> scheduler_;
  scoped_ptr<gpu::GpuControlService> gpu_control_;
  base::RepeatingTimer<CommandBufferImpl> timer_;

  DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl);
};

}  // namespace services
}  // namespace mojo

#endif  // MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_