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_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/timer/timer.h"
10effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "mojo/public/cpp/system/core.h"
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "mojo/services/gles2/command_buffer.mojom.h"
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/native_widget_types.h"
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/size.h"
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace gpu {
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CommandBufferService;
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class GpuScheduler;
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class GpuControlService;
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace gles2 {
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class GLES2Decoder;
2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class MailboxManager;
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
25116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace gfx {
2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class GLContext;
2703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class GLShareGroup;
28116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass GLSurface;
29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
30116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace mojo {
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
330de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)class CommandBufferImpl : public InterfaceImpl<CommandBuffer> {
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public:
3503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Offscreen.
3603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  CommandBufferImpl(gfx::GLShareGroup* share_group,
3703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)                    gpu::gles2::MailboxManager* mailbox_manager);
3803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  // Onscreen.
390de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)  CommandBufferImpl(gfx::AcceleratedWidget widget,
4003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)                    const gfx::Size& size,
4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)                    gfx::GLShareGroup* share_group,
4203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)                    gpu::gles2::MailboxManager* mailbox_manager);
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual ~CommandBufferImpl();
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
450de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)  virtual void Initialize(CommandBufferSyncClientPtr sync_client,
46c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch                          mojo::ScopedSharedBufferHandle shared_state) OVERRIDE;
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void SetGetBuffer(int32_t buffer) OVERRIDE;
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void Flush(int32_t put_offset) OVERRIDE;
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void MakeProgress(int32_t last_get_offset) OVERRIDE;
50c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  virtual void RegisterTransferBuffer(
51c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      int32_t id,
52c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      mojo::ScopedSharedBufferHandle transfer_buffer,
53c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      uint32_t size) OVERRIDE;
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void DestroyTransferBuffer(int32_t id) OVERRIDE;
55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  virtual void Echo(const Callback<void()>& callback) OVERRIDE;
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private:
58c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state);
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void OnResize(gfx::Size size, float scale_factor);
61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void OnParseError();
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
640de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles)  CommandBufferSyncClientPtr sync_client_;
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::AcceleratedWidget widget_;
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  gfx::Size size_;
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<gpu::CommandBufferService> command_buffer_;
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<gpu::gles2::GLES2Decoder> decoder_;
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<gpu::GpuScheduler> scheduler_;
7103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  scoped_refptr<gfx::GLContext> context_;
72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  scoped_refptr<gfx::GLSurface> surface_;
7303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  scoped_refptr<gfx::GLShareGroup> share_group_;
7403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl);
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)};
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace mojo
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
82