Chromium Code Reviews| Index: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| index c0d011345fa3aa6df6b94c9bb0ec459811750274..7f2b332604ba633e69673d8a94ca4c5d13d372f0 100644 |
| --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc |
| @@ -27,14 +27,18 @@ |
| #include "base/synchronization/lock.h" |
| #include "gpu/command_buffer/client/gles2_implementation.h" |
| #include "gpu/command_buffer/client/gles2_lib.h" |
| +#include "gpu/command_buffer/client/gpu_memory_buffer_factory.h" |
| +#include "gpu/command_buffer/client/image_factory.h" |
| #include "gpu/command_buffer/client/transfer_buffer.h" |
| #include "gpu/command_buffer/common/constants.h" |
| #include "gpu/command_buffer/service/command_buffer_service.h" |
| #include "gpu/command_buffer/service/context_group.h" |
| #include "gpu/command_buffer/service/gl_context_virtual.h" |
| #include "gpu/command_buffer/service/gpu_scheduler.h" |
| +#include "gpu/command_buffer/service/image_manager.h" |
| #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| #include "ui/gl/gl_context.h" |
| +#include "ui/gl/gl_image.h" |
| #include "ui/gl/gl_share_group.h" |
| #include "ui/gl/gl_surface.h" |
| #include "webkit/gpu/gl_bindings_skia_cmd_buffer.h" |
| @@ -42,8 +46,11 @@ |
| using gpu::Buffer; |
| using gpu::CommandBuffer; |
| using gpu::CommandBufferService; |
| +using gpu::gles2::ImageFactory; |
|
no sievers
2013/05/10 01:21:51
nit: order
kaanb
2013/05/13 23:00:36
Done.
|
| using gpu::gles2::GLES2CmdHelper; |
| using gpu::gles2::GLES2Implementation; |
| +using gpu::gles2::ImageManager; |
| +using gpu::GpuMemoryBuffer; |
| using gpu::GpuScheduler; |
| using gpu::TransferBuffer; |
| using gpu::TransferBufferManager; |
| @@ -162,6 +169,8 @@ class GLInProcessContext { |
| void OnContextLost(); |
| + ::gpu::gles2::ImageManager* GetImageManager(); |
| + |
| base::Closure context_lost_callback_; |
| scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
| scoped_ptr<CommandBufferService> command_buffer_; |
| @@ -190,6 +199,47 @@ const size_t kStartTransferBufferSize = 4 * 1024 * 1024; |
| const size_t kMinTransferBufferSize = 1 * 256 * 1024; |
| const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; |
| +class ImageFactoryInProcess : public ImageFactory { |
| + public: |
| + explicit ImageFactoryInProcess(ImageManager* image_manager); |
| + virtual ~ImageFactoryInProcess(); |
| + |
| + // methods from ImageFactory |
| + virtual scoped_ptr<GpuMemoryBuffer> CreateGpuMemoryBuffer( |
| + int width, int height, unsigned int* image_id) OVERRIDE; |
| + virtual void RemoveFromManager(unsigned int image_id) OVERRIDE; |
| + private: |
| + scoped_refptr<ImageManager> image_manager_; |
| + unsigned int next_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ImageFactoryInProcess); |
| +}; |
| + |
| +ImageFactoryInProcess::ImageFactoryInProcess( |
| + ImageManager* image_manager) : image_manager_(image_manager), |
| + next_id_(0) { |
| +} |
| + |
| +ImageFactoryInProcess::~ImageFactoryInProcess() { |
| +} |
| + |
| +scoped_ptr<GpuMemoryBuffer> ImageFactoryInProcess:: |
| + CreateGpuMemoryBuffer(int width, int height, unsigned int* image_id) { |
| + scoped_ptr<GpuMemoryBuffer> buffer = |
| + ::gpu::gles2::GetProcessDefaultGpuMemoryBufferFactory().Run( |
| + width, height); |
| + scoped_refptr<gfx::GLImage> gl_image = |
| + gfx::GLImage::CreateGLImageForGpuMemoryBuffer(buffer->GetNativeBuffer(), |
| + gfx::Size(width, height)); |
| + *image_id = ++next_id_; // Valid image_ids start from 1. |
| + image_manager_->AddImage(gl_image, *image_id); |
| + return buffer.Pass(); |
| +} |
| + |
| +void ImageFactoryInProcess::RemoveFromManager(unsigned int image_id) { |
| + image_manager_->RemoveImage(image_id); |
| +} |
| + |
| // Singleton used to initialize and terminate the gles2 library. |
| class GLES2Initializer { |
| public: |
| @@ -417,6 +467,10 @@ GLES2Implementation* GLInProcessContext::GetImplementation() { |
| return gles2_implementation_.get(); |
| } |
| +::gpu::gles2::ImageManager* GLInProcessContext::GetImageManager() { |
| + return decoder_->GetContextGroup()->image_manager(); |
| +} |
| + |
| GLInProcessContext::GLInProcessContext(bool share_resources) |
| : last_error_(SUCCESS), |
| share_resources_(share_resources), |
| @@ -601,6 +655,13 @@ bool GLInProcessContext::Initialize( |
| true, |
| false)); |
| + // GLES2Implementation::Initialize() which is called next |
| + // needs the ImageFactory so we set it before Initialize is called. |
| + scoped_ptr<ImageFactory> image_factory( |
| + new ImageFactoryInProcess(GetImageManager())); |
|
no sievers
2013/05/10 01:21:51
That means different clients in the share group wi
kaanb
2013/05/13 23:00:36
Let me know how this change looks.
|
| + // GLES2Implementation takes the ownership of |image_factory|. |
| + gles2_implementation_->SetImageFactory(image_factory.Pass()); |
| + |
| if (!gles2_implementation_->Initialize( |
| kStartTransferBufferSize, |
| kMinTransferBufferSize, |
| @@ -1829,6 +1890,20 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { |
| } |
| } |
| +DELEGATE_TO_GL_2R(createImageCHROMIUM, CreateImageCHROMIUM, |
| + WGC3Dsizei, WGC3Dsizei, WGC3Duint); |
| + |
| +DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint); |
| + |
| +DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM, |
| + WGC3Duint, WGC3Denum, GLint*); |
| + |
| +DELEGATE_TO_GL_2R(mapImageCHROMIUM, MapImageCHROMIUM, |
| + WGC3Duint, WGC3Denum, void*); |
| + |
| +DELEGATE_TO_GL_1R(unmapImageCHROMIUM, UnmapImageCHROMIUM, |
| + WGC3Duint, WGC3Dboolean); |
| + |
| DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM, |
| WebGLId, WGC3Dint, const WGC3Dchar*) |