1 // Copyright 2015 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 COMPONENTS_MUS_GLES2_COMMAND_BUFFER_LOCAL_H_
6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_LOCAL_H_
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/mus/gles2/gpu_state.h"
13 #include "gpu/command_buffer/client/gpu_control.h"
14 #include "gpu/command_buffer/common/command_buffer.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/gpu_memory_buffer.h"
17 #include "ui/gfx/native_widget_types.h"
21 class CommandBufferService
;
23 class GpuControlService
;
36 class CommandBufferLocalClient
;
39 // This class provides a thin wrapper around a CommandBufferService and a
40 // GpuControl implementation to allow cc::Display to generate GL directly on
42 class CommandBufferLocal
: public gpu::GpuControl
{
44 CommandBufferLocal(CommandBufferLocalClient
* client
,
45 gfx::AcceleratedWidget widget
,
46 const scoped_refptr
<GpuState
>& gpu_state
);
47 ~CommandBufferLocal() override
;
51 gpu::CommandBuffer
* GetCommandBuffer();
53 // gpu::GpuControl implementation:
54 gpu::Capabilities
GetCapabilities() override
;
55 int32_t CreateImage(ClientBuffer buffer
,
58 unsigned internalformat
) override
;
59 void DestroyImage(int32_t id
) override
;
60 int32_t CreateGpuMemoryBufferImage(size_t width
,
62 unsigned internalformat
,
63 unsigned usage
) override
;
64 uint32
InsertSyncPoint() override
;
65 uint32
InsertFutureSyncPoint() override
;
66 void RetireSyncPoint(uint32 sync_point
) override
;
67 void SignalSyncPoint(uint32 sync_point
,
68 const base::Closure
& callback
) override
;
69 void SignalQuery(uint32 query
, const base::Closure
& callback
) override
;
70 void SetSurfaceVisible(bool visible
) override
;
71 uint32
CreateStreamTexture(uint32 texture_id
) override
;
72 void SetLock(base::Lock
*) override
;
73 bool IsGpuChannelLost() override
;
74 gpu::CommandBufferNamespace
GetNamespaceID() const override
;
75 uint64_t GetCommandBufferID() const override
;
80 void OnResize(gfx::Size size
, float scale_factor
);
81 void OnUpdateVSyncParameters(const base::TimeTicks timebase
,
82 const base::TimeDelta interval
);
83 bool OnWaitSyncPoint(uint32_t sync_point
);
85 void OnContextLost(uint32_t reason
);
86 void OnSyncPointRetired();
88 gfx::AcceleratedWidget widget_
;
89 scoped_refptr
<GpuState
> gpu_state_
;
90 scoped_ptr
<gpu::CommandBufferService
> command_buffer_
;
91 scoped_ptr
<gpu::GpuScheduler
> scheduler_
;
92 scoped_ptr
<gpu::gles2::GLES2Decoder
> decoder_
;
93 scoped_refptr
<gfx::GLContext
> context_
;
94 scoped_refptr
<gfx::GLSurface
> surface_
;
95 CommandBufferLocalClient
* client_
;
97 base::WeakPtrFactory
<CommandBufferLocal
> weak_factory_
;
99 DISALLOW_COPY_AND_ASSIGN(CommandBufferLocal
);
104 #endif // COMPONENTS_MUS_GLES2_COMMAND_BUFFER_LOCAL_H_