Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: content/common/gpu/client/ipc/chrome/chrome_command_buffer_ipc_transport.h

Issue 1656433002: Sample code: IPC Transport object for GPU Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GpuMemoryBufferService + Transport object. TODO: Eliminate ChildThreadImpl dependency Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/client/ipc/chrome/chrome_command_buffer_ipc_transport.h
diff --git a/content/common/gpu/client/ipc/chrome/chrome_command_buffer_ipc_transport.h b/content/common/gpu/client/ipc/chrome/chrome_command_buffer_ipc_transport.h
new file mode 100644
index 0000000000000000000000000000000000000000..a39c52b2d28f77c5cff3a5e2e499229e16ae92ed
--- /dev/null
+++ b/content/common/gpu/client/ipc/chrome/chrome_command_buffer_ipc_transport.h
@@ -0,0 +1,108 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_GPU_CLIENT_IPC_CHROME_CHROME_COMMAND_BUFFER_IPC_TRANSPORT_H_
+#define CONTENT_COMMON_GPU_CLIENT_IPC_CHROME_CHROME_COMMAND_BUFFER_IPC_TRANSPORT_H_
+
+#include "content/common/gpu/client/ipc/command_buffer_ipc_transport.h"
+
+#include "ipc/ipc_listener.h"
+
+namespace IPC {
+class Message;
+}
+
+namespace content {
+
+class ChromeGpuChannelHostIPCTransport;
+class GpuChannelHost;
+
+class ChromeCommandBufferIPCTransport : public IPC::Listener,
+ public CommandBufferIPCTransport {
+ public:
+ static scoped_ptr<CommandBufferIPCTransport> Create();
+
+ ~ChromeCommandBufferIPCTransport() override;
+
+ base::WeakPtr<ChromeCommandBufferIPCTransport> AsWeakPtr();
+
+ int32_t route_id() const { return route_id_; }
+
+ void BindToService(ChromeGpuChannelHostIPCTransport* channel_transport);
+
+ // IPC::Listener implementation:
+ bool OnMessageReceived(const IPC::Message& message) override;
+ void OnChannelError() override;
+
+ // CommandBufferIPCTransport implementation.
+ scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override;
+ bool CreateImage(const CreateImageParams& params) override;
+ bool CreateStreamTexture(uint32_t client_texture_id,
+ int32_t* stream_id,
+ bool* succeeded) override;
+ bool CreateVideoDecoder(GpuVideoDecodeAcceleratorHostIPCTransport* transport,
+ const media::VideoDecodeAccelerator::Config& config,
+ bool* succeeded) override;
+ bool CreateVideoEncoder(GpuVideoEncodeAcceleratorHostIPCTransport* transport,
+ media::VideoPixelFormat input_format,
+ const gfx::Size& input_visible_size,
+ media::VideoCodecProfile output_profile,
+ uint32_t initial_bitrate,
+ bool* succeeded) override;
+ bool DestroyImage(int32_t id) override;
+ bool DestroyTransferBuffer(int32_t id) override;
+ uint64_t GetCommandBufferID() const override;
+ int32_t GetShareGroupID() const override;
+ bool Initialize(base::SharedMemoryHandle shared_state_handle,
+ bool* result,
+ gpu::Capabilities* capabilities) override;
+ bool ProduceFrontBuffer(const gpu::Mailbox& mailbox) override;
+ bool RegisterTransferBuffer(int32_t id,
+ base::SharedMemoryHandle transfer_buffer,
+ uint32_t size) override;
+ bool SetGetBuffer(int32_t shm_id) override;
+ void SetClient(CommandBufferIPCTransport::Client* client) override;
+ bool SignalQuery(uint32_t query, uint32_t signal_id) override;
+ bool SignalSyncToken(const gpu::SyncToken& sync_token,
+ uint32_t signal_id) override;
+ bool WaitForGetOffsetInRange(int32_t start,
+ int32_t end,
+ gpu::CommandBuffer::State* state) override;
+ bool WaitForTokenInRange(int32_t start,
+ int32_t end,
+ gpu::CommandBuffer::State* state) override;
+
+ private:
+ ChromeCommandBufferIPCTransport();
+
+ void InvalidGpuMessage();
+
+ // Send an IPC message over the GPU channel. This is private to fully
+ // encapsulate the channel; all callers of this function must explicitly
+ // verify that the context has not been lost.
+ bool Send(IPC::Message* msg);
+
+ // Message handlers:
+ void OnConsoleMessage(const CommandBufferConsoleMessage& message);
+ void OnDestroyed(gpu::error::ContextLostReason reason,
+ gpu::error::Error error);
+ void OnSignalAck(uint32_t id);
+ void OnSwapBuffersCompleted(const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::SwapResult result);
+ void OnUpdateState(const gpu::CommandBuffer::State& state);
+ void OnUpdateVSyncParameters(base::TimeTicks timebase,
+ base::TimeDelta interval);
+
+ ChromeGpuChannelHostIPCTransport* channel_transport_;
+ uint64_t command_buffer_id_;
+ int route_id_;
+ CommandBufferIPCTransport::Client* client_;
+ base::WeakPtrFactory<ChromeCommandBufferIPCTransport> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeCommandBufferIPCTransport);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_CLIENT_IPC_CHROME_CHROME_COMMAND_BUFFER_IPC_TRANSPORT_H_

Powered by Google App Engine
This is Rietveld 408576698