diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 23:16:22 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-14 23:16:22 +0000 |
commit | 09ddb91f6a81adebe023e461387c6510471e6778 (patch) | |
tree | 2abb8507621721af69610222aace5e7818885c08 /gpu | |
parent | 6cf19311fbe08c5c8c674a50fd834ae818b549c0 (diff) | |
download | chromium_src-09ddb91f6a81adebe023e461387c6510471e6778.zip chromium_src-09ddb91f6a81adebe023e461387c6510471e6778.tar.gz chromium_src-09ddb91f6a81adebe023e461387c6510471e6778.tar.bz2 |
Landing issue 6828049 on behalf of KushalP.
http://codereview.chromium.org/6826049/
Original message:
Renaming GPUProcessor to GpuScheduler
TEST=try
BUG=76585
Review URL: http://codereview.chromium.org/6853027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
16 files changed, 161 insertions, 161 deletions
diff --git a/gpu/command_buffer/client/cmd_buffer_helper_test.cc b/gpu/command_buffer/client/cmd_buffer_helper_test.cc index 9f526df..1daa942 100644 --- a/gpu/command_buffer/client/cmd_buffer_helper_test.cc +++ b/gpu/command_buffer/client/cmd_buffer_helper_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -10,7 +10,7 @@ #include "gpu/command_buffer/client/cmd_buffer_helper.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/command_buffer_service.h" -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "testing/gtest/include/gtest/gtest.h" namespace gpu { @@ -77,19 +77,19 @@ class CommandBufferHelperTest : public testing::Test { .WillRepeatedly( Invoke(do_jump_command_.get(), &DoJumpCommand::DoCommand)); - gpu_processor_.reset(new GPUProcessor( + gpu_scheduler_.reset(new GpuScheduler( command_buffer_.get(), NULL, parser_, 1)); command_buffer_->SetPutOffsetChangeCallback(NewCallback( - gpu_processor_.get(), &GPUProcessor::ProcessCommands)); + gpu_scheduler_.get(), &GpuScheduler::ProcessCommands)); - api_mock_->set_engine(gpu_processor_.get()); + api_mock_->set_engine(gpu_scheduler_.get()); helper_.reset(new CommandBufferHelper(command_buffer_.get())); helper_->Initialize(kCommandBufferSizeBytes); } virtual void TearDown() { - // If the GPUProcessor posts any tasks, this forces them to run. + // If the GpuScheduler posts any tasks, this forces them to run. MessageLoop::current()->RunAllPending(); } @@ -156,7 +156,7 @@ class CommandBufferHelperTest : public testing::Test { MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; scoped_ptr<CommandBufferService> command_buffer_; - scoped_ptr<GPUProcessor> gpu_processor_; + scoped_ptr<GpuScheduler> gpu_scheduler_; CommandParser* parser_; scoped_ptr<CommandBufferHelper> helper_; Sequence sequence_; diff --git a/gpu/command_buffer/client/fenced_allocator_test.cc b/gpu/command_buffer/client/fenced_allocator_test.cc index 658deef2..533e867 100644 --- a/gpu/command_buffer/client/fenced_allocator_test.cc +++ b/gpu/command_buffer/client/fenced_allocator_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +12,7 @@ #include "gpu/command_buffer/service/cmd_buffer_engine.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/command_buffer_service.h" -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "testing/gtest/include/gtest/gtest.h" namespace gpu { @@ -51,12 +51,12 @@ class BaseFencedAllocatorTest : public testing::Test { 0, api_mock_.get()); - gpu_processor_.reset(new GPUProcessor( + gpu_scheduler_.reset(new GpuScheduler( command_buffer_.get(), NULL, parser_, INT_MAX)); command_buffer_->SetPutOffsetChangeCallback(NewCallback( - gpu_processor_.get(), &GPUProcessor::ProcessCommands)); + gpu_scheduler_.get(), &GpuScheduler::ProcessCommands)); - api_mock_->set_engine(gpu_processor_.get()); + api_mock_->set_engine(gpu_scheduler_.get()); helper_.reset(new CommandBufferHelper(command_buffer_.get())); helper_->Initialize(kBufferSize); @@ -70,7 +70,7 @@ class BaseFencedAllocatorTest : public testing::Test { MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; scoped_ptr<CommandBufferService> command_buffer_; - scoped_ptr<GPUProcessor> gpu_processor_; + scoped_ptr<GpuScheduler> gpu_scheduler_; CommandParser* parser_; scoped_ptr<CommandBufferHelper> helper_; }; @@ -91,7 +91,7 @@ class FencedAllocatorTest : public BaseFencedAllocatorTest { } virtual void TearDown() { - // If the GPUProcessor posts any tasks, this forces them to run. + // If the GpuScheduler posts any tasks, this forces them to run. MessageLoop::current()->RunAllPending(); EXPECT_TRUE(allocator_->CheckConsistency()); @@ -387,7 +387,7 @@ class FencedAllocatorWrapperTest : public BaseFencedAllocatorTest { } virtual void TearDown() { - // If the GPUProcessor posts any tasks, this forces them to run. + // If the GpuScheduler posts any tasks, this forces them to run. MessageLoop::current()->RunAllPending(); EXPECT_TRUE(allocator_->CheckConsistency()); diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc index 91ef9bf2..096a9d3 100644 --- a/gpu/command_buffer/client/gles2_demo.cc +++ b/gpu/command_buffer/client/gles2_demo.cc @@ -19,7 +19,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/shared_memory.h" -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "gpu/command_buffer/service/command_buffer_service.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/client/gles2_lib.h" @@ -29,7 +29,7 @@ using base::SharedMemory; using gpu::Buffer; -using gpu::GPUProcessor; +using gpu::GpuScheduler; using gpu::CommandBufferService; using gpu::gles2::GLES2CmdHelper; using gpu::gles2::GLES2Implementation; @@ -56,8 +56,8 @@ bool GLES2Demo::Setup(void* hwnd, int32 size) { if (!command_buffer->Initialize(size)) return NULL; - GPUProcessor* gpu_processor = new GPUProcessor(command_buffer.get(), NULL); - if (!gpu_processor->Initialize(reinterpret_cast<HWND>(hwnd), + GpuScheduler* gpu_scheduler = new GpuScheduler(command_buffer.get(), NULL); + if (!gpu_scheduler->Initialize(reinterpret_cast<HWND>(hwnd), gfx::Size(), gpu::gles2::DisallowedExtensions(), NULL, @@ -68,7 +68,7 @@ bool GLES2Demo::Setup(void* hwnd, int32 size) { } command_buffer->SetPutOffsetChangeCallback( - NewCallback(gpu_processor, &GPUProcessor::ProcessCommands)); + NewCallback(gpu_scheduler, &GpuScheduler::ProcessCommands)); GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); if (!helper->Initialize(size)) { diff --git a/gpu/command_buffer/client/mapped_memory_unittest.cc b/gpu/command_buffer/client/mapped_memory_unittest.cc index 87bac68..93e63e7 100644 --- a/gpu/command_buffer/client/mapped_memory_unittest.cc +++ b/gpu/command_buffer/client/mapped_memory_unittest.cc @@ -10,7 +10,7 @@ #include "gpu/command_buffer/client/cmd_buffer_helper.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/command_buffer_service.h" -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "testing/gtest/include/gtest/gtest.h" namespace gpu { @@ -49,12 +49,12 @@ class MappedMemoryTestBase : public testing::Test { 0, api_mock_.get()); - gpu_processor_.reset(new GPUProcessor( + gpu_scheduler_.reset(new GpuScheduler( command_buffer_.get(), NULL, parser_, INT_MAX)); command_buffer_->SetPutOffsetChangeCallback(NewCallback( - gpu_processor_.get(), &GPUProcessor::ProcessCommands)); + gpu_scheduler_.get(), &GpuScheduler::ProcessCommands)); - api_mock_->set_engine(gpu_processor_.get()); + api_mock_->set_engine(gpu_scheduler_.get()); helper_.reset(new CommandBufferHelper(command_buffer_.get())); helper_->Initialize(kBufferSize); @@ -68,7 +68,7 @@ class MappedMemoryTestBase : public testing::Test { MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; scoped_ptr<CommandBufferService> command_buffer_; - scoped_ptr<GPUProcessor> gpu_processor_; + scoped_ptr<GpuScheduler> gpu_scheduler_; CommandParser* parser_; scoped_ptr<CommandBufferHelper> helper_; }; @@ -94,7 +94,7 @@ class MemoryChunkTest : public MappedMemoryTestBase { } virtual void TearDown() { - // If the GPUProcessor posts any tasks, this forces them to run. + // If the GpuScheduler posts any tasks, this forces them to run. MessageLoop::current()->RunAllPending(); MappedMemoryTestBase::TearDown(); @@ -145,7 +145,7 @@ class MappedMemoryManagerTest : public MappedMemoryTestBase { } virtual void TearDown() { - // If the GPUProcessor posts any tasks, this forces them to run. + // If the GpuScheduler posts any tasks, this forces them to run. MessageLoop::current()->RunAllPending(); manager_.reset(); MappedMemoryTestBase::TearDown(); diff --git a/gpu/command_buffer/client/ring_buffer_test.cc b/gpu/command_buffer/client/ring_buffer_test.cc index 6510611..e3c14c7 100644 --- a/gpu/command_buffer/client/ring_buffer_test.cc +++ b/gpu/command_buffer/client/ring_buffer_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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,7 +12,7 @@ #include "gpu/command_buffer/service/cmd_buffer_engine.h" #include "gpu/command_buffer/service/mocks.h" #include "gpu/command_buffer/service/command_buffer_service.h" -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "testing/gtest/include/gtest/gtest.h" namespace gpu { @@ -52,12 +52,12 @@ class BaseRingBufferTest : public testing::Test { 0, api_mock_.get()); - gpu_processor_.reset(new GPUProcessor( + gpu_scheduler_.reset(new GpuScheduler( command_buffer_.get(), NULL, parser_, INT_MAX)); command_buffer_->SetPutOffsetChangeCallback(NewCallback( - gpu_processor_.get(), &GPUProcessor::ProcessCommands)); + gpu_scheduler_.get(), &GpuScheduler::ProcessCommands)); - api_mock_->set_engine(gpu_processor_.get()); + api_mock_->set_engine(gpu_scheduler_.get()); helper_.reset(new CommandBufferHelper(command_buffer_.get())); helper_->Initialize(kBufferSize); @@ -71,7 +71,7 @@ class BaseRingBufferTest : public testing::Test { MessageLoop message_loop_; scoped_ptr<AsyncAPIMock> api_mock_; scoped_ptr<CommandBufferService> command_buffer_; - scoped_ptr<GPUProcessor> gpu_processor_; + scoped_ptr<GpuScheduler> gpu_scheduler_; CommandParser* parser_; scoped_ptr<CommandBufferHelper> helper_; }; @@ -93,7 +93,7 @@ class RingBufferTest : public BaseRingBufferTest { } virtual void TearDown() { - // If the GPUProcessor posts any tasks, this forces them to run. + // If the GpuScheduler posts any tasks, this forces them to run. MessageLoop::current()->RunAllPending(); BaseRingBufferTest::TearDown(); @@ -189,7 +189,7 @@ class RingBufferWrapperTest : public BaseRingBufferTest { } virtual void TearDown() { - // If the GPUProcessor posts any tasks, this forces them to run. + // If the GpuScheduler posts any tasks, this forces them to run. MessageLoop::current()->RunAllPending(); BaseRingBufferTest::TearDown(); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 3b6990d..03b4735 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -1841,7 +1841,7 @@ bool GLES2DecoderImpl::Initialize( } if (!group_->Initialize(disallowed_extensions, allowed_extensions)) { - LOG(ERROR) << "GPUProcessor::InitializeCommon failed because group " + LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " << "failed to initialize."; Destroy(); return false; diff --git a/gpu/command_buffer/service/gpu_processor_mock.h b/gpu/command_buffer/service/gpu_processor_mock.h deleted file mode 100644 index 8eab35d..0000000 --- a/gpu/command_buffer/service/gpu_processor_mock.h +++ /dev/null @@ -1,29 +0,0 @@ -// 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_MOCK_H_ -#define GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_MOCK_H_ - -#include "gpu/command_buffer/service/gpu_processor.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace gpu { - -class MockGPUProcessor : public GPUProcessor { - public: - explicit MockGPUProcessor(CommandBuffer* command_buffer) - : GPUProcessor(command_buffer) { - } - - MOCK_METHOD0(ProcessCommands, void()); - MOCK_METHOD1(GetSharedMemoryBuffer, Buffer(int32 shm_id)); - MOCK_METHOD1(set_token, void(int32 token)); - - private: - DISALLOW_COPY_AND_ASSIGN(MockGPUProcessor); -}; - -} // namespace gpu - -#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_MOCK_H_ diff --git a/gpu/command_buffer/service/gpu_processor.cc b/gpu/command_buffer/service/gpu_scheduler.cc index c2363b8..933b468 100644 --- a/gpu/command_buffer/service/gpu_processor.cc +++ b/gpu/command_buffer/service/gpu_scheduler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "base/callback.h" #include "base/compiler_specific.h" @@ -17,7 +17,7 @@ static size_t kNumThrottleFences = 1; namespace gpu { -GPUProcessor::GPUProcessor(CommandBuffer* command_buffer, +GpuScheduler::GpuScheduler(CommandBuffer* command_buffer, gles2::ContextGroup* group) : command_buffer_(command_buffer), commands_per_update_(100), @@ -32,7 +32,7 @@ GPUProcessor::GPUProcessor(CommandBuffer* command_buffer, decoder_->set_engine(this); } -GPUProcessor::GPUProcessor(CommandBuffer* command_buffer, +GpuScheduler::GpuScheduler(CommandBuffer* command_buffer, gles2::GLES2Decoder* decoder, CommandParser* parser, int commands_per_update) @@ -49,11 +49,11 @@ GPUProcessor::GPUProcessor(CommandBuffer* command_buffer, parser_.reset(parser); } -GPUProcessor::~GPUProcessor() { +GpuScheduler::~GpuScheduler() { Destroy(); } -bool GPUProcessor::InitializeCommon( +bool GpuScheduler::InitializeCommon( gfx::GLContext* context, const gfx::Size& size, const gles2::DisallowedExtensions& disallowed_extensions, @@ -98,7 +98,7 @@ bool GPUProcessor::InitializeCommon( attribs, parent_decoder, parent_texture_id)) { - LOG(ERROR) << "GPUProcessor::InitializeCommon failed because decoder " + LOG(ERROR) << "GpuScheduler::InitializeCommon failed because decoder " << "failed to initialize."; Destroy(); return false; @@ -107,7 +107,7 @@ bool GPUProcessor::InitializeCommon( return true; } -void GPUProcessor::DestroyCommon() { +void GpuScheduler::DestroyCommon() { bool have_context = false; if (decoder_.get()) { have_context = decoder_->MakeCurrent(); @@ -124,8 +124,8 @@ const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; } #endif -void GPUProcessor::ProcessCommands() { - GPU_TRACE_EVENT0("gpu", "GPUProcessor:ProcessCommands"); +void GpuScheduler::ProcessCommands() { + GPU_TRACE_EVENT0("gpu", "GpuScheduler:ProcessCommands"); CommandBuffer::State state = command_buffer_->GetState(); if (state.error != error::kNoError) return; @@ -206,21 +206,21 @@ void GPUProcessor::ProcessCommands() { } } -void GPUProcessor::ScheduleProcessCommands() { +void GpuScheduler::ScheduleProcessCommands() { MessageLoop::current()->PostTask( FROM_HERE, - method_factory_.NewRunnableMethod(&GPUProcessor::ProcessCommands)); + method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); } -Buffer GPUProcessor::GetSharedMemoryBuffer(int32 shm_id) { +Buffer GpuScheduler::GetSharedMemoryBuffer(int32 shm_id) { return command_buffer_->GetTransferBuffer(shm_id); } -void GPUProcessor::set_token(int32 token) { +void GpuScheduler::set_token(int32 token) { command_buffer_->SetToken(token); } -bool GPUProcessor::SetGetOffset(int32 offset) { +bool GpuScheduler::SetGetOffset(int32 offset) { if (parser_->set_get(offset)) { command_buffer_->SetGetOffset(static_cast<int32>(parser_->get())); return true; @@ -228,27 +228,27 @@ bool GPUProcessor::SetGetOffset(int32 offset) { return false; } -int32 GPUProcessor::GetGetOffset() { +int32 GpuScheduler::GetGetOffset() { return parser_->get(); } -void GPUProcessor::ResizeOffscreenFrameBuffer(const gfx::Size& size) { +void GpuScheduler::ResizeOffscreenFrameBuffer(const gfx::Size& size) { decoder_->ResizeOffscreenFrameBuffer(size); } -void GPUProcessor::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { +void GpuScheduler::SetResizeCallback(Callback1<gfx::Size>::Type* callback) { decoder_->SetResizeCallback(callback); } -void GPUProcessor::SetSwapBuffersCallback( +void GpuScheduler::SetSwapBuffersCallback( Callback0::Type* callback) { wrapped_swap_buffers_callback_.reset(callback); decoder_->SetSwapBuffersCallback( NewCallback(this, - &GPUProcessor::WillSwapBuffers)); + &GpuScheduler::WillSwapBuffers)); } -void GPUProcessor::SetCommandProcessedCallback( +void GpuScheduler::SetCommandProcessedCallback( Callback0::Type* callback) { command_processed_callback_.reset(callback); } diff --git a/gpu/command_buffer/service/gpu_processor.h b/gpu/command_buffer/service/gpu_scheduler.h index 234c437..5ed808c 100644 --- a/gpu/command_buffer/service/gpu_processor.h +++ b/gpu/command_buffer/service/gpu_scheduler.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_SERVICE_GPU_PROCESSOR_H_ -#define GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ +#ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ #include <queue> #include <vector> @@ -36,18 +36,18 @@ class ContextGroup; // 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 CommandBufferEngine { +class GpuScheduler : public CommandBufferEngine { public: // If a group is not passed in one will be created. - GPUProcessor(CommandBuffer* command_buffer, gles2::ContextGroup* group); + GpuScheduler(CommandBuffer* command_buffer, gles2::ContextGroup* group); // This constructor is for unit tests. - GPUProcessor(CommandBuffer* command_buffer, + GpuScheduler(CommandBuffer* command_buffer, gles2::GLES2Decoder* decoder, CommandParser* parser, int commands_per_update); - virtual ~GPUProcessor(); + virtual ~GpuScheduler(); // Perform platform specific and common initialization. bool Initialize(gfx::PluginWindowHandle hwnd, @@ -55,7 +55,7 @@ class GPUProcessor : public CommandBufferEngine { const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, - GPUProcessor* parent, + GpuScheduler* parent, uint32 parent_texture_id); void Destroy(); @@ -114,7 +114,7 @@ class GPUProcessor : public CommandBufferEngine { virtual void SetCommandProcessedCallback(Callback0::Type* callback); - // Get the GLES2Decoder associated with this processor. + // Get the GLES2Decoder associated with this scheduler. gles2::GLES2Decoder* decoder() const { return decoder_.get(); } protected: @@ -134,8 +134,8 @@ class GPUProcessor : public CommandBufferEngine { // user's swap buffers callback. virtual void WillSwapBuffers(); - // The GPUProcessor holds a weak reference to the CommandBuffer. The - // CommandBuffer owns the GPUProcessor and holds a strong reference to it + // The GpuScheduler holds a weak reference to the CommandBuffer. The + // CommandBuffer owns the GpuScheduler and holds a strong reference to it // through the ProcessCommands callback. CommandBuffer* command_buffer_; @@ -153,11 +153,11 @@ class GPUProcessor : public CommandBufferEngine { uint64 acknowledged_swap_buffers_count_; #endif - ScopedRunnableMethodFactory<GPUProcessor> method_factory_; + ScopedRunnableMethodFactory<GpuScheduler> method_factory_; scoped_ptr<Callback0::Type> wrapped_swap_buffers_callback_; scoped_ptr<Callback0::Type> command_processed_callback_; }; } // namespace gpu -#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_PROCESSOR_H_ +#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_H_ diff --git a/gpu/command_buffer/service/gpu_processor_linux.cc b/gpu/command_buffer/service/gpu_scheduler_linux.cc index 87f694e..48ed470 100644 --- a/gpu/command_buffer/service/gpu_processor_linux.cc +++ b/gpu/command_buffer/service/gpu_scheduler_linux.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "ui/gfx/gl/gl_context.h" using ::base::SharedMemory; namespace gpu { -bool GPUProcessor::Initialize( +bool GpuScheduler::Initialize( gfx::PluginWindowHandle window, const gfx::Size& size, const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, - GPUProcessor* parent, + GpuScheduler* parent, uint32 parent_texture_id) { // Get the parent decoder and the GLContext to share IDs with, if any. gles2::GLES2Decoder* parent_decoder = NULL; @@ -41,7 +41,7 @@ bool GPUProcessor::Initialize( } if (!context.get()) { - LOG(ERROR) << "GPUProcessor::Initialize failed"; + LOG(ERROR) << "GpuScheduler::Initialize failed"; return false; } @@ -54,11 +54,11 @@ bool GPUProcessor::Initialize( parent_texture_id); } -void GPUProcessor::Destroy() { +void GpuScheduler::Destroy() { DestroyCommon(); } -void GPUProcessor::WillSwapBuffers() { +void GpuScheduler::WillSwapBuffers() { if (wrapped_swap_buffers_callback_.get()) { wrapped_swap_buffers_callback_->Run(); } diff --git a/gpu/command_buffer/service/gpu_processor_mac.cc b/gpu/command_buffer/service/gpu_scheduler_mac.cc index 4d250ac..f89bfb5 100644 --- a/gpu/command_buffer/service/gpu_processor_mac.cc +++ b/gpu/command_buffer/service/gpu_scheduler_mac.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "ui/gfx/gl/gl_context.h" using ::base::SharedMemory; namespace gpu { -bool GPUProcessor::Initialize( +bool GpuScheduler::Initialize( gfx::PluginWindowHandle window, const gfx::Size& size, const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, - GPUProcessor* parent, + GpuScheduler* parent, uint32 parent_texture_id) { // Get the parent decoder and the GLContext to share IDs with, if any. gles2::GLES2Decoder* parent_decoder = NULL; @@ -46,7 +46,7 @@ bool GPUProcessor::Initialize( // not hold on to the reference. It simply extracts the underlying GL // context in order to share the namespace with another context. if (!surface_->Initialize(context.get(), false)) { - LOG(ERROR) << "GPUProcessor::Initialize failed to " + LOG(ERROR) << "GpuScheduler::Initialize failed to " << "initialize AcceleratedSurface."; Destroy(); return false; @@ -62,7 +62,7 @@ bool GPUProcessor::Initialize( parent_texture_id); } -void GPUProcessor::Destroy() { +void GpuScheduler::Destroy() { if (surface_.get()) { surface_->Destroy(); surface_.reset(); @@ -71,7 +71,7 @@ void GPUProcessor::Destroy() { DestroyCommon(); } -uint64 GPUProcessor::SetWindowSizeForIOSurface(const gfx::Size& size) { +uint64 GpuScheduler::SetWindowSizeForIOSurface(const gfx::Size& size) { // This is called from an IPC handler, so it's undefined which context is // current. Make sure the right one is. decoder_->GetGLContext()->MakeCurrent(); @@ -83,36 +83,36 @@ uint64 GPUProcessor::SetWindowSizeForIOSurface(const gfx::Size& size) { return surface_->SetSurfaceSize(size); } -TransportDIB::Handle GPUProcessor::SetWindowSizeForTransportDIB( +TransportDIB::Handle GpuScheduler::SetWindowSizeForTransportDIB( const gfx::Size& size) { ResizeOffscreenFrameBuffer(size); decoder_->UpdateOffscreenFrameBufferSize(); return surface_->SetTransportDIBSize(size); } -void GPUProcessor::SetTransportDIBAllocAndFree( +void GpuScheduler::SetTransportDIBAllocAndFree( Callback2<size_t, TransportDIB::Handle*>::Type* allocator, Callback1<TransportDIB::Id>::Type* deallocator) { surface_->SetTransportDIBAllocAndFree(allocator, deallocator); } -uint64 GPUProcessor::GetSurfaceId() { +uint64 GpuScheduler::GetSurfaceId() { if (!surface_.get()) return 0; return surface_->GetSurfaceId(); } -uint64 GPUProcessor::swap_buffers_count() const { +uint64 GpuScheduler::swap_buffers_count() const { return swap_buffers_count_; } -void GPUProcessor::set_acknowledged_swap_buffers_count( +void GpuScheduler::set_acknowledged_swap_buffers_count( uint64 acknowledged_swap_buffers_count) { acknowledged_swap_buffers_count_ = acknowledged_swap_buffers_count; } -void GPUProcessor::DidDestroySurface() { - // When a browser window with a GPUProcessor is closed, the render process +void GpuScheduler::DidDestroySurface() { + // When a browser window with a GpuScheduler is closed, the render process // will attempt to finish all GL commands, it will busy-wait on the GPU // process until the command queue is empty. If a paint is pending, the GPU // process won't process any GL commands until the browser sends a paint ack, @@ -123,7 +123,7 @@ void GPUProcessor::DidDestroySurface() { surface_.reset(); } -void GPUProcessor::WillSwapBuffers() { +void GpuScheduler::WillSwapBuffers() { DCHECK(decoder_.get()); DCHECK(decoder_->GetGLContext()); DCHECK(decoder_->GetGLContext()->IsCurrent()); diff --git a/gpu/command_buffer/service/gpu_scheduler_mock.h b/gpu/command_buffer/service/gpu_scheduler_mock.h new file mode 100644 index 0000000..4bc1bb5 --- /dev/null +++ b/gpu/command_buffer/service/gpu_scheduler_mock.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 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_SCHEDULER_MOCK_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_MOCK_H_ + +#include "gpu/command_buffer/service/gpu_scheduler.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace gpu { + +class MockGpuScheduler : public GpuScheduler { + public: + explicit MockGpuScheduler(CommandBuffer* command_buffer) + : GpuScheduler(command_buffer) { + } + + MOCK_METHOD0(ProcessCommands, void()); + MOCK_METHOD1(GetSharedMemoryBuffer, Buffer(int32 shm_id)); + MOCK_METHOD1(set_token, void(int32 token)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockGpuScheduler); +}; + +} // namespace gpu + +#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SCHEDULER_MOCK_H_ diff --git a/gpu/command_buffer/service/gpu_processor_unittest.cc b/gpu/command_buffer/service/gpu_scheduler_unittest.cc index ce91210..b992fa7 100644 --- a/gpu/command_buffer/service/gpu_processor_unittest.cc +++ b/gpu/command_buffer/service/gpu_scheduler_unittest.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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/mac/scoped_nsautorelease_pool.h" #include "base/message_loop.h" #include "gpu/command_buffer/common/command_buffer_mock.h" -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" #include "gpu/command_buffer/service/mocks.h" @@ -25,7 +25,7 @@ namespace gpu { const size_t kRingBufferSize = 1024; const size_t kRingBufferEntries = kRingBufferSize / sizeof(CommandBufferEntry); -class GPUProcessorTest : public testing::Test { +class GpuSchedulerTest : public testing::Test { protected: virtual void SetUp() { shared_memory_.reset(new ::base::SharedMemory); @@ -55,7 +55,7 @@ class GPUProcessorTest : public testing::Test { 0, async_api_.get()); - processor_.reset(new GPUProcessor(command_buffer_.get(), + scheduler_.reset(new GpuScheduler(command_buffer_.get(), decoder_, parser_, 2)); @@ -66,7 +66,7 @@ class GPUProcessorTest : public testing::Test { } virtual void TearDown() { - // Ensure that any unexpected tasks posted by the GPU processor are executed + // Ensure that any unexpected tasks posted by the GPU scheduler are executed // in order to fail the test. MessageLoop::current()->RunAllPending(); } @@ -84,10 +84,10 @@ class GPUProcessorTest : public testing::Test { gles2::MockGLES2Decoder* decoder_; CommandParser* parser_; scoped_ptr<AsyncAPIMock> async_api_; - scoped_ptr<GPUProcessor> processor_; + scoped_ptr<GpuScheduler> scheduler_; }; -TEST_F(GPUProcessorTest, ProcessorDoesNothingIfRingBufferIsEmpty) { +TEST_F(GpuSchedulerTest, SchedulerDoesNothingIfRingBufferIsEmpty) { CommandBuffer::State state; state.put_offset = 0; @@ -98,10 +98,10 @@ TEST_F(GPUProcessorTest, ProcessorDoesNothingIfRingBufferIsEmpty) { EXPECT_CALL(*command_buffer_, SetParseError(_)) .Times(0); - processor_->ProcessCommands(); + scheduler_->ProcessCommands(); } -TEST_F(GPUProcessorTest, ProcessesOneCommand) { +TEST_F(GpuSchedulerTest, ProcessesOneCommand) { CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 2; @@ -120,10 +120,10 @@ TEST_F(GPUProcessorTest, ProcessesOneCommand) { EXPECT_CALL(*command_buffer_, SetParseError(_)) .Times(0); - processor_->ProcessCommands(); + scheduler_->ProcessCommands(); } -TEST_F(GPUProcessorTest, ProcessesTwoCommands) { +TEST_F(GpuSchedulerTest, ProcessesTwoCommands) { CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 2; @@ -144,10 +144,10 @@ TEST_F(GPUProcessorTest, ProcessesTwoCommands) { EXPECT_CALL(*async_api_, DoCommand(8, 0, &buffer_[2])) .WillOnce(Return(error::kNoError)); - processor_->ProcessCommands(); + scheduler_->ProcessCommands(); } -TEST_F(GPUProcessorTest, ProcessorSetsTheGLContext) { +TEST_F(GpuSchedulerTest, SchedulerSetsTheGLContext) { EXPECT_CALL(*decoder_, MakeCurrent()) .WillOnce(Return(true)) .WillOnce(Return(true)); @@ -159,10 +159,10 @@ TEST_F(GPUProcessorTest, ProcessorSetsTheGLContext) { EXPECT_CALL(*command_buffer_, SetGetOffset(0)); - processor_->ProcessCommands(); + scheduler_->ProcessCommands(); } -TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { +TEST_F(GpuSchedulerTest, PostsTaskToFinishRemainingCommands) { CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 2; @@ -186,7 +186,7 @@ TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { EXPECT_CALL(*command_buffer_, SetGetOffset(3)); - processor_->ProcessCommands(); + scheduler_->ProcessCommands(); // ProcessCommands is called a second time when the pending task is run. @@ -202,7 +202,7 @@ TEST_F(GPUProcessorTest, PostsTaskToFinishRemainingCommands) { MessageLoop::current()->RunAllPending(); } -TEST_F(GPUProcessorTest, SetsErrorCodeOnCommandBuffer) { +TEST_F(GpuSchedulerTest, SetsErrorCodeOnCommandBuffer) { CommandHeader* header = reinterpret_cast<CommandHeader*>(&buffer_[0]); header[0].command = 7; header[0].size = 1; @@ -220,40 +220,40 @@ TEST_F(GPUProcessorTest, SetsErrorCodeOnCommandBuffer) { EXPECT_CALL(*command_buffer_, SetParseError(error::kUnknownCommand)); - processor_->ProcessCommands(); + scheduler_->ProcessCommands(); } -TEST_F(GPUProcessorTest, ProcessCommandsDoesNothingAfterError) { +TEST_F(GpuSchedulerTest, ProcessCommandsDoesNothingAfterError) { CommandBuffer::State state; state.error = error::kGenericError; EXPECT_CALL(*command_buffer_, GetState()) .WillOnce(Return(state)); - processor_->ProcessCommands(); + scheduler_->ProcessCommands(); } -TEST_F(GPUProcessorTest, CanGetAddressOfSharedMemory) { +TEST_F(GpuSchedulerTest, CanGetAddressOfSharedMemory) { EXPECT_CALL(*command_buffer_.get(), GetTransferBuffer(7)) .WillOnce(Return(shared_memory_buffer_)); - EXPECT_EQ(&buffer_[0], processor_->GetSharedMemoryBuffer(7).ptr); + EXPECT_EQ(&buffer_[0], scheduler_->GetSharedMemoryBuffer(7).ptr); } ACTION_P2(SetPointee, address, value) { *address = value; } -TEST_F(GPUProcessorTest, CanGetSizeOfSharedMemory) { +TEST_F(GpuSchedulerTest, CanGetSizeOfSharedMemory) { EXPECT_CALL(*command_buffer_.get(), GetTransferBuffer(7)) .WillOnce(Return(shared_memory_buffer_)); - EXPECT_EQ(kRingBufferSize, processor_->GetSharedMemoryBuffer(7).size); + EXPECT_EQ(kRingBufferSize, scheduler_->GetSharedMemoryBuffer(7).size); } -TEST_F(GPUProcessorTest, SetTokenForwardsToCommandBuffer) { +TEST_F(GpuSchedulerTest, SetTokenForwardsToCommandBuffer) { EXPECT_CALL(*command_buffer_, SetToken(7)); - processor_->set_token(7); + scheduler_->set_token(7); } } // namespace gpu diff --git a/gpu/command_buffer/service/gpu_processor_win.cc b/gpu/command_buffer/service/gpu_scheduler_win.cc index fb48f74..23c8782 100644 --- a/gpu/command_buffer/service/gpu_processor_win.cc +++ b/gpu/command_buffer/service/gpu_scheduler_win.cc @@ -4,20 +4,20 @@ #include <windows.h> -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "ui/gfx/gl/gl_context.h" using ::base::SharedMemory; namespace gpu { -bool GPUProcessor::Initialize( +bool GpuScheduler::Initialize( gfx::PluginWindowHandle window, const gfx::Size& size, const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, - GPUProcessor* parent, + GpuScheduler* parent, uint32 parent_texture_id) { // Get the parent decoder and the GLContext to share IDs with, if any. gles2::GLES2Decoder* parent_decoder = NULL; @@ -53,11 +53,11 @@ bool GPUProcessor::Initialize( parent_texture_id); } -void GPUProcessor::Destroy() { +void GpuScheduler::Destroy() { DestroyCommon(); } -void GPUProcessor::WillSwapBuffers() { +void GpuScheduler::WillSwapBuffers() { if (wrapped_swap_buffers_callback_.get()) { wrapped_swap_buffers_callback_->Run(); } diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc index fead4ac..974a5ee 100644 --- a/gpu/demos/framework/window.cc +++ b/gpu/demos/framework/window.cc @@ -8,13 +8,13 @@ #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/client/gles2_lib.h" #include "gpu/command_buffer/service/command_buffer_service.h" -#include "gpu/command_buffer/service/gpu_processor.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" #include "gpu/demos/framework/demo.h" #include "gpu/demos/framework/demo_factory.h" using gpu::Buffer; using gpu::CommandBufferService; -using gpu::GPUProcessor; +using gpu::GpuScheduler; using gpu::gles2::GLES2CmdHelper; using gpu::gles2::GLES2Implementation; @@ -59,9 +59,9 @@ bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) { return false; } - GPUProcessor* gpu_processor( - new GPUProcessor(command_buffer.get(), NULL)); - if (!gpu_processor->Initialize(hwnd, gfx::Size(), + GpuScheduler* gpu_scheduler( + new GpuScheduler(command_buffer.get(), NULL)); + if (!gpu_scheduler->Initialize(hwnd, gfx::Size(), gpu::gles2::DisallowedExtensions(), NULL, std::vector<int32>(), NULL, 0)) { @@ -69,7 +69,7 @@ bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) { } command_buffer->SetPutOffsetChangeCallback( - NewCallback(gpu_processor, &GPUProcessor::ProcessCommands)); + NewCallback(gpu_scheduler, &GpuScheduler::ProcessCommands)); GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); if (!helper->Initialize(kCommandBufferSize)) { diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index e33c78ca..3915877 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -217,12 +217,12 @@ 'command_buffer/service/gles2_cmd_validation_autogen.h', 'command_buffer/service/gles2_cmd_validation_implementation_autogen.h', 'command_buffer/service/gl_utils.h', - 'command_buffer/service/gpu_processor.h', - 'command_buffer/service/gpu_processor.cc', - 'command_buffer/service/gpu_processor_linux.cc', - 'command_buffer/service/gpu_processor_mac.cc', - 'command_buffer/service/gpu_processor_mock.h', - 'command_buffer/service/gpu_processor_win.cc', + 'command_buffer/service/gpu_scheduler.h', + 'command_buffer/service/gpu_scheduler.cc', + 'command_buffer/service/gpu_scheduler_linux.cc', + 'command_buffer/service/gpu_scheduler_mac.cc', + 'command_buffer/service/gpu_scheduler_mock.h', + 'command_buffer/service/gpu_scheduler_win.cc', 'command_buffer/service/id_manager.h', 'command_buffer/service/id_manager.cc', 'command_buffer/service/mocks.h', @@ -293,7 +293,7 @@ 'command_buffer/service/common_decoder_unittest.cc', 'command_buffer/service/feature_info_unittest.cc', 'command_buffer/service/framebuffer_manager_unittest.cc', - 'command_buffer/service/gpu_processor_unittest.cc', + 'command_buffer/service/gpu_scheduler_unittest.cc', 'command_buffer/service/gles2_cmd_decoder_unittest_base.h', 'command_buffer/service/gles2_cmd_decoder_unittest_base.cc', 'command_buffer/service/gles2_cmd_decoder_unittest.cc', |