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/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
22 #include "base/metrics/field_trial.h" | 22 #include "base/metrics/field_trial.h" |
23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
| 24 #include "base/profiler/scoped_tracker.h" |
24 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
25 #include "base/tracked_objects.h" | |
26 #include "content/common/gpu/client/gpu_channel_host.h" | 26 #include "content/common/gpu/client/gpu_channel_host.h" |
27 #include "content/public/common/content_constants.h" | 27 #include "content/public/common/content_constants.h" |
28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
29 #include "gpu/GLES2/gl2extchromium.h" | 29 #include "gpu/GLES2/gl2extchromium.h" |
30 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 30 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
31 #include "gpu/command_buffer/client/gles2_implementation.h" | 31 #include "gpu/command_buffer/client/gles2_implementation.h" |
32 #include "gpu/command_buffer/client/gles2_trace_implementation.h" | 32 #include "gpu/command_buffer/client/gles2_trace_implementation.h" |
33 #include "gpu/command_buffer/client/transfer_buffer.h" | 33 #include "gpu/command_buffer/client/transfer_buffer.h" |
34 #include "gpu/command_buffer/common/constants.h" | 34 #include "gpu/command_buffer/common/constants.h" |
35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { | 122 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { |
123 if (initialized_) | 123 if (initialized_) |
124 return true; | 124 return true; |
125 | 125 |
126 if (initialize_failed_) | 126 if (initialize_failed_) |
127 return false; | 127 return false; |
128 | 128 |
129 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); | 129 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); |
130 | 130 |
131 // Below, we perform an expensive one-time initialization that is required to | 131 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. |
132 // get first pixels to the screen. This can't be called "jank" since there is | 132 tracked_objects::ScopedTracker tracking_profile( |
133 // nothing on the screen. Using TaskStopwatch to exclude the operation from | 133 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
134 // jank calculations. | 134 "125248 WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL")); |
135 tracked_objects::TaskStopwatch stopwatch; | |
136 stopwatch.Start(); | |
137 | 135 |
138 if (!CreateContext(surface_id_ != 0)) { | 136 if (!CreateContext(surface_id_ != 0)) { |
139 Destroy(); | 137 Destroy(); |
140 | 138 |
141 stopwatch.Stop(); | |
142 | |
143 initialize_failed_ = true; | 139 initialize_failed_ = true; |
144 return false; | 140 return false; |
145 } | 141 } |
146 | 142 |
147 if (gl_ && attributes_.webGL) | 143 if (gl_ && attributes_.webGL) |
148 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); | 144 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); |
149 | 145 |
150 command_buffer_->SetChannelErrorCallback( | 146 command_buffer_->SetChannelErrorCallback( |
151 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnGpuChannelLost, | 147 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnGpuChannelLost, |
152 weak_ptr_factory_.GetWeakPtr())); | 148 weak_ptr_factory_.GetWeakPtr())); |
153 | 149 |
154 command_buffer_->SetOnConsoleMessageCallback( | 150 command_buffer_->SetOnConsoleMessageCallback( |
155 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage, | 151 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage, |
156 weak_ptr_factory_.GetWeakPtr())); | 152 weak_ptr_factory_.GetWeakPtr())); |
157 | 153 |
158 real_gl_->SetErrorMessageCallback(getErrorMessageCallback()); | 154 real_gl_->SetErrorMessageCallback(getErrorMessageCallback()); |
159 | 155 |
160 stopwatch.Stop(); | |
161 | |
162 visible_ = true; | 156 visible_ = true; |
163 initialized_ = true; | 157 initialized_ = true; |
164 return true; | 158 return true; |
165 } | 159 } |
166 | 160 |
167 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( | 161 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( |
168 bool onscreen, WebGraphicsContext3DCommandBufferImpl* share_context) { | 162 bool onscreen, WebGraphicsContext3DCommandBufferImpl* share_context) { |
169 if (!host_.get()) | 163 if (!host_.get()) |
170 return false; | 164 return false; |
171 | 165 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 share_group_->RemoveAllContexts(); | 405 share_group_->RemoveAllContexts(); |
412 | 406 |
413 DCHECK(host_.get()); | 407 DCHECK(host_.get()); |
414 { | 408 { |
415 base::AutoLock lock(g_default_share_groups_lock.Get()); | 409 base::AutoLock lock(g_default_share_groups_lock.Get()); |
416 g_default_share_groups.Get().erase(host_.get()); | 410 g_default_share_groups.Get().erase(host_.get()); |
417 } | 411 } |
418 } | 412 } |
419 | 413 |
420 } // namespace content | 414 } // namespace content |
OLD | NEW |