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 <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; | 45 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; |
46 | 46 |
47 class GLInProcessContextImpl | 47 class GLInProcessContextImpl |
48 : public GLInProcessContext, | 48 : public GLInProcessContext, |
49 public base::SupportsWeakPtr<GLInProcessContextImpl> { | 49 public base::SupportsWeakPtr<GLInProcessContextImpl> { |
50 public: | 50 public: |
51 explicit GLInProcessContextImpl(); | 51 explicit GLInProcessContextImpl(); |
52 virtual ~GLInProcessContextImpl(); | 52 virtual ~GLInProcessContextImpl(); |
53 | 53 |
54 bool Initialize( | 54 bool Initialize( |
55 scoped_refptr<gfx::GLSurface> surface, | 55 gfx::GLSurface* surface, |
56 bool is_offscreen, | 56 bool is_offscreen, |
57 bool use_global_share_group, | 57 bool use_global_share_group, |
58 GLInProcessContext* share_context, | 58 GLInProcessContext* share_context, |
59 gfx::AcceleratedWidget window, | 59 gfx::AcceleratedWidget window, |
60 const gfx::Size& size, | 60 const gfx::Size& size, |
61 const GLInProcessContextAttribs& attribs, | 61 const GLInProcessContextAttribs& attribs, |
62 gfx::GpuPreference gpu_preference, | 62 gfx::GpuPreference gpu_preference, |
63 const scoped_refptr<InProcessCommandBuffer::Service>& service); | 63 const scoped_refptr<InProcessCommandBuffer::Service>& service); |
64 | 64 |
65 // GLInProcessContext implementation: | 65 // GLInProcessContext implementation: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 void GLInProcessContextImpl::OnContextLost() { | 115 void GLInProcessContextImpl::OnContextLost() { |
116 context_lost_ = true; | 116 context_lost_ = true; |
117 if (!context_lost_callback_.is_null()) { | 117 if (!context_lost_callback_.is_null()) { |
118 context_lost_callback_.Run(); | 118 context_lost_callback_.Run(); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 bool GLInProcessContextImpl::Initialize( | 122 bool GLInProcessContextImpl::Initialize( |
123 scoped_refptr<gfx::GLSurface> surface, | 123 gfx::GLSurface* surface, |
124 bool is_offscreen, | 124 bool is_offscreen, |
125 bool use_global_share_group, | 125 bool use_global_share_group, |
126 GLInProcessContext* share_context, | 126 GLInProcessContext* share_context, |
127 gfx::AcceleratedWidget window, | 127 gfx::AcceleratedWidget window, |
128 const gfx::Size& size, | 128 const gfx::Size& size, |
129 const GLInProcessContextAttribs& attribs, | 129 const GLInProcessContextAttribs& attribs, |
130 gfx::GpuPreference gpu_preference, | 130 gfx::GpuPreference gpu_preference, |
131 const scoped_refptr<InProcessCommandBuffer::Service>& service) { | 131 const scoped_refptr<InProcessCommandBuffer::Service>& service) { |
132 DCHECK(!use_global_share_group || !share_context); | 132 DCHECK(!use_global_share_group || !share_context); |
133 DCHECK(size.width() >= 0 && size.height() >= 0); | 133 DCHECK(size.width() >= 0 && size.height() >= 0); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 attribs, | 332 attribs, |
333 gpu_preference, | 333 gpu_preference, |
334 scoped_refptr<InProcessCommandBuffer::Service>())) | 334 scoped_refptr<InProcessCommandBuffer::Service>())) |
335 return NULL; | 335 return NULL; |
336 | 336 |
337 return context.release(); | 337 return context.release(); |
338 } | 338 } |
339 | 339 |
340 // static | 340 // static |
341 GLInProcessContext* GLInProcessContext::CreateWithSurface( | 341 GLInProcessContext* GLInProcessContext::CreateWithSurface( |
342 scoped_refptr<gfx::GLSurface> surface, | 342 gfx::GLSurface* surface, |
343 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, | 343 scoped_refptr<gpu::InProcessCommandBuffer::Service> service, |
344 GLInProcessContext* share_context, | 344 GLInProcessContext* share_context, |
345 const GLInProcessContextAttribs& attribs, | 345 const GLInProcessContextAttribs& attribs, |
346 gfx::GpuPreference gpu_preference) { | 346 gfx::GpuPreference gpu_preference) { |
347 scoped_ptr<GLInProcessContextImpl> context( | 347 scoped_ptr<GLInProcessContextImpl> context( |
348 new GLInProcessContextImpl()); | 348 new GLInProcessContextImpl()); |
349 if (!context->Initialize( | 349 if (!context->Initialize( |
350 surface, | 350 surface, |
351 surface->IsOffscreen(), | 351 surface->IsOffscreen(), |
352 false, | 352 false, |
353 share_context, | 353 share_context, |
354 gfx::kNullAcceleratedWidget, | 354 gfx::kNullAcceleratedWidget, |
355 surface->GetSize(), | 355 surface->GetSize(), |
356 attribs, | 356 attribs, |
357 gpu_preference, | 357 gpu_preference, |
358 service)) | 358 service)) |
359 return NULL; | 359 return NULL; |
360 | 360 |
361 return context.release(); | 361 return context.release(); |
362 } | 362 } |
363 | 363 |
364 } // namespace gpu | 364 } // namespace gpu |
OLD | NEW |