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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
6 | 6 |
7 #include "third_party/khronos/GLES2/gl2.h" | 7 #include "third_party/khronos/GLES2/gl2.h" |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
11 #include "third_party/khronos/GLES2/gl2ext.h" | 11 #include "third_party/khronos/GLES2/gl2ext.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <map> | 14 #include <map> |
15 | 15 |
16 #include "base/atomicops.h" | 16 #include "base/atomicops.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/debug/trace_event.h" | 19 #include "base/debug/trace_event.h" |
20 #include "base/lazy_instance.h" | 20 #include "base/lazy_instance.h" |
21 #include "base/logging.h" | 21 #include "base/logging.h" |
22 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
23 #include "base/metrics/field_trial.h" | 23 #include "base/metrics/field_trial.h" |
24 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
25 #include "base/synchronization/lock.h" | |
26 #include "content/common/gpu/client/gpu_channel_host.h" | 25 #include "content/common/gpu/client/gpu_channel_host.h" |
27 #include "content/public/common/content_constants.h" | 26 #include "content/public/common/content_constants.h" |
28 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
29 #include "gpu/GLES2/gl2extchromium.h" | 28 #include "gpu/GLES2/gl2extchromium.h" |
30 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 29 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
31 #include "gpu/command_buffer/client/gles2_implementation.h" | 30 #include "gpu/command_buffer/client/gles2_implementation.h" |
32 #include "gpu/command_buffer/client/gles2_lib.h" | 31 #include "gpu/command_buffer/client/gles2_lib.h" |
33 #include "gpu/command_buffer/client/gles2_trace_implementation.h" | 32 #include "gpu/command_buffer/client/gles2_trace_implementation.h" |
34 #include "gpu/command_buffer/client/transfer_buffer.h" | 33 #include "gpu/command_buffer/client/transfer_buffer.h" |
35 #include "gpu/command_buffer/common/constants.h" | 34 #include "gpu/command_buffer/common/constants.h" |
36 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
37 #include "gpu/command_buffer/common/mailbox.h" | 36 #include "gpu/command_buffer/common/mailbox.h" |
38 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 37 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
39 #include "third_party/skia/include/core/SkTypes.h" | 38 #include "third_party/skia/include/core/SkTypes.h" |
40 | 39 |
41 namespace content { | 40 namespace content { |
42 | 41 |
43 namespace { | 42 namespace { |
44 | 43 |
45 static base::LazyInstance<base::Lock>::Leaky | 44 static base::LazyInstance<base::Lock>::Leaky |
46 g_all_shared_contexts_lock = LAZY_INSTANCE_INITIALIZER; | 45 g_default_share_groups_lock = LAZY_INSTANCE_INITIALIZER; |
47 | 46 |
48 typedef std::multimap<GpuChannelHost*, WebGraphicsContext3DCommandBufferImpl*> | 47 typedef std::map<GpuChannelHost*, |
49 ContextMap; | 48 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> > |
50 static base::LazyInstance<ContextMap> g_all_shared_contexts = | 49 ShareGroupMap; |
50 static base::LazyInstance<ShareGroupMap> g_default_share_groups = | |
51 LAZY_INSTANCE_INITIALIZER; | 51 LAZY_INSTANCE_INITIALIZER; |
52 | 52 |
53 WebGraphicsContext3DCommandBufferImpl::ShareGroup* defaultShareGroupForHost( | |
piman
2014/01/08 01:39:24
nit: chrome style - DefaultShareGroupForHost. Mayb
Ken Russell (switch to Gerrit)
2014/01/08 02:40:39
Since a lock is needed for the share group map, it
no sievers
2014/01/08 14:03:54
Yes, good catch. For example:
1) WGC3D is construc
bajones
2014/01/08 21:24:37
Good catch. Fixed.
| |
54 GpuChannelHost* host) { | |
55 base::AutoLock lock(g_default_share_groups_lock.Get()); | |
56 | |
57 ShareGroupMap& share_groups = g_default_share_groups.Get(); | |
58 ShareGroupMap::iterator it = share_groups.find(host); | |
59 if (it == share_groups.end()) { | |
60 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> group = | |
61 new WebGraphicsContext3DCommandBufferImpl::ShareGroup(); | |
62 share_groups[host] = group; | |
63 return group; | |
64 } | |
65 return it->second; | |
66 } | |
67 | |
53 uint32_t GenFlushID() { | 68 uint32_t GenFlushID() { |
54 static base::subtle::Atomic32 flush_id = 0; | 69 static base::subtle::Atomic32 flush_id = 0; |
55 | 70 |
56 base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( | 71 base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement( |
57 &flush_id, 1); | 72 &flush_id, 1); |
58 return static_cast<uint32_t>(my_id); | 73 return static_cast<uint32_t>(my_id); |
59 } | 74 } |
60 | 75 |
61 // Singleton used to initialize and terminate the gles2 library. | 76 // Singleton used to initialize and terminate the gles2 library. |
62 class GLES2Initializer { | 77 class GLES2Initializer { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 graphics_context_->OnErrorMessage(msg, id); | 210 graphics_context_->OnErrorMessage(msg, id); |
196 } | 211 } |
197 | 212 |
198 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits::SharedMemoryLimits() | 213 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits::SharedMemoryLimits() |
199 : command_buffer_size(kDefaultCommandBufferSize), | 214 : command_buffer_size(kDefaultCommandBufferSize), |
200 start_transfer_buffer_size(kDefaultStartTransferBufferSize), | 215 start_transfer_buffer_size(kDefaultStartTransferBufferSize), |
201 min_transfer_buffer_size(kDefaultMinTransferBufferSize), | 216 min_transfer_buffer_size(kDefaultMinTransferBufferSize), |
202 max_transfer_buffer_size(kDefaultMaxTransferBufferSize), | 217 max_transfer_buffer_size(kDefaultMaxTransferBufferSize), |
203 mapped_memory_reclaim_limit(gpu::gles2::GLES2Implementation::kNoLimit) {} | 218 mapped_memory_reclaim_limit(gpu::gles2::GLES2Implementation::kNoLimit) {} |
204 | 219 |
220 WebGraphicsContext3DCommandBufferImpl::ShareGroup::ShareGroup() { | |
221 } | |
222 | |
223 WebGraphicsContext3DCommandBufferImpl::ShareGroup::~ShareGroup() { | |
224 DCHECK(contexts_.empty()); | |
225 } | |
226 | |
205 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( | 227 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( |
206 int surface_id, | 228 int surface_id, |
207 const GURL& active_url, | 229 const GURL& active_url, |
208 GpuChannelHost* host, | 230 GpuChannelHost* host, |
209 const Attributes& attributes, | 231 const Attributes& attributes, |
210 bool bind_generates_resources, | 232 bool bind_generates_resources, |
211 const SharedMemoryLimits& limits) | 233 const SharedMemoryLimits& limits, |
234 WebGraphicsContext3DCommandBufferImpl* share_context) | |
212 : initialize_failed_(false), | 235 : initialize_failed_(false), |
213 visible_(false), | 236 visible_(false), |
214 host_(host), | 237 host_(host), |
215 surface_id_(surface_id), | 238 surface_id_(surface_id), |
216 active_url_(active_url), | 239 active_url_(active_url), |
217 context_lost_callback_(0), | 240 context_lost_callback_(0), |
218 context_lost_reason_(GL_NO_ERROR), | 241 context_lost_reason_(GL_NO_ERROR), |
219 error_message_callback_(0), | 242 error_message_callback_(0), |
220 attributes_(attributes), | 243 attributes_(attributes), |
221 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu | 244 gpu_preference_(attributes.preferDiscreteGPU ? gfx::PreferDiscreteGpu |
222 : gfx::PreferIntegratedGpu), | 245 : gfx::PreferIntegratedGpu), |
223 weak_ptr_factory_(this), | 246 weak_ptr_factory_(this), |
224 initialized_(false), | 247 initialized_(false), |
225 gl_(NULL), | 248 gl_(NULL), |
226 bind_generates_resources_(bind_generates_resources), | 249 bind_generates_resources_(bind_generates_resources), |
227 mem_limits_(limits), | 250 mem_limits_(limits), |
228 flush_id_(0) { | 251 flush_id_(0) { |
252 if (share_context) { | |
no sievers
2014/01/08 14:03:54
DCHECK(!attributes_.shareResources);
On the other
bajones
2014/01/08 21:24:37
Yes, that's correct. Slightly confusing, but I thi
no sievers
2014/01/09 13:39:42
Sounds good. I'd still add the DCHECK(!attributes_
| |
253 share_group_ = share_context->share_group_; | |
no sievers
2014/01/08 14:03:54
It's possible that host_ != share_context->host_ i
bajones
2014/01/08 21:24:37
Hm... thanks for pointing this out. I need to thin
no sievers
2014/01/09 13:39:42
Can we just do this maybe to mimick the behavior o
| |
254 } else { | |
255 share_group_ = attributes_.shareResources ? defaultShareGroupForHost(host) | |
256 : new ShareGroup(); | |
257 } | |
229 } | 258 } |
230 | 259 |
231 WebGraphicsContext3DCommandBufferImpl:: | 260 WebGraphicsContext3DCommandBufferImpl:: |
232 ~WebGraphicsContext3DCommandBufferImpl() { | 261 ~WebGraphicsContext3DCommandBufferImpl() { |
233 if (real_gl_) { | 262 if (real_gl_) { |
234 real_gl_->SetErrorMessageCallback(NULL); | 263 real_gl_->SetErrorMessageCallback(NULL); |
235 } | 264 } |
236 | 265 |
237 Destroy(); | 266 Destroy(); |
238 } | 267 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 attributes_.stencil = pvalues[2] > 0; | 317 attributes_.stencil = pvalues[2] > 0; |
289 attributes_.antialias = pvalues[3] > 0; | 318 attributes_.antialias = pvalues[3] > 0; |
290 } | 319 } |
291 | 320 |
292 visible_ = true; | 321 visible_ = true; |
293 initialized_ = true; | 322 initialized_ = true; |
294 return true; | 323 return true; |
295 } | 324 } |
296 | 325 |
297 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( | 326 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( |
298 bool onscreen) { | 327 bool onscreen, WebGraphicsContext3DCommandBufferImpl* share_context) { |
299 if (!host_.get()) | 328 if (!host_.get()) |
300 return false; | 329 return false; |
301 // We need to lock g_all_shared_contexts to ensure that the context we picked | 330 |
302 // for our share group isn't deleted. | 331 CommandBufferProxyImpl* share_group_command_buffer = NULL; |
303 // (There's also a lock in our destructor.) | 332 |
304 base::AutoLock lock(g_all_shared_contexts_lock.Get()); | 333 if (share_context) { |
305 CommandBufferProxyImpl* share_group = NULL; | 334 share_group_command_buffer = share_context->command_buffer_.get(); |
306 if (attributes_.shareResources) { | |
307 ContextMap& all_contexts = g_all_shared_contexts.Get(); | |
308 ContextMap::const_iterator it = all_contexts.find(host_.get()); | |
309 if (it != all_contexts.end()) | |
310 share_group = it->second->command_buffer_.get(); | |
311 } | 335 } |
312 | 336 |
313 std::vector<int32> attribs; | 337 std::vector<int32> attribs; |
314 attribs.push_back(ALPHA_SIZE); | 338 attribs.push_back(ALPHA_SIZE); |
315 attribs.push_back(attributes_.alpha ? 8 : 0); | 339 attribs.push_back(attributes_.alpha ? 8 : 0); |
316 attribs.push_back(DEPTH_SIZE); | 340 attribs.push_back(DEPTH_SIZE); |
317 attribs.push_back(attributes_.depth ? 24 : 0); | 341 attribs.push_back(attributes_.depth ? 24 : 0); |
318 attribs.push_back(STENCIL_SIZE); | 342 attribs.push_back(STENCIL_SIZE); |
319 attribs.push_back(attributes_.stencil ? 8 : 0); | 343 attribs.push_back(attributes_.stencil ? 8 : 0); |
320 attribs.push_back(SAMPLES); | 344 attribs.push_back(SAMPLES); |
321 attribs.push_back(attributes_.antialias ? 4 : 0); | 345 attribs.push_back(attributes_.antialias ? 4 : 0); |
322 attribs.push_back(SAMPLE_BUFFERS); | 346 attribs.push_back(SAMPLE_BUFFERS); |
323 attribs.push_back(attributes_.antialias ? 1 : 0); | 347 attribs.push_back(attributes_.antialias ? 1 : 0); |
324 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); | 348 attribs.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); |
325 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0); | 349 attribs.push_back(attributes_.failIfMajorPerformanceCaveat ? 1 : 0); |
326 attribs.push_back(NONE); | 350 attribs.push_back(NONE); |
327 | 351 |
328 // Create a proxy to a command buffer in the GPU process. | 352 // Create a proxy to a command buffer in the GPU process. |
329 if (onscreen) { | 353 if (onscreen) { |
330 command_buffer_.reset(host_->CreateViewCommandBuffer( | 354 command_buffer_.reset(host_->CreateViewCommandBuffer( |
331 surface_id_, | 355 surface_id_, |
332 share_group, | 356 share_group_command_buffer, |
333 attribs, | 357 attribs, |
334 active_url_, | 358 active_url_, |
335 gpu_preference_)); | 359 gpu_preference_)); |
336 } else { | 360 } else { |
337 command_buffer_.reset(host_->CreateOffscreenCommandBuffer( | 361 command_buffer_.reset(host_->CreateOffscreenCommandBuffer( |
338 gfx::Size(1, 1), | 362 gfx::Size(1, 1), |
339 share_group, | 363 share_group_command_buffer, |
340 attribs, | 364 attribs, |
341 active_url_, | 365 active_url_, |
342 gpu_preference_)); | 366 gpu_preference_)); |
343 } | 367 } |
344 | 368 |
345 if (!command_buffer_) | 369 if (!command_buffer_) |
346 return false; | 370 return false; |
347 | 371 |
348 // Initialize the command buffer. | 372 // Initialize the command buffer. |
349 return command_buffer_->Initialize(); | 373 return command_buffer_->Initialize(); |
350 } | 374 } |
351 | 375 |
352 bool WebGraphicsContext3DCommandBufferImpl::CreateContext( | 376 bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) { |
353 bool onscreen) { | |
354 // Ensure the gles2 library is initialized first in a thread safe way. | 377 // Ensure the gles2 library is initialized first in a thread safe way. |
355 g_gles2_initializer.Get(); | 378 g_gles2_initializer.Get(); |
356 | 379 |
357 if (!command_buffer_ && | 380 scoped_refptr<gpu::gles2::ShareGroup> gles2_share_group; |
358 !InitializeCommandBuffer(onscreen)) { | 381 |
359 return false; | 382 scoped_ptr<base::AutoLock> share_group_lock; |
383 if (!command_buffer_) { | |
384 WebGraphicsContext3DCommandBufferImpl* share_context = NULL; | |
385 | |
386 share_group_lock.reset(new base::AutoLock(share_group_->lock())); | |
387 share_context = share_group_->GetAnyContextLocked(); | |
388 | |
389 if (!InitializeCommandBuffer(onscreen, share_context)) | |
390 return false; | |
391 | |
392 if (share_context) | |
393 gles2_share_group = share_context->GetImplementation()->share_group(); | |
no sievers
2014/01/08 14:03:54
Can you keep the DCHECK, i.e. DCHECK(!share_contex
| |
394 | |
395 share_group_->AddContextLocked(this); | |
360 } | 396 } |
361 | 397 |
362 // Create the GLES2 helper, which writes the command buffer protocol. | 398 // Create the GLES2 helper, which writes the command buffer protocol. |
363 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get())); | 399 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get())); |
364 if (!gles2_helper_->Initialize(mem_limits_.command_buffer_size)) | 400 if (!gles2_helper_->Initialize(mem_limits_.command_buffer_size)) |
365 return false; | 401 return false; |
366 | 402 |
367 if (attributes_.noAutomaticFlushes) | 403 if (attributes_.noAutomaticFlushes) |
368 gles2_helper_->SetAutomaticFlushes(false); | 404 gles2_helper_->SetAutomaticFlushes(false); |
369 | 405 |
370 // Create a transfer buffer used to copy resources between the renderer | 406 // Create a transfer buffer used to copy resources between the renderer |
371 // process and the GPU process. | 407 // process and the GPU process. |
372 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); | 408 transfer_buffer_ .reset(new gpu::TransferBuffer(gles2_helper_.get())); |
373 | 409 |
374 DCHECK(host_.get()); | 410 DCHECK(host_.get()); |
375 scoped_ptr<base::AutoLock> lock; | |
376 scoped_refptr<gpu::gles2::ShareGroup> share_group; | |
377 if (attributes_.shareResources) { | |
378 // Make sure two clients don't try to create a new ShareGroup | |
379 // simultaneously. | |
380 lock.reset(new base::AutoLock(g_all_shared_contexts_lock.Get())); | |
381 ContextMap& all_contexts = g_all_shared_contexts.Get(); | |
382 ContextMap::const_iterator it = all_contexts.find(host_.get()); | |
383 if (it != all_contexts.end()) { | |
384 share_group = it->second->GetImplementation()->share_group(); | |
385 DCHECK(share_group); | |
386 } | |
387 } | |
388 | 411 |
389 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 412 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
390 bool free_command_buffer_when_invisible = | 413 bool free_command_buffer_when_invisible = |
391 command_line.HasSwitch(switches::kEnablePruneGpuCommandBuffers); | 414 command_line.HasSwitch(switches::kEnablePruneGpuCommandBuffers); |
392 | 415 |
393 // Create the object exposing the OpenGL API. | 416 // Create the object exposing the OpenGL API. |
394 real_gl_.reset(new gpu::gles2::GLES2Implementation( | 417 real_gl_.reset(new gpu::gles2::GLES2Implementation( |
395 gles2_helper_.get(), | 418 gles2_helper_.get(), |
396 share_group, | 419 gles2_share_group, |
397 transfer_buffer_.get(), | 420 transfer_buffer_.get(), |
398 bind_generates_resources_, | 421 bind_generates_resources_, |
399 free_command_buffer_when_invisible, | 422 free_command_buffer_when_invisible, |
400 command_buffer_.get())); | 423 command_buffer_.get())); |
401 gl_ = real_gl_.get(); | 424 gl_ = real_gl_.get(); |
402 | 425 |
no sievers
2014/01/08 14:03:54
Can we still release the lock here so it isn't hel
| |
403 if (attributes_.shareResources) { | |
404 // Don't add ourselves to the list before others can get to our ShareGroup. | |
405 g_all_shared_contexts.Get().insert(std::make_pair(host_.get(), this)); | |
406 lock.reset(); | |
407 } | |
408 | |
409 if (!real_gl_->Initialize( | 426 if (!real_gl_->Initialize( |
410 mem_limits_.start_transfer_buffer_size, | 427 mem_limits_.start_transfer_buffer_size, |
411 mem_limits_.min_transfer_buffer_size, | 428 mem_limits_.min_transfer_buffer_size, |
412 mem_limits_.max_transfer_buffer_size, | 429 mem_limits_.max_transfer_buffer_size, |
413 mem_limits_.mapped_memory_reclaim_limit)) { | 430 mem_limits_.mapped_memory_reclaim_limit)) { |
414 return false; | 431 return false; |
415 } | 432 } |
416 | 433 |
417 if (CommandLine::ForCurrentProcess()->HasSwitch( | 434 if (CommandLine::ForCurrentProcess()->HasSwitch( |
418 switches::kEnableGpuClientTracing)) { | 435 switches::kEnableGpuClientTracing)) { |
(...skipping 14 matching lines...) Expand all Loading... | |
433 return true; | 450 return true; |
434 } | 451 } |
435 | 452 |
436 uint32_t WebGraphicsContext3DCommandBufferImpl::lastFlushID() { | 453 uint32_t WebGraphicsContext3DCommandBufferImpl::lastFlushID() { |
437 return flush_id_; | 454 return flush_id_; |
438 } | 455 } |
439 | 456 |
440 DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned int) | 457 DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned int) |
441 | 458 |
442 void WebGraphicsContext3DCommandBufferImpl::Destroy() { | 459 void WebGraphicsContext3DCommandBufferImpl::Destroy() { |
443 if (host_.get()) { | 460 share_group_->RemoveContext(this); |
444 base::AutoLock lock(g_all_shared_contexts_lock.Get()); | |
445 ContextMap& all_contexts = g_all_shared_contexts.Get(); | |
446 ContextMap::iterator it = std::find( | |
447 all_contexts.begin(), | |
448 all_contexts.end(), | |
449 std::pair<GpuChannelHost* const, | |
450 WebGraphicsContext3DCommandBufferImpl*>(host_.get(), this)); | |
451 if (it != all_contexts.end()) | |
452 all_contexts.erase(it); | |
453 } | |
454 | 461 |
455 if (gl_) { | 462 if (gl_) { |
456 // First flush the context to ensure that any pending frees of resources | 463 // First flush the context to ensure that any pending frees of resources |
457 // are completed. Otherwise, if this context is part of a share group, | 464 // are completed. Otherwise, if this context is part of a share group, |
458 // those resources might leak. Also, any remaining side effects of commands | 465 // those resources might leak. Also, any remaining side effects of commands |
459 // issued on this context might not be visible to other contexts in the | 466 // issued on this context might not be visible to other contexts in the |
460 // share group. | 467 // share group. |
461 gl_->Flush(); | 468 gl_->Flush(); |
462 gl_ = NULL; | 469 gl_ = NULL; |
463 } | 470 } |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1175 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 1182 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
1176 return state.error == gpu::error::kLostContext; | 1183 return state.error == gpu::error::kLostContext; |
1177 } | 1184 } |
1178 | 1185 |
1179 // static | 1186 // static |
1180 WebGraphicsContext3DCommandBufferImpl* | 1187 WebGraphicsContext3DCommandBufferImpl* |
1181 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 1188 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
1182 GpuChannelHost* host, | 1189 GpuChannelHost* host, |
1183 const WebGraphicsContext3D::Attributes& attributes, | 1190 const WebGraphicsContext3D::Attributes& attributes, |
1184 const GURL& active_url, | 1191 const GURL& active_url, |
1185 const SharedMemoryLimits& limits) { | 1192 const SharedMemoryLimits& limits, |
1193 WebGraphicsContext3DCommandBufferImpl* share_context) { | |
1186 if (!host) | 1194 if (!host) |
1187 return NULL; | 1195 return NULL; |
1196 | |
1188 return new WebGraphicsContext3DCommandBufferImpl(0, | 1197 return new WebGraphicsContext3DCommandBufferImpl(0, |
1189 active_url, | 1198 active_url, |
1190 host, | 1199 host, |
1191 attributes, | 1200 attributes, |
1192 false, | 1201 false, |
1193 limits); | 1202 limits, |
1203 share_context); | |
1194 } | 1204 } |
1195 | 1205 |
1196 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, | 1206 DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM, |
1197 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint) | 1207 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint) |
1198 | 1208 |
1199 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT, | 1209 DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT, |
1200 WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint) | 1210 WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint) |
1201 | 1211 |
1202 WebGLId WebGraphicsContext3DCommandBufferImpl::createQueryEXT() { | 1212 WebGLId WebGraphicsContext3DCommandBufferImpl::createQueryEXT() { |
1203 GLuint o; | 1213 GLuint o; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1356 | 1366 |
1357 } // anonymous namespace | 1367 } // anonymous namespace |
1358 | 1368 |
1359 void WebGraphicsContext3DCommandBufferImpl::OnGpuChannelLost() { | 1369 void WebGraphicsContext3DCommandBufferImpl::OnGpuChannelLost() { |
1360 context_lost_reason_ = convertReason( | 1370 context_lost_reason_ = convertReason( |
1361 command_buffer_->GetLastState().context_lost_reason); | 1371 command_buffer_->GetLastState().context_lost_reason); |
1362 if (context_lost_callback_) { | 1372 if (context_lost_callback_) { |
1363 context_lost_callback_->onContextLost(); | 1373 context_lost_callback_->onContextLost(); |
1364 } | 1374 } |
1365 | 1375 |
1376 share_group_->RemoveAllContexts(); | |
1377 | |
1366 DCHECK(host_.get()); | 1378 DCHECK(host_.get()); |
1367 { | 1379 { |
1368 base::AutoLock lock(g_all_shared_contexts_lock.Get()); | 1380 base::AutoLock lock(g_default_share_groups_lock.Get()); |
1369 g_all_shared_contexts.Get().erase(host_.get()); | 1381 g_default_share_groups.Get().erase(host_.get()); |
1370 } | 1382 } |
1371 } | 1383 } |
1372 | 1384 |
1373 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1385 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1374 const std::string& message, int id) { | 1386 const std::string& message, int id) { |
1375 if (error_message_callback_) { | 1387 if (error_message_callback_) { |
1376 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); | 1388 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); |
1377 error_message_callback_->onErrorMessage(str, id); | 1389 error_message_callback_->onErrorMessage(str, id); |
1378 } | 1390 } |
1379 } | 1391 } |
1380 | 1392 |
1381 } // namespace content | 1393 } // namespace content |
OLD | NEW |