1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
6 #define MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/timer/timer.h"
10 #include "mojo/public/cpp/system/core.h"
11 #include "mojo/services/gles2/command_buffer.mojom.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/gfx/size.h"
16 class CommandBufferService
;
18 class GpuControlService
;
33 class CommandBufferImpl
: public InterfaceImpl
<CommandBuffer
> {
36 CommandBufferImpl(gfx::GLShareGroup
* share_group
,
37 gpu::gles2::MailboxManager
* mailbox_manager
);
39 CommandBufferImpl(gfx::AcceleratedWidget widget
,
40 const gfx::Size
& size
,
41 gfx::GLShareGroup
* share_group
,
42 gpu::gles2::MailboxManager
* mailbox_manager
);
43 virtual ~CommandBufferImpl();
45 virtual void Initialize(CommandBufferSyncClientPtr sync_client
,
46 mojo::ScopedSharedBufferHandle shared_state
) OVERRIDE
;
47 virtual void SetGetBuffer(int32_t buffer
) OVERRIDE
;
48 virtual void Flush(int32_t put_offset
) OVERRIDE
;
49 virtual void MakeProgress(int32_t last_get_offset
) OVERRIDE
;
50 virtual void RegisterTransferBuffer(
52 mojo::ScopedSharedBufferHandle transfer_buffer
,
53 uint32_t size
) OVERRIDE
;
54 virtual void DestroyTransferBuffer(int32_t id
) OVERRIDE
;
55 virtual void Echo(const Callback
<void()>& callback
) OVERRIDE
;
58 bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state
);
60 void OnResize(gfx::Size size
, float scale_factor
);
64 CommandBufferSyncClientPtr sync_client_
;
66 gfx::AcceleratedWidget widget_
;
68 scoped_ptr
<gpu::CommandBufferService
> command_buffer_
;
69 scoped_ptr
<gpu::gles2::GLES2Decoder
> decoder_
;
70 scoped_ptr
<gpu::GpuScheduler
> scheduler_
;
71 scoped_refptr
<gfx::GLContext
> context_
;
72 scoped_refptr
<gfx::GLSurface
> surface_
;
73 scoped_refptr
<gfx::GLShareGroup
> share_group_
;
74 scoped_refptr
<gpu::gles2::MailboxManager
> mailbox_manager_
;
76 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl
);
81 #endif // MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_