| 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, |
| 57 const gpu::gles2::ContextCreationAttribHelper& attribs, | 58 const gpu::gles2::ContextCreationAttribHelper& attribs, |
| 59 gl::GpuPreference gpu_preference, |
| 58 const scoped_refptr<InProcessCommandBuffer::Service>& service, | 60 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
| 59 const SharedMemoryLimits& mem_limits, | 61 const SharedMemoryLimits& mem_limits, |
| 60 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 62 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 61 ImageFactory* image_factory); | 63 ImageFactory* image_factory); |
| 62 | 64 |
| 63 // GLInProcessContext implementation: | 65 // GLInProcessContext implementation: |
| 64 gles2::GLES2Implementation* GetImplementation() override; | 66 gles2::GLES2Implementation* GetImplementation() override; |
| 65 void SetLock(base::Lock* lock) override; | 67 void SetLock(base::Lock* lock) override; |
| 66 | 68 |
| 67 private: | 69 private: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 | 90 |
| 89 void GLInProcessContextImpl::SetLock(base::Lock* lock) { | 91 void GLInProcessContextImpl::SetLock(base::Lock* lock) { |
| 90 NOTREACHED(); | 92 NOTREACHED(); |
| 91 } | 93 } |
| 92 | 94 |
| 93 bool GLInProcessContextImpl::Initialize( | 95 bool GLInProcessContextImpl::Initialize( |
| 94 scoped_refptr<gl::GLSurface> surface, | 96 scoped_refptr<gl::GLSurface> surface, |
| 95 bool is_offscreen, | 97 bool is_offscreen, |
| 96 GLInProcessContext* share_context, | 98 GLInProcessContext* share_context, |
| 97 gfx::AcceleratedWidget window, | 99 gfx::AcceleratedWidget window, |
| 100 const gfx::Size& size, |
| 98 const gles2::ContextCreationAttribHelper& attribs, | 101 const gles2::ContextCreationAttribHelper& attribs, |
| 102 gl::GpuPreference gpu_preference, |
| 99 const scoped_refptr<InProcessCommandBuffer::Service>& service, | 103 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
| 100 const SharedMemoryLimits& mem_limits, | 104 const SharedMemoryLimits& mem_limits, |
| 101 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 105 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 102 ImageFactory* image_factory) { | 106 ImageFactory* image_factory) { |
| 103 DCHECK_GE(attribs.offscreen_framebuffer_size.width(), 0); | 107 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 104 DCHECK_GE(attribs.offscreen_framebuffer_size.height(), 0); | |
| 105 | 108 |
| 106 command_buffer_.reset(new InProcessCommandBuffer(service)); | 109 command_buffer_.reset(new InProcessCommandBuffer(service)); |
| 107 | 110 |
| 108 scoped_refptr<gles2::ShareGroup> share_group; | 111 scoped_refptr<gles2::ShareGroup> share_group; |
| 109 InProcessCommandBuffer* share_command_buffer = nullptr; | 112 InProcessCommandBuffer* share_command_buffer = nullptr; |
| 110 if (share_context) { | 113 if (share_context) { |
| 111 GLInProcessContextImpl* impl = | 114 GLInProcessContextImpl* impl = |
| 112 static_cast<GLInProcessContextImpl*>(share_context); | 115 static_cast<GLInProcessContextImpl*>(share_context); |
| 113 share_group = impl->gles2_implementation_->share_group(); | 116 share_group = impl->gles2_implementation_->share_group(); |
| 114 share_command_buffer = impl->command_buffer_.get(); | 117 share_command_buffer = impl->command_buffer_.get(); |
| 115 DCHECK(share_group); | 118 DCHECK(share_group); |
| 116 DCHECK(share_command_buffer); | 119 DCHECK(share_command_buffer); |
| 117 } | 120 } |
| 118 | 121 |
| 119 if (!command_buffer_->Initialize(surface, | 122 if (!command_buffer_->Initialize(surface, |
| 120 is_offscreen, | 123 is_offscreen, |
| 121 window, | 124 window, |
| 125 size, |
| 122 attribs, | 126 attribs, |
| 127 gpu_preference, |
| 123 share_command_buffer, | 128 share_command_buffer, |
| 124 gpu_memory_buffer_manager, | 129 gpu_memory_buffer_manager, |
| 125 image_factory)) { | 130 image_factory)) { |
| 126 DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; | 131 DLOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; |
| 127 return false; | 132 return false; |
| 128 } | 133 } |
| 129 | 134 |
| 130 // Create the GLES2 helper, which writes the command buffer protocol. | 135 // Create the GLES2 helper, which writes the command buffer protocol. |
| 131 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); | 136 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); |
| 132 if (!gles2_helper_->Initialize(mem_limits.command_buffer_size)) { | 137 if (!gles2_helper_->Initialize(mem_limits.command_buffer_size)) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 187 } |
| 183 | 188 |
| 184 } // anonymous namespace | 189 } // anonymous namespace |
| 185 | 190 |
| 186 // static | 191 // static |
| 187 GLInProcessContext* GLInProcessContext::Create( | 192 GLInProcessContext* GLInProcessContext::Create( |
| 188 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 193 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
| 189 scoped_refptr<gl::GLSurface> surface, | 194 scoped_refptr<gl::GLSurface> surface, |
| 190 bool is_offscreen, | 195 bool is_offscreen, |
| 191 gfx::AcceleratedWidget window, | 196 gfx::AcceleratedWidget window, |
| 197 const gfx::Size& size, |
| 192 GLInProcessContext* share_context, | 198 GLInProcessContext* share_context, |
| 193 const ::gpu::gles2::ContextCreationAttribHelper& attribs, | 199 const ::gpu::gles2::ContextCreationAttribHelper& attribs, |
| 200 gl::GpuPreference gpu_preference, |
| 194 const SharedMemoryLimits& memory_limits, | 201 const SharedMemoryLimits& memory_limits, |
| 195 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 202 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 196 ImageFactory* image_factory) { | 203 ImageFactory* image_factory) { |
| 197 if (surface.get()) { | 204 if (surface.get()) { |
| 198 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); | 205 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); |
| 206 DCHECK(surface->GetSize() == size); |
| 199 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); | 207 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); |
| 200 } | 208 } |
| 201 | 209 |
| 202 std::unique_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl); | 210 std::unique_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl); |
| 203 if (!context->Initialize(surface, is_offscreen, share_context, window, | 211 if (!context->Initialize(surface, is_offscreen, share_context, window, size, |
| 204 attribs, service, memory_limits, | 212 attribs, gpu_preference, service, memory_limits, |
| 205 gpu_memory_buffer_manager, image_factory)) | 213 gpu_memory_buffer_manager, image_factory)) |
| 206 return NULL; | 214 return NULL; |
| 207 | 215 |
| 208 return context.release(); | 216 return context.release(); |
| 209 } | 217 } |
| 210 | 218 |
| 211 } // namespace gpu | 219 } // namespace gpu |
| OLD | NEW |