diff options
author | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-12 00:11:25 +0000 |
---|---|---|
committer | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-12 00:11:25 +0000 |
commit | a7a27ace0760f1ed19016822a45c6ec5300e861c (patch) | |
tree | b7641f10c9fb3130c0ae8f50e7223db2ae722cda /gpu/command_buffer/service | |
parent | 82017272e7272182443d7054911c4f890346353e (diff) | |
download | chromium_src-a7a27ace0760f1ed19016822a45c6ec5300e861c.zip chromium_src-a7a27ace0760f1ed19016822a45c6ec5300e861c.tar.gz chromium_src-a7a27ace0760f1ed19016822a45c6ec5300e861c.tar.bz2 |
Added CommandBufferProxy, CommandBufferStub. Replaced NPAPI with IPC for synchronous messages. WebPluginDelegateImpl can instantiate a command buffer. Removed remaining dependencies on NPAPI.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/465040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
25 files changed, 164 insertions, 202 deletions
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_ |