| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_DRIVER_H_ | |
| 6 #define COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_DRIVER_H_ | |
| 7 | |
| 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/view_manager/public/interfaces/command_buffer.mojom.h" | |
| 15 #include "ui/gfx/geometry/size.h" | |
| 16 | |
| 17 namespace gpu { | |
| 18 class CommandBufferService; | |
| 19 class GpuScheduler; | |
| 20 class GpuControlService; | |
| 21 namespace gles2 { | |
| 22 class GLES2Decoder; | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 namespace gfx { | |
| 27 class GLContext; | |
| 28 class GLSurface; | |
| 29 } | |
| 30 | |
| 31 namespace gles2 { | |
| 32 | |
| 33 class GpuState; | |
| 34 | |
| 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; | |
| 43 }; | |
| 44 explicit CommandBufferDriver(scoped_refptr<GpuState> gpu_state); | |
| 45 | |
| 46 ~CommandBufferDriver(); | |
| 47 | |
| 48 void set_client(scoped_ptr<Client> client) { client_ = client.Pass(); } | |
| 49 | |
| 50 void Initialize(mojo::CommandBufferSyncClientPtr sync_client, | |
| 51 mojo::CommandBufferLostContextObserverPtr loss_observer, | |
| 52 mojo::ScopedSharedBufferHandle shared_state); | |
| 53 void SetGetBuffer(int32_t buffer); | |
| 54 void Flush(int32_t put_offset); | |
| 55 void MakeProgress(int32_t last_get_offset); | |
| 56 void RegisterTransferBuffer(int32_t id, | |
| 57 mojo::ScopedSharedBufferHandle transfer_buffer, | |
| 58 uint32_t size); | |
| 59 void DestroyTransferBuffer(int32_t id); | |
| 60 void Echo(const mojo::Callback<void()>& callback); | |
| 61 void CreateImage(int32_t id, | |
| 62 mojo::ScopedHandle memory_handle, | |
| 63 int32_t type, | |
| 64 mojo::SizePtr size, | |
| 65 int32_t format, | |
| 66 int32_t internal_format); | |
| 67 void DestroyImage(int32_t id); | |
| 68 | |
| 69 private: | |
| 70 bool MakeCurrent(); | |
| 71 bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state); | |
| 72 void OnResize(gfx::Size size, float scale_factor); | |
| 73 bool OnWaitSyncPoint(uint32_t sync_point); | |
| 74 void OnSyncPointRetired(); | |
| 75 void OnParseError(); | |
| 76 void OnContextLost(uint32_t reason); | |
| 77 void DestroyDecoder(); | |
| 78 | |
| 79 scoped_ptr<Client> client_; | |
| 80 mojo::CommandBufferSyncClientPtr sync_client_; | |
| 81 mojo::CommandBufferLostContextObserverPtr loss_observer_; | |
| 82 scoped_ptr<gpu::CommandBufferService> command_buffer_; | |
| 83 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | |
| 84 scoped_ptr<gpu::GpuScheduler> scheduler_; | |
| 85 scoped_refptr<gfx::GLContext> context_; | |
| 86 scoped_refptr<gfx::GLSurface> surface_; | |
| 87 scoped_refptr<GpuState> gpu_state_; | |
| 88 | |
| 89 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; | |
| 90 base::Callback<void(int32_t)> context_lost_callback_; | |
| 91 | |
| 92 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); | |
| 95 }; | |
| 96 | |
| 97 } // namespace gles2 | |
| 98 | |
| 99 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_ | |
| OLD | NEW |