diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 18:58:54 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-16 18:58:54 +0000 |
commit | 4bbe6d0c3ceb04efe623184d299867d1f5a320f2 (patch) | |
tree | e3705f4cc2ebbf5c6de112ba92ce2a8cc434c2da /gpu/demos/framework | |
parent | 4d1ffe7bb8cf7d97dc66e4a72af992177b293052 (diff) | |
download | chromium_src-4bbe6d0c3ceb04efe623184d299867d1f5a320f2.zip chromium_src-4bbe6d0c3ceb04efe623184d299867d1f5a320f2.tar.gz chromium_src-4bbe6d0c3ceb04efe623184d299867d1f5a320f2.tar.bz2 |
Moved code not relating to GPU scheduling out of GpuScheduler and into GpuCommandBufferStub.
This was mostly a refactor because the code was awkward.
I also deleted the original gles2_demo since we have the gles2 book demos now.
THings still to do are a common way of setting up the few objects involved in initializing a command buffer that is now more-or-less duplicated in the gles2 conformance tests, the gles2 demos, the command buffer stub and the in-process webgl context. I also want to completely remove the reference to the decoder from the scheduler.
I tested WebGL on both windows and mac and saw no regressions. I checked the conformance tests, the gpu tests and am running by the try bots now. The gles2 demos still work.
Review URL: http://codereview.chromium.org/7782041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/demos/framework')
-rw-r--r-- | gpu/demos/framework/window.cc | 63 | ||||
-rw-r--r-- | gpu/demos/framework/window.h | 13 |
2 files changed, 53 insertions, 23 deletions
diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc index 30e4b5e..2fea47b 100644 --- a/gpu/demos/framework/window.cc +++ b/gpu/demos/framework/window.cc @@ -5,10 +5,11 @@ #include "gpu/demos/framework/window.h" #include "base/callback.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #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_scheduler.h" +#include "gpu/command_buffer/service/context_group.h" #include "gpu/demos/framework/demo.h" #include "gpu/demos/framework/demo_factory.h" @@ -50,47 +51,63 @@ void Window::OnPaint() { ::gles2::GetGLContext()->SwapBuffers(); } -// TODO(apatrick): It looks like all the resources allocated here leak. We -// should fix that if we want to use this Window class for anything beyond this -// simple use case. bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) { - scoped_ptr<CommandBufferService> command_buffer(new CommandBufferService); - if (!command_buffer->Initialize(kCommandBufferSize)) { + command_buffer_.reset(new CommandBufferService); + if (!command_buffer_->Initialize(kCommandBufferSize)) { return false; } - GpuScheduler* gpu_scheduler( - GpuScheduler::Create(command_buffer.get(), NULL)); - if (!gpu_scheduler->Initialize(hwnd, gfx::Size(), false, - gpu::gles2::DisallowedExtensions(), - NULL, std::vector<int32>(), - NULL)) { + gpu::gles2::ContextGroup::Ref group(new gpu::gles2::ContextGroup(true)); + + decoder_.reset(gpu::gles2::GLES2Decoder::Create(group.get())); + if (!decoder_.get()) + return false; + + gpu_scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), + decoder_.get(), + NULL)); + + decoder_->set_engine(gpu_scheduler_.get()); + + surface_ = gfx::GLSurface::CreateViewGLSurface(false, hwnd); + if (!surface_.get()) return false; - } - command_buffer->SetPutOffsetChangeCallback( - NewCallback(gpu_scheduler, &GpuScheduler::PutChanged)); + context_ = gfx::GLContext::CreateGLContext(NULL, surface_.get()); + if (!context_.get()) + return false; - GLES2CmdHelper* helper = new GLES2CmdHelper(command_buffer.get()); - if (!helper->Initialize(kCommandBufferSize)) { - // TODO(alokp): cleanup. + std::vector<int32> attribs; + if (!decoder_->Initialize(surface_.get(), + context_.get(), + gfx::Size(), + gpu::gles2::DisallowedExtensions(), + NULL, + attribs)) { return false; } + command_buffer_->SetPutOffsetChangeCallback( + NewCallback(gpu_scheduler_.get(), &GpuScheduler::PutChanged)); + + gles2_cmd_helper_.reset(new GLES2CmdHelper(command_buffer_.get())); + if (!gles2_cmd_helper_->Initialize(kCommandBufferSize)) + return false; + int32 transfer_buffer_id = - command_buffer->CreateTransferBuffer(kTransferBufferSize, -1); + command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1); Buffer transfer_buffer = - command_buffer->GetTransferBuffer(transfer_buffer_id); + command_buffer_->GetTransferBuffer(transfer_buffer_id); if (transfer_buffer.ptr == NULL) return false; ::gles2::Initialize(); - ::gles2::SetGLContext(new GLES2Implementation(helper, + ::gles2::SetGLContext(new GLES2Implementation(gles2_cmd_helper_.get(), transfer_buffer.size, transfer_buffer.ptr, transfer_buffer_id, false, true)); - return command_buffer.release() != NULL; + return true; } } // namespace demos diff --git a/gpu/demos/framework/window.h b/gpu/demos/framework/window.h index 3054def..4c6cd46 100644 --- a/gpu/demos/framework/window.h +++ b/gpu/demos/framework/window.h @@ -6,6 +6,12 @@ #define GPU_DEMOS_FRAMEWORK_WINDOW_H_ #include "base/memory/scoped_ptr.h" +#include "gpu/command_buffer/client/gles2_cmd_helper.h" +#include "gpu/command_buffer/service/command_buffer_service.h" +#include "gpu/command_buffer/service/gpu_scheduler.h" +#include "gpu/command_buffer/service/gles2_cmd_decoder.h" +#include "ui/gfx/gl/gl_context.h" +#include "ui/gfx/gl/gl_surface.h" #include "ui/gfx/native_widget_types.h" namespace gpu { @@ -40,6 +46,13 @@ class Window { gfx::NativeWindow window_handle_; scoped_ptr<Demo> demo_; + scoped_ptr<gpu::CommandBufferService> command_buffer_; + scoped_ptr<gpu::GpuScheduler> gpu_scheduler_; + scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; + scoped_refptr<gfx::GLContext> context_; + scoped_refptr<gfx::GLSurface> surface_; + scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_; + DISALLOW_COPY_AND_ASSIGN(Window); }; |