| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/client/gl_in_process_context.h" | 5 #include "gpu/command_buffer/client/gl_in_process_context.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 : public GLInProcessContext, | 47 : public GLInProcessContext, |
| 48 public base::SupportsWeakPtr<GLInProcessContextImpl> { | 48 public base::SupportsWeakPtr<GLInProcessContextImpl> { |
| 49 public: | 49 public: |
| 50 GLInProcessContextImpl(); | 50 GLInProcessContextImpl(); |
| 51 ~GLInProcessContextImpl() override; | 51 ~GLInProcessContextImpl() override; |
| 52 | 52 |
| 53 bool Initialize(scoped_refptr<gl::GLSurface> surface, | 53 bool Initialize(scoped_refptr<gl::GLSurface> surface, |
| 54 bool is_offscreen, | 54 bool is_offscreen, |
| 55 GLInProcessContext* share_context, | 55 GLInProcessContext* share_context, |
| 56 gfx::AcceleratedWidget window, | 56 gfx::AcceleratedWidget window, |
| 57 const gfx::Size& size, | |
| 58 const gpu::gles2::ContextCreationAttribHelper& attribs, | 57 const gpu::gles2::ContextCreationAttribHelper& attribs, |
| 59 gl::GpuPreference gpu_preference, | |
| 60 const scoped_refptr<InProcessCommandBuffer::Service>& service, | 58 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
| 61 const SharedMemoryLimits& mem_limits, | 59 const SharedMemoryLimits& mem_limits, |
| 62 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 60 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 63 ImageFactory* image_factory); | 61 ImageFactory* image_factory); |
| 64 | 62 |
| 65 // GLInProcessContext implementation: | 63 // GLInProcessContext implementation: |
| 66 gles2::GLES2Implementation* GetImplementation() override; | 64 gles2::GLES2Implementation* GetImplementation() override; |
| 67 void SetLock(base::Lock* lock) override; | 65 void SetLock(base::Lock* lock) override; |
| 68 | 66 |
| 69 private: | 67 private: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 90 | 88 |
| 91 void GLInProcessContextImpl::SetLock(base::Lock* lock) { | 89 void GLInProcessContextImpl::SetLock(base::Lock* lock) { |
| 92 NOTREACHED(); | 90 NOTREACHED(); |
| 93 } | 91 } |
| 94 | 92 |
| 95 bool GLInProcessContextImpl::Initialize( | 93 bool GLInProcessContextImpl::Initialize( |
| 96 scoped_refptr<gl::GLSurface> surface, | 94 scoped_refptr<gl::GLSurface> surface, |
| 97 bool is_offscreen, | 95 bool is_offscreen, |
| 98 GLInProcessContext* share_context, | 96 GLInProcessContext* share_context, |
| 99 gfx::AcceleratedWidget window, | 97 gfx::AcceleratedWidget window, |
| 100 const gfx::Size& size, | |
| 101 const gles2::ContextCreationAttribHelper& attribs, | 98 const gles2::ContextCreationAttribHelper& attribs, |
| 102 gl::GpuPreference gpu_preference, | |
| 103 const scoped_refptr<InProcessCommandBuffer::Service>& service, | 99 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
| 104 const SharedMemoryLimits& mem_limits, | 100 const SharedMemoryLimits& mem_limits, |
| 105 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 101 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 106 ImageFactory* image_factory) { | 102 ImageFactory* image_factory) { |
| 107 DCHECK(size.width() >= 0 && size.height() >= 0); | 103 DCHECK_GE(attribs.offscreen_framebuffer_size.width(), 0); |
| 104 DCHECK_GE(attribs.offscreen_framebuffer_size.height(), 0); |
| 108 | 105 |
| 109 command_buffer_.reset(new InProcessCommandBuffer(service)); | 106 command_buffer_.reset(new InProcessCommandBuffer(service)); |
| 110 | 107 |
| 111 scoped_refptr<gles2::ShareGroup> share_group; | 108 scoped_refptr<gles2::ShareGroup> share_group; |
| 112 InProcessCommandBuffer* share_command_buffer = nullptr; | 109 InProcessCommandBuffer* share_command_buffer = nullptr; |
| 113 if (share_context) { | 110 if (share_context) { |
| 114 GLInProcessContextImpl* impl = | 111 GLInProcessContextImpl* impl = |
| 115 static_cast<GLInProcessContextImpl*>(share_context); | 112 static_cast<GLInProcessContextImpl*>(share_context); |
| 116 share_group = impl->gles2_implementation_->share_group(); | 113 share_group = impl->gles2_implementation_->share_group(); |
| 117 share_command_buffer = impl->command_buffer_.get(); | 114 share_command_buffer = impl->command_buffer_.get(); |
| 118 DCHECK(share_group); | 115 DCHECK(share_group); |
| 119 DCHECK(share_command_buffer); | 116 DCHECK(share_command_buffer); |
| 120 } | 117 } |
| 121 | 118 |
| 122 if (!command_buffer_->Initialize(surface, | 119 if (!command_buffer_->Initialize(surface, |
| 123 is_offscreen, | 120 is_offscreen, |
| 124 window, | 121 window, |
| 125 size, | |
| 126 attribs, | 122 attribs, |
| 127 gpu_preference, | |
| 128 share_command_buffer, | 123 share_command_buffer, |
| 129 gpu_memory_buffer_manager, | 124 gpu_memory_buffer_manager, |
| 130 image_factory)) { | 125 image_factory)) { |
| 131 DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; | 126 DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; |
| 132 return false; | 127 return false; |
| 133 } | 128 } |
| 134 | 129 |
| 135 // Create the GLES2 helper, which writes the command buffer protocol. | 130 // Create the GLES2 helper, which writes the command buffer protocol. |
| 136 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); | 131 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); |
| 137 if (!gles2_helper_->Initialize(mem_limits.command_buffer_size)) { | 132 if (!gles2_helper_->Initialize(mem_limits.command_buffer_size)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 182 } |
| 188 | 183 |
| 189 } // anonymous namespace | 184 } // anonymous namespace |
| 190 | 185 |
| 191 // static | 186 // static |
| 192 GLInProcessContext* GLInProcessContext::Create( | 187 GLInProcessContext* GLInProcessContext::Create( |
| 193 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 188 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| 194 scoped_refptr<gl::GLSurface> surface, | 189 scoped_refptr<gl::GLSurface> surface, |
| 195 bool is_offscreen, | 190 bool is_offscreen, |
| 196 gfx::AcceleratedWidget window, | 191 gfx::AcceleratedWidget window, |
| 197 const gfx::Size& size, | |
| 198 GLInProcessContext* share_context, | 192 GLInProcessContext* share_context, |
| 199 const ::gpu::gles2::ContextCreationAttribHelper& attribs, | 193 const ::gpu::gles2::ContextCreationAttribHelper& attribs, |
| 200 gl::GpuPreference gpu_preference, | |
| 201 const SharedMemoryLimits& memory_limits, | 194 const SharedMemoryLimits& memory_limits, |
| 202 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 195 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 203 ImageFactory* image_factory) { | 196 ImageFactory* image_factory) { |
| 204 if (surface.get()) { | 197 if (surface.get()) { |
| 205 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); | 198 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); |
| 206 DCHECK(surface->GetSize() == size); | |
| 207 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); | 199 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); |
| 208 } | 200 } |
| 209 | 201 |
| 210 std::unique_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl); | 202 std::unique_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl); |
| 211 if (!context->Initialize(surface, is_offscreen, share_context, window, size, | 203 if (!context->Initialize(surface, is_offscreen, share_context, window, |
| 212 attribs, gpu_preference, service, memory_limits, | 204 attribs, service, memory_limits, |
| 213 gpu_memory_buffer_manager, image_factory)) | 205 gpu_memory_buffer_manager, image_factory)) |
| 214 return NULL; | 206 return NULL; |
| 215 | 207 |
| 216 return context.release(); | 208 return context.release(); |
| 217 } | 209 } |
| 218 | 210 |
| 219 } // namespace gpu | 211 } // namespace gpu |
| OLD | NEW |