diff options
90 files changed, 1096 insertions, 1738 deletions
diff --git a/chrome/DEPS b/chrome/DEPS index d3f8343..e96251a 100644 --- a/chrome/DEPS +++ b/chrome/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+app", + "+gpu/command_buffer", "+net", "+printing", "+views", diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 8272579..d0dd9f3 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -493,6 +493,8 @@ 'common/chrome_plugin_lib.h', 'common/chrome_plugin_util.cc', 'common/chrome_plugin_util.h', + 'common/command_buffer_messages.h', + 'common/command_buffer_messages_internal.h', 'common/common_glue.cc', 'common/common_param_traits.cc', 'common/common_param_traits.h', @@ -771,6 +773,12 @@ 'third_party/wtl/include', ], },], + ['enable_gpu==1', { + 'sources': [ + 'plugin/command_buffer_stub.cc', + 'plugin/command_buffer_stub.h', + ], + },], ], }, { diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index ebe31de..a0c8e09 100755 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -152,6 +152,10 @@ 'dependencies': [ '../gpu/gpu.gyp:gpu_plugin', ], + 'sources': [ + 'renderer/command_buffer_proxy.cc', + 'renderer/command_buffer_proxy.h', + ], }], ['disable_nacl!=1', { 'dependencies': [ diff --git a/chrome/common/command_buffer_messages.h b/chrome/common/command_buffer_messages.h new file mode 100644 index 0000000..2c586d0 --- /dev/null +++ b/chrome/common/command_buffer_messages.h @@ -0,0 +1,11 @@ +// Copyright (c) 2009 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 CHROME_COMMON_COMMAND_BUFFER_MESSAGES_H_ +#define CHROME_COMMON_COMMAND_BUFFER_MESSAGES_H_ + +#define MESSAGES_INTERNAL_FILE "chrome/common/command_buffer_messages_internal.h" +#include "ipc/ipc_message_macros.h" + +#endif // CHROME_COMMON_COMMAND_BUFFER_MESSAGES_H_ diff --git a/chrome/common/command_buffer_messages_internal.h b/chrome/common/command_buffer_messages_internal.h new file mode 100644 index 0000000..ae28ecc --- /dev/null +++ b/chrome/common/command_buffer_messages_internal.h @@ -0,0 +1,65 @@ +// Copyright (c) 2009 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. + +#include "base/shared_memory.h" +#include "ipc/ipc_message_macros.h" + +IPC_BEGIN_MESSAGES(CommandBuffer) + // Initialize a command buffer with the given number of command entries. + // Returns the shared memory handle for the command buffer mapped to the + // calling process. + IPC_SYNC_MESSAGE_ROUTED1_1(CommandBufferMsg_Initialize, + int32 /* size */, + base::SharedMemoryHandle /* ring_buffer */) + + // Get the number of command entries in the command buffer. + IPC_SYNC_MESSAGE_ROUTED0_1(CommandBufferMsg_GetSize, + int32 /* size */) + + // Synchronize the put and get offsets of both processes. Caller passes its + // current put offset. Current get offset is returned. + IPC_SYNC_MESSAGE_ROUTED1_1(CommandBufferMsg_SyncOffsets, + int32 /* put_offset */, + int32 /* get_offset */) + + // Get the current get offset. + IPC_SYNC_MESSAGE_ROUTED0_1(CommandBufferMsg_GetGetOffset, + int32 /* get_offset */) + + // Get the current put offset. + IPC_SYNC_MESSAGE_ROUTED0_1(CommandBufferMsg_GetPutOffset, + int32 /* put_offset */) + + // Create a shared memory transfer buffer. Returns an id that can be used to + // identify the transfer buffer from a comment. + IPC_SYNC_MESSAGE_ROUTED1_1(CommandBufferMsg_CreateTransferBuffer, + int32 /* size */, + int32 /* id */) + + // Destroy a previously created transfer buffer. + IPC_SYNC_MESSAGE_ROUTED1_0(CommandBufferMsg_DestroyTransferBuffer, + int32 /* id */) + + // Get the shared memory handle for a transfer buffer mapped to the callers + // process. + IPC_SYNC_MESSAGE_ROUTED1_1(CommandBufferMsg_GetTransferBuffer, + int32 /* id */, + base::SharedMemoryHandle /* transfer_buffer */) + + // Get the most recently processed token. Used for implementing fences. + IPC_SYNC_MESSAGE_ROUTED0_1(CommandBufferMsg_GetToken, + int32 /* token */) + + // Get the current parse error. Calling this resets the parse error if it is + // recoverable. + // TODO(apatrick): Switch to the parse_error::ParseError enum now that NPAPI + // no longer limits to restricted set of datatypes. + IPC_SYNC_MESSAGE_ROUTED0_1(CommandBufferMsg_ResetParseError, + int32 /* parse_error */) + + // Get the current error status. + IPC_SYNC_MESSAGE_ROUTED0_1(CommandBufferMsg_GetErrorStatus, + bool /* status */) + +IPC_END_MESSAGES(CommandBuffer) diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index fb5dd77..c220b8b 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -267,6 +267,9 @@ IPC_BEGIN_MESSAGES(Plugin) IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_HandleURLRequestReply, PluginMsg_URLRequestReply_Params) + IPC_SYNC_MESSAGE_ROUTED0_1(PluginMsg_CreateCommandBuffer, + int /* route_id */) + IPC_MESSAGE_CONTROL1(PluginMsg_SignalModalDialogEvent, gfx::NativeViewId /* containing_window */) diff --git a/chrome/plugin/command_buffer_stub.cc b/chrome/plugin/command_buffer_stub.cc new file mode 100644 index 0000000..632e868 --- /dev/null +++ b/chrome/plugin/command_buffer_stub.cc @@ -0,0 +1,135 @@ +// Copyright (c) 2009 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. + +#include "base/process_util.h" +#include "base/shared_memory.h" +#include "chrome/common/command_buffer_messages.h" +#include "chrome/plugin/command_buffer_stub.h" +#include "chrome/plugin/plugin_channel.h" + +CommandBufferStub::CommandBufferStub(PluginChannel* channel, + gfx::NativeView view) + : channel_(channel), + view_(view) { + route_id_ = channel->GenerateRouteID(); + channel->AddRoute(route_id_, this, false); +} + +CommandBufferStub::~CommandBufferStub() { + channel_->RemoveRoute(route_id_); +} + +void CommandBufferStub::OnChannelError() { + NOTREACHED() << "CommandBufferService::OnChannelError called"; +} + +bool CommandBufferStub::Send(IPC::Message* message) { + if (!channel_) { + delete message; + return false; + } + + return channel_->Send(message); +} + +void CommandBufferStub::OnInitialize(int32 size, + base::SharedMemoryHandle* ring_buffer) { + DCHECK(!command_buffer_.get()); + + *ring_buffer = base::SharedMemory::NULLHandle(); + + // Assume service is responsible for duplicating the handle from the calling + // process. + base::ProcessHandle peer_handle; + if (base::OpenProcessHandle(channel_->peer_pid(), &peer_handle)) + return; + + command_buffer_.reset(new gpu::CommandBufferService); + + // Initialize the CommandBufferService and GPUProcessor. + base::SharedMemory* shared_memory = command_buffer_->Initialize(size); + if (shared_memory) { + processor_ = new gpu::GPUProcessor(command_buffer_.get()); + if (processor_->Initialize(view_)) { + command_buffer_->SetPutOffsetChangeCallback( + NewCallback(processor_.get(), + &gpu::GPUProcessor::ProcessCommands)); + shared_memory->ShareToProcess(peer_handle, ring_buffer); + } else { + processor_ = NULL; + command_buffer_.reset(); + } + } + + base::CloseProcessHandle(peer_handle); +} + +void CommandBufferStub::OnSyncOffsets(int32 put_offset, int32* get_offset) { + *get_offset = command_buffer_->SyncOffsets(put_offset); +} + +void CommandBufferStub::OnGetGetOffset(int32* get_offset) { + *get_offset = command_buffer_->GetGetOffset(); +} + +void CommandBufferStub::OnGetPutOffset(int32* put_offset) { + *put_offset = command_buffer_->GetPutOffset(); +} + +void CommandBufferStub::OnCreateTransferBuffer(int32 size, int32* id) { + *id = command_buffer_->CreateTransferBuffer(size); +} + +void CommandBufferStub::OnDestroyTransferBuffer(int32 id) { + command_buffer_->DestroyTransferBuffer(id); +} + +void CommandBufferStub::OnGetTransferBuffer(int32 id, + base::SharedMemoryHandle* transfer_buffer) { + *transfer_buffer = 0; + + // Assume service is responsible for duplicating the handle to the calling + // process. + base::ProcessHandle peer_handle; + if (base::OpenProcessHandle(channel_->peer_pid(), &peer_handle)) + return; + + base::SharedMemory* shared_memory = command_buffer_->GetTransferBuffer(id); + if (shared_memory) { + shared_memory->ShareToProcess(peer_handle, transfer_buffer); + } + + base::CloseProcessHandle(peer_handle); +} + +void CommandBufferStub::OnGetToken(int32* token) { + *token = command_buffer_->GetToken(); +} + +void CommandBufferStub::OnResetParseError(int32* parse_error) { + *parse_error = command_buffer_->ResetParseError(); +} + +void CommandBufferStub::OnGetErrorStatus(bool* error_status) { + *error_status = command_buffer_->GetErrorStatus(); +} + +void CommandBufferStub::OnMessageReceived(const IPC::Message& msg) { + IPC_BEGIN_MESSAGE_MAP(CommandBufferStub, msg) + IPC_MESSAGE_HANDLER(CommandBufferMsg_Initialize, OnInitialize); + IPC_MESSAGE_HANDLER(CommandBufferMsg_SyncOffsets, OnSyncOffsets); + IPC_MESSAGE_HANDLER(CommandBufferMsg_GetGetOffset, OnGetGetOffset); + IPC_MESSAGE_HANDLER(CommandBufferMsg_GetPutOffset, OnGetPutOffset); + IPC_MESSAGE_HANDLER(CommandBufferMsg_CreateTransferBuffer, + OnCreateTransferBuffer); + IPC_MESSAGE_HANDLER(CommandBufferMsg_DestroyTransferBuffer, + OnDestroyTransferBuffer); + IPC_MESSAGE_HANDLER(CommandBufferMsg_GetTransferBuffer, + OnGetTransferBuffer); + IPC_MESSAGE_HANDLER(CommandBufferMsg_GetToken, OnGetToken); + IPC_MESSAGE_HANDLER(CommandBufferMsg_ResetParseError, OnResetParseError); + IPC_MESSAGE_HANDLER(CommandBufferMsg_GetErrorStatus, OnGetErrorStatus); + IPC_MESSAGE_UNHANDLED_ERROR() + IPC_END_MESSAGE_MAP() +} diff --git a/chrome/plugin/command_buffer_stub.h b/chrome/plugin/command_buffer_stub.h new file mode 100644 index 0000000..2a167c3 --- /dev/null +++ b/chrome/plugin/command_buffer_stub.h @@ -0,0 +1,60 @@ +// Copyright (c) 2009 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 CHROME_PLUGIN_COMMAND_BUFFER_STUB_H_ +#define CHROME_PLUGIN_COMMAND_BUFFER_STUB_H_ + +#if defined(ENABLE_GPU) + +#include "app/gfx/native_widget_types.h" +#include "base/ref_counted.h" +#include "gpu/command_buffer/service/command_buffer_service.h" +#include "gpu/command_buffer/service/gpu_processor.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_message.h" + +class PluginChannel; + +class CommandBufferService; + +class CommandBufferStub : public IPC::Channel::Listener, + public IPC::Message::Sender { + public: + CommandBufferStub(PluginChannel* channel, gfx::NativeView view); + + virtual ~CommandBufferStub(); + + // IPC::Channel::Listener implementation: + virtual void OnMessageReceived(const IPC::Message& message); + virtual void OnChannelError(); + + // IPC::Message::Sender implementation: + virtual bool Send(IPC::Message* msg); + + int route_id() const { return route_id_; } + + private: + // Message handlers: + void OnInitialize(int32 size, base::SharedMemoryHandle* ring_buffer); + void OnSyncOffsets(int32 put_offset, int32* get_offset); + void OnGetGetOffset(int32* get_offset); + void OnGetPutOffset(int32* put_offset); + void OnCreateTransferBuffer(int32 size, int32* id); + void OnDestroyTransferBuffer(int32 id); + void OnGetTransferBuffer(int32 id, + base::SharedMemoryHandle* transfer_buffer); + void OnGetToken(int32* token); + void OnResetParseError(int32* parse_error); + void OnGetErrorStatus(bool* error_status); + + scoped_refptr<PluginChannel> channel_; + gfx::NativeView view_; + int route_id_; + scoped_ptr<gpu::CommandBufferService> command_buffer_; + scoped_refptr<gpu::GPUProcessor> processor_; +}; + +#endif // ENABLE_GPU + +#endif // CHROME_PLUGIN_COMMAND_BUFFER_STUB_H_ diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index d0fe483..c6bd74f 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -130,6 +130,8 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginMsg_InstallMissingPlugin, OnInstallMissingPlugin) IPC_MESSAGE_HANDLER(PluginMsg_HandleURLRequestReply, OnHandleURLRequestReply) + IPC_MESSAGE_HANDLER(PluginMsg_CreateCommandBuffer, + OnCreateCommandBuffer) IPC_MESSAGE_UNHANDLED_ERROR() IPC_END_MESSAGE_MAP() @@ -302,8 +304,9 @@ void WebPluginDelegateStub::OnUpdateGeometry( ); } -void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, - intptr_t* npobject_ptr) { +void WebPluginDelegateStub::OnGetPluginScriptableObject( + int* route_id, + intptr_t* npobject_ptr) { NPObject* object = delegate_->GetPluginScriptableObject(); if (!object) { *route_id = MSG_ROUTING_NONE; @@ -357,6 +360,16 @@ void WebPluginDelegateStub::OnInstallMissingPlugin() { delegate_->InstallMissingPlugin(); } +void WebPluginDelegateStub::OnCreateCommandBuffer(int* route_id) { +#if defined(ENABLE_GPU) + command_buffer_stub_.reset(new CommandBufferStub( + static_cast<PluginChannel*>(PluginChannelBase::GetCurrentChannel()), + delegate_->windowed_handle())); + + *route_id = command_buffer_stub_->route_id(); +#endif +} + void WebPluginDelegateStub::CreateSharedBuffer( size_t size, base::SharedMemory* shared_buf, diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index 79b36bf..d5d3ab0 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -12,6 +12,7 @@ #include "base/shared_memory.h" #include "base/task.h" #include "chrome/common/transport_dib.h" +#include "chrome/plugin/command_buffer_stub.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_channel.h" #include "third_party/npapi/bindings/npapi.h" @@ -93,6 +94,8 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, void OnHandleURLRequestReply( const PluginMsg_URLRequestReply_Params& params); + void OnCreateCommandBuffer(int* route_id); + void CreateSharedBuffer(size_t size, base::SharedMemory* shared_buf, base::SharedMemoryHandle* remote_handle); @@ -109,6 +112,12 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, // The url of the main frame hosting the plugin. GURL page_url_; +#if defined(ENABLE_GPU) + // If this is the GPU plugin, the stub object that forwards to the + // command buffer service. + scoped_ptr<CommandBufferStub> command_buffer_stub_; +#endif + DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub); }; diff --git a/chrome/renderer/command_buffer_proxy.cc b/chrome/renderer/command_buffer_proxy.cc new file mode 100644 index 0000000..262bb8e --- /dev/null +++ b/chrome/renderer/command_buffer_proxy.cc @@ -0,0 +1,173 @@ +// Copyright (c) 2009 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. + +#include "base/logging.h" +#include "base/process_util.h" +#include "chrome/common/command_buffer_messages.h" +#include "chrome/common/plugin_messages.h" +#include "chrome/renderer/command_buffer_proxy.h" +#include "chrome/renderer/plugin_channel_host.h" + +CommandBufferProxy::CommandBufferProxy( + PluginChannelHost* channel, + int route_id) + : size_(0), + channel_(channel), + route_id_(route_id) { +} + +CommandBufferProxy::~CommandBufferProxy() { +} + +bool CommandBufferProxy::Send(IPC::Message* msg) { + if (channel_) + return channel_->Send(msg); + + // Callee takes ownership of message, regardless of whether Send is + // successful. See IPC::Message::Sender. + delete msg; + return false; +} + +base::SharedMemory* CommandBufferProxy::Initialize(int32 size) { + DCHECK(!ring_buffer_.get()); + + // Initialize the service. Assuming we are in the renderer process, the GPU + // process is responsible for duplicating the handle. This might not be true + // for NaCl. + base::SharedMemoryHandle handle; + if (Send(new CommandBufferMsg_Initialize(route_id_, size, &handle)) && + base::SharedMemory::IsHandleValid(handle)) { + ring_buffer_.reset(new base::SharedMemory(handle, false)); + if (ring_buffer_->Map(size * sizeof(int32))) { + size_ = size; + return ring_buffer_.get(); + } + + ring_buffer_.reset(); + } + + return NULL; +} + +base::SharedMemory* CommandBufferProxy::GetRingBuffer() { + // Return locally cached ring buffer. + return ring_buffer_.get(); +} + +int32 CommandBufferProxy::GetSize() { + // Return locally cached size. + return size_; +} + +int32 CommandBufferProxy::SyncOffsets(int32 put_offset) { + int32 get_offset; + if (Send(new CommandBufferMsg_SyncOffsets(route_id_, + put_offset, + &get_offset))) + return get_offset; + + return -1; +} + +int32 CommandBufferProxy::GetGetOffset() { + int32 get_offset; + if (Send(new CommandBufferMsg_GetGetOffset(route_id_, &get_offset))) + return get_offset; + + return -1; +} + +void CommandBufferProxy::SetGetOffset(int32 get_offset) { + // Not implemented in proxy. + NOTREACHED(); +} + +int32 CommandBufferProxy::GetPutOffset() { + int put_offset; + if (Send(new CommandBufferMsg_GetPutOffset(route_id_, &put_offset))) + return put_offset; + + return -1; +} + +void CommandBufferProxy::SetPutOffsetChangeCallback(Callback0::Type* callback) { + // Not implemented in proxy. + NOTREACHED(); +} + +int32 CommandBufferProxy::CreateTransferBuffer(size_t size) { + int32 id; + if (Send(new CommandBufferMsg_CreateTransferBuffer(route_id_, size, &id))) + return id; + + return -1; +} + +void CommandBufferProxy::DestroyTransferBuffer(int32 id) { + // Remove the transfer buffer from the client side4 cache. + transfer_buffers_.erase(id); + + Send(new CommandBufferMsg_DestroyTransferBuffer(route_id_, id)); +} + +base::SharedMemory* CommandBufferProxy::GetTransferBuffer(int32 id) { + // Check local cache to see if there is already a client side shared memory + // object for this id. + TransferBufferMap::iterator it = transfer_buffers_.find(id); + if (it != transfer_buffers_.end()) + return it->second.get(); + + // Assuming we are in the renderer process, the service is responsible for + // duplicating the handle. This might not be true for NaCl. + base::SharedMemoryHandle handle; + if (!Send(new CommandBufferMsg_GetTransferBuffer(route_id_, id, &handle))) + return NULL; + + // Cache the transfer buffer shared memory object client side. + base::SharedMemory* transfer_buffer = + new base::SharedMemory(handle, false, base::GetCurrentProcessHandle()); + transfer_buffers_[id].reset(transfer_buffer); + + return transfer_buffer; +} + +int32 CommandBufferProxy::GetToken() { + int32 token; + if (Send(new CommandBufferMsg_GetToken(route_id_, &token))) + return token; + + return -1; +} + +void CommandBufferProxy::SetToken(int32 token) { + // Not implemented in proxy. + NOTREACHED(); +} + +int32 CommandBufferProxy::ResetParseError() { + int32 parse_error; + if (Send(new CommandBufferMsg_ResetParseError(route_id_, &parse_error))) + return parse_error; + + return -1; +} + +void CommandBufferProxy::SetParseError(int32 parse_error) { + // Not implemented in proxy. + NOTREACHED(); +} + +bool CommandBufferProxy::GetErrorStatus() { + bool status; + if (Send(new CommandBufferMsg_GetErrorStatus(route_id_, &status))) + return status; + + return true; +} + +void CommandBufferProxy::RaiseErrorStatus() { + // Not implemented in proxy. + NOTREACHED(); +} diff --git a/chrome/renderer/command_buffer_proxy.h b/chrome/renderer/command_buffer_proxy.h new file mode 100644 index 0000000..5abfead --- /dev/null +++ b/chrome/renderer/command_buffer_proxy.h @@ -0,0 +1,71 @@ +// Copyright (c) 2009 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 CHROME_RENDERER_COMMAND_BUFFER_PROXY_H_ +#define CHROME_RENDERER_COMMAND_BUFFER_PROXY_H_ + +#if defined(ENABLE_GPU) + +#include <map> + +#include "base/linked_ptr.h" +#include "base/ref_counted.h" +#include "base/scoped_ptr.h" +#include "base/shared_memory.h" +#include "gpu/command_buffer/common/command_buffer.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_message.h" + +class PluginChannelHost; + +// Client side proxy that forwards messages synchronously to a +// CommandBufferStub. +class CommandBufferProxy : public gpu::CommandBuffer, + public IPC::Message::Sender { + public: + explicit CommandBufferProxy( + PluginChannelHost* channel, + int route_id); + virtual ~CommandBufferProxy(); + + // IPC::Message::Sender implementation: + virtual bool Send(IPC::Message* msg); + + // CommandBuffer implementation: + virtual base::SharedMemory* Initialize(int32 size); + virtual base::SharedMemory* GetRingBuffer(); + virtual int32 GetSize(); + virtual int32 SyncOffsets(int32 put_offset); + virtual int32 GetGetOffset(); + virtual void SetGetOffset(int32 get_offset); + virtual int32 GetPutOffset(); + virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); + virtual int32 CreateTransferBuffer(size_t size); + virtual void DestroyTransferBuffer(int32 id); + virtual base::SharedMemory* GetTransferBuffer(int32 handle); + virtual int32 GetToken(); + virtual void SetToken(int32 token); + virtual int32 ResetParseError(); + virtual void SetParseError(int32 parse_error); + virtual bool GetErrorStatus(); + virtual void RaiseErrorStatus(); + + private: + // As with the service, the client takes ownership of the ring buffer. + int32 size_; + scoped_ptr<base::SharedMemory> ring_buffer_; + + // Local cache of id to transfer buffer mapping. + typedef std::map<int32, linked_ptr<base::SharedMemory> > TransferBufferMap; + TransferBufferMap transfer_buffers_; + + scoped_refptr<PluginChannelHost> channel_; + int route_id_; + + DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy); +}; + +#endif // ENABLE_GPU + +#endif // CHROME_RENDERER_COMMAND_BUFFER_PROXY_H_ diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 66aa755..78f3dfe 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -27,6 +27,7 @@ #include "chrome/plugin/npobject_proxy.h" #include "chrome/plugin/npobject_stub.h" #include "chrome/plugin/npobject_util.h" +#include "chrome/renderer/command_buffer_proxy.h" #include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_view.h" #include "grit/generated_resources.h" @@ -1141,6 +1142,20 @@ WebPluginDelegateProxy::CreateResourceClient( return proxy; } +CommandBufferProxy* WebPluginDelegateProxy::CreateCommandBuffer() { +#if defined(ENABLE_GPU) + int command_buffer_id; + if (!Send(new PluginMsg_CreateCommandBuffer(instance_id_, + &command_buffer_id))) { + return NULL; + } + + return new CommandBufferProxy(channel_host_, command_buffer_id); +#else + return NULL; +#endif +} + void WebPluginDelegateProxy::OnCancelDocumentLoad() { plugin_->CancelDocumentLoad(); } diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index f01ae092..c884c9f 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -16,6 +16,7 @@ #include "chrome/common/transport_dib.h" #include "chrome/renderer/plugin_channel_host.h" #include "googleurl/src/gurl.h" +#include "gpu/command_buffer/common/command_buffer.h" #include "ipc/ipc_message.h" #include "skia/ext/platform_canvas.h" #include "webkit/glue/webplugin.h" @@ -27,6 +28,7 @@ #include "base/linked_ptr.h" #endif +class CommandBufferProxy; struct NPObject; class NPObjectStub; struct NPVariant_Param; @@ -97,6 +99,8 @@ class WebPluginDelegateProxy intptr_t notify_data, intptr_t existing_stream); + CommandBufferProxy* CreateCommandBuffer(); + protected: template<class WebPluginDelegateProxy> friend class DeleteTask; ~WebPluginDelegateProxy(); @@ -1,4 +1,7 @@ include_rules = [ "+webkit/glue/plugins", "+third_party/npapi", + + # For gfx::PluginWindowHandle + "+app/gfx", ] diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index 5c26709..09e0249 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -17,7 +17,7 @@ _SIZE_OF_COMMAND_HEADER = 4 _FIRST_SPECIFIC_COMMAND_ID = 256 _LICENSE = """ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -418,7 +418,7 @@ class TypeHandler(object): func.WriteCmdInit(file) func.WriteCmdSet(file) - file.Write(" command_buffer::CommandHeader header;\n") + file.Write(" gpu::CommandHeader header;\n") args = func.GetCmdArgs() for arg in args: file.Write(" %s %s;\n" % (arg.cmd_type, arg.name)) @@ -2417,14 +2417,14 @@ class GLGenerator(object): def WriteNamespaceOpen(self, file): """Writes the code for the namespace.""" - file.Write("namespace command_buffer {\n") + file.Write("namespace gpu {\n") file.Write("namespace gles2 {\n") file.Write("\n") def WriteNamespaceClose(self, file): """Writes the code to close the namespace.""" file.Write("} // namespace gles2\n") - file.Write("} // namespace command_buffer\n") + file.Write("} // namespace gpu\n") file.Write("\n") def MakeGuard(self, filename): diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc index 67227fb..fee11ae 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper.cc @@ -35,9 +35,9 @@ #include "gpu/command_buffer/client/cmd_buffer_helper.h" #include "gpu/command_buffer/common/command_buffer.h" -namespace command_buffer { +namespace gpu { -using command_buffer::CommandBuffer; +using gpu::CommandBuffer; CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) : command_buffer_(command_buffer), @@ -188,4 +188,4 @@ parse_error::ParseError CommandBufferHelper::GetParseError() { return static_cast<parse_error::ParseError>(parse_error); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h index 7cac568..831e994 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper.h +++ b/gpu/command_buffer/client/cmd_buffer_helper.h @@ -32,15 +32,15 @@ // This file contains the command buffer helper class. -#ifndef GPU_COMMAND_BUFFER_CLIENT_CROSS_CMD_BUFFER_HELPER_H_ -#define GPU_COMMAND_BUFFER_CLIENT_CROSS_CMD_BUFFER_HELPER_H_ +#ifndef GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ +#define GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ #include "gpu/command_buffer/common/logging.h" #include "gpu/command_buffer/common/constants.h" #include "gpu/command_buffer/common/cmd_buffer_common.h" #include "gpu/command_buffer/common/command_buffer.h" -namespace command_buffer { +namespace gpu { // Command buffer helper class. This class simplifies ring buffer management: // it will allocate the buffer, give it to the buffer interface, and let the @@ -59,7 +59,7 @@ namespace command_buffer { // // commands have been executed. class CommandBufferHelper { public: - explicit CommandBufferHelper(command_buffer::CommandBuffer* command_buffer); + explicit CommandBufferHelper(gpu::CommandBuffer* command_buffer); virtual ~CommandBufferHelper(); bool Initialize(); @@ -198,7 +198,7 @@ class CommandBufferHelper { return (get_ - put_ - 1 + entry_count_) % entry_count_; } - command_buffer::CommandBuffer* command_buffer_; + gpu::CommandBuffer* command_buffer_; ::base::SharedMemory* ring_buffer_; CommandBufferEntry *entries_; int32 entry_count_; @@ -211,6 +211,6 @@ class CommandBufferHelper { DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper); }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_CLIENT_CROSS_CMD_BUFFER_HELPER_H_ +#endif // GPU_COMMAND_BUFFER_CLIENT_CMD_BUFFER_HELPER_H_ diff --git a/gpu/command_buffer/client/cmd_buffer_helper_test.cc b/gpu/command_buffer/client/cmd_buffer_helper_test.cc index 912df89..3cdc634 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper_test.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper_test.cc @@ -40,10 +40,10 @@ #include "gpu/command_buffer/service/gpu_processor.h" #include "testing/gtest/include/gtest/gtest.h" -namespace command_buffer { +namespace gpu { -using command_buffer::CommandBufferService; -using command_buffer::GPUProcessor; +using gpu::CommandBufferService; +using gpu::GPUProcessor; using testing::Return; using testing::Mock; using testing::Truly; @@ -53,7 +53,8 @@ using testing::Invoke; using testing::_; const int32 kNumCommandEntries = 10; -const int32 kCommandBufferSizeBytes = kNumCommandEntries * sizeof(int32); +const int32 kCommandBufferSizeBytes = + kNumCommandEntries * sizeof(CommandBufferEntry); // Test fixture for CommandBufferHelper test - Creates a CommandBufferHelper, // using a CommandBufferEngine with a mock AsyncAPIInterface for its interface @@ -67,14 +68,12 @@ class CommandBufferHelperTest : public testing::Test { EXPECT_CALL(*api_mock_, DoCommand(0, 0, _)) .WillRepeatedly(Return(parse_error::kParseNoError)); - base::SharedMemory* ring_buffer = new base::SharedMemory; - ring_buffer->Create(std::wstring(), false, false, kCommandBufferSizeBytes); - ring_buffer->Map(1024); - command_buffer_.reset(new CommandBufferService); - command_buffer_->Initialize(ring_buffer); + base::SharedMemory* ring_buffer = command_buffer_->Initialize( + kNumCommandEntries); + - parser_ = new command_buffer::CommandParser(ring_buffer->memory(), + parser_ = new gpu::CommandParser(ring_buffer->memory(), kCommandBufferSizeBytes, 0, kCommandBufferSizeBytes, @@ -140,7 +139,7 @@ class CommandBufferHelperTest : public testing::Test { MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; scoped_ptr<CommandBufferService> command_buffer_; - command_buffer::CommandParser* parser_; + gpu::CommandParser* parser_; scoped_ptr<CommandBufferHelper> helper_; Sequence sequence_; }; @@ -295,4 +294,4 @@ TEST_F(CommandBufferHelperTest, TestToken) { EXPECT_EQ(parse_error::kParseNoError, command_buffer_->ResetParseError()); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/fenced_allocator.cc b/gpu/command_buffer/client/fenced_allocator.cc index 810feb5..27634f0 100644 --- a/gpu/command_buffer/client/fenced_allocator.cc +++ b/gpu/command_buffer/client/fenced_allocator.cc @@ -36,7 +36,7 @@ #include <algorithm> #include "gpu/command_buffer/client/cmd_buffer_helper.h" -namespace command_buffer { +namespace gpu { #ifndef COMPILER_MSVC const FencedAllocator::Offset FencedAllocator::kInvalidOffset; @@ -211,4 +211,4 @@ FencedAllocator::BlockIndex FencedAllocator::GetBlockByOffset(Offset offset) { return it-blocks_.begin(); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/fenced_allocator.h b/gpu/command_buffer/client/fenced_allocator.h index 72bba33..f0faf37 100644 --- a/gpu/command_buffer/client/fenced_allocator.h +++ b/gpu/command_buffer/client/fenced_allocator.h @@ -32,14 +32,14 @@ // This file contains the definition of the FencedAllocator class. -#ifndef GPU_COMMAND_BUFFER_CLIENT_CROSS_FENCED_ALLOCATOR_H_ -#define GPU_COMMAND_BUFFER_CLIENT_CROSS_FENCED_ALLOCATOR_H_ +#ifndef GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ +#define GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ #include <vector> #include "base/basictypes.h" #include "gpu/command_buffer/common/logging.h" -namespace command_buffer { +namespace gpu { class CommandBufferHelper; // FencedAllocator provides a mechanism to manage allocations within a fixed @@ -156,7 +156,7 @@ class FencedAllocator { // the other functions that return a block index). Offset AllocInBlock(BlockIndex index, unsigned int size); - command_buffer::CommandBufferHelper *helper_; + gpu::CommandBufferHelper *helper_; Container blocks_; DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocator); @@ -261,6 +261,6 @@ class FencedAllocatorWrapper { DISALLOW_IMPLICIT_CONSTRUCTORS(FencedAllocatorWrapper); }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_CLIENT_CROSS_FENCED_ALLOCATOR_H_ +#endif // GPU_COMMAND_BUFFER_CLIENT_FENCED_ALLOCATOR_H_ diff --git a/gpu/command_buffer/client/fenced_allocator_test.cc b/gpu/command_buffer/client/fenced_allocator_test.cc index f6bde77..2f5c917 100644 --- a/gpu/command_buffer/client/fenced_allocator_test.cc +++ b/gpu/command_buffer/client/fenced_allocator_test.cc @@ -42,10 +42,10 @@ #include "gpu/command_buffer/service/gpu_processor.h" #include "testing/gtest/include/gtest/gtest.h" -namespace command_buffer { +namespace gpu { -using command_buffer::CommandBufferService; -using command_buffer::GPUProcessor; +using gpu::CommandBufferService; +using gpu::GPUProcessor; using testing::Return; using testing::Mock; using testing::Truly; @@ -69,14 +69,11 @@ class BaseFencedAllocatorTest : public testing::Test { .WillRepeatedly(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), Return(parse_error::kParseNoError))); - base::SharedMemory* ring_buffer = new base::SharedMemory; - ring_buffer->Create(std::wstring(), false, false, 1024); - ring_buffer->Map(1024); - command_buffer_.reset(new CommandBufferService); - command_buffer_->Initialize(ring_buffer); + base::SharedMemory* ring_buffer = command_buffer_->Initialize( + kBufferSize / sizeof(CommandBufferEntry)); - parser_ = new command_buffer::CommandParser(ring_buffer->memory(), + parser_ = new gpu::CommandParser(ring_buffer->memory(), kBufferSize, 0, kBufferSize, @@ -102,7 +99,7 @@ class BaseFencedAllocatorTest : public testing::Test { MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; scoped_ptr<CommandBufferService> command_buffer_; - command_buffer::CommandParser* parser_; + gpu::CommandParser* parser_; scoped_ptr<CommandBufferHelper> helper_; }; @@ -493,4 +490,4 @@ TEST_F(FencedAllocatorWrapperTest, TestFreePendingToken) { } } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/gles2_cmd_helper.cc b/gpu/command_buffer/client/gles2_cmd_helper.cc index 1dff914..bc6d13f 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper.cc +++ b/gpu/command_buffer/client/gles2_cmd_helper.cc @@ -4,11 +4,11 @@ #include "gpu/command_buffer/client/gles2_cmd_helper.h" -namespace command_buffer { +namespace gpu { // Currently this is a place holder. -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/gles2_cmd_helper.h b/gpu/command_buffer/client/gles2_cmd_helper.h index fbb1ce1..7b26605 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper.h +++ b/gpu/command_buffer/client/gles2_cmd_helper.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H -#define GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H_ +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H_ #include "gpu/command_buffer/client/cmd_buffer_helper.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" -namespace command_buffer { +namespace gpu { namespace gles2 { // A class that helps write GL command buffers. class GLES2CmdHelper : public CommandBufferHelper { public: - explicit GLES2CmdHelper(command_buffer::CommandBuffer* command_buffer) + explicit GLES2CmdHelper(gpu::CommandBuffer* command_buffer) : CommandBufferHelper(command_buffer) { } virtual ~GLES2CmdHelper() { @@ -70,7 +70,7 @@ class GLES2CmdHelper : public CommandBufferHelper { }; } // namespace gles2 -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_H_ diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc index 86f31b5..74d9a7e 100644 --- a/gpu/command_buffer/client/gles2_demo.cc +++ b/gpu/command_buffer/client/gles2_demo.cc @@ -25,10 +25,10 @@ #include "gpu/command_buffer/client/gles2_demo_cc.h" using base::SharedMemory; -using command_buffer::GPUProcessor; -using command_buffer::CommandBufferService; -using command_buffer::gles2::GLES2CmdHelper; -using command_buffer::gles2::GLES2Implementation; +using gpu::GPUProcessor; +using gpu::CommandBufferService; +using gpu::gles2::GLES2CmdHelper; +using gpu::gles2::GLES2Implementation; class GLES2Demo { public: @@ -44,17 +44,8 @@ GLES2Demo::GLES2Demo() { } bool GLES2Demo::Setup(void* hwnd, int32 size) { - scoped_ptr<SharedMemory> ring_buffer(new SharedMemory); - if (!ring_buffer->Create(std::wstring(), false, false, size)) { - return NULL; - } - - if (!ring_buffer->Map(size)) { - return NULL; - } - scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); - if (!command_buffer->Initialize(ring_buffer.release())) { + if (!command_buffer->Initialize(size)) { return NULL; } diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 0280d94..dddc705 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -9,7 +9,7 @@ #include "gpu/command_buffer/client/gles2_implementation_gen.h" #include "gpu/command_buffer/common/gles2_cmd_utils.h" -namespace command_buffer { +namespace gpu { namespace gles2 { // A 32-bit and 64-bit compatible way of converting a pointer to a GLuint. @@ -253,4 +253,4 @@ void GLES2Implementation::TexSubImage2D( } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/gles2_implementation.h b/gpu/command_buffer/client/gles2_implementation.h index bfd0d32..0557556 100644 --- a/gpu/command_buffer/client/gles2_implementation.h +++ b/gpu/command_buffer/client/gles2_implementation.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H -#define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ #include "base/shared_memory.h" #include "gpu/command_buffer/common/gles2_cmd_utils.h" @@ -11,7 +11,7 @@ #include "gpu/command_buffer/client/id_allocator.h" #include "gpu/command_buffer/client/fenced_allocator.h" -namespace command_buffer { +namespace gpu { namespace gles2 { // This class emulates GLES2 over command buffers. It can be used by a client @@ -87,7 +87,7 @@ class GLES2Implementation { } // namespace gles2 -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_H_ diff --git a/gpu/command_buffer/client/gles2_implementation_gen.h b/gpu/command_buffer/client/gles2_implementation_gen.h index d385f8f..0926960 100644 --- a/gpu/command_buffer/client/gles2_implementation_gen.h +++ b/gpu/command_buffer/client/gles2_implementation_gen.h @@ -1,5 +1,5 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -8,7 +8,7 @@ #include "gpu/command_buffer/client/gles2_implementation.h" -namespace command_buffer { +namespace gpu { namespace gles2 { GLenum GLES2Implementation::CheckFramebufferStatus(GLenum target) { @@ -68,5 +68,5 @@ void GLES2Implementation::ReadPixels( } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/gles2_lib.cc b/gpu/command_buffer/client/gles2_lib.cc index 681f7ad..04813d4 100644 --- a/gpu/command_buffer/client/gles2_lib.cc +++ b/gpu/command_buffer/client/gles2_lib.cc @@ -6,7 +6,7 @@ namespace gles2 { -::command_buffer::gles2::GLES2Implementation* g_gl_impl; +::gpu::gles2::GLES2Implementation* g_gl_impl; bool InitGLES2Lib() { // TODO(gman): Encapulate initalizing the GLES2 library for client apps. diff --git a/gpu/command_buffer/client/gles2_lib.h b/gpu/command_buffer/client/gles2_lib.h index 589d2050..c642582 100644 --- a/gpu/command_buffer/client/gles2_lib.h +++ b/gpu/command_buffer/client/gles2_lib.h @@ -4,16 +4,16 @@ // These functions emluate GLES2 over command buffers. -#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H -#define GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H_ +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H_ #include "gpu/command_buffer/client/gles2_implementation.h" namespace gles2 { -extern ::command_buffer::gles2::GLES2Implementation* g_gl_impl; +extern ::gpu::gles2::GLES2Implementation* g_gl_impl; -inline ::command_buffer::gles2::GLES2Implementation* GetGLContext() { +inline ::gpu::gles2::GLES2Implementation* GetGLContext() { return g_gl_impl; } @@ -22,5 +22,5 @@ bool InitGLES2Lib(); } // namespace gles2 -#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_LIB_H_ diff --git a/gpu/command_buffer/client/id_allocator.cc b/gpu/command_buffer/client/id_allocator.cc index 49104e5..12e4f75 100644 --- a/gpu/command_buffer/client/id_allocator.cc +++ b/gpu/command_buffer/client/id_allocator.cc @@ -34,7 +34,7 @@ #include "gpu/command_buffer/client/id_allocator.h" -namespace command_buffer { +namespace gpu { IdAllocator::IdAllocator() : bitmap_(1) { bitmap_[0] = 0; } @@ -82,4 +82,4 @@ bool IdAllocator::GetBit(unsigned int bit) const { return (bitmap_[bit / kBitsPerUint32] & mask) != 0; } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/client/id_allocator.h b/gpu/command_buffer/client/id_allocator.h index b2b14b9..52c448c2 100644 --- a/gpu/command_buffer/client/id_allocator.h +++ b/gpu/command_buffer/client/id_allocator.h @@ -32,15 +32,15 @@ // This file contains the definition of the IdAllocator class. -#ifndef GPU_COMMAND_BUFFER_CLIENT_CROSS_ID_ALLOCATOR_H_ -#define GPU_COMMAND_BUFFER_CLIENT_CROSS_ID_ALLOCATOR_H_ +#ifndef GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ +#define GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ #include <vector> #include "base/basictypes.h" #include "gpu/command_buffer/common/types.h" #include "gpu/command_buffer/common/resource.h" -namespace command_buffer { +namespace gpu { // A class to manage the allocation of resource IDs. It uses a bitfield stored // into a vector of unsigned ints. @@ -49,19 +49,19 @@ class IdAllocator { IdAllocator(); // Allocates a new resource ID. - command_buffer::ResourceId AllocateID() { + gpu::ResourceId AllocateID() { unsigned int bit = FindFirstFree(); SetBit(bit, true); return bit; } // Frees a resource ID. - void FreeID(command_buffer::ResourceId id) { + void FreeID(gpu::ResourceId id) { SetBit(id, false); } // Checks whether or not a resource ID is in use. - bool InUse(command_buffer::ResourceId id) { + bool InUse(gpu::ResourceId id) { return GetBit(id); } private: @@ -73,6 +73,6 @@ class IdAllocator { DISALLOW_COPY_AND_ASSIGN(IdAllocator); }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_CLIENT_CROSS_ID_ALLOCATOR_H_ +#endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ diff --git a/gpu/command_buffer/client/id_allocator_test.cc b/gpu/command_buffer/client/id_allocator_test.cc index bb8d5f9b..7bc6f01 100644 --- a/gpu/command_buffer/client/id_allocator_test.cc +++ b/gpu/command_buffer/client/id_allocator_test.cc @@ -35,9 +35,9 @@ #include "gpu/command_buffer/client/id_allocator.h" #include "testing/gtest/include/gtest/gtest.h" -namespace command_buffer { +namespace gpu { -using command_buffer::ResourceId; +using gpu::ResourceId; class IdAllocatorTest : public testing::Test { protected: @@ -109,4 +109,4 @@ TEST_F(IdAllocatorTest, TestAdvanced) { EXPECT_EQ(id1, id2); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/bitfield_helpers.h b/gpu/command_buffer/common/bitfield_helpers.h index b74374d..7143c69 100644 --- a/gpu/command_buffer/common/bitfield_helpers.h +++ b/gpu/command_buffer/common/bitfield_helpers.h @@ -33,10 +33,10 @@ // This file contains a helper template class used to access bit fields in // unsigned int_ts. -#ifndef GPU_COMMAND_BUFFER_COMMON_CROSS_BITFIELD_HELPERS_H_ -#define GPU_COMMAND_BUFFER_COMMON_CROSS_BITFIELD_HELPERS_H_ +#ifndef GPU_COMMAND_BUFFER_COMMON_BITFIELD_HELPERS_H_ +#define GPU_COMMAND_BUFFER_COMMON_BITFIELD_HELPERS_H_ -namespace command_buffer { +namespace gpu { // Bitfield template class, used to access bit fields in unsigned int_ts. template<int shift, int length> class BitField { @@ -63,6 +63,6 @@ template<int shift, int length> class BitField { } }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_COMMON_CROSS_BITFIELD_HELPERS_H_ +#endif // GPU_COMMAND_BUFFER_COMMON_BITFIELD_HELPERS_H_ diff --git a/gpu/command_buffer/common/bitfield_helpers_test.cc b/gpu/command_buffer/common/bitfield_helpers_test.cc index 779b540..b71410e 100644 --- a/gpu/command_buffer/common/bitfield_helpers_test.cc +++ b/gpu/command_buffer/common/bitfield_helpers_test.cc @@ -35,7 +35,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "gpu/command_buffer/common/bitfield_helpers.h" -namespace command_buffer { +namespace gpu { // Tests that BitField<>::Get returns the right bits. TEST(BitFieldTest, TestGet) { @@ -63,4 +63,4 @@ TEST(BitFieldTest, TestSet) { EXPECT_EQ(0x87654321u, value); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/cmd_buffer_common.cc b/gpu/command_buffer/common/cmd_buffer_common.cc index e9172eb..c2d8d97 100644 --- a/gpu/command_buffer/common/cmd_buffer_common.cc +++ b/gpu/command_buffer/common/cmd_buffer_common.cc @@ -35,7 +35,7 @@ #include "gpu/command_buffer/common/cmd_buffer_common.h" -namespace command_buffer { +namespace gpu { namespace cmd { const char* GetCommandName(CommandId command_id) { @@ -52,6 +52,6 @@ const char* GetCommandName(CommandId command_id) { } } // namespace cmd -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/cmd_buffer_common.h b/gpu/command_buffer/common/cmd_buffer_common.h index 1d0c4cb..7f02e3e 100644 --- a/gpu/command_buffer/common/cmd_buffer_common.h +++ b/gpu/command_buffer/common/cmd_buffer_common.h @@ -32,15 +32,15 @@ // This file contains the common parts of command buffer formats. -#ifndef GPU_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_COMMON_H_ -#define GPU_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_COMMON_H_ +#ifndef GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ +#define GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ #include "base/basictypes.h" #include "gpu/command_buffer/common/types.h" #include "gpu/command_buffer/common/bitfield_helpers.h" #include "gpu/command_buffer/common/logging.h" -namespace command_buffer { +namespace gpu { namespace cmd { enum ArgFlags { @@ -680,7 +680,7 @@ COMPILE_ASSERT(offsetof(GetBucketData, shared_memory_offset) == 20, #pragma pack(pop) -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_COMMON_CROSS_CMD_BUFFER_COMMON_H_ +#endif // GPU_COMMAND_BUFFER_COMMON_CMD_BUFFER_COMMON_H_ diff --git a/gpu/command_buffer/common/command_buffer.h b/gpu/command_buffer/common/command_buffer.h index 3ce841a..92e38ff 100644 --- a/gpu/command_buffer/common/command_buffer.h +++ b/gpu/command_buffer/common/command_buffer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -8,7 +8,7 @@ #include "base/shared_memory.h" #include "base/task.h" -namespace command_buffer { +namespace gpu { // Common interface for CommandBuffer implementations. class CommandBuffer { @@ -19,12 +19,12 @@ class CommandBuffer { virtual ~CommandBuffer() { } - // Initialize the command buffer with the given ring buffer. Takes ownership - // of ring buffer. - virtual bool Initialize(::base::SharedMemory* ring_buffer) = 0; + // Initialize the command buffer with the given size (number of command + // entries). + virtual base::SharedMemory* Initialize(int32 size) = 0; // Gets the shared memory ring buffer object for the command buffer. - virtual ::base::SharedMemory* GetRingBuffer() = 0; + virtual base::SharedMemory* GetRingBuffer() = 0; virtual int32 GetSize() = 0; @@ -62,7 +62,7 @@ class CommandBuffer { virtual void DestroyTransferBuffer(int32 id) = 0; // Get the shared memory associated with a handle. - virtual ::base::SharedMemory* GetTransferBuffer(int32 handle) = 0; + virtual base::SharedMemory* GetTransferBuffer(int32 handle) = 0; // Get the current token value. This is used for by the writer to defer // changes to shared memory objects until the reader has reached a certain @@ -92,6 +92,6 @@ class CommandBuffer { DISALLOW_COPY_AND_ASSIGN(CommandBuffer); }; -} // namespace command_buffer +} // namespace gpu #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_H_ diff --git a/gpu/command_buffer/common/command_buffer_mock.h b/gpu/command_buffer/common/command_buffer_mock.h index faa5536..79d5682 100644 --- a/gpu/command_buffer/common/command_buffer_mock.h +++ b/gpu/command_buffer/common/command_buffer_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -8,7 +8,7 @@ #include "gpu/command_buffer/common/command_buffer.h" #include "testing/gmock/include/gmock/gmock.h" -namespace command_buffer { +namespace gpu { // An NPObject that implements a shared memory command buffer and a synchronous // API to manage the put and get pointers. @@ -16,13 +16,13 @@ class MockCommandBuffer : public CommandBuffer { public: MockCommandBuffer() { ON_CALL(*this, GetRingBuffer()) - .WillByDefault(testing::Return(static_cast<::base::SharedMemory*>(NULL))); + .WillByDefault(testing::Return(static_cast<base::SharedMemory*>(NULL))); ON_CALL(*this, GetTransferBuffer(testing::_)) - .WillByDefault(testing::Return(static_cast<::base::SharedMemory*>(NULL))); + .WillByDefault(testing::Return(static_cast<base::SharedMemory*>(NULL))); } - MOCK_METHOD1(Initialize, bool(::base::SharedMemory* ring_buffer)); - MOCK_METHOD0(GetRingBuffer, ::base::SharedMemory*()); + MOCK_METHOD1(Initialize, base::SharedMemory*(int32 size)); + MOCK_METHOD0(GetRingBuffer, base::SharedMemory*()); MOCK_METHOD0(GetSize, int32()); MOCK_METHOD1(SyncOffsets, int32(int32 put_offset)); MOCK_METHOD0(GetGetOffset, int32()); @@ -31,7 +31,7 @@ class MockCommandBuffer : public CommandBuffer { MOCK_METHOD1(SetPutOffsetChangeCallback, void(Callback0::Type* callback)); MOCK_METHOD1(CreateTransferBuffer, int32(size_t size)); MOCK_METHOD1(DestroyTransferBuffer, void(int32 handle)); - MOCK_METHOD1(GetTransferBuffer, ::base::SharedMemory*(int32 handle)); + MOCK_METHOD1(GetTransferBuffer, base::SharedMemory*(int32 handle)); MOCK_METHOD0(GetToken, int32()); MOCK_METHOD1(SetToken, void(int32 token)); MOCK_METHOD0(ResetParseError, int32()); @@ -43,6 +43,6 @@ class MockCommandBuffer : public CommandBuffer { DISALLOW_COPY_AND_ASSIGN(MockCommandBuffer); }; -} // namespace command_buffer +} // namespace gpu #endif // GPU_COMMAND_BUFFER_COMMON_COMMAND_BUFFER_MOCK_H_ diff --git a/gpu/command_buffer/common/constants.h b/gpu/command_buffer/common/constants.h index ee874cd..1b0593d 100644 --- a/gpu/command_buffer/common/constants.h +++ b/gpu/command_buffer/common/constants.h @@ -30,12 +30,12 @@ */ -#ifndef O3D_COMMAND_BUFFER_COMMON_CROSS_CONSTANTS_H_ -#define O3D_COMMAND_BUFFER_COMMON_CROSS_CONSTANTS_H_ +#ifndef GPU_COMMAND_BUFFER_COMMON_CONSTANTS_H_ +#define GPU_COMMAND_BUFFER_COMMON_CONSTANTS_H_ #include "base/basictypes.h" -namespace command_buffer { +namespace gpu { typedef int32 CommandBufferOffset; const CommandBufferOffset kInvalidCommandBufferOffset = -1; @@ -66,6 +66,6 @@ namespace parse_error { // failure. const int32 kInvalidSharedMemoryId = -1; -} // namespace command_buffer +} // namespace gpu -#endif // O3D_COMMAND_BUFFER_COMMON_CROSS_CONSTANTS_H_ +#endif // GPU_COMMAND_BUFFER_COMMON_CONSTANTS_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format.cc b/gpu/command_buffer/common/gles2_cmd_format.cc index 7c88a84..7770514 100644 --- a/gpu/command_buffer/common/gles2_cmd_format.cc +++ b/gpu/command_buffer/common/gles2_cmd_format.cc @@ -9,7 +9,7 @@ // and service side have different requirements. #include "gpu/command_buffer/common/cmd_buffer_common.h" -namespace command_buffer { +namespace gpu { namespace gles2 { #include "gpu/command_buffer/common/gles2_cmd_ids_autogen.h" @@ -29,6 +29,6 @@ const char* GetCommandName(CommandId id) { } } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h index 6e3a09b..4fcd273 100644 --- a/gpu/command_buffer/common/gles2_cmd_format.h +++ b/gpu/command_buffer/common/gles2_cmd_format.h @@ -4,8 +4,8 @@ // This file defines the GLES2 command buffer commands. -#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H -#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ // This is here because service side code must include the system's version of // the GL headers where as client side code includes the Chrome version. @@ -24,7 +24,7 @@ #include "gpu/command_buffer/common/cmd_buffer_common.h" #include "gpu/command_buffer/common/gles2_cmd_ids.h" -namespace command_buffer { +namespace gpu { namespace gles2 { #include "gpu/command_buffer/common/gles2_cmd_format_autogen.h" @@ -69,7 +69,7 @@ struct GetAttribLocation { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 name_shm_id; uint32 name_shm_offset; @@ -132,7 +132,7 @@ struct GetAttribLocationImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 location_shm_id; uint32 location_shm_offset; @@ -189,7 +189,7 @@ struct GetUniformLocation { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 name_shm_id; uint32 name_shm_offset; @@ -252,7 +252,7 @@ struct GetUniformLocationImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 location_shm_id; uint32 location_shm_offset; @@ -275,7 +275,7 @@ COMPILE_ASSERT(offsetof(GetUniformLocationImmediate, data_size) == 16, } // namespace gles2 -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 83c7869..affe2c0 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -25,7 +25,7 @@ struct ActiveTexture { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 texture; }; @@ -60,7 +60,7 @@ struct AttachShader { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 shader; }; @@ -107,7 +107,7 @@ struct BindAttribLocation { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 index; uint32 name_shm_id; @@ -162,7 +162,7 @@ struct BindAttribLocationImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 index; uint32 data_size; @@ -203,7 +203,7 @@ struct BindBuffer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 buffer; }; @@ -241,7 +241,7 @@ struct BindFramebuffer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 framebuffer; }; @@ -279,7 +279,7 @@ struct BindRenderbuffer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 renderbuffer; }; @@ -317,7 +317,7 @@ struct BindTexture { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 texture; }; @@ -359,7 +359,7 @@ struct BlendColor { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; float red; float green; float blue; @@ -402,7 +402,7 @@ struct BlendEquation { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 mode; }; @@ -437,7 +437,7 @@ struct BlendEquationSeparate { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 modeRGB; uint32 modeAlpha; }; @@ -475,7 +475,7 @@ struct BlendFunc { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 sfactor; uint32 dfactor; }; @@ -518,7 +518,7 @@ struct BlendFuncSeparate { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 srcRGB; uint32 dstRGB; uint32 srcAlpha; @@ -570,7 +570,7 @@ struct BufferData { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 size; uint32 data_shm_id; @@ -622,7 +622,7 @@ struct BufferDataImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 size; uint32 usage; @@ -671,7 +671,7 @@ struct BufferSubData { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 offset; uint32 size; @@ -723,7 +723,7 @@ struct BufferSubDataImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 offset; uint32 size; @@ -763,7 +763,7 @@ struct CheckFramebufferStatus { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; }; @@ -797,7 +797,7 @@ struct Clear { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 mask; }; @@ -836,7 +836,7 @@ struct ClearColor { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; float red; float green; float blue; @@ -879,7 +879,7 @@ struct ClearDepthf { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; float depth; }; @@ -913,7 +913,7 @@ struct ClearStencil { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 s; }; @@ -953,7 +953,7 @@ struct ColorMask { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 red; uint32 green; uint32 blue; @@ -996,7 +996,7 @@ struct CompileShader { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; }; @@ -1047,7 +1047,7 @@ struct CompressedTexImage2D { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 internalformat; @@ -1122,7 +1122,7 @@ struct CompressedTexImage2DImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 internalformat; @@ -1192,7 +1192,7 @@ struct CompressedTexSubImage2D { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 xoffset; @@ -1271,7 +1271,7 @@ struct CompressedTexSubImage2DImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 xoffset; @@ -1340,7 +1340,7 @@ struct CopyTexImage2D { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 internalformat; @@ -1408,7 +1408,7 @@ struct CopyTexSubImage2D { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 xoffset; @@ -1463,7 +1463,7 @@ struct CreateProgram { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 client_id; }; @@ -1498,7 +1498,7 @@ struct CreateShader { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 type; uint32 client_id; }; @@ -1535,7 +1535,7 @@ struct CullFace { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 mode; }; @@ -1574,7 +1574,7 @@ struct DeleteBuffers { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 buffers_shm_id; uint32 buffers_shm_offset; @@ -1622,7 +1622,7 @@ struct DeleteBuffersImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -1663,7 +1663,7 @@ struct DeleteFramebuffers { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 framebuffers_shm_id; uint32 framebuffers_shm_offset; @@ -1711,7 +1711,7 @@ struct DeleteFramebuffersImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -1745,7 +1745,7 @@ struct DeleteProgram { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; }; @@ -1786,7 +1786,7 @@ struct DeleteRenderbuffers { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 renderbuffers_shm_id; uint32 renderbuffers_shm_offset; @@ -1834,7 +1834,7 @@ struct DeleteRenderbuffersImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -1868,7 +1868,7 @@ struct DeleteShader { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; }; @@ -1907,7 +1907,7 @@ struct DeleteTextures { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 textures_shm_id; uint32 textures_shm_offset; @@ -1955,7 +1955,7 @@ struct DeleteTexturesImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -1989,7 +1989,7 @@ struct DepthFunc { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 func; }; @@ -2023,7 +2023,7 @@ struct DepthMask { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 flag; }; @@ -2058,7 +2058,7 @@ struct DepthRangef { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; float zNear; float zFar; }; @@ -2096,7 +2096,7 @@ struct DetachShader { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 shader; }; @@ -2133,7 +2133,7 @@ struct Disable { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 cap; }; @@ -2167,7 +2167,7 @@ struct DisableVertexAttribArray { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 index; }; @@ -2203,7 +2203,7 @@ struct DrawArrays { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 mode; uint32 first; uint32 count; @@ -2248,7 +2248,7 @@ struct DrawElements { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 mode; uint32 count; uint32 type; @@ -2291,7 +2291,7 @@ struct Enable { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 cap; }; @@ -2325,7 +2325,7 @@ struct EnableVertexAttribArray { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 index; }; @@ -2358,7 +2358,7 @@ struct Finish { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; }; COMPILE_ASSERT(sizeof(Finish) == 4, @@ -2388,7 +2388,7 @@ struct Flush { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; }; COMPILE_ASSERT(sizeof(Flush) == 4, @@ -2427,7 +2427,7 @@ struct FramebufferRenderbuffer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 attachment; uint32 renderbuffertarget; @@ -2479,7 +2479,7 @@ struct FramebufferTexture2D { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 attachment; uint32 textarget; @@ -2525,7 +2525,7 @@ struct FrontFace { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 mode; }; @@ -2564,7 +2564,7 @@ struct GenBuffers { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 buffers_shm_id; uint32 buffers_shm_offset; @@ -2612,7 +2612,7 @@ struct GenBuffersImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -2646,7 +2646,7 @@ struct GenerateMipmap { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; }; @@ -2687,7 +2687,7 @@ struct GenFramebuffers { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 framebuffers_shm_id; uint32 framebuffers_shm_offset; @@ -2735,7 +2735,7 @@ struct GenFramebuffersImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -2776,7 +2776,7 @@ struct GenRenderbuffers { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 renderbuffers_shm_id; uint32 renderbuffers_shm_offset; @@ -2824,7 +2824,7 @@ struct GenRenderbuffersImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -2863,7 +2863,7 @@ struct GenTextures { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; uint32 textures_shm_id; uint32 textures_shm_offset; @@ -2911,7 +2911,7 @@ struct GenTexturesImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 n; }; @@ -2967,7 +2967,7 @@ struct GetActiveAttrib { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 index; uint32 bufsize; @@ -3053,7 +3053,7 @@ struct GetActiveUniform { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 index; uint32 bufsize; @@ -3131,7 +3131,7 @@ struct GetAttachedShaders { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 maxcount; uint32 count_shm_id; @@ -3185,7 +3185,7 @@ struct GetBooleanv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 pname; uint32 params_shm_id; uint32 params_shm_offset; @@ -3233,7 +3233,7 @@ struct GetBufferParameteriv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; uint32 params_shm_id; @@ -3277,7 +3277,7 @@ struct GetError { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 result_shm_id; uint32 result_shm_offset; }; @@ -3319,7 +3319,7 @@ struct GetFloatv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 pname; uint32 params_shm_id; uint32 params_shm_offset; @@ -3369,7 +3369,7 @@ struct GetFramebufferAttachmentParameteriv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 attachment; uint32 pname; @@ -3422,7 +3422,7 @@ struct GetIntegerv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 pname; uint32 params_shm_id; uint32 params_shm_offset; @@ -3470,7 +3470,7 @@ struct GetProgramiv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 pname; uint32 params_shm_id; @@ -3527,7 +3527,7 @@ struct GetProgramInfoLog { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 bufsize; uint32 length_shm_id; @@ -3584,7 +3584,7 @@ struct GetRenderbufferParameteriv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; uint32 params_shm_id; @@ -3635,7 +3635,7 @@ struct GetShaderiv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; uint32 pname; uint32 params_shm_id; @@ -3692,7 +3692,7 @@ struct GetShaderInfoLog { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; uint32 bufsize; uint32 length_shm_id; @@ -3755,7 +3755,7 @@ struct GetShaderPrecisionFormat { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shadertype; uint32 precisiontype; uint32 range_shm_id; @@ -3818,7 +3818,7 @@ struct GetShaderSource { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; uint32 bufsize; uint32 length_shm_id; @@ -3867,7 +3867,7 @@ struct GetString { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 name; }; @@ -3909,7 +3909,7 @@ struct GetTexParameterfv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; uint32 params_shm_id; @@ -3960,7 +3960,7 @@ struct GetTexParameteriv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; uint32 params_shm_id; @@ -4011,7 +4011,7 @@ struct GetUniformfv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 location; uint32 params_shm_id; @@ -4062,7 +4062,7 @@ struct GetUniformiv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 location; uint32 params_shm_id; @@ -4113,7 +4113,7 @@ struct GetVertexAttribfv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 index; uint32 pname; uint32 params_shm_id; @@ -4164,7 +4164,7 @@ struct GetVertexAttribiv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 index; uint32 pname; uint32 params_shm_id; @@ -4215,7 +4215,7 @@ struct GetVertexAttribPointerv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 index; uint32 pname; uint32 pointer_shm_id; @@ -4259,7 +4259,7 @@ struct Hint { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 mode; }; @@ -4301,7 +4301,7 @@ struct IsBuffer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 buffer; uint32 result_shm_id; uint32 result_shm_offset; @@ -4346,7 +4346,7 @@ struct IsEnabled { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 cap; uint32 result_shm_id; uint32 result_shm_offset; @@ -4392,7 +4392,7 @@ struct IsFramebuffer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 framebuffer; uint32 result_shm_id; uint32 result_shm_offset; @@ -4438,7 +4438,7 @@ struct IsProgram { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; uint32 result_shm_id; uint32 result_shm_offset; @@ -4484,7 +4484,7 @@ struct IsRenderbuffer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 renderbuffer; uint32 result_shm_id; uint32 result_shm_offset; @@ -4529,7 +4529,7 @@ struct IsShader { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; uint32 result_shm_id; uint32 result_shm_offset; @@ -4575,7 +4575,7 @@ struct IsTexture { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 texture; uint32 result_shm_id; uint32 result_shm_offset; @@ -4615,7 +4615,7 @@ struct LineWidth { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; float width; }; @@ -4649,7 +4649,7 @@ struct LinkProgram { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; }; @@ -4684,7 +4684,7 @@ struct PixelStorei { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 pname; uint32 param; }; @@ -4722,7 +4722,7 @@ struct PolygonOffset { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; float factor; float units; }; @@ -4774,7 +4774,7 @@ struct ReadPixels { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 x; uint32 y; uint32 width; @@ -4837,7 +4837,7 @@ struct RenderbufferStorage { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 internalformat; uint32 width; @@ -4881,7 +4881,7 @@ struct SampleCoverage { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; float value; uint32 invert; }; @@ -4921,7 +4921,7 @@ struct Scissor { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 x; uint32 y; uint32 width; @@ -4974,7 +4974,7 @@ struct ShaderSource { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; uint32 count; uint32 data_shm_id; @@ -5026,7 +5026,7 @@ struct ShaderSourceImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 shader; uint32 count; uint32 data_size; @@ -5068,7 +5068,7 @@ struct StencilFunc { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 func; uint32 ref; uint32 mask; @@ -5111,7 +5111,7 @@ struct StencilFuncSeparate { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 face; uint32 func; uint32 ref; @@ -5154,7 +5154,7 @@ struct StencilMask { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 mask; }; @@ -5189,7 +5189,7 @@ struct StencilMaskSeparate { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 face; uint32 mask; }; @@ -5228,7 +5228,7 @@ struct StencilOp { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 fail; uint32 zfail; uint32 zpass; @@ -5272,7 +5272,7 @@ struct StencilOpSeparate { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 face; uint32 fail; uint32 zfail; @@ -5333,7 +5333,7 @@ struct TexImage2D { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 internalformat; @@ -5413,7 +5413,7 @@ struct TexImage2DImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 internalformat; @@ -5470,7 +5470,7 @@ struct TexParameterf { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; float param; @@ -5518,7 +5518,7 @@ struct TexParameterfv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; uint32 params_shm_id; @@ -5571,7 +5571,7 @@ struct TexParameterfvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; }; @@ -5610,7 +5610,7 @@ struct TexParameteri { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; uint32 param; @@ -5658,7 +5658,7 @@ struct TexParameteriv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; uint32 params_shm_id; @@ -5711,7 +5711,7 @@ struct TexParameterivImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 pname; }; @@ -5766,7 +5766,7 @@ struct TexSubImage2D { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 xoffset; @@ -5845,7 +5845,7 @@ struct TexSubImage2DImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, total_size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 target; uint32 level; uint32 xoffset; @@ -5901,7 +5901,7 @@ struct Uniform1f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; float x; }; @@ -5946,7 +5946,7 @@ struct Uniform1fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -5999,7 +5999,7 @@ struct Uniform1fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -6037,7 +6037,7 @@ struct Uniform1i { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 x; }; @@ -6082,7 +6082,7 @@ struct Uniform1iv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -6135,7 +6135,7 @@ struct Uniform1ivImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -6174,7 +6174,7 @@ struct Uniform2f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; float x; float y; @@ -6222,7 +6222,7 @@ struct Uniform2fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -6275,7 +6275,7 @@ struct Uniform2fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -6314,7 +6314,7 @@ struct Uniform2i { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 x; uint32 y; @@ -6362,7 +6362,7 @@ struct Uniform2iv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -6415,7 +6415,7 @@ struct Uniform2ivImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -6455,7 +6455,7 @@ struct Uniform3f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; float x; float y; @@ -6506,7 +6506,7 @@ struct Uniform3fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -6559,7 +6559,7 @@ struct Uniform3fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -6599,7 +6599,7 @@ struct Uniform3i { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 x; uint32 y; @@ -6650,7 +6650,7 @@ struct Uniform3iv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -6703,7 +6703,7 @@ struct Uniform3ivImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -6746,7 +6746,7 @@ struct Uniform4f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; float x; float y; @@ -6800,7 +6800,7 @@ struct Uniform4fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -6853,7 +6853,7 @@ struct Uniform4fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -6895,7 +6895,7 @@ struct Uniform4i { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 x; uint32 y; @@ -6949,7 +6949,7 @@ struct Uniform4iv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 v_shm_id; @@ -7002,7 +7002,7 @@ struct Uniform4ivImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; }; @@ -7049,7 +7049,7 @@ struct UniformMatrix2fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 transpose; @@ -7110,7 +7110,7 @@ struct UniformMatrix2fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 transpose; @@ -7160,7 +7160,7 @@ struct UniformMatrix3fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 transpose; @@ -7221,7 +7221,7 @@ struct UniformMatrix3fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 transpose; @@ -7271,7 +7271,7 @@ struct UniformMatrix4fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 transpose; @@ -7332,7 +7332,7 @@ struct UniformMatrix4fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 location; uint32 count; uint32 transpose; @@ -7372,7 +7372,7 @@ struct UseProgram { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; }; @@ -7406,7 +7406,7 @@ struct ValidateProgram { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 program; }; @@ -7441,7 +7441,7 @@ struct VertexAttrib1f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; float x; }; @@ -7483,7 +7483,7 @@ struct VertexAttrib1fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; uint32 values_shm_id; uint32 values_shm_offset; @@ -7532,7 +7532,7 @@ struct VertexAttrib1fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; }; @@ -7568,7 +7568,7 @@ struct VertexAttrib2f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; float x; float y; @@ -7613,7 +7613,7 @@ struct VertexAttrib2fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; uint32 values_shm_id; uint32 values_shm_offset; @@ -7662,7 +7662,7 @@ struct VertexAttrib2fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; }; @@ -7699,7 +7699,7 @@ struct VertexAttrib3f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; float x; float y; @@ -7747,7 +7747,7 @@ struct VertexAttrib3fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; uint32 values_shm_id; uint32 values_shm_offset; @@ -7796,7 +7796,7 @@ struct VertexAttrib3fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; }; @@ -7836,7 +7836,7 @@ struct VertexAttrib4f { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; float x; float y; @@ -7887,7 +7887,7 @@ struct VertexAttrib4fv { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; uint32 values_shm_id; uint32 values_shm_offset; @@ -7936,7 +7936,7 @@ struct VertexAttrib4fvImmediate { return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; }; @@ -7980,7 +7980,7 @@ struct VertexAttribPointer { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 indx; uint32 size; uint32 type; @@ -8032,7 +8032,7 @@ struct Viewport { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; uint32 x; uint32 y; uint32 width; @@ -8074,7 +8074,7 @@ struct SwapBuffers { return NextCmdAddress<ValueType>(cmd); } - command_buffer::CommandHeader header; + gpu::CommandHeader header; }; COMPILE_ASSERT(sizeof(SwapBuffers) == 4, diff --git a/gpu/command_buffer/common/gles2_cmd_format_test.cc b/gpu/command_buffer/common/gles2_cmd_format_test.cc index c699a1d..216dc68 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test.cc +++ b/gpu/command_buffer/common/gles2_cmd_format_test.cc @@ -7,11 +7,11 @@ #include "testing/gtest/include/gtest/gtest.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" -namespace command_buffer { +namespace gpu { namespace gles2 { #include "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h" } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/gles2_cmd_id_test.cc b/gpu/command_buffer/common/gles2_cmd_id_test.cc index 05035f9..401ce5b 100644 --- a/gpu/command_buffer/common/gles2_cmd_id_test.cc +++ b/gpu/command_buffer/common/gles2_cmd_id_test.cc @@ -1,5 +1,5 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -8,7 +8,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" -namespace command_buffer { +namespace gpu { namespace gles2 { // *** These IDs MUST NOT CHANGE!!! *** @@ -368,5 +368,5 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) { GLES2_SwapBuffers_kCmdId_mismatch); } } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/gles2_cmd_ids.h b/gpu/command_buffer/common/gles2_cmd_ids.h index 130fce9..b6f317f 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids.h +++ b/gpu/command_buffer/common/gles2_cmd_ids.h @@ -4,12 +4,12 @@ // This file defines the GLES2 command buffer commands. -#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_H -#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_H +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_H_ +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_H_ #include "gpu/command_buffer/common/cmd_buffer_common.h" -namespace command_buffer { +namespace gpu { namespace gles2 { #include "gpu/command_buffer/common/gles2_cmd_ids_autogen.h" @@ -17,7 +17,7 @@ namespace gles2 { const char* GetCommandName(CommandId command_id); } // namespace gles2 -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_H +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index 1268c23..d35ea3d 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -8,7 +8,7 @@ #include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" -namespace command_buffer { +namespace gpu { namespace gles2 { int GLES2Util::GLGetNumValuesReturned(int id) const { @@ -344,5 +344,5 @@ uint32 GLES2Util::ComputeImageDataSize( } } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index 9674a30..74ba8f1 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -5,13 +5,13 @@ // This file is here so other GLES2 related files can have a common set of // includes where appropriate. -#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H -#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ #include "base/basictypes.h" #include "gpu/command_buffer/common/types.h" -namespace command_buffer { +namespace gpu { namespace gles2 { // Utilties for GLES2 support. @@ -35,7 +35,7 @@ class GLES2Util { }; } // namespace gles2 -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_H_ diff --git a/gpu/command_buffer/common/logging.h b/gpu/command_buffer/common/logging.h index a9bbad8..76aef5e 100644 --- a/gpu/command_buffer/common/logging.h +++ b/gpu/command_buffer/common/logging.h @@ -33,8 +33,8 @@ // This file abstracts differences in logging between NaCl and host // environment. -#ifndef GPU_COMMAND_BUFFER_COMMON_CROSS_LOGGING_H_ -#define GPU_COMMAND_BUFFER_COMMON_CROSS_LOGGING_H_ +#ifndef GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ +#define GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ #ifndef __native_client__ #include "base/logging.h" @@ -64,4 +64,4 @@ #endif -#endif // GPU_COMMAND_BUFFER_COMMON_CROSS_LOGGING_H_ +#endif // GPU_COMMAND_BUFFER_COMMON_LOGGING_H_ diff --git a/gpu/command_buffer/common/resource.cc b/gpu/command_buffer/common/resource.cc index f3b75ec..2aec518 100644 --- a/gpu/command_buffer/common/resource.cc +++ b/gpu/command_buffer/common/resource.cc @@ -34,7 +34,7 @@ #include "gpu/command_buffer/common/resource.h" -namespace command_buffer { +namespace gpu { namespace texture { @@ -117,4 +117,4 @@ unsigned int GetDataSize(DataType type) { } // namespace effect_param -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/common/resource.h b/gpu/command_buffer/common/resource.h index 01de6a1..1ad0981 100644 --- a/gpu/command_buffer/common/resource.h +++ b/gpu/command_buffer/common/resource.h @@ -33,8 +33,8 @@ // This file contains definitions for resource flags, enums, and helper // functions. -#ifndef GPU_COMMAND_BUFFER_COMMON_CROSS_RESOURCE_H_ -#define GPU_COMMAND_BUFFER_COMMON_CROSS_RESOURCE_H_ +#ifndef GPU_COMMAND_BUFFER_COMMON_RESOURCE_H_ +#define GPU_COMMAND_BUFFER_COMMON_RESOURCE_H_ #include <algorithm> #include "base/basictypes.h" @@ -42,7 +42,7 @@ #include "gpu/command_buffer/common/types.h" #include "gpu/command_buffer/common/logging.h" -namespace command_buffer { +namespace gpu { // A resource ID, key to the resource maps. typedef uint32 ResourceId; @@ -224,6 +224,6 @@ enum FilteringMode { }; } // namespace sampler -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_COMMON_CROSS_RESOURCE_H_ +#endif // GPU_COMMAND_BUFFER_COMMON_RESOURCE_H_ diff --git a/gpu/command_buffer/common/types.h b/gpu/command_buffer/common/types.h index daa01cb..8387120 100644 --- a/gpu/command_buffer/common/types.h +++ b/gpu/command_buffer/common/types.h @@ -29,11 +29,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - // This file contains cross-platform basic type definitions -#ifndef GPU_COMMAND_BUFFER_COMMON_CROSS_TYPES_H_ -#define GPU_COMMAND_BUFFER_COMMON_CROSS_TYPES_H_ +#ifndef GPU_COMMAND_BUFFER_COMMON_TYPES_H_ +#define GPU_COMMAND_BUFFER_COMMON_TYPES_H_ #include <build/build_config.h> #if !defined(COMPILER_MSVC) @@ -41,7 +40,7 @@ #endif #include <string> -namespace command_buffer { +namespace gpu { #if defined(COMPILER_MSVC) typedef short Int16; typedef unsigned short Uint16; @@ -55,6 +54,6 @@ typedef uint32_t Uint32; #endif typedef std::string String; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_COMMON_CROSS_TYPES_H_ +#endif // GPU_COMMAND_BUFFER_COMMON_TYPES_H_ diff --git a/gpu/command_buffer/service/cmd_buffer_engine.h b/gpu/command_buffer/service/cmd_buffer_engine.h index 74ad649..4312b47 100644 --- a/gpu/command_buffer/service/cmd_buffer_engine.h +++ b/gpu/command_buffer/service/cmd_buffer_engine.h @@ -33,12 +33,12 @@ // This file defines the CommandBufferEngine class, providing the main loop for // the service, exposing the RPC API, managing the command parser. -#ifndef GPU_COMMAND_BUFFER_SERVICE_CROSS_CMD_BUFFER_ENGINE_H_ -#define GPU_COMMAND_BUFFER_SERVICE_CROSS_CMD_BUFFER_ENGINE_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_CMD_BUFFER_ENGINE_H_ +#define GPU_COMMAND_BUFFER_SERVICE_CMD_BUFFER_ENGINE_H_ #include "base/basictypes.h" -namespace command_buffer { +namespace gpu { class CommandBufferEngine { public: @@ -65,6 +65,6 @@ class CommandBufferEngine { DISALLOW_COPY_AND_ASSIGN(CommandBufferEngine); }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_SERVICE_CROSS_CMD_BUFFER_ENGINE_H_ +#endif // GPU_COMMAND_BUFFER_SERVICE_CMD_BUFFER_ENGINE_H_ diff --git a/gpu/command_buffer/service/cmd_parser.cc b/gpu/command_buffer/service/cmd_parser.cc index 1341732..dfdb8ce 100644 --- a/gpu/command_buffer/service/cmd_parser.cc +++ b/gpu/command_buffer/service/cmd_parser.cc @@ -35,7 +35,7 @@ #include "gpu/command_buffer/service/precompile.h" #include "gpu/command_buffer/service/cmd_parser.h" -namespace command_buffer { +namespace gpu { CommandParser::CommandParser(void *shm_address, size_t shm_size, @@ -107,4 +107,4 @@ parse_error::ParseError CommandParser::ProcessAllCommands() { return parse_error::kParseNoError; } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/cmd_parser.h b/gpu/command_buffer/service/cmd_parser.h index 2209cf8..131a459 100644 --- a/gpu/command_buffer/service/cmd_parser.h +++ b/gpu/command_buffer/service/cmd_parser.h @@ -32,13 +32,13 @@ // This file contains the command parser class. -#ifndef GPU_COMMAND_BUFFER_SERVICE_CROSS_CMD_PARSER_H_ -#define GPU_COMMAND_BUFFER_SERVICE_CROSS_CMD_PARSER_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ +#define GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ #include "gpu/command_buffer/common/constants.h" #include "gpu/command_buffer/common/cmd_buffer_common.h" -namespace command_buffer { +namespace gpu { class AsyncAPIInterface; @@ -110,6 +110,6 @@ class AsyncAPIInterface { virtual const char* GetCommandName(unsigned int command_id) const = 0; }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_SERVICE_CROSS_CMD_PARSER_H_ +#endif // GPU_COMMAND_BUFFER_SERVICE_CMD_PARSER_H_ diff --git a/gpu/command_buffer/service/cmd_parser_test.cc b/gpu/command_buffer/service/cmd_parser_test.cc index 59c5528..1a847b2 100644 --- a/gpu/command_buffer/service/cmd_parser_test.cc +++ b/gpu/command_buffer/service/cmd_parser_test.cc @@ -39,7 +39,7 @@ #include "gpu/command_buffer/service/mocks.h" #include "testing/gtest/include/gtest/gtest.h" -namespace command_buffer { +namespace gpu { using testing::Return; using testing::Mock; @@ -313,4 +313,4 @@ TEST_F(CommandParserTest, TestError) { Mock::VerifyAndClearExpectations(api_mock()); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/command_buffer_service.cc b/gpu/command_buffer/service/command_buffer_service.cc index 94d2148..e2dffec 100644 --- a/gpu/command_buffer/service/command_buffer_service.cc +++ b/gpu/command_buffer/service/command_buffer_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -8,7 +8,7 @@ using ::base::SharedMemory; -namespace command_buffer { +namespace gpu { CommandBufferService::CommandBufferService() : size_(0), @@ -24,18 +24,21 @@ CommandBufferService::CommandBufferService() CommandBufferService::~CommandBufferService() { } -bool CommandBufferService::Initialize(::base::SharedMemory* ring_buffer) { - DCHECK(ring_buffer); - +base::SharedMemory* CommandBufferService::Initialize(int32 size) { // Fail if already initialized. if (ring_buffer_.get()) return false; - size_t size_in_bytes = ring_buffer->max_size(); - size_ = size_in_bytes / sizeof(int32); - ring_buffer_.reset(ring_buffer); + size_ = size; + + ring_buffer_.reset(new SharedMemory); + if (ring_buffer_->Create(std::wstring(), false, false, size_)) { + if (ring_buffer_->Map(size_)) + return ring_buffer_.get(); + } - return true; + ring_buffer_.reset(); + return NULL; } SharedMemory* CommandBufferService::GetRingBuffer() { @@ -158,4 +161,4 @@ void CommandBufferService::RaiseErrorStatus() { error_status_ = true; } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/command_buffer_service.h b/gpu/command_buffer/service/command_buffer_service.h index d6da953..6784581 100644 --- a/gpu/command_buffer/service/command_buffer_service.h +++ b/gpu/command_buffer/service/command_buffer_service.h @@ -1,9 +1,9 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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 GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_H_ -#define GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ +#define GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ #include <set> #include <vector> @@ -13,81 +13,48 @@ #include "base/shared_memory.h" #include "base/task.h" #include "gpu/command_buffer/common/command_buffer.h" -#include "gpu/np_utils/default_np_object.h" -#include "gpu/np_utils/np_dispatcher.h" -namespace command_buffer { +namespace gpu { -// An NPObject that implements a shared memory command buffer and a synchronous +// An object that implements a shared memory command buffer and a synchronous // API to manage the put and get pointers. class CommandBufferService : public CommandBuffer { public: CommandBufferService(); virtual ~CommandBufferService(); - // Overrides CommandBuffer. - virtual bool Initialize(::base::SharedMemory* ring_buffer); - - // Overrides CommandBuffer. - virtual ::base::SharedMemory* GetRingBuffer(); - + // CommandBuffer implementation: + virtual base::SharedMemory* Initialize(int32 size); + virtual base::SharedMemory* GetRingBuffer(); virtual int32 GetSize(); - - // Overrides CommandBuffer. virtual int32 SyncOffsets(int32 put_offset); - - // Overrides CommandBuffer. virtual int32 GetGetOffset(); - - // Overrides CommandBuffer. virtual void SetGetOffset(int32 get_offset); - - // Overrides CommandBuffer. virtual int32 GetPutOffset(); - - // Overrides CommandBuffer. virtual void SetPutOffsetChangeCallback(Callback0::Type* callback); - - // Overrides CommandBuffer. virtual int32 CreateTransferBuffer(size_t size); - - // Overrides CommandBuffer. virtual void DestroyTransferBuffer(int32 id); - - // Overrides CommandBuffer. - virtual ::base::SharedMemory* GetTransferBuffer(int32 handle); - - // Overrides CommandBuffer. + virtual base::SharedMemory* GetTransferBuffer(int32 handle); virtual int32 GetToken(); - - // Overrides CommandBuffer. virtual void SetToken(int32 token); - - // Overrides CommandBuffer. virtual int32 ResetParseError(); - - // Overrides CommandBuffer. virtual void SetParseError(int32 parse_error); - - // Overrides CommandBuffer. virtual bool GetErrorStatus(); - - // Overrides CommandBuffer. virtual void RaiseErrorStatus(); private: - scoped_ptr< ::base::SharedMemory> ring_buffer_; + scoped_ptr< base::SharedMemory> ring_buffer_; int32 size_; int32 get_offset_; int32 put_offset_; scoped_ptr<Callback0::Type> put_offset_change_callback_; - std::vector<linked_ptr< ::base::SharedMemory> > registered_objects_; + std::vector<linked_ptr< base::SharedMemory> > registered_objects_; std::set<int32> unused_registered_object_elements_; int32 token_; int32 parse_error_; bool error_status_; }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_H_ +#endif // GPU_COMMAND_BUFFER_SERVICE_COMMAND_BUFFER_SERVICE_H_ diff --git a/gpu/command_buffer/service/command_buffer_service_unittest.cc b/gpu/command_buffer/service/command_buffer_service_unittest.cc index 68ff221..b5749af 100644 --- a/gpu/command_buffer/service/command_buffer_service_unittest.cc +++ b/gpu/command_buffer/service/command_buffer_service_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -14,7 +14,7 @@ using testing::Return; using testing::SetArgumentPointee; using testing::StrictMock; -namespace command_buffer { +namespace gpu { class CommandBufferServiceTest : public testing::Test { protected: @@ -30,17 +30,16 @@ TEST_F(CommandBufferServiceTest, NullRingBufferByDefault) { } TEST_F(CommandBufferServiceTest, InitializesCommandBuffer) { - SharedMemory* ring_buffer = new SharedMemory; - EXPECT_TRUE(ring_buffer->Create(std::wstring(), false, false, 1024)); - EXPECT_TRUE(command_buffer_->Initialize(ring_buffer)); - EXPECT_TRUE(ring_buffer == command_buffer_->GetRingBuffer()); - EXPECT_EQ(256, command_buffer_->GetSize()); + base::SharedMemory* ring_buffer = command_buffer_->Initialize(1024); + EXPECT_TRUE(NULL != ring_buffer); + EXPECT_EQ(ring_buffer, command_buffer_->GetRingBuffer()); + EXPECT_GT(command_buffer_->GetSize(), 0); } TEST_F(CommandBufferServiceTest, InitializeFailsSecondTime) { SharedMemory* ring_buffer = new SharedMemory; - EXPECT_TRUE(command_buffer_->Initialize(ring_buffer)); - EXPECT_FALSE(command_buffer_->Initialize(ring_buffer)); + EXPECT_TRUE(NULL != command_buffer_->Initialize(1024)); + EXPECT_TRUE(NULL == command_buffer_->Initialize(1024)); } TEST_F(CommandBufferServiceTest, GetAndPutOffsetsDefaultToZero) { @@ -54,10 +53,7 @@ class MockCallback : public CallbackRunner<Tuple0> { }; TEST_F(CommandBufferServiceTest, CanSyncGetAndPutOffset) { - SharedMemory* ring_buffer = new SharedMemory; - ring_buffer->Create(std::wstring(), false, false, 1024); - - EXPECT_TRUE(command_buffer_->Initialize(ring_buffer)); + command_buffer_->Initialize(1024); StrictMock<MockCallback>* put_offset_change_callback = new StrictMock<MockCallback>; @@ -175,4 +171,4 @@ TEST_F(CommandBufferServiceTest, CanRaiseErrorStatus) { EXPECT_TRUE(command_buffer_->GetErrorStatus()); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/common_decoder.cc b/gpu/command_buffer/service/common_decoder.cc index c0d545f..478d281 100644 --- a/gpu/command_buffer/service/common_decoder.cc +++ b/gpu/command_buffer/service/common_decoder.cc @@ -33,7 +33,7 @@ #include "gpu/command_buffer/service/common_decoder.h" #include "gpu/command_buffer/service/cmd_buffer_engine.h" -namespace command_buffer { +namespace gpu { const void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const { if (OffsetSizeValid(offset, size)) { @@ -295,4 +295,4 @@ parse_error::ParseError CommonDecoder::HandleGetBucketData( return parse_error::kParseNoError; } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/common_decoder.h b/gpu/command_buffer/service/common_decoder.h index c96cc9c..f33926b 100644 --- a/gpu/command_buffer/service/common_decoder.h +++ b/gpu/command_buffer/service/common_decoder.h @@ -29,15 +29,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GPU_COMMAND_BUFFER_SERVICE_CROSS_COMMON_DECODER_H_ -#define GPU_COMMAND_BUFFER_SERVICE_CROSS_COMMON_DECODER_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ +#define GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ #include <map> #include "base/linked_ptr.h" #include "base/scoped_ptr.h" #include "gpu/command_buffer/service/cmd_parser.h" -namespace command_buffer { +namespace gpu { class CommandBufferEngine; @@ -176,7 +176,7 @@ class CommonDecoder : public AsyncAPIInterface { BucketMap buckets_; }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_SERVICE_CROSS_COMMON_DECODER_H_ +#endif // GPU_COMMAND_BUFFER_SERVICE_COMMON_DECODER_H_ diff --git a/gpu/command_buffer/service/common_decoder_unittest.cc b/gpu/command_buffer/service/common_decoder_unittest.cc index ce3a5d5..54f1941 100644 --- a/gpu/command_buffer/service/common_decoder_unittest.cc +++ b/gpu/command_buffer/service/common_decoder_unittest.cc @@ -6,7 +6,7 @@ #include "gpu/command_buffer/service/cmd_buffer_engine.h" #include "testing/gtest/include/gtest/gtest.h" -namespace command_buffer { +namespace gpu { TEST(CommonDecoderBucket, Basic) { CommonDecoder::Bucket bucket; @@ -414,5 +414,5 @@ TEST_F(CommonDecoderTest, GetBucketData) { } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 5d0d2d7..7ceef0e 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -14,7 +14,7 @@ #include "gpu/command_buffer/service/gl_utils.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" -namespace command_buffer { +namespace gpu { namespace gles2 { namespace { @@ -103,7 +103,7 @@ enum GLErrorBit { } uint32 GLErrorToErrorBit(GLenum error) { - switch(error) { + switch (error) { case GL_INVALID_ENUM: return GLErrorBit::kInvalidEnum; case GL_INVALID_VALUE: @@ -121,7 +121,7 @@ uint32 GLErrorToErrorBit(GLenum error) { } GLenum GLErrorBitToGLError(uint32 error_bit) { - switch(error_bit) { + switch (error_bit) { case GLErrorBit::kInvalidEnum: return GL_INVALID_ENUM; case GLErrorBit::kInvalidValue: @@ -698,12 +698,12 @@ parse_error::ParseError GLES2DecoderImpl::DoCommand( } } // namespace gles2 -} // namespace command_buffer +} // namespace gpu // This is included so the compiler will make these inline. #include "gpu/command_buffer/service/gles2_cmd_decoder_validate.h" -namespace command_buffer { +namespace gpu { namespace gles2 { void GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) { @@ -1231,5 +1231,5 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetActiveAttrib( #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index a131e50..fbac4f0 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -4,8 +4,8 @@ // This file contains the GLES2Decoder class. -#ifndef O3D_COMMAND_BUFFER_SERVICE_CROSS_GLES2_CMD_DECODER_H -#define O3D_COMMAND_BUFFER_SERVICE_CROSS_GLES2_CMD_DECODER_H +#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_H_ #include <build/build_config.h> #if defined(OS_LINUX) @@ -15,7 +15,7 @@ #endif #include "gpu/command_buffer/service/common_decoder.h" -namespace command_buffer { +namespace gpu { namespace gles2 { // This class implements the AsyncAPIInterface interface, decoding GLES2 @@ -80,6 +80,6 @@ class GLES2Decoder : public CommonDecoder { }; } // namespace gles2 -} // namespace command_buffer +} // namespace gpu -#endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_GLES2_CMD_DECODER_H +#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_H_ diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_validate.h b/gpu/command_buffer/service/gles2_cmd_decoder_validate.h index ff51aae..cfb5157 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_validate.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_validate.h @@ -1,10 +1,10 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. -namespace command_buffer { +namespace gpu { namespace gles2 { namespace { @@ -1258,5 +1258,5 @@ parse_error::ParseError ValidateSwapBuffers( } } // anonymous namespace } // namespace gles2 -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/gpu_processor.cc b/gpu/command_buffer/service/gpu_processor.cc index 6d71a9c..61449c0 100644 --- a/gpu/command_buffer/service/gpu_processor.cc +++ b/gpu/command_buffer/service/gpu_processor.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -7,7 +7,7 @@ using ::base::SharedMemory; -namespace command_buffer { +namespace gpu { GPUProcessor::~GPUProcessor() { } @@ -20,16 +20,16 @@ void GPUProcessor::ProcessCommands() { int commands_processed = 0; while (commands_processed < commands_per_update_ && !parser_->IsEmpty()) { - command_buffer::parse_error::ParseError parse_error = + gpu::parse_error::ParseError parse_error = parser_->ProcessCommand(); switch (parse_error) { - case command_buffer::parse_error::kParseUnknownCommand: - case command_buffer::parse_error::kParseInvalidArguments: + case gpu::parse_error::kParseUnknownCommand: + case gpu::parse_error::kParseInvalidArguments: command_buffer_->SetParseError(parse_error); break; - case command_buffer::parse_error::kParseInvalidSize: - case command_buffer::parse_error::kParseOutOfBounds: + case gpu::parse_error::kParseInvalidSize: + case gpu::parse_error::kParseOutOfBounds: command_buffer_->SetParseError(parse_error); command_buffer_->RaiseErrorStatus(); return; @@ -75,4 +75,4 @@ void GPUProcessor::set_token(int32 token) { command_buffer_->SetToken(token); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/gpu_processor.h b/gpu/command_buffer/service/gpu_processor.h index 6797ef1..a594f0b 100644 --- a/gpu/command_buffer/service/gpu_processor.h +++ b/gpu/command_buffer/service/gpu_processor.h @@ -1,10 +1,11 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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 GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ #define GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ +#include "app/gfx/native_widget_types.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/shared_memory.h" @@ -13,12 +14,12 @@ #include "gpu/command_buffer/service/cmd_parser.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" -namespace command_buffer { +namespace gpu { // This class processes commands in a command buffer. It is event driven and // posts tasks to the current message loop to do additional work. class GPUProcessor : public ::base::RefCounted<GPUProcessor>, - public command_buffer::CommandBufferEngine { + public gpu::CommandBufferEngine { public: explicit GPUProcessor(CommandBuffer* command_buffer); @@ -28,7 +29,7 @@ class GPUProcessor : public ::base::RefCounted<GPUProcessor>, CommandParser* parser, int commands_per_update); - virtual bool Initialize(HWND hwnd); + virtual bool Initialize(gfx::PluginWindowHandle hwnd); virtual ~GPUProcessor(); @@ -36,9 +37,7 @@ class GPUProcessor : public ::base::RefCounted<GPUProcessor>, virtual void ProcessCommands(); -#if defined(OS_WIN) - virtual bool SetWindow(HWND handle, int width, int height); -#endif + virtual bool SetWindow(gfx::PluginWindowHandle handle, int width, int height); // Implementation of CommandBufferEngine. @@ -68,13 +67,13 @@ class GPUProcessor : public ::base::RefCounted<GPUProcessor>, scoped_ptr<CommandParser> parser_; }; -} // namespace command_buffer +} // namespace gpu // Callbacks to the GPUProcessor hold a reference count. template <typename Method> -class CallbackStorage<command_buffer::GPUProcessor, Method> { +class CallbackStorage<gpu::GPUProcessor, Method> { public: - CallbackStorage(command_buffer::GPUProcessor* obj, Method method) + CallbackStorage(gpu::GPUProcessor* obj, Method method) : obj_(obj), meth_(method) { DCHECK(obj_); @@ -86,7 +85,7 @@ class CallbackStorage<command_buffer::GPUProcessor, Method> { } protected: - command_buffer::GPUProcessor* obj_; + gpu::GPUProcessor* obj_; Method meth_; private: diff --git a/gpu/command_buffer/service/gpu_processor_mock.h b/gpu/command_buffer/service/gpu_processor_mock.h index 852782b..be6a938 100644 --- a/gpu/command_buffer/service/gpu_processor_mock.h +++ b/gpu/command_buffer/service/gpu_processor_mock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -8,7 +8,7 @@ #include "gpu/command_buffer/service/gpu_processor.h" #include "testing/gmock/include/gmock/gmock.h" -namespace command_buffer { +namespace gpu { class MockGPUProcessor : public GPUProcessor { public: @@ -16,17 +16,12 @@ class MockGPUProcessor : public GPUProcessor { : GPUProcessor(command_buffer) { } -#if defined(OS_WIN) - MOCK_METHOD1(Initialize, bool(HWND handle)); -#endif - + MOCK_METHOD1(Initialize, bool(gfx::PluginWindowHandle handle)); MOCK_METHOD0(Destroy, void()); MOCK_METHOD0(ProcessCommands, void()); - -#if defined(OS_WIN) - MOCK_METHOD3(SetWindow, bool(HWND handle, int width, int height)); -#endif - + MOCK_METHOD3(SetWindow, bool(gfx::PluginWindowHandle handle, + int width, + int height)); MOCK_METHOD1(GetSharedMemoryAddress, void*(int32 shm_id)); MOCK_METHOD1(GetSharedMemorySize, size_t(int32 shm_id)); MOCK_METHOD1(set_token, void(int32 token)); @@ -35,6 +30,6 @@ class MockGPUProcessor : public GPUProcessor { DISALLOW_COPY_AND_ASSIGN(MockGPUProcessor); }; -} // namespace command_buffer +} // namespace gpu #endif // GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_MOCK_H_ diff --git a/gpu/command_buffer/service/gpu_processor_unittest.cc b/gpu/command_buffer/service/gpu_processor_unittest.cc index db60f3a..5041371 100644 --- a/gpu/command_buffer/service/gpu_processor_unittest.cc +++ b/gpu/command_buffer/service/gpu_processor_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -19,10 +19,10 @@ using testing::Return; using testing::SetArgumentPointee; using testing::StrictMock; -namespace command_buffer { +namespace gpu { const size_t kRingBufferSize = 1024; -const size_t kRingBufferEntries = kRingBufferSize / sizeof(int32); +const size_t kRingBufferEntries = kRingBufferSize / sizeof(CommandBufferEntry); class GPUProcessorTest : public testing::Test { protected: @@ -40,11 +40,11 @@ class GPUProcessorTest : public testing::Test { ON_CALL(*command_buffer_.get(), GetSize()) .WillByDefault(Return(kRingBufferEntries)); - async_api_.reset(new StrictMock<command_buffer::AsyncAPIMock>); + async_api_.reset(new StrictMock<gpu::AsyncAPIMock>); decoder_ = gles2::GLES2Decoder::Create(); - parser_ = new command_buffer::CommandParser(buffer_, + parser_ = new gpu::CommandParser(buffer_, kRingBufferEntries, 0, kRingBufferEntries, @@ -68,9 +68,9 @@ class GPUProcessorTest : public testing::Test { scoped_ptr<MockCommandBuffer> command_buffer_; scoped_ptr<::base::SharedMemory> shared_memory_; int32* buffer_; - command_buffer::gles2::GLES2Decoder* decoder_; - command_buffer::CommandParser* parser_; - scoped_ptr<command_buffer::AsyncAPIMock> async_api_; + gpu::gles2::GLES2Decoder* decoder_; + gpu::CommandParser* parser_; + scoped_ptr<gpu::AsyncAPIMock> async_api_; scoped_refptr<GPUProcessor> processor_; }; @@ -81,14 +81,14 @@ TEST_F(GPUProcessorTest, ProcessorDoesNothingIfRingBufferIsEmpty) { processor_->ProcessCommands(); - EXPECT_EQ(command_buffer::parse_error::kParseNoError, + EXPECT_EQ(gpu::parse_error::kParseNoError, command_buffer_->ResetParseError()); EXPECT_FALSE(command_buffer_->GetErrorStatus()); } TEST_F(GPUProcessorTest, ProcessesOneCommand) { - command_buffer::CommandHeader* header = - reinterpret_cast<command_buffer::CommandHeader*>(&buffer_[0]); + gpu::CommandHeader* header = + reinterpret_cast<gpu::CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 2; buffer_[1] = 123; @@ -98,18 +98,18 @@ TEST_F(GPUProcessorTest, ProcessesOneCommand) { EXPECT_CALL(*command_buffer_, SetGetOffset(2)); EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0])) - .WillOnce(Return(command_buffer::parse_error::kParseNoError)); + .WillOnce(Return(gpu::parse_error::kParseNoError)); processor_->ProcessCommands(); - EXPECT_EQ(command_buffer::parse_error::kParseNoError, + EXPECT_EQ(gpu::parse_error::kParseNoError, command_buffer_->ResetParseError()); EXPECT_FALSE(command_buffer_->GetErrorStatus()); } TEST_F(GPUProcessorTest, ProcessesTwoCommands) { - command_buffer::CommandHeader* header = - reinterpret_cast<command_buffer::CommandHeader*>(&buffer_[0]); + gpu::CommandHeader* header = + reinterpret_cast<gpu::CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 2; buffer_[1] = 123; @@ -121,17 +121,17 @@ TEST_F(GPUProcessorTest, ProcessesTwoCommands) { EXPECT_CALL(*command_buffer_, SetGetOffset(3)); EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0])) - .WillOnce(Return(command_buffer::parse_error::kParseNoError)); + .WillOnce(Return(gpu::parse_error::kParseNoError)); EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2])) - .WillOnce(Return(command_buffer::parse_error::kParseNoError)); + .WillOnce(Return(gpu::parse_error::kParseNoError)); processor_->ProcessCommands(); } TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { - command_buffer::CommandHeader* header = - reinterpret_cast<command_buffer::CommandHeader*>(&buffer_[0]); + gpu::CommandHeader* header = + reinterpret_cast<gpu::CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 2; buffer_[1] = 123; @@ -144,10 +144,10 @@ TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { .WillOnce(Return(4)); EXPECT_CALL(*async_api_, DoCommand(7, 1, &buffer_[0])) - .WillOnce(Return(command_buffer::parse_error::kParseNoError)); + .WillOnce(Return(gpu::parse_error::kParseNoError)); EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2])) - .WillOnce(Return(command_buffer::parse_error::kParseNoError)); + .WillOnce(Return(gpu::parse_error::kParseNoError)); EXPECT_CALL(*command_buffer_, SetGetOffset(3)); @@ -159,7 +159,7 @@ TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { .WillOnce(Return(4)); EXPECT_CALL(*async_api_, DoCommand(9, 0, &buffer_[3])) - .WillOnce(Return(command_buffer::parse_error::kParseNoError)); + .WillOnce(Return(gpu::parse_error::kParseNoError)); EXPECT_CALL(*command_buffer_, SetGetOffset(4)); @@ -167,8 +167,8 @@ TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { } TEST_F(GPUProcessorTest, SetsErrorCodeOnCommandBuffer) { - command_buffer::CommandHeader* header = - reinterpret_cast<command_buffer::CommandHeader*>(&buffer_[0]); + gpu::CommandHeader* header = + reinterpret_cast<gpu::CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 1; @@ -178,18 +178,18 @@ TEST_F(GPUProcessorTest, SetsErrorCodeOnCommandBuffer) { EXPECT_CALL(*async_api_, DoCommand(7, 0, &buffer_[0])) .WillOnce(Return( - command_buffer::parse_error::kParseUnknownCommand)); + gpu::parse_error::kParseUnknownCommand)); EXPECT_CALL(*command_buffer_, - SetParseError(command_buffer::parse_error::kParseUnknownCommand)); + SetParseError(gpu::parse_error::kParseUnknownCommand)); processor_->ProcessCommands(); } TEST_F(GPUProcessorTest, RecoverableParseErrorsAreNotClearedByFollowingSuccessfulCommands) { - command_buffer::CommandHeader* header = - reinterpret_cast<command_buffer::CommandHeader*>(&buffer_[0]); + gpu::CommandHeader* header = + reinterpret_cast<gpu::CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 1; header[1].command = 8; @@ -201,20 +201,20 @@ TEST_F(GPUProcessorTest, EXPECT_CALL(*async_api_, DoCommand(7, 0, &buffer_[0])) .WillOnce(Return( - command_buffer::parse_error::kParseUnknownCommand)); + gpu::parse_error::kParseUnknownCommand)); EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[1])) - .WillOnce(Return(command_buffer::parse_error::kParseNoError)); + .WillOnce(Return(gpu::parse_error::kParseNoError)); EXPECT_CALL(*command_buffer_, - SetParseError(command_buffer::parse_error::kParseUnknownCommand)); + SetParseError(gpu::parse_error::kParseUnknownCommand)); processor_->ProcessCommands(); } TEST_F(GPUProcessorTest, UnrecoverableParseErrorsRaiseTheErrorStatus) { - command_buffer::CommandHeader* header = - reinterpret_cast<command_buffer::CommandHeader*>(&buffer_[0]); + gpu::CommandHeader* header = + reinterpret_cast<gpu::CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 1; header[1].command = 8; @@ -224,10 +224,10 @@ TEST_F(GPUProcessorTest, UnrecoverableParseErrorsRaiseTheErrorStatus) { .WillOnce(Return(2)); EXPECT_CALL(*async_api_, DoCommand(7, 0, &buffer_[0])) - .WillOnce(Return(command_buffer::parse_error::kParseInvalidSize)); + .WillOnce(Return(gpu::parse_error::kParseInvalidSize)); EXPECT_CALL(*command_buffer_, - SetParseError(command_buffer::parse_error::kParseInvalidSize)); + SetParseError(gpu::parse_error::kParseInvalidSize)); EXPECT_CALL(*command_buffer_, RaiseErrorStatus()); @@ -274,4 +274,4 @@ TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) { processor_->set_token(7); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/gpu_processor_win.cc b/gpu/command_buffer/service/gpu_processor_win.cc index a4e138b..c08e102 100644 --- a/gpu/command_buffer/service/gpu_processor_win.cc +++ b/gpu/command_buffer/service/gpu_processor_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -8,7 +8,7 @@ using ::base::SharedMemory; -namespace command_buffer { +namespace gpu { GPUProcessor::GPUProcessor(CommandBuffer* command_buffer) : command_buffer_(command_buffer), @@ -29,7 +29,7 @@ GPUProcessor::GPUProcessor(CommandBuffer* command_buffer, parser_.reset(parser); } -bool GPUProcessor::Initialize(HWND handle) { +bool GPUProcessor::Initialize(gfx::PluginWindowHandle handle) { DCHECK(handle); // Cannot reinitialize. @@ -45,10 +45,10 @@ bool GPUProcessor::Initialize(HWND handle) { } void* ptr = ring_buffer->memory(); - parser_.reset(new command_buffer::CommandParser(ptr, size, 0, size, 0, + parser_.reset(new gpu::CommandParser(ptr, size, 0, size, 0, decoder_.get())); } else { - parser_.reset(new command_buffer::CommandParser(NULL, 0, 0, 0, 0, + parser_.reset(new gpu::CommandParser(NULL, 0, 0, 0, 0, decoder_.get())); } @@ -65,7 +65,9 @@ void GPUProcessor::Destroy() { } } -bool GPUProcessor::SetWindow(HWND handle, int width, int height) { +bool GPUProcessor::SetWindow(gfx::PluginWindowHandle handle, + int width, + int height) { if (handle == NULL) { // Destroy GAPI when the window handle becomes invalid. Destroy(); @@ -75,4 +77,4 @@ bool GPUProcessor::SetWindow(HWND handle, int width, int height) { } } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/mocks.h b/gpu/command_buffer/service/mocks.h index 3d85e32..d77c566 100644 --- a/gpu/command_buffer/service/mocks.h +++ b/gpu/command_buffer/service/mocks.h @@ -36,15 +36,15 @@ // would be definitely preferable, unfortunately it doesn't work on Windows // yet. -#ifndef GPU_COMMAND_BUFFER_SERVICE_CROSS_MOCKS_H_ -#define GPU_COMMAND_BUFFER_SERVICE_CROSS_MOCKS_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_MOCKS_H_ +#define GPU_COMMAND_BUFFER_SERVICE_MOCKS_H_ #include <vector> #include "testing/gmock/include/gmock/gmock.h" #include "gpu/command_buffer/service/cmd_parser.h" #include "gpu/command_buffer/service/cmd_buffer_engine.h" -namespace command_buffer { +namespace gpu { // Mocks an AsyncAPIInterface, using GMock. class AsyncAPIMock : public AsyncAPIInterface { @@ -103,6 +103,6 @@ class AsyncAPIMock : public AsyncAPIInterface { CommandBufferEngine *engine_; }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_SERVICE_CROSS_MOCKS_H_ +#endif // GPU_COMMAND_BUFFER_SERVICE_MOCKS_H_ diff --git a/gpu/command_buffer/service/precompile.h b/gpu/command_buffer/service/precompile.h index 55d2b21..ce2cf9f 100644 --- a/gpu/command_buffer/service/precompile.h +++ b/gpu/command_buffer/service/precompile.h @@ -33,8 +33,8 @@ // This file contains includes for common headers used by command buffer server // files. It is used for pre-compiled header support. -#ifndef GPU_COMMAND_BUFFER_SERVICE_CROSS_PRECOMPILE_H_ -#define GPU_COMMAND_BUFFER_SERVICE_CROSS_PRECOMPILE_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_PRECOMPILE_H_ +#define GPU_COMMAND_BUFFER_SERVICE_PRECOMPILE_H_ #include <build/build_config.h> @@ -47,4 +47,4 @@ #include <map> #include <vector> -#endif // O3D_CORE_CROSS_PRECOMPILE_H_ +#endif // O3D_CORE_PRECOMPILE_H_ diff --git a/gpu/command_buffer/service/resource.cc b/gpu/command_buffer/service/resource.cc index 1208d30..288cc4f 100644 --- a/gpu/command_buffer/service/resource.cc +++ b/gpu/command_buffer/service/resource.cc @@ -35,7 +35,7 @@ #include "gpu/command_buffer/service/precompile.h" #include "gpu/command_buffer/service/resource.h" -namespace command_buffer { +namespace gpu { // Assigns a resource to a resource ID, by setting it at the right location // into the list, resizing the list if necessary, and destroying an existing @@ -98,4 +98,4 @@ void ResourceMapBase::DestroyAllResources() { resources_.clear(); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/resource.h b/gpu/command_buffer/service/resource.h index 20e3038..819f7b2 100644 --- a/gpu/command_buffer/service/resource.h +++ b/gpu/command_buffer/service/resource.h @@ -32,14 +32,14 @@ // This file contains the definition for resource classes and the resource map. -#ifndef GPU_COMMAND_BUFFER_SERVICE_CROSS_RESOURCE_H_ -#define GPU_COMMAND_BUFFER_SERVICE_CROSS_RESOURCE_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_RESOURCE_H_ +#define GPU_COMMAND_BUFFER_SERVICE_RESOURCE_H_ #include <vector> #include "base/scoped_ptr.h" #include "gpu/command_buffer/common/resource.h" -namespace command_buffer { +namespace gpu { // Base class for resources, just providing a common Destroy function. class Resource { @@ -263,6 +263,6 @@ template<class T> class ResourceMap { ResourceMapBase container_; }; -} // namespace command_buffer +} // namespace gpu -#endif // GPU_COMMAND_BUFFER_SERVICE_CROSS_RESOURCE_H_ +#endif // GPU_COMMAND_BUFFER_SERVICE_RESOURCE_H_ diff --git a/gpu/command_buffer/service/resource_test.cc b/gpu/command_buffer/service/resource_test.cc index 7a9438b..50eba1d 100644 --- a/gpu/command_buffer/service/resource_test.cc +++ b/gpu/command_buffer/service/resource_test.cc @@ -36,7 +36,7 @@ #include "gpu/command_buffer/service/resource.h" #include "testing/gtest/include/gtest/gtest.h" -namespace command_buffer { +namespace gpu { // Mock resource implementation that checks for leaks. class ResourceMock : public Resource { @@ -124,4 +124,4 @@ TEST_F(ResourceMapTest, TestMap) { CheckLeaks(); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/x_utils.cc b/gpu/command_buffer/service/x_utils.cc index 3e1776b..2ed6cae 100644 --- a/gpu/command_buffer/service/x_utils.cc +++ b/gpu/command_buffer/service/x_utils.cc @@ -36,7 +36,7 @@ #include "gpu/command_buffer/common/logging.h" #include "gpu/command_buffer/service/x_utils.h" -namespace command_buffer { +namespace gpu { bool XWindowWrapper::Initialize() { XWindowAttributes attributes; @@ -89,4 +89,4 @@ void XWindowWrapper::SwapBuffers() { glXSwapBuffers(display_, window_); } -} // namespace command_buffer +} // namespace gpu diff --git a/gpu/command_buffer/service/x_utils.h b/gpu/command_buffer/service/x_utils.h index bd2dd53..5647ba2 100644 --- a/gpu/command_buffer/service/x_utils.h +++ b/gpu/command_buffer/service/x_utils.h @@ -39,7 +39,7 @@ #include "base/basictypes.h" #include "gpu/command_buffer/common/logging.h" -namespace command_buffer { +namespace gpu { // This class is a wrapper around an X Window and associated GL context. It is // useful to isolate intrusive X headers, since it can be forward declared @@ -71,6 +71,6 @@ class XWindowWrapper { DISALLOW_COPY_AND_ASSIGN(XWindowWrapper); }; -} // namespace command_buffer +} // namespace gpu #endif // GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_ diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index c43e37d..5ebc19b 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -80,6 +80,9 @@ '..', ], }, + 'dependencies': [ + '../base/base.gyp:base', + ], 'sources': [ 'command_buffer/common/bitfield_helpers.h', 'command_buffer/common/cmd_buffer_common.h', @@ -107,7 +110,6 @@ 'type': 'static_library', 'dependencies': [ 'command_buffer_common', - 'np_utils', ], 'sources': [ 'command_buffer/client/gles2_cmd_helper.cc', @@ -271,68 +273,11 @@ }, }, { - 'target_name': 'np_utils', - 'type': '<(library)', - 'dependencies': [ - '../base/base.gyp:base', - ], - 'include_dirs': [ - '..', - ], - 'all_dependent_settings': { - 'include_dirs': [ - '..', - ], - }, - 'sources': [ - 'np_utils/default_np_object.h', - 'np_utils/dynamic_np_object.cc', - 'np_utils/dynamic_np_object.h', - 'np_utils/np_browser.cc', - 'np_utils/np_browser.h', - 'np_utils/np_browser_mock.h', - 'np_utils/np_browser_stub.cc', - 'np_utils/np_browser_stub.h', - 'np_utils/np_class.h', - 'np_utils/np_dispatcher.cc', - 'np_utils/np_dispatcher.h', - 'np_utils/np_dispatcher_specializations.h', - 'np_utils/np_headers.h', - 'np_utils/np_object_mock.h', - 'np_utils/np_object_pointer.h', - 'np_utils/np_plugin_object.h', - 'np_utils/np_plugin_object_mock.h', - 'np_utils/np_plugin_object_factory.cc', - 'np_utils/np_plugin_object_factory.h', - 'np_utils/np_plugin_object_factory_mock.h', - 'np_utils/np_utils.cc', - 'np_utils/np_utils.h', - 'np_utils/webkit_browser.h', - ], - }, - { - 'target_name': 'np_utils_unittests', - 'type': 'none', - 'direct_dependent_settings': { - 'include_dirs': [ - '..', - ], - 'sources': [ - 'np_utils/dispatched_np_object_unittest.cc', - 'np_utils/dynamic_np_object_unittest.cc', - 'np_utils/np_class_unittest.cc', - 'np_utils/np_object_pointer_unittest.cc', - 'np_utils/np_utils_unittest.cc', - ], - }, - }, - { 'target_name': 'gpu_plugin', 'type': '<(library)', 'dependencies': [ '../base/base.gyp:base', 'command_buffer_service', - 'np_utils', ], 'include_dirs': [ '..', @@ -345,28 +290,9 @@ 'sources': [ 'gpu_plugin/gpu_plugin.cc', 'gpu_plugin/gpu_plugin.h', - 'gpu_plugin/gpu_plugin_object.cc', - 'gpu_plugin/gpu_plugin_object.h', - 'gpu_plugin/gpu_plugin_object_win.cc', - 'gpu_plugin/gpu_plugin_object_factory.cc', - 'gpu_plugin/gpu_plugin_object_factory.h', ], }, { - 'target_name': 'gpu_plugin_unittests', - 'type': 'none', - 'direct_dependent_settings': { - 'include_dirs': [ - '..', - ], - 'sources': [ - 'gpu_plugin/gpu_plugin_unittest.cc', - 'gpu_plugin/gpu_plugin_object_unittest.cc', - 'gpu_plugin/gpu_plugin_object_factory_unittest.cc', - ], - }, - }, - { 'target_name': 'gpu_all_unittests', 'type': 'executable', 'dependencies': [ @@ -379,10 +305,6 @@ 'command_buffer_common_unittests', 'command_buffer_service', 'command_buffer_service_unittests', - 'gpu_plugin', - 'gpu_plugin_unittests', - 'np_utils', - 'np_utils_unittests', ], }, { @@ -394,7 +316,6 @@ 'gles2_lib', 'gles2_c_lib', 'gpu_plugin', - 'np_utils', ], 'sources': [ 'command_buffer/client/gles2_demo.cc', diff --git a/gpu/gpu_plugin/gpu_plugin.cc b/gpu/gpu_plugin/gpu_plugin.cc index 35771fd..e43caf1 100644 --- a/gpu/gpu_plugin/gpu_plugin.cc +++ b/gpu/gpu_plugin/gpu_plugin.cc @@ -1,25 +1,15 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. #include "gpu/gpu_plugin/gpu_plugin.h" -#include "gpu/gpu_plugin/gpu_plugin_object_factory.h" -#include "gpu/np_utils/np_browser.h" -#include "gpu/np_utils/np_plugin_object.h" -#include "gpu/np_utils/np_plugin_object_factory.h" #include "webkit/glue/plugins/nphostapi.h" -using np_utils::NPBrowser; -using np_utils::NPPluginObjectFactory; -using np_utils::PluginObject; - namespace gpu_plugin { // Definitions of NPAPI plugin entry points. namespace { -NPBrowser* g_browser; -GPUPluginObjectFactory g_plugin_object_factory; NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc, char* argn[], @@ -27,64 +17,29 @@ NPError NPP_New(NPMIMEType plugin_type, NPP instance, if (!instance) return NPERR_INVALID_INSTANCE_ERROR; - PluginObject* plugin_object = - NPPluginObjectFactory::get()->CreatePluginObject(instance, plugin_type); - if (!plugin_object) - return NPERR_GENERIC_ERROR; - - instance->pdata = plugin_object; - - NPError error = plugin_object->New(plugin_type, argc, argn, argv, saved); - if (error != NPERR_NO_ERROR) { - plugin_object->Release(); - } - - return error; + return NPERR_NO_ERROR; } NPError NPP_Destroy(NPP instance, NPSavedData** saved) { if (!instance) return NPERR_INVALID_INSTANCE_ERROR; - PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata); - NPError error = plugin_object->Destroy(saved); - - if (error == NPERR_NO_ERROR) { - plugin_object->Release(); - } - - return error; + return NPERR_NO_ERROR; } NPError NPP_SetWindow(NPP instance, NPWindow* window) { - if (!instance) - return NPERR_INVALID_INSTANCE_ERROR; - - PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata); - return plugin_object->SetWindow(window); + return NPERR_NO_ERROR; } int16 NPP_HandleEvent(NPP instance, void* event) { - if (!instance) - return 0; - - PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata); - return plugin_object->HandleEvent(static_cast<NPEvent*>(event)); + return 0; } NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { if (!instance) return NPERR_INVALID_INSTANCE_ERROR; - PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata); - switch (variable) { - case NPPVpluginScriptableNPObject: - *reinterpret_cast<NPObject**>(value) = - plugin_object->GetScriptableNPObject(); - return NPERR_NO_ERROR; - default: - return NPERR_GENERIC_ERROR; - } + return NPERR_GENERIC_ERROR; } NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { @@ -111,25 +66,14 @@ NPError NP_Initialize(NPNetscapeFuncs *browser_funcs) { if (!browser_funcs) return NPERR_INVALID_FUNCTABLE_ERROR; - if (g_browser) - return NPERR_GENERIC_ERROR; - #if defined(OS_LINUX) NP_GetEntryPoints(plugin_funcs); #endif - g_browser = new NPBrowser(browser_funcs); - return NPERR_NO_ERROR; } NPError NP_Shutdown() { - if (!g_browser) - return NPERR_GENERIC_ERROR; - - delete g_browser; - g_browser = NULL; - return NPERR_NO_ERROR; } } // namespace gpu_plugin diff --git a/gpu/gpu_plugin/gpu_plugin.h b/gpu/gpu_plugin/gpu_plugin.h index 0f90f77..a667872 100644 --- a/gpu/gpu_plugin/gpu_plugin.h +++ b/gpu/gpu_plugin/gpu_plugin.h @@ -1,11 +1,12 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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 GPU_GPU_PLUGIN_GPU_PLUGIN_H_ #define GPU_GPU_PLUGIN_GPU_PLUGIN_H_ -#include "gpu/np_utils/np_headers.h" +#include "third_party/npapi/bindings/npapi.h" +#include "third_party/npapi/bindings/npruntime.h" typedef struct _NPPluginFuncs NPPluginFuncs; typedef struct _NPNetscapeFuncs NPNetscapeFuncs; @@ -18,7 +19,7 @@ NPError NP_GetEntryPoints(NPPluginFuncs* funcs); #if defined(OS_LINUX) NPError NP_Initialize(NPNetscapeFuncs *browser_funcs, - NPPluginFuncs* plugin_funcs); + NPPluginFuncs* plugin_funcs); #else NPError NP_Initialize(NPNetscapeFuncs* browser_funcs); #endif diff --git a/gpu/gpu_plugin/gpu_plugin_object.cc b/gpu/gpu_plugin/gpu_plugin_object.cc deleted file mode 100644 index c8dadc2..0000000 --- a/gpu/gpu_plugin/gpu_plugin_object.cc +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include <stdlib.h> - -#include "base/logging.h" -#include "gpu/command_buffer/service/command_buffer_service.h" -#include "gpu/command_buffer/service/gpu_processor.h" -#include "gpu/np_utils/np_utils.h" -#include "gpu/gpu_plugin/gpu_plugin_object.h" - -using ::base::SharedMemory; -using command_buffer::CommandBuffer; -using command_buffer::CommandBufferService; -using command_buffer::GPUProcessor; -using np_utils::NPBrowser; -using np_utils::NPObjectPointer; - -namespace gpu_plugin { - -const NPUTF8 GPUPluginObject::kPluginType[] = - "application/vnd.google.chrome.gpu-plugin"; - -GPUPluginObject::GPUPluginObject(NPP npp) - : npp_(npp), - status_(kWaitingForNew), - command_buffer_(new CommandBufferService), - processor_(new GPUProcessor(command_buffer_.get())) { - memset(&window_, 0, sizeof(window_)); -} - -NPError GPUPluginObject::New(NPMIMEType plugin_type, - int16 argc, - char* argn[], - char* argv[], - NPSavedData* saved) { - if (status_ != kWaitingForNew) - return NPERR_GENERIC_ERROR; - - status_ = kWaitingForSetWindow; - - return NPERR_NO_ERROR; -} - -NPError GPUPluginObject::SetWindow(NPWindow* new_window) { - if (status_ == kWaitingForNew || status_ == kDestroyed) - return NPERR_GENERIC_ERROR; - - // PlatformSpecificSetWindow advances the status depending on what happens. - NPError error = PlatformSpecificSetWindow(new_window); - if (error == NPERR_NO_ERROR) { - window_ = *new_window; - - if (event_sync_.Get()) { - NPInvokeVoid(npp_, - event_sync_, - "resize", - static_cast<int32>(window_.width), - static_cast<int32>(window_.height)); - } - } else { - memset(&window_, 0, sizeof(window_)); - } - - return error; -} - -int16 GPUPluginObject::HandleEvent(NPEvent* event) { - return 0; -} - -NPError GPUPluginObject::Destroy(NPSavedData** saved) { - if (status_ == kWaitingForNew || status_ == kDestroyed) - return NPERR_GENERIC_ERROR; - - if (command_buffer_.get()) { - command_buffer_->SetPutOffsetChangeCallback(NULL); - } - - status_ = kDestroyed; - - return NPERR_NO_ERROR; -} - -void GPUPluginObject::Release() { - DCHECK(status_ == kWaitingForNew || status_ == kDestroyed); - NPBrowser::get()->ReleaseObject(this); -} - -NPObject*GPUPluginObject::GetScriptableNPObject() { - NPBrowser::get()->RetainObject(this); - return this; -} - -CommandBuffer* GPUPluginObject::OpenCommandBuffer() { - if (status_ == kInitializationSuccessful) - return command_buffer_.get(); - - // SetWindow must have been called before OpenCommandBuffer. - // PlatformSpecificSetWindow advances the status to - // kWaitingForOpenCommandBuffer. - if (status_ != kWaitingForOpenCommandBuffer) - return NULL; - - scoped_ptr<SharedMemory> ring_buffer(new SharedMemory); - if (!ring_buffer->Create(std::wstring(), false, false, kCommandBufferSize)) - return NULL; - - if (command_buffer_->Initialize(ring_buffer.release())) { - if (processor_->Initialize(static_cast<HWND>(window_.window))) { - command_buffer_->SetPutOffsetChangeCallback( - NewCallback(processor_.get(), - &GPUProcessor::ProcessCommands)); - status_ = kInitializationSuccessful; - return command_buffer_.get(); - } - } - - return NULL; -} - -} // namespace gpu_plugin diff --git a/gpu/gpu_plugin/gpu_plugin_object.h b/gpu/gpu_plugin/gpu_plugin_object.h deleted file mode 100644 index 0602aa9..0000000 --- a/gpu/gpu_plugin/gpu_plugin_object.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2006-2008 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 GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ -#define GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ - -#include <string> - -#include "base/ref_counted.h" -#include "base/thread.h" -#include "gpu/command_buffer/common/command_buffer.h" -#include "gpu/command_buffer/service/gpu_processor.h" -#include "gpu/np_utils/default_np_object.h" -#include "gpu/np_utils/np_dispatcher.h" -#include "gpu/np_utils/np_headers.h" -#include "gpu/np_utils/np_plugin_object.h" -#include "gpu/np_utils/np_utils.h" - -namespace gpu_plugin { - -// The scriptable object for the GPU plugin. -class GPUPluginObject : public np_utils::DefaultNPObject<NPObject>, - public np_utils::PluginObject { - public: - static const int32 kCommandBufferSize = 1024 * 1024; - - enum Status { - // In the state of waiting for the named function to be called to continue - // the initialization sequence. - kWaitingForNew, - kWaitingForSetWindow, - kWaitingForOpenCommandBuffer, - - // Initialization either succeeded or failed. - kInitializationSuccessful, - kInitializationFailed, - - // Destroy has now been called and the plugin object cannot be used. - kDestroyed, - }; - - static const NPUTF8 kPluginType[]; - - explicit GPUPluginObject(NPP npp); - - virtual NPError New(NPMIMEType plugin_type, - int16 argc, - char* argn[], - char* argv[], - NPSavedData* saved); - - virtual NPError SetWindow(NPWindow* new_window); - const NPWindow& GetWindow() { return window_; } - - virtual int16 HandleEvent(NPEvent* event); - - virtual NPError Destroy(NPSavedData** saved); - - virtual void Release(); - - virtual NPObject* GetScriptableNPObject(); - - // Returns the current initialization status. See Status enum. - int32 GetStatus() { - return status_; - } - - // Get the width of the plugin window. - int32 GetWidth() { - return window_.width; - } - - // Get the height of the plugin window. - int32 GetHeight() { - return window_.height; - } - - // Set the object that receives notifications of GPU plugin object events - // such as resize and keyboard and mouse input. - void SetEventSync(np_utils::NPObjectPointer<NPObject> event_sync) { - event_sync_ = event_sync; - } - - np_utils::NPObjectPointer<NPObject> GetEventSync() { - return event_sync_; - } - - // Initializes and returns the command buffer object. Returns NULL if the - // command buffer cannot be initialized, for example if the plugin does not - // yet have a window handle. - command_buffer::CommandBuffer* OpenCommandBuffer(); - - // Set the status for testing. - void set_status(Status status) { - status_ = status; - } - - // Replace the default command buffer for testing. Takes ownership. - void set_command_buffer(command_buffer::CommandBuffer* - command_buffer) { - command_buffer_.reset(command_buffer); - } - - // Replace the default GPU processor for testing. - void set_gpu_processor( - const scoped_refptr<command_buffer::GPUProcessor>& processor) { - processor_ = processor; - } - - NP_UTILS_BEGIN_DISPATCHER_CHAIN(GPUPluginObject, DefaultNPObject<NPObject>) - NP_UTILS_DISPATCHER(GetStatus, int32()) - NP_UTILS_DISPATCHER(GetWidth, int32()) - NP_UTILS_DISPATCHER(GetHeight, int32()) - NP_UTILS_DISPATCHER(SetEventSync, - void(np_utils::NPObjectPointer<NPObject> sync)) - NP_UTILS_DISPATCHER(GetEventSync, np_utils::NPObjectPointer<NPObject>()) - NP_UTILS_END_DISPATCHER_CHAIN - - private: - NPError PlatformSpecificSetWindow(NPWindow* new_window); - - NPP npp_; - Status status_; - NPWindow window_; - scoped_ptr<command_buffer::CommandBuffer> command_buffer_; - scoped_refptr<command_buffer::GPUProcessor> processor_; - np_utils::NPObjectPointer<NPObject> event_sync_; -}; - -} // namespace gpu_plugin - -#endif // GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_ diff --git a/gpu/gpu_plugin/gpu_plugin_object_factory.cc b/gpu/gpu_plugin/gpu_plugin_object_factory.cc deleted file mode 100644 index da9e17a..0000000 --- a/gpu/gpu_plugin/gpu_plugin_object_factory.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include "gpu/gpu_plugin/gpu_plugin_object.h" -#include "gpu/gpu_plugin/gpu_plugin_object_factory.h" -#include "gpu/np_utils/np_utils.h" - -namespace gpu_plugin { - -GPUPluginObjectFactory::GPUPluginObjectFactory() { -} - -GPUPluginObjectFactory::~GPUPluginObjectFactory() { -} - -np_utils::PluginObject* GPUPluginObjectFactory::CreatePluginObject( - NPP npp, - NPMIMEType plugin_type) { - if (strcmp(plugin_type, GPUPluginObject::kPluginType) == 0) { - return np_utils::NPCreateObject<GPUPluginObject>(npp).ToReturned(); - } - - return NULL; -} - -} // namespace gpu_plugin diff --git a/gpu/gpu_plugin/gpu_plugin_object_factory.h b/gpu/gpu_plugin/gpu_plugin_object_factory.h deleted file mode 100644 index 0d1d80e..0000000 --- a/gpu/gpu_plugin/gpu_plugin_object_factory.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2006-2008 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 GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_FACTORY_H_ -#define GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_FACTORY_H_ - -#include "gpu/np_utils/np_plugin_object_factory.h" - -namespace gpu_plugin { - -// Plugin object factory for creating the GPUPluginObject. -class GPUPluginObjectFactory : public np_utils::NPPluginObjectFactory { - public: - GPUPluginObjectFactory(); - virtual ~GPUPluginObjectFactory(); - - virtual np_utils::PluginObject* CreatePluginObject(NPP npp, - NPMIMEType plugin_type); - - private: - DISALLOW_COPY_AND_ASSIGN(GPUPluginObjectFactory); -}; - -} // namespace gpu_plugin - -#endif // GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_FACTORY_H_ diff --git a/gpu/gpu_plugin/gpu_plugin_object_factory_unittest.cc b/gpu/gpu_plugin/gpu_plugin_object_factory_unittest.cc deleted file mode 100644 index 298a8c5..0000000 --- a/gpu/gpu_plugin/gpu_plugin_object_factory_unittest.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include "gpu/gpu_plugin/gpu_plugin_object.h" -#include "gpu/gpu_plugin/gpu_plugin_object_factory.h" -#include "gpu/np_utils/np_browser_stub.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -using np_utils::PluginObject; - -namespace gpu_plugin { - -class PluginObjectFactoryTest : public testing::Test { - protected: - virtual void SetUp() { - factory_ = new GPUPluginObjectFactory; - } - - virtual void TearDown() { - delete factory_; - } - - np_utils::StubNPBrowser stub_browser_; - GPUPluginObjectFactory* factory_; -}; - -TEST_F(PluginObjectFactoryTest, ReturnsNullForUnknownMimeType) { - PluginObject* plugin_object = factory_->CreatePluginObject( - NULL, "application/unknown"); - EXPECT_TRUE(NULL == plugin_object); -} - -TEST_F(PluginObjectFactoryTest, CreatesGPUPlugin) { - PluginObject* plugin_object = factory_->CreatePluginObject( - NULL, const_cast<NPMIMEType>(GPUPluginObject::kPluginType)); - EXPECT_TRUE(NULL != plugin_object); -} - -} // namespace gpu_plugin diff --git a/gpu/gpu_plugin/gpu_plugin_object_unittest.cc b/gpu/gpu_plugin/gpu_plugin_object_unittest.cc deleted file mode 100644 index b032aa0..0000000 --- a/gpu/gpu_plugin/gpu_plugin_object_unittest.cc +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include "gpu/command_buffer/common/command_buffer_mock.h" -#include "gpu/gpu_plugin/gpu_plugin_object.h" -#include "gpu/command_buffer/service/gpu_processor_mock.h" -#include "gpu/np_utils/np_browser_mock.h" -#include "gpu/np_utils/dynamic_np_object.h" -#include "gpu/np_utils/np_object_mock.h" -#include "gpu/np_utils/np_object_pointer.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "webkit/glue/plugins/nphostapi.h" - -using ::base::SharedMemory; -using command_buffer::GPUProcessor; -using command_buffer::MockCommandBuffer; -using command_buffer::MockGPUProcessor; -using np_utils::MockNPBrowser; -using np_utils::NPBrowser; -using np_utils::NPObjectPointer; -using testing::_; -using testing::DoAll; -using testing::Invoke; -using testing::NotNull; -using testing::Return; -using testing::SetArgumentPointee; -using testing::StrictMock; - -namespace gpu_plugin { - -class GPUPluginObjectTest : public testing::Test { - protected: - virtual void SetUp() { - plugin_object_ = np_utils::NPCreateObject<GPUPluginObject>(NULL); - - command_buffer_ = new MockCommandBuffer; - - // Takes ownership. - plugin_object_->set_command_buffer(command_buffer_); - - processor_ = new MockGPUProcessor(command_buffer_); - plugin_object_->set_gpu_processor(processor_.get()); - } - - MockNPBrowser mock_browser_; - NPObjectPointer<GPUPluginObject> plugin_object_; - MockCommandBuffer* command_buffer_; - scoped_refptr<MockGPUProcessor> processor_; -}; - -namespace { -template <typename T> -void DeleteObject(T* object) { - delete object; -} -} // namespace anonymous - - -TEST_F(GPUPluginObjectTest, CanInstantiateAndDestroyPluginObject) { - EXPECT_EQ(GPUPluginObject::kWaitingForNew, plugin_object_->GetStatus()); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - EXPECT_EQ(GPUPluginObject::kWaitingForSetWindow, plugin_object_->GetStatus()); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); - - EXPECT_EQ(GPUPluginObject::kDestroyed, plugin_object_->GetStatus()); -} - -TEST_F(GPUPluginObjectTest, DestroyFailsIfNotInitialized) { - EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->Destroy(NULL)); -} - -TEST_F(GPUPluginObjectTest, NewFailsIfAlreadyInitialized) { - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - EXPECT_EQ(GPUPluginObject::kWaitingForSetWindow, plugin_object_->GetStatus()); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); - - EXPECT_EQ(GPUPluginObject::kDestroyed, plugin_object_->GetStatus()); -} - -TEST_F(GPUPluginObjectTest, NewFailsIfObjectHasPreviouslyBeenDestroyed) { - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); - - EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - EXPECT_EQ(GPUPluginObject::kDestroyed, plugin_object_->GetStatus()); -} - -TEST_F(GPUPluginObjectTest, WindowIsNullBeforeSetWindowCalled) { - NPWindow window = plugin_object_->GetWindow(); - EXPECT_EQ(NULL, window.window); -} - -TEST_F(GPUPluginObjectTest, CanSetWindow) { - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - NPWindow window = {0}; - window.window = &window; - window.x = 7; - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->SetWindow(&window)); - EXPECT_EQ(0, memcmp(&window, &plugin_object_->GetWindow(), sizeof(window))); - EXPECT_EQ(GPUPluginObject::kWaitingForOpenCommandBuffer, - plugin_object_->GetStatus()); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); -} - -TEST_F(GPUPluginObjectTest, CanGetWindowSize) { - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - NPWindow window = {0}; - window.window = &window; - window.x = 10; - window.y = 10; - window.width = 100; - window.height = 200; - - EXPECT_EQ(0, plugin_object_->GetWidth()); - EXPECT_EQ(0, plugin_object_->GetHeight()); - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->SetWindow(&window)); - EXPECT_EQ(100, plugin_object_->GetWidth()); - EXPECT_EQ(200, plugin_object_->GetHeight()); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); -} - -TEST_F(GPUPluginObjectTest, SetWindowFailsIfNotInitialized) { - NPWindow window = {0}; - EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->SetWindow(&window)); - EXPECT_EQ(GPUPluginObject::kWaitingForNew, plugin_object_->GetStatus()); -} - -TEST_F(GPUPluginObjectTest, CanGetScriptableNPObject) { - NPObject* scriptable_object = plugin_object_->GetScriptableNPObject(); - EXPECT_EQ(plugin_object_.Get(), scriptable_object); - NPBrowser::get()->ReleaseObject(scriptable_object); -} - -TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsInitializedCommandBuffer) { - EXPECT_CALL(*command_buffer_, Initialize(NotNull())) - .WillOnce(DoAll(Invoke(DeleteObject<SharedMemory>), - Return(true))); - - EXPECT_CALL(*processor_.get(), Initialize(NULL)) - .WillOnce(Return(true)); - - EXPECT_CALL(*command_buffer_, SetPutOffsetChangeCallback(NotNull())) - .WillOnce(Invoke(DeleteObject<Callback0::Type>)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - // Set status as though SetWindow has been called. Avoids having to create a - // valid window handle to pass to SetWindow in tests. - plugin_object_->set_status(GPUPluginObject::kWaitingForOpenCommandBuffer); - - EXPECT_EQ(command_buffer_, plugin_object_->OpenCommandBuffer()); - - // Calling OpenCommandBuffer again just returns the existing command buffer. - EXPECT_EQ(command_buffer_, plugin_object_->OpenCommandBuffer()); - - EXPECT_EQ(GPUPluginObject::kInitializationSuccessful, - plugin_object_->GetStatus()); - - EXPECT_CALL(*command_buffer_, SetPutOffsetChangeCallback(NULL)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); -} - -TEST_F(GPUPluginObjectTest, OpenCommandBufferReturnsNullIfWindowNotReady) { - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - // Set status as though SetWindow has not been called. - plugin_object_->set_status(GPUPluginObject::kWaitingForSetWindow); - - EXPECT_TRUE(NULL == plugin_object_->OpenCommandBuffer()); - - EXPECT_EQ(GPUPluginObject::kWaitingForSetWindow, plugin_object_->GetStatus()); -} - - -TEST_F(GPUPluginObjectTest, - OpenCommandBufferReturnsNullIfCommandBufferCannotInitialize) { - EXPECT_CALL(*command_buffer_, Initialize(NotNull())) - .WillOnce(DoAll(Invoke(DeleteObject<SharedMemory>), - Return(false))); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - // Set status as though SetWindow has been called. Avoids having to create a - // valid window handle to pass to SetWindow in tests. - plugin_object_->set_status(GPUPluginObject::kWaitingForOpenCommandBuffer); - - EXPECT_TRUE(NULL == plugin_object_->OpenCommandBuffer()); - - EXPECT_EQ(GPUPluginObject::kWaitingForOpenCommandBuffer, - plugin_object_->GetStatus()); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); -} - -TEST_F(GPUPluginObjectTest, - OpenCommandBufferReturnsNullIGPUProcessorCannotInitialize) { - EXPECT_CALL(*command_buffer_, Initialize(NotNull())) - .WillOnce(DoAll(Invoke(DeleteObject<SharedMemory>), - Return(true))); - - EXPECT_CALL(*processor_.get(), Initialize(NULL)) - .WillOnce(Return(false)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - // Set status as though SetWindow has been called. Avoids having to create a - // valid window handle to pass to SetWindow in tests. - plugin_object_->set_status(GPUPluginObject::kWaitingForOpenCommandBuffer); - - EXPECT_TRUE(NULL == plugin_object_->OpenCommandBuffer()); - - EXPECT_EQ(GPUPluginObject::kWaitingForOpenCommandBuffer, - plugin_object_->GetStatus()); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); -} - -class MockEventSync : public np_utils::DefaultNPObject<NPObject> { - public: - explicit MockEventSync(NPP npp) { - } - - MOCK_METHOD2(Resize, void(int32 width, int32 height)); - - NP_UTILS_BEGIN_DISPATCHER_CHAIN(MockEventSync, DefaultNPObject<NPObject>) - NP_UTILS_DISPATCHER(Resize, void(int32 width, int32 height)) - NP_UTILS_END_DISPATCHER_CHAIN - - private: - DISALLOW_COPY_AND_ASSIGN(MockEventSync); -}; - -TEST_F(GPUPluginObjectTest, SendsResizeEventOnSetWindow) { - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo", - 0, - NULL, - NULL, - NULL)); - - NPObjectPointer<MockEventSync> event_sync = - np_utils::NPCreateObject<MockEventSync>(NULL); - plugin_object_->SetEventSync(event_sync); - - EXPECT_CALL(*event_sync.Get(), Resize(100, 200)); - - NPWindow window = {0}; - window.window = &window; - window.x = 10; - window.y = 10; - window.width = 100; - window.height = 200; - - plugin_object_->SetWindow(&window); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL)); -} - -} // namespace gpu_plugin diff --git a/gpu/gpu_plugin/gpu_plugin_object_win.cc b/gpu/gpu_plugin/gpu_plugin_object_win.cc deleted file mode 100644 index 31c6393..0000000 --- a/gpu/gpu_plugin/gpu_plugin_object_win.cc +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include <windows.h> - -#include "gpu/command_buffer/service/gpu_processor.h" -#include "gpu/gpu_plugin/gpu_plugin_object.h" - -namespace gpu_plugin { - -namespace { -const LPCTSTR kPluginObjectProperty = TEXT("GPUPluginObject"); -const LPCTSTR kOriginalWindowProc = TEXT("GPUPluginObjectOriginalWindowProc"); - -LRESULT CALLBACK WindowProc(HWND handle, - UINT message, - WPARAM w_param, - LPARAM l_param) { - return ::DefWindowProc(handle, message, w_param, l_param); -} -} // namespace anonymous - -NPError GPUPluginObject::PlatformSpecificSetWindow(NPWindow* new_window) { - // Detach properties from old window and restore the original window proc. - if (window_.window) { - HWND handle = reinterpret_cast<HWND>(window_.window); - ::RemoveProp(handle, kPluginObjectProperty); - - LONG original_window_proc = reinterpret_cast<LONG>( - ::GetProp(handle, kOriginalWindowProc)); - ::SetWindowLong(handle, GWL_WNDPROC, - original_window_proc); - ::RemoveProp(handle, kOriginalWindowProc); - } - - // Attach properties to new window and set a new window proc. - if (new_window->window) { - HWND handle = reinterpret_cast<HWND>(new_window->window); - ::SetProp(handle, - kPluginObjectProperty, - reinterpret_cast<HANDLE>(this)); - - LONG original_window_proc = ::GetWindowLong(handle, GWL_WNDPROC); - ::SetProp(handle, - kOriginalWindowProc, - reinterpret_cast<HANDLE>(original_window_proc)); - ::SetWindowLong(handle, GWL_WNDPROC, - reinterpret_cast<LONG>(WindowProc)); - - status_ = kWaitingForOpenCommandBuffer; - } else { - status_ = kWaitingForSetWindow; - if (processor_) { - processor_->Destroy(); - } - } - - return NPERR_NO_ERROR; -} - -} // namespace gpu_plugin diff --git a/gpu/gpu_plugin/gpu_plugin_unittest.cc b/gpu/gpu_plugin/gpu_plugin_unittest.cc deleted file mode 100644 index ea1bb5f..0000000 --- a/gpu/gpu_plugin/gpu_plugin_unittest.cc +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#include "gpu/gpu_plugin/gpu_plugin.h" -#include "gpu/gpu_plugin/gpu_plugin_object.h" -#include "gpu/np_utils/np_object_mock.h" -#include "gpu/np_utils/np_plugin_object_factory_mock.h" -#include "gpu/np_utils/np_plugin_object_mock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/plugins/nphostapi.h" - -#if defined(OS_LINUX) -#define INITIALIZE_PLUGIN_FUNCS , &plugin_funcs_ -#else -#define INITIALIZE_PLUGIN_FUNCS -#endif - -using np_utils::MockPluginObject; -using np_utils::PluginObject; -using testing::_; -using testing::DoAll; -using testing::NiceMock; -using testing::Return; -using testing::SetArgumentPointee; -using testing::StrictMock; - -namespace gpu_plugin { - -class GPUPluginTest : public testing::Test { - protected: - virtual void SetUp() { - memset(&npp_, 0, sizeof(npp_)); - memset(&browser_funcs_, 0, sizeof(browser_funcs_)); - memset(&plugin_funcs_, 0, sizeof(plugin_funcs_)); - - plugin_object_factory_ = new StrictMock<np_utils::MockPluginObjectFactory>; - - np_class_ = np_utils::NPGetClass<StrictMock<np_utils::MockNPObject> >(); - } - - virtual void TearDown() { - delete plugin_object_factory_; - } - - NPP_t npp_; - NPNetscapeFuncs browser_funcs_; - NPPluginFuncs plugin_funcs_; - np_utils::MockPluginObjectFactory* plugin_object_factory_; - const NPClass* np_class_; -}; - -TEST_F(GPUPluginTest, GetEntryPointsSetsNeededFunctionPointers) { -#if defined(OS_LINUX) - NPError error = gpu_plugin::NP_Initialize(&browser_funcs_, - &plugin_funcs_); - gpu_plugin::NP_Shutdown(); -#else - NPError error = gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); -#endif - - EXPECT_EQ(NPERR_NO_ERROR, error); - EXPECT_TRUE(NULL != plugin_funcs_.newp); - EXPECT_TRUE(NULL != plugin_funcs_.destroy); - EXPECT_TRUE(NULL != plugin_funcs_.setwindow); - EXPECT_TRUE(NULL != plugin_funcs_.event); - EXPECT_TRUE(NULL != plugin_funcs_.getvalue); - EXPECT_TRUE(NULL != plugin_funcs_.setvalue); -} - -TEST_F(GPUPluginTest, CanInitializeAndShutdownPlugin) { - EXPECT_EQ(NPERR_NO_ERROR, - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS)); - EXPECT_EQ(NPERR_NO_ERROR, gpu_plugin::NP_Shutdown()); -} - -TEST_F(GPUPluginTest, InitializeFailsIfBrowserFuncsIsNull) { - EXPECT_EQ(NPERR_INVALID_FUNCTABLE_ERROR, - gpu_plugin::NP_Initialize(NULL INITIALIZE_PLUGIN_FUNCS)); -} - -TEST_F(GPUPluginTest, InitializeFailsIfAlreadyInitialized) { - EXPECT_EQ(NPERR_NO_ERROR, - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS)); - EXPECT_EQ(NPERR_GENERIC_ERROR, - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS)); - EXPECT_EQ(NPERR_NO_ERROR, gpu_plugin::NP_Shutdown()); -} - -TEST_F(GPUPluginTest, ShutdownFailsIfNotInitialized) { - EXPECT_EQ(NPERR_GENERIC_ERROR, gpu_plugin::NP_Shutdown()); -} - -TEST_F(GPUPluginTest, NewReturnsErrorForInvalidInstance) { - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_INVALID_INSTANCE_ERROR, plugin_funcs_.newp( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - NULL, 0, 0, NULL, NULL, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, GetValueReturnsErrorForInvalidInstance) { - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - int* result = NULL; - EXPECT_EQ(NPERR_INVALID_INSTANCE_ERROR, plugin_funcs_.getvalue( - NULL, NPPVjavaClass, &result)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, DestroyReturnsErrorForInvalidInstance) { - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_INVALID_INSTANCE_ERROR, plugin_funcs_.destroy(NULL, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, SetWindowReturnsErrorForInvalidInstance) { - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_INVALID_INSTANCE_ERROR, plugin_funcs_.setwindow(NULL, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, HandleEventReturnsFalseForInvalidInstance) { - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(0, plugin_funcs_.event(NULL, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, NewCreatesAPluginObjectAndInitializesIt) { - StrictMock<np_utils::MockPluginObject> plugin_object; - - EXPECT_CALL(*plugin_object_factory_, CreatePluginObject( - &npp_, const_cast<NPMIMEType>(GPUPluginObject::kPluginType))) - .WillOnce(Return(&plugin_object)); - - NPObject scriptable_object; - - EXPECT_CALL(plugin_object, New( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - 0, NULL, NULL, NULL)) - .WillOnce(Return(NPERR_NO_ERROR)); - - EXPECT_CALL(plugin_object, GetScriptableNPObject()) - .WillOnce(Return(&scriptable_object)); - - EXPECT_CALL(plugin_object, Destroy(static_cast<NPSavedData**>(NULL))) - .WillOnce(Return(NPERR_NO_ERROR)); - - EXPECT_CALL(plugin_object, Release()); - - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.newp( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - &npp_, 0, 0, NULL, NULL, NULL)); - - NPObject* result; - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.getvalue( - &npp_, NPPVpluginScriptableNPObject, &result)); - EXPECT_EQ(&scriptable_object, result); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.destroy(&npp_, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, NewFailsIfPluginObjectFactoryFails) { - EXPECT_CALL(*plugin_object_factory_, CreatePluginObject( - &npp_, const_cast<NPMIMEType>(GPUPluginObject::kPluginType))) - .WillOnce(Return(static_cast<PluginObject*>(NULL))); - - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_funcs_.newp( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - &npp_, 0, 0, NULL, NULL, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, SetWindowForwardsToPluginObject) { - StrictMock<MockPluginObject> plugin_object; - - EXPECT_CALL(*plugin_object_factory_, CreatePluginObject( - &npp_, const_cast<NPMIMEType>(GPUPluginObject::kPluginType))) - .WillOnce(Return(&plugin_object)); - - EXPECT_CALL(plugin_object, New( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - 0, NULL, NULL, NULL)) - .WillOnce(Return(NPERR_NO_ERROR)); - - NPWindow window = {0}; - - EXPECT_CALL(plugin_object, SetWindow(&window)) - .WillOnce(Return(NPERR_NO_ERROR)); - - EXPECT_CALL(plugin_object, Destroy(static_cast<NPSavedData**>(NULL))) - .WillOnce(Return(NPERR_NO_ERROR)); - - EXPECT_CALL(plugin_object, Release()); - - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.newp( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - &npp_, 0, 0, NULL, NULL, NULL)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.setwindow(&npp_, &window)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.destroy(&npp_, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, HandleEventForwardsToPluginObject) { - StrictMock<MockPluginObject> plugin_object; - - EXPECT_CALL(*plugin_object_factory_, CreatePluginObject( - &npp_, const_cast<NPMIMEType>(GPUPluginObject::kPluginType))) - .WillOnce(Return(&plugin_object)); - - EXPECT_CALL(plugin_object, New( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - 0, NULL, NULL, NULL)) - .WillOnce(Return(NPERR_NO_ERROR)); - - NPEvent event = {0}; - - EXPECT_CALL(plugin_object, HandleEvent(&event)) - .WillOnce(Return(7)); - - EXPECT_CALL(plugin_object, Destroy(static_cast<NPSavedData**>(NULL))) - .WillOnce(Return(NPERR_NO_ERROR)); - - EXPECT_CALL(plugin_object, Release()); - - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.newp( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - &npp_, 0, 0, NULL, NULL, NULL)); - - EXPECT_EQ(7, plugin_funcs_.event(&npp_, &event)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.destroy(&npp_, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -TEST_F(GPUPluginTest, GetValueReturnsErrorForUnknownVariable) { - StrictMock<MockPluginObject> plugin_object; - - EXPECT_CALL(*plugin_object_factory_, CreatePluginObject( - &npp_, const_cast<NPMIMEType>(GPUPluginObject::kPluginType))) - .WillOnce(Return(&plugin_object)); - - EXPECT_CALL(plugin_object, New( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - 0, NULL, NULL, NULL)) - .WillOnce(Return(NPERR_NO_ERROR)); - - EXPECT_CALL(plugin_object, Destroy(static_cast<NPSavedData**>(NULL))) - .WillOnce(Return(NPERR_NO_ERROR)); - - EXPECT_CALL(plugin_object, Release()); - - gpu_plugin::NP_GetEntryPoints(&plugin_funcs_); - gpu_plugin::NP_Initialize(&browser_funcs_ INITIALIZE_PLUGIN_FUNCS); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.newp( - const_cast<NPMIMEType>(GPUPluginObject::kPluginType), - &npp_, 0, 0, NULL, NULL, NULL)); - - int* result = NULL; - EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_funcs_.getvalue( - &npp_, NPPVjavaClass, &result)); - - EXPECT_EQ(NPERR_NO_ERROR, plugin_funcs_.destroy(&npp_, NULL)); - - gpu_plugin::NP_Shutdown(); -} - -} // namespace gpu_plugin diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index 114ec25..e24f98c 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -45,15 +45,12 @@ enum IPCMessageStart { WorkerMsgStart, WorkerHostMsgStart, NaClProcessMsgStart, - //CommandBufferMsgStart, + CommandBufferMsgStart, // NOTE: When you add a new message class, also update // IPCStatusView::IPCStatusView to ensure logging works. LastMsgIndex }; -COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); - - namespace IPC { //----------------------------------------------------------------------------- diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 305d4f7..8a22538 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 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. @@ -134,6 +134,12 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { } #endif +#if !defined(OS_MACOSX) + gfx::PluginWindowHandle windowed_handle() const { + return windowed_handle_; + } +#endif + private: friend class DeleteTask<WebPluginDelegateImpl>; friend class webkit_glue::WebPluginDelegate; |