Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / mus / gles2 / command_buffer_driver.h
blob97ede0c9e595b4308713643cb49d577a56d0019e
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 COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_
6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/timer/timer.h"
14 #include "components/mus/public/interfaces/command_buffer.mojom.h"
15 #include "ui/gfx/geometry/size.h"
17 namespace gpu {
18 class CommandBufferService;
19 class GpuScheduler;
20 class GpuControlService;
21 namespace gles2 {
22 class GLES2Decoder;
26 namespace gfx {
27 class GLContext;
28 class GLSurface;
31 namespace mus {
33 class GpuState;
35 // This class receives CommandBuffer messages on the same thread as the native
36 // viewport.
37 class CommandBufferDriver {
38 public:
39 class Client {
40 public:
41 virtual ~Client();
42 virtual void DidLoseContext() = 0;
44 explicit CommandBufferDriver(scoped_refptr<GpuState> gpu_state);
46 ~CommandBufferDriver();
48 void set_client(scoped_ptr<Client> client) { client_ = client.Pass(); }
50 void Initialize(mojo::CommandBufferSyncClientPtr sync_client,
51 mojo::CommandBufferLostContextObserverPtr loss_observer,
52 mojo::ScopedSharedBufferHandle shared_state,
53 mojo::Array<int32_t> attribs);
54 void SetGetBuffer(int32_t buffer);
55 void Flush(int32_t put_offset);
56 void MakeProgress(int32_t last_get_offset);
57 void RegisterTransferBuffer(int32_t id,
58 mojo::ScopedSharedBufferHandle transfer_buffer,
59 uint32_t size);
60 void DestroyTransferBuffer(int32_t id);
61 void Echo(const mojo::Callback<void()>& callback);
62 void CreateImage(int32_t id,
63 mojo::ScopedHandle memory_handle,
64 int32_t type,
65 mojo::SizePtr size,
66 int32_t format,
67 int32_t internal_format);
68 void DestroyImage(int32_t id);
70 private:
71 bool MakeCurrent();
72 bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state,
73 mojo::Array<int32_t> attribs);
74 void OnResize(gfx::Size size, float scale_factor);
75 bool OnWaitSyncPoint(uint32_t sync_point);
76 void OnSyncPointRetired();
77 void OnParseError();
78 void OnContextLost(uint32_t reason);
79 void DestroyDecoder();
81 scoped_ptr<Client> client_;
82 mojo::CommandBufferSyncClientPtr sync_client_;
83 mojo::CommandBufferLostContextObserverPtr loss_observer_;
84 scoped_ptr<gpu::CommandBufferService> command_buffer_;
85 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_;
86 scoped_ptr<gpu::GpuScheduler> scheduler_;
87 scoped_refptr<gfx::GLContext> context_;
88 scoped_refptr<gfx::GLSurface> surface_;
89 scoped_refptr<GpuState> gpu_state_;
91 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_;
92 base::Callback<void(int32_t)> context_lost_callback_;
94 base::WeakPtrFactory<CommandBufferDriver> weak_factory_;
96 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver);
99 } // namespace mus
101 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_