| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 virtual void OnWillDeleteImpl() = 0; | 55 virtual void OnWillDeleteImpl() = 0; |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 virtual ~DeletionObserver() {} | 58 virtual ~DeletionObserver() {} |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 typedef base::Callback<void( | 61 typedef base::Callback<void( |
| 62 const std::string& msg, int id)> GpuConsoleMessageCallback; | 62 const std::string& msg, int id)> GpuConsoleMessageCallback; |
| 63 | 63 |
| 64 CommandBufferProxyImpl(GpuChannelHost* channel, int route_id); | 64 CommandBufferProxyImpl(GpuChannelHost* channel, int route_id); |
| 65 virtual ~CommandBufferProxyImpl(); | 65 ~CommandBufferProxyImpl() override; |
| 66 | 66 |
| 67 // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and | 67 // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and |
| 68 // returns it as an owned pointer to a media::VideoDecodeAccelerator. Returns | 68 // returns it as an owned pointer to a media::VideoDecodeAccelerator. Returns |
| 69 // NULL on failure to create the GpuVideoDecodeAcceleratorHost. | 69 // NULL on failure to create the GpuVideoDecodeAcceleratorHost. |
| 70 // Note that the GpuVideoDecodeAccelerator may still fail to be created in | 70 // Note that the GpuVideoDecodeAccelerator may still fail to be created in |
| 71 // the GPU process, even if this returns non-NULL. In this case the VDA client | 71 // the GPU process, even if this returns non-NULL. In this case the VDA client |
| 72 // is notified of an error later, after Initialize(). | 72 // is notified of an error later, after Initialize(). |
| 73 scoped_ptr<media::VideoDecodeAccelerator> CreateVideoDecoder(); | 73 scoped_ptr<media::VideoDecodeAccelerator> CreateVideoDecoder(); |
| 74 | 74 |
| 75 // Sends an IPC message to create a GpuVideoEncodeAccelerator. Creates and | 75 // Sends an IPC message to create a GpuVideoEncodeAccelerator. Creates and |
| 76 // returns it as an owned pointer to a media::VideoEncodeAccelerator. Returns | 76 // returns it as an owned pointer to a media::VideoEncodeAccelerator. Returns |
| 77 // NULL on failure to create the GpuVideoEncodeAcceleratorHost. | 77 // NULL on failure to create the GpuVideoEncodeAcceleratorHost. |
| 78 // Note that the GpuVideoEncodeAccelerator may still fail to be created in | 78 // Note that the GpuVideoEncodeAccelerator may still fail to be created in |
| 79 // the GPU process, even if this returns non-NULL. In this case the VEA client | 79 // the GPU process, even if this returns non-NULL. In this case the VEA client |
| 80 // is notified of an error later, after Initialize(); | 80 // is notified of an error later, after Initialize(); |
| 81 scoped_ptr<media::VideoEncodeAccelerator> CreateVideoEncoder(); | 81 scoped_ptr<media::VideoEncodeAccelerator> CreateVideoEncoder(); |
| 82 | 82 |
| 83 // IPC::Listener implementation: | 83 // IPC::Listener implementation: |
| 84 virtual bool OnMessageReceived(const IPC::Message& message) override; | 84 bool OnMessageReceived(const IPC::Message& message) override; |
| 85 virtual void OnChannelError() override; | 85 void OnChannelError() override; |
| 86 | 86 |
| 87 // CommandBuffer implementation: | 87 // CommandBuffer implementation: |
| 88 virtual bool Initialize() override; | 88 bool Initialize() override; |
| 89 virtual State GetLastState() override; | 89 State GetLastState() override; |
| 90 virtual int32 GetLastToken() override; | 90 int32 GetLastToken() override; |
| 91 virtual void Flush(int32 put_offset) override; | 91 void Flush(int32 put_offset) override; |
| 92 virtual void WaitForTokenInRange(int32 start, int32 end) override; | 92 void WaitForTokenInRange(int32 start, int32 end) override; |
| 93 virtual void WaitForGetOffsetInRange(int32 start, int32 end) override; | 93 void WaitForGetOffsetInRange(int32 start, int32 end) override; |
| 94 virtual void SetGetBuffer(int32 shm_id) override; | 94 void SetGetBuffer(int32 shm_id) override; |
| 95 virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, | 95 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, |
| 96 int32* id) override; | 96 int32* id) override; |
| 97 virtual void DestroyTransferBuffer(int32 id) override; | 97 void DestroyTransferBuffer(int32 id) override; |
| 98 | 98 |
| 99 // gpu::GpuControl implementation: | 99 // gpu::GpuControl implementation: |
| 100 virtual gpu::Capabilities GetCapabilities() override; | 100 gpu::Capabilities GetCapabilities() override; |
| 101 virtual int32 CreateImage(ClientBuffer buffer, | 101 int32 CreateImage(ClientBuffer buffer, |
| 102 size_t width, | 102 size_t width, |
| 103 size_t height, | 103 size_t height, |
| 104 unsigned internalformat) override; | 104 unsigned internalformat) override; |
| 105 virtual void DestroyImage(int32 id) override; | 105 void DestroyImage(int32 id) override; |
| 106 virtual int32 CreateGpuMemoryBufferImage(size_t width, | 106 int32 CreateGpuMemoryBufferImage(size_t width, |
| 107 size_t height, | 107 size_t height, |
| 108 unsigned internalformat, | 108 unsigned internalformat, |
| 109 unsigned usage) override; | 109 unsigned usage) override; |
| 110 virtual uint32 InsertSyncPoint() override; | 110 uint32 InsertSyncPoint() override; |
| 111 virtual uint32_t InsertFutureSyncPoint() override; | 111 uint32_t InsertFutureSyncPoint() override; |
| 112 virtual void RetireSyncPoint(uint32_t sync_point) override; | 112 void RetireSyncPoint(uint32_t sync_point) override; |
| 113 virtual void SignalSyncPoint(uint32 sync_point, | 113 void SignalSyncPoint(uint32 sync_point, |
| 114 const base::Closure& callback) override; | 114 const base::Closure& callback) override; |
| 115 virtual void SignalQuery(uint32 query, | 115 void SignalQuery(uint32 query, const base::Closure& callback) override; |
| 116 const base::Closure& callback) override; | 116 void SetSurfaceVisible(bool visible) override; |
| 117 virtual void SetSurfaceVisible(bool visible) override; | 117 uint32 CreateStreamTexture(uint32 texture_id) override; |
| 118 virtual uint32 CreateStreamTexture(uint32 texture_id) override; | |
| 119 | 118 |
| 120 int GetRouteID() const; | 119 int GetRouteID() const; |
| 121 bool ProduceFrontBuffer(const gpu::Mailbox& mailbox); | 120 bool ProduceFrontBuffer(const gpu::Mailbox& mailbox); |
| 122 void SetChannelErrorCallback(const base::Closure& callback); | 121 void SetChannelErrorCallback(const base::Closure& callback); |
| 123 | 122 |
| 124 typedef base::Callback<void(const gpu::MemoryAllocation&)> | 123 typedef base::Callback<void(const gpu::MemoryAllocation&)> |
| 125 MemoryAllocationChangedCallback; | 124 MemoryAllocationChangedCallback; |
| 126 void SetMemoryAllocationChangedCallback( | 125 void SetMemoryAllocationChangedCallback( |
| 127 const MemoryAllocationChangedCallback& callback); | 126 const MemoryAllocationChangedCallback& callback); |
| 128 void AddDeletionObserver(DeletionObserver* observer); | 127 void AddDeletionObserver(DeletionObserver* observer); |
| 129 void RemoveDeletionObserver(DeletionObserver* observer); | 128 void RemoveDeletionObserver(DeletionObserver* observer); |
| 130 | 129 |
| 131 bool EnsureBackbuffer(); | 130 bool EnsureBackbuffer(); |
| 132 | 131 |
| 133 void SetOnConsoleMessageCallback( | 132 void SetOnConsoleMessageCallback( |
| 134 const GpuConsoleMessageCallback& callback); | 133 const GpuConsoleMessageCallback& callback); |
| 135 | 134 |
| 136 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 135 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
| 137 typedef base::Callback<void(const std::vector<ui::LatencyInfo>& latency_info)> | 136 typedef base::Callback<void(const std::vector<ui::LatencyInfo>& latency_info)> |
| 138 SwapBuffersCompletionCallback; | 137 SwapBuffersCompletionCallback; |
| 139 void SetSwapBuffersCompletionCallback( | 138 void SetSwapBuffersCompletionCallback( |
| 140 const SwapBuffersCompletionCallback& callback); | 139 const SwapBuffersCompletionCallback& callback); |
| 141 | 140 |
| 142 // TODO(apatrick): this is a temporary optimization while skia is calling | 141 // TODO(apatrick): this is a temporary optimization while skia is calling |
| 143 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6 | 142 // ContentGLContext::MakeCurrent prior to every GL call. It saves returning 6 |
| 144 // ints redundantly when only the error is needed for the | 143 // ints redundantly when only the error is needed for the |
| 145 // CommandBufferProxyImpl implementation. | 144 // CommandBufferProxyImpl implementation. |
| 146 virtual gpu::error::Error GetLastError() override; | 145 gpu::error::Error GetLastError() override; |
| 147 | 146 |
| 148 GpuChannelHost* channel() const { return channel_; } | 147 GpuChannelHost* channel() const { return channel_; } |
| 149 | 148 |
| 150 base::SharedMemoryHandle GetSharedStateHandle() const { | 149 base::SharedMemoryHandle GetSharedStateHandle() const { |
| 151 return shared_state_shm_->handle(); | 150 return shared_state_shm_->handle(); |
| 152 } | 151 } |
| 153 | 152 |
| 154 private: | 153 private: |
| 155 typedef std::map<int32, scoped_refptr<gpu::Buffer> > TransferBufferMap; | 154 typedef std::map<int32, scoped_refptr<gpu::Buffer> > TransferBufferMap; |
| 156 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; | 155 typedef base::hash_map<uint32, base::Closure> SignalTaskMap; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 std::vector<ui::LatencyInfo> latency_info_; | 209 std::vector<ui::LatencyInfo> latency_info_; |
| 211 | 210 |
| 212 SwapBuffersCompletionCallback swap_buffers_completion_callback_; | 211 SwapBuffersCompletionCallback swap_buffers_completion_callback_; |
| 213 | 212 |
| 214 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); | 213 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); |
| 215 }; | 214 }; |
| 216 | 215 |
| 217 } // namespace content | 216 } // namespace content |
| 218 | 217 |
| 219 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 218 #endif // CONTENT_COMMON_GPU_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| OLD | NEW |