Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/context_provider_command_buffer.h" | 5 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "cc/output/managed_memory_policy.h" | 17 #include "cc/output/managed_memory_policy.h" |
| 18 #include "content/common/gpu/client/command_buffer_metrics.h" | 18 #include "content/common/gpu/client/command_buffer_metrics.h" |
| 19 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | |
| 19 #include "gpu/command_buffer/client/gles2_implementation.h" | 20 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 20 #include "gpu/command_buffer/client/gles2_trace_implementation.h" | 21 #include "gpu/command_buffer/client/gles2_trace_implementation.h" |
| 21 #include "gpu/command_buffer/client/gpu_switches.h" | 22 #include "gpu/command_buffer/client/gpu_switches.h" |
| 23 #include "gpu/ipc/client/gpu_channel_host.h" | |
| 22 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" | 24 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" |
| 23 #include "third_party/skia/include/gpu/GrContext.h" | 25 #include "third_party/skia/include/gpu/GrContext.h" |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| 27 ContextProviderCommandBuffer::SharedProviders::SharedProviders() = default; | 29 ContextProviderCommandBuffer::SharedProviders::SharedProviders() = default; |
| 28 ContextProviderCommandBuffer::SharedProviders::~SharedProviders() = default; | 30 ContextProviderCommandBuffer::SharedProviders::~SharedProviders() = default; |
| 29 | 31 |
| 30 ContextProviderCommandBuffer::ContextProviderCommandBuffer( | 32 ContextProviderCommandBuffer::ContextProviderCommandBuffer( |
| 31 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 33 scoped_refptr<gpu::GpuChannelHost> channel, |
| 34 gpu::SurfaceHandle surface_handle, | |
| 35 const GURL& active_url, | |
| 36 gfx::GpuPreference gpu_preference, | |
| 37 bool automatic_flushes, | |
| 32 const gpu::SharedMemoryLimits& memory_limits, | 38 const gpu::SharedMemoryLimits& memory_limits, |
| 33 const gpu::gles2::ContextCreationAttribHelper& attributes, | 39 const gpu::gles2::ContextCreationAttribHelper& attributes, |
| 34 ContextProviderCommandBuffer* shared_context_provider, | 40 ContextProviderCommandBuffer* shared_context_provider, |
| 35 command_buffer_metrics::ContextType type) | 41 command_buffer_metrics::ContextType type) |
| 36 : shared_providers_(shared_context_provider | 42 : surface_handle_(surface_handle), |
| 43 active_url_(active_url), | |
| 44 gpu_preference_(gpu_preference), | |
| 45 automatic_flushes_(automatic_flushes), | |
| 46 memory_limits_(memory_limits), | |
| 47 attributes_(attributes), | |
| 48 context_type_(type), | |
| 49 shared_providers_(shared_context_provider | |
| 37 ? shared_context_provider->shared_providers_ | 50 ? shared_context_provider->shared_providers_ |
| 38 : new SharedProviders), | 51 : new SharedProviders), |
| 39 context3d_(std::move(context3d)), | 52 channel_(std::move(channel)), |
| 40 memory_limits_(memory_limits), | 53 context3d_(new WebGraphicsContext3DCommandBufferImpl) { |
| 41 attributes_(attributes), | |
| 42 context_type_(type) { | |
| 43 DCHECK(main_thread_checker_.CalledOnValidThread()); | 54 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 44 DCHECK(context3d_); | 55 DCHECK(channel_); |
| 45 context_thread_checker_.DetachFromThread(); | 56 context_thread_checker_.DetachFromThread(); |
| 46 } | 57 } |
| 47 | 58 |
| 48 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { | 59 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { |
| 49 DCHECK(main_thread_checker_.CalledOnValidThread() || | 60 DCHECK(main_thread_checker_.CalledOnValidThread() || |
| 50 context_thread_checker_.CalledOnValidThread()); | 61 context_thread_checker_.CalledOnValidThread()); |
| 51 | 62 |
| 52 { | 63 { |
| 53 base::AutoLock hold(shared_providers_->lock); | 64 base::AutoLock hold(shared_providers_->lock); |
| 54 auto it = std::find(shared_providers_->list.begin(), | 65 auto it = std::find(shared_providers_->list.begin(), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 105 |
| 95 if (!shared_providers_->list.empty()) { | 106 if (!shared_providers_->list.empty()) { |
| 96 shared_context_provider = shared_providers_->list.front(); | 107 shared_context_provider = shared_providers_->list.front(); |
| 97 shared_command_buffer = | 108 shared_command_buffer = |
| 98 shared_context_provider->context3d_->GetCommandBufferProxy(); | 109 shared_context_provider->context3d_->GetCommandBufferProxy(); |
| 99 share_group = shared_context_provider->context3d_->GetImplementation() | 110 share_group = shared_context_provider->context3d_->GetImplementation() |
| 100 ->share_group(); | 111 ->share_group(); |
| 101 } | 112 } |
| 102 | 113 |
| 103 if (!context3d_->InitializeOnCurrentThread( | 114 if (!context3d_->InitializeOnCurrentThread( |
| 104 memory_limits_, shared_command_buffer, std::move(share_group), | 115 surface_handle_, active_url_, channel_.get(), gpu_preference_, |
|
piman
2016/05/03 01:44:18
We don't need channel_ after this point, and Comma
danakj
2016/05/03 01:56:18
Well, all WGC3DCBImpl does with it is channel_->Cr
| |
| 105 attributes_, context_type_)) { | 116 automatic_flushes_, memory_limits_, shared_command_buffer, |
| 117 std::move(share_group), attributes_, context_type_)) { | |
|
piman
2016/05/03 01:44:18
mmh. This was true before, but we use share_group
danakj
2016/05/03 01:56:18
Gah, yes thanks. We're not checking lost because o
| |
| 106 context3d_ = nullptr; | 118 context3d_ = nullptr; |
| 107 return false; | 119 return false; |
| 108 } | 120 } |
| 109 | 121 |
| 110 // If any context in the share group has been lost, then abort and don't | 122 // If any context in the share group has been lost, then abort and don't |
| 111 // continue since we need to go back to the caller of the constructor to | 123 // continue since we need to go back to the caller of the constructor to |
| 112 // find the correct share group. | 124 // find the correct share group. |
| 113 // This may happen in between the share group being chosen at the | 125 // This may happen in between the share group being chosen at the |
| 114 // constructor, and getting to run this BindToCurrentThread method which | 126 // constructor, and getting to run this BindToCurrentThread method which |
| 115 // can be on some other thread. | 127 // can be on some other thread. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 | 247 |
| 236 void ContextProviderCommandBuffer::SetLostContextCallback( | 248 void ContextProviderCommandBuffer::SetLostContextCallback( |
| 237 const LostContextCallback& lost_context_callback) { | 249 const LostContextCallback& lost_context_callback) { |
| 238 DCHECK(context_thread_checker_.CalledOnValidThread()); | 250 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 239 DCHECK(lost_context_callback_.is_null() || | 251 DCHECK(lost_context_callback_.is_null() || |
| 240 lost_context_callback.is_null()); | 252 lost_context_callback.is_null()); |
| 241 lost_context_callback_ = lost_context_callback; | 253 lost_context_callback_ = lost_context_callback; |
| 242 } | 254 } |
| 243 | 255 |
| 244 } // namespace content | 256 } // namespace content |
| OLD | NEW |