From 2573ce7d143bee9c1f88dac18b9213c03597daae Mon Sep 17 00:00:00 2001 From: lukasza Date: Tue, 16 Feb 2016 11:17:22 -0800 Subject: Introducing gpu::CommandBufferId as a distinct, IdType<...>-based type. This CL generalizes the pattern used by content::SavePackageId and cc::SurfaceId and puts it into //base/id_type.h. Using this pattern for gpu::CommandBufferId should hopefully help avoid bugs like the mixup fixed by https://crrev.com/365437. BUG=514815, 565545 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel TBR=wolenetz@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/1548443002 Cr-Commit-Position: refs/heads/master@{#375620} --- ppapi/proxy/ppapi_command_buffer_proxy.cc | 4 ++-- ppapi/proxy/ppapi_command_buffer_proxy.h | 7 ++++--- ppapi/proxy/ppapi_messages.h | 3 ++- ppapi/proxy/ppb_graphics_3d_proxy.cc | 19 ++++++++++--------- ppapi/proxy/ppb_graphics_3d_proxy.h | 5 +++-- ppapi/proxy/resource_creation_proxy.cc | 2 +- ppapi/proxy/resource_creation_proxy.h | 2 +- ppapi/thunk/DEPS | 1 + ppapi/thunk/resource_creation_api.h | 3 ++- 9 files changed, 26 insertions(+), 20 deletions(-) (limited to 'ppapi') diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc index 0a7524b..58ad59a 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.cc +++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc @@ -20,7 +20,7 @@ PpapiCommandBufferProxy::PpapiCommandBufferProxy( PluginDispatcher* dispatcher, const gpu::Capabilities& capabilities, const SerializedHandle& shared_state, - uint64_t command_buffer_id) + gpu::CommandBufferId command_buffer_id) : command_buffer_id_(command_buffer_id), capabilities_(capabilities), resource_(resource), @@ -195,7 +195,7 @@ gpu::CommandBufferNamespace PpapiCommandBufferProxy::GetNamespaceID() const { return gpu::CommandBufferNamespace::GPU_IO; } -uint64_t PpapiCommandBufferProxy::GetCommandBufferID() const { +gpu::CommandBufferId PpapiCommandBufferProxy::GetCommandBufferID() const { return command_buffer_id_; } diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.h b/ppapi/proxy/ppapi_command_buffer_proxy.h index 486e310..e0629bf 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.h +++ b/ppapi/proxy/ppapi_command_buffer_proxy.h @@ -14,6 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "gpu/command_buffer/client/gpu_control.h" #include "gpu/command_buffer/common/command_buffer.h" +#include "gpu/command_buffer/common/command_buffer_id.h" #include "gpu/command_buffer/common/command_buffer_shared.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_proxy_export.h" @@ -35,7 +36,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer, PluginDispatcher* dispatcher, const gpu::Capabilities& capabilities, const SerializedHandle& shared_state, - uint64_t command_buffer_id); + gpu::CommandBufferId command_buffer_id); ~PpapiCommandBufferProxy() override; // gpu::CommandBuffer implementation: @@ -67,7 +68,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer, bool IsGpuChannelLost() override; void EnsureWorkVisible() override; gpu::CommandBufferNamespace GetNamespaceID() const override; - uint64_t GetCommandBufferID() const override; + gpu::CommandBufferId GetCommandBufferID() const override; uint64_t GenerateFenceSyncRelease() override; bool IsFenceSyncRelease(uint64_t release) override; bool IsFenceSyncFlushed(uint64_t release) override; @@ -89,7 +90,7 @@ class PPAPI_PROXY_EXPORT PpapiCommandBufferProxy : public gpu::CommandBuffer, void FlushInternal(); - const uint64_t command_buffer_id_; + const gpu::CommandBufferId command_buffer_id_; gpu::Capabilities capabilities_; State last_state_; diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 19ed110..ebaeed9 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -17,6 +17,7 @@ #include "base/sync_socket.h" #include "build/build_config.h" #include "gpu/command_buffer/common/command_buffer.h" +#include "gpu/command_buffer/common/command_buffer_id.h" #include "gpu/command_buffer/common/mailbox.h" #include "gpu/command_buffer/common/sync_token.h" #include "gpu/ipc/gpu_command_buffer_traits.h" @@ -1015,7 +1016,7 @@ IPC_SYNC_MESSAGE_ROUTED3_4(PpapiHostMsg_PPBGraphics3D_Create, ppapi::HostResource /* result */, gpu::Capabilities /* capabilities */, ppapi::proxy::SerializedHandle /* shared_state */, - uint64_t /* command_buffer_id */) + gpu::CommandBufferId /* command_buffer_id */) IPC_SYNC_MESSAGE_ROUTED2_0(PpapiHostMsg_PPBGraphics3D_SetGetBuffer, ppapi::HostResource /* context */, int32_t /* transfer_buffer_id */) diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index 0ad81ad..9646df7 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -59,7 +59,7 @@ Graphics3D::~Graphics3D() { bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2, const gpu::Capabilities& capabilities, const SerializedHandle& shared_state, - uint64_t command_buffer_id) { + gpu::CommandBufferId command_buffer_id) { PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); if (!dispatcher) return false; @@ -177,7 +177,7 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( HostResource result; gpu::Capabilities capabilities; ppapi::proxy::SerializedHandle shared_state; - uint64_t command_buffer_id = 0; + gpu::CommandBufferId command_buffer_id; dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D, instance, share_host, attribs, &result, &capabilities, &shared_state, &command_buffer_id)); @@ -226,13 +226,14 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { } #if !defined(OS_NACL) -void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, - HostResource share_context, - const std::vector& attribs, - HostResource* result, - gpu::Capabilities* capabilities, - SerializedHandle* shared_state, - uint64_t* command_buffer_id) { +void PPB_Graphics3D_Proxy::OnMsgCreate( + PP_Instance instance, + HostResource share_context, + const std::vector& attribs, + HostResource* result, + gpu::Capabilities* capabilities, + SerializedHandle* shared_state, + gpu::CommandBufferId* command_buffer_id) { shared_state->set_null_shmem(); if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE || diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h index f6805da..e2b4dda 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.h +++ b/ppapi/proxy/ppb_graphics_3d_proxy.h @@ -11,6 +11,7 @@ #include "base/macros.h" #include "gpu/command_buffer/common/command_buffer.h" +#include "gpu/command_buffer/common/command_buffer_id.h" #include "ppapi/c/pp_graphics_3d.h" #include "ppapi/c/pp_instance.h" #include "ppapi/proxy/interface_proxy.h" @@ -41,7 +42,7 @@ class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared { bool Init(gpu::gles2::GLES2Implementation* share_gles2, const gpu::Capabilities& capabilities, const SerializedHandle& shared_state, - uint64_t command_buffer_id); + gpu::CommandBufferId command_buffer_id); // Graphics3DTrusted API. These are not implemented in the proxy. PP_Bool SetGetBuffer(int32_t shm_id) override; @@ -88,7 +89,7 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy { HostResource* result, gpu::Capabilities* capabilities, SerializedHandle* handle, - uint64_t* command_buffer_id); + gpu::CommandBufferId* command_buffer_id); void OnMsgSetGetBuffer(const HostResource& context, int32_t id); void OnMsgWaitForTokenInRange(const HostResource& context, int32_t start, diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index fa08843..31b2cfd 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -267,7 +267,7 @@ PP_Resource ResourceCreationProxy::CreateGraphics3DRaw( const int32_t* attrib_list, gpu::Capabilities* capabilities, base::SharedMemoryHandle* shared_state, - uint64_t* command_buffer_id) { + gpu::CommandBufferId* command_buffer_id) { // Not proxied. The raw creation function is used only in the implementation // of the proxy on the host side. return 0; diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index aad6bf3..498c93c 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -126,7 +126,7 @@ class ResourceCreationProxy : public InterfaceProxy, const int32_t* attrib_list, gpu::Capabilities* capabilities, base::SharedMemoryHandle* shared_state, - uint64_t* command_buffer_id) override; + gpu::CommandBufferId* command_buffer_id) override; PP_Resource CreateHostResolver(PP_Instance instance) override; PP_Resource CreateHostResolverPrivate(PP_Instance instance) override; PP_Resource CreateImageData(PP_Instance instance, diff --git a/ppapi/thunk/DEPS b/ppapi/thunk/DEPS index ded1323..0621249 100644 --- a/ppapi/thunk/DEPS +++ b/ppapi/thunk/DEPS @@ -1,6 +1,7 @@ include_rules = [ # For gpu::CommandBuffer::State "+gpu/command_buffer/common/command_buffer.h", + "+gpu/command_buffer/common/command_buffer_id.h", "+gpu/command_buffer/common/sync_token.h", "-ppapi/cpp", "-ppapi/proxy", diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index e9ca691..582d9a1 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -9,6 +9,7 @@ #include "base/memory/shared_memory.h" #include "build/build_config.h" +#include "gpu/command_buffer/common/command_buffer_id.h" #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/dev/ppb_file_chooser_dev.h" #include "ppapi/c/dev/ppb_truetype_font_dev.h" @@ -144,7 +145,7 @@ class ResourceCreationAPI { const int32_t* attrib_list, gpu::Capabilities* capabilities, base::SharedMemoryHandle* shared_state, - uint64_t* command_buffer_id) = 0; + gpu::CommandBufferId* command_buffer_id) = 0; virtual PP_Resource CreateHostResolver(PP_Instance instance) = 0; virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) = 0; virtual PP_Resource CreateImageData(PP_Instance instance, -- cgit v1.1