[Sync] Fix invalidations on Android.
[chromium-blink-merge.git] / mojo / services / gles2 / command_buffer_impl.h
blob61b33a25c9bb733fec5ffd6a23ac8e9aff75c9ed
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 SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
6 #define SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/single_thread_task_runner.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
12 #include "third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom.h"
13 #include "third_party/mojo_services/src/gpu/public/interfaces/viewport_parameter_listener.mojom.h"
15 namespace gpu {
16 class SyncPointManager;
19 namespace gles2 {
20 class CommandBufferDriver;
22 // This class listens to the CommandBuffer message pipe on a low-latency thread
23 // so that we can insert sync points without blocking on the GL driver. It
24 // forwards most method calls to the CommandBufferDriver, which runs on the
25 // same thread as the native viewport.
26 class CommandBufferImpl : public mojo::CommandBuffer {
27 public:
28 CommandBufferImpl(
29 mojo::InterfaceRequest<CommandBuffer> request,
30 mojo::ViewportParameterListenerPtr listener,
31 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner,
32 gpu::SyncPointManager* sync_point_manager,
33 scoped_ptr<CommandBufferDriver> driver);
34 ~CommandBufferImpl() override;
36 void Initialize(mojo::CommandBufferSyncClientPtr sync_client,
37 mojo::CommandBufferSyncPointClientPtr sync_point_client,
38 mojo::CommandBufferLostContextObserverPtr loss_observer,
39 mojo::ScopedSharedBufferHandle shared_state) override;
40 void SetGetBuffer(int32_t buffer) override;
41 void Flush(int32_t put_offset) override;
42 void MakeProgress(int32_t last_get_offset) override;
43 void RegisterTransferBuffer(int32_t id,
44 mojo::ScopedSharedBufferHandle transfer_buffer,
45 uint32_t size) override;
46 void DestroyTransferBuffer(int32_t id) override;
47 void InsertSyncPoint(bool retire) override;
48 void RetireSyncPoint(uint32_t sync_point) override;
49 void Echo(const mojo::Callback<void()>& callback) override;
51 void DidLoseContext();
52 void UpdateVSyncParameters(base::TimeTicks timebase,
53 base::TimeDelta interval);
55 private:
56 void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request);
58 scoped_refptr<gpu::SyncPointManager> sync_point_manager_;
59 scoped_refptr<base::SingleThreadTaskRunner> driver_task_runner_;
60 scoped_ptr<CommandBufferDriver> driver_;
61 mojo::CommandBufferSyncPointClientPtr sync_point_client_;
62 mojo::ViewportParameterListenerPtr viewport_parameter_listener_;
63 mojo::StrongBinding<CommandBuffer> binding_;
65 base::WeakPtrFactory<CommandBufferImpl> weak_factory_;
66 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl);
69 } // namespace gles2
71 #endif // SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_