[Telemetry] Always collect garbage on between telemetry page runs [Regressionable...
[chromium-blink-merge.git] / mojo / gles2 / command_buffer_client_impl.h
blob1ec0f1f5c6e4653faa7f7dcd324f3405d21a8adf
1 // Copyright 2014 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_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_
6 #define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_
8 #include <map>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/view_manager/public/interfaces/command_buffer.mojom.h"
13 #include "gpu/command_buffer/client/gpu_control.h"
14 #include "gpu/command_buffer/common/command_buffer.h"
15 #include "gpu/command_buffer/common/command_buffer_shared.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
18 namespace base {
19 class RunLoop;
22 namespace gles2 {
23 class CommandBufferClientImpl;
25 class CommandBufferDelegate {
26 public:
27 virtual ~CommandBufferDelegate();
28 virtual void ContextLost();
31 class CommandBufferClientImpl : public mojo::CommandBufferLostContextObserver,
32 public gpu::CommandBuffer,
33 public gpu::GpuControl {
34 public:
35 explicit CommandBufferClientImpl(
36 CommandBufferDelegate* delegate,
37 const MojoAsyncWaiter* async_waiter,
38 mojo::ScopedMessagePipeHandle command_buffer_handle);
39 ~CommandBufferClientImpl() override;
41 // CommandBuffer implementation:
42 bool Initialize() override;
43 State GetLastState() override;
44 int32_t GetLastToken() override;
45 void Flush(int32_t put_offset) override;
46 void OrderingBarrier(int32_t put_offset) override;
47 void WaitForTokenInRange(int32_t start, int32_t end) override;
48 void WaitForGetOffsetInRange(int32_t start, int32_t end) override;
49 void SetGetBuffer(int32_t shm_id) override;
50 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size,
51 int32_t* id) override;
52 void DestroyTransferBuffer(int32_t id) override;
54 // gpu::GpuControl implementation:
55 gpu::Capabilities GetCapabilities() override;
56 int32_t CreateImage(ClientBuffer buffer,
57 size_t width,
58 size_t height,
59 unsigned internalformat) override;
60 void DestroyImage(int32_t id) override;
61 int32_t CreateGpuMemoryBufferImage(size_t width,
62 size_t height,
63 unsigned internalformat,
64 unsigned usage) override;
65 uint32 InsertSyncPoint() override;
66 uint32 InsertFutureSyncPoint() override;
67 void RetireSyncPoint(uint32 sync_point) override;
68 void SignalSyncPoint(uint32 sync_point,
69 const base::Closure& callback) override;
70 void SignalQuery(uint32 query, const base::Closure& callback) override;
71 void SetSurfaceVisible(bool visible) override;
72 uint32 CreateStreamTexture(uint32 texture_id) override;
73 void SetLock(base::Lock*) override;
74 bool IsGpuChannelLost() override;
76 private:
77 class SyncClientImpl;
78 class SyncPointClientImpl;
80 // mojo::CommandBufferLostContextObserver implementation:
81 void DidLoseContext(int32_t lost_reason) override;
83 void TryUpdateState();
84 void MakeProgressAndUpdateState();
86 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; }
88 CommandBufferDelegate* delegate_;
89 mojo::Binding<mojo::CommandBufferLostContextObserver> observer_binding_;
90 mojo::CommandBufferPtr command_buffer_;
91 scoped_ptr<SyncClientImpl> sync_client_impl_;
92 scoped_ptr<SyncPointClientImpl> sync_point_client_impl_;
94 gpu::Capabilities capabilities_;
95 State last_state_;
96 mojo::ScopedSharedBufferHandle shared_state_handle_;
97 gpu::CommandBufferSharedState* shared_state_;
98 int32_t last_put_offset_;
99 int32_t next_transfer_buffer_id_;
101 // Image IDs are allocated in sequence.
102 int next_image_id_;
104 const MojoAsyncWaiter* async_waiter_;
107 } // gles2
109 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_