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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 class GLInProcessContextImpl | 46 class GLInProcessContextImpl |
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<gfx::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 gfx::Size& size, |
58 const gpu::gles2::ContextCreationAttribHelper& attribs, | 58 const gpu::gles2::ContextCreationAttribHelper& attribs, |
59 gfx::GpuPreference gpu_preference, | 59 gl::GpuPreference gpu_preference, |
60 const scoped_refptr<InProcessCommandBuffer::Service>& service, | 60 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
61 const SharedMemoryLimits& mem_limits, | 61 const SharedMemoryLimits& mem_limits, |
62 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 62 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
63 ImageFactory* image_factory); | 63 ImageFactory* image_factory); |
64 | 64 |
65 // GLInProcessContext implementation: | 65 // GLInProcessContext implementation: |
66 gles2::GLES2Implementation* GetImplementation() override; | 66 gles2::GLES2Implementation* GetImplementation() override; |
67 void SetLock(base::Lock* lock) override; | 67 void SetLock(base::Lock* lock) override; |
68 | 68 |
69 private: | 69 private: |
(...skipping 16 matching lines...) Expand all Loading... |
86 | 86 |
87 gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() { | 87 gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() { |
88 return gles2_implementation_.get(); | 88 return gles2_implementation_.get(); |
89 } | 89 } |
90 | 90 |
91 void GLInProcessContextImpl::SetLock(base::Lock* lock) { | 91 void GLInProcessContextImpl::SetLock(base::Lock* lock) { |
92 NOTREACHED(); | 92 NOTREACHED(); |
93 } | 93 } |
94 | 94 |
95 bool GLInProcessContextImpl::Initialize( | 95 bool GLInProcessContextImpl::Initialize( |
96 scoped_refptr<gfx::GLSurface> surface, | 96 scoped_refptr<gl::GLSurface> surface, |
97 bool is_offscreen, | 97 bool is_offscreen, |
98 GLInProcessContext* share_context, | 98 GLInProcessContext* share_context, |
99 gfx::AcceleratedWidget window, | 99 gfx::AcceleratedWidget window, |
100 const gfx::Size& size, | 100 const gfx::Size& size, |
101 const gles2::ContextCreationAttribHelper& attribs, | 101 const gles2::ContextCreationAttribHelper& attribs, |
102 gfx::GpuPreference gpu_preference, | 102 gl::GpuPreference gpu_preference, |
103 const scoped_refptr<InProcessCommandBuffer::Service>& service, | 103 const scoped_refptr<InProcessCommandBuffer::Service>& service, |
104 const SharedMemoryLimits& mem_limits, | 104 const SharedMemoryLimits& mem_limits, |
105 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 105 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
106 ImageFactory* image_factory) { | 106 ImageFactory* image_factory) { |
107 DCHECK(size.width() >= 0 && size.height() >= 0); | 107 DCHECK(size.width() >= 0 && size.height() >= 0); |
108 | 108 |
109 command_buffer_.reset(new InProcessCommandBuffer(service)); | 109 command_buffer_.reset(new InProcessCommandBuffer(service)); |
110 | 110 |
111 scoped_refptr<gles2::ShareGroup> share_group; | 111 scoped_refptr<gles2::ShareGroup> share_group; |
112 InProcessCommandBuffer* share_command_buffer = nullptr; | 112 InProcessCommandBuffer* share_command_buffer = nullptr; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 transfer_buffer_.reset(); | 184 transfer_buffer_.reset(); |
185 gles2_helper_.reset(); | 185 gles2_helper_.reset(); |
186 command_buffer_.reset(); | 186 command_buffer_.reset(); |
187 } | 187 } |
188 | 188 |
189 } // anonymous namespace | 189 } // anonymous namespace |
190 | 190 |
191 // static | 191 // static |
192 GLInProcessContext* GLInProcessContext::Create( | 192 GLInProcessContext* GLInProcessContext::Create( |
193 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 193 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
194 scoped_refptr<gfx::GLSurface> surface, | 194 scoped_refptr<gl::GLSurface> surface, |
195 bool is_offscreen, | 195 bool is_offscreen, |
196 gfx::AcceleratedWidget window, | 196 gfx::AcceleratedWidget window, |
197 const gfx::Size& size, | 197 const gfx::Size& size, |
198 GLInProcessContext* share_context, | 198 GLInProcessContext* share_context, |
199 const ::gpu::gles2::ContextCreationAttribHelper& attribs, | 199 const ::gpu::gles2::ContextCreationAttribHelper& attribs, |
200 gfx::GpuPreference gpu_preference, | 200 gl::GpuPreference gpu_preference, |
201 const SharedMemoryLimits& memory_limits, | 201 const SharedMemoryLimits& memory_limits, |
202 GpuMemoryBufferManager* gpu_memory_buffer_manager, | 202 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
203 ImageFactory* image_factory) { | 203 ImageFactory* image_factory) { |
204 if (surface.get()) { | 204 if (surface.get()) { |
205 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); | 205 DCHECK_EQ(surface->IsOffscreen(), is_offscreen); |
206 DCHECK(surface->GetSize() == size); | 206 DCHECK(surface->GetSize() == size); |
207 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); | 207 DCHECK_EQ(gfx::kNullAcceleratedWidget, window); |
208 } | 208 } |
209 | 209 |
210 std::unique_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl); | 210 std::unique_ptr<GLInProcessContextImpl> context(new GLInProcessContextImpl); |
211 if (!context->Initialize(surface, is_offscreen, share_context, window, size, | 211 if (!context->Initialize(surface, is_offscreen, share_context, window, size, |
212 attribs, gpu_preference, service, memory_limits, | 212 attribs, gpu_preference, service, memory_limits, |
213 gpu_memory_buffer_manager, image_factory)) | 213 gpu_memory_buffer_manager, image_factory)) |
214 return NULL; | 214 return NULL; |
215 | 215 |
216 return context.release(); | 216 return context.release(); |
217 } | 217 } |
218 | 218 |
219 } // namespace gpu | 219 } // namespace gpu |
OLD | NEW |