Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc

Issue 470973002: gpu: Remove WebGraphicsContext3D::makeContextCurrent() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix in unittests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 10 matching lines...) Expand all
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 "content/common/gpu/client/gpu_channel_host.h" 25 #include "content/common/gpu/client/gpu_channel_host.h"
26 #include "content/public/common/content_constants.h" 26 #include "content/public/common/content_constants.h"
27 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
28 #include "gpu/GLES2/gl2extchromium.h" 28 #include "gpu/GLES2/gl2extchromium.h"
29 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 29 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
30 #include "gpu/command_buffer/client/gles2_implementation.h" 30 #include "gpu/command_buffer/client/gles2_implementation.h"
31 #include "gpu/command_buffer/client/gles2_lib.h"
32 #include "gpu/command_buffer/client/gles2_trace_implementation.h" 31 #include "gpu/command_buffer/client/gles2_trace_implementation.h"
33 #include "gpu/command_buffer/client/transfer_buffer.h" 32 #include "gpu/command_buffer/client/transfer_buffer.h"
34 #include "gpu/command_buffer/common/constants.h" 33 #include "gpu/command_buffer/common/constants.h"
35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 34 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
36 #include "gpu/command_buffer/common/mailbox.h" 35 #include "gpu/command_buffer/common/mailbox.h"
37 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" 36 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
38 #include "third_party/skia/include/core/SkTypes.h" 37 #include "third_party/skia/include/core/SkTypes.h"
39 38
40 namespace content { 39 namespace content {
41 40
(...skipping 16 matching lines...) Expand all
58 ShareGroupMap::iterator it = share_groups.find(host); 57 ShareGroupMap::iterator it = share_groups.find(host);
59 if (it == share_groups.end()) { 58 if (it == share_groups.end()) {
60 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> group = 59 scoped_refptr<WebGraphicsContext3DCommandBufferImpl::ShareGroup> group =
61 new WebGraphicsContext3DCommandBufferImpl::ShareGroup(); 60 new WebGraphicsContext3DCommandBufferImpl::ShareGroup();
62 share_groups[host] = group; 61 share_groups[host] = group;
63 return group; 62 return group;
64 } 63 }
65 return it->second; 64 return it->second;
66 } 65 }
67 66
68 // Singleton used to initialize and terminate the gles2 library.
69 class GLES2Initializer {
70 public:
71 GLES2Initializer() {
72 gles2::Initialize();
73 }
74
75 ~GLES2Initializer() {
76 gles2::Terminate();
77 }
78
79 private:
80 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
81 };
82
83 ////////////////////////////////////////////////////////////////////////////////
84
85 base::LazyInstance<GLES2Initializer> g_gles2_initializer =
86 LAZY_INSTANCE_INITIALIZER;
87
88 ////////////////////////////////////////////////////////////////////////////////
89
90 } // namespace anonymous 67 } // namespace anonymous
91 68
92 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits::SharedMemoryLimits() 69 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits::SharedMemoryLimits()
93 : command_buffer_size(kDefaultCommandBufferSize), 70 : command_buffer_size(kDefaultCommandBufferSize),
94 start_transfer_buffer_size(kDefaultStartTransferBufferSize), 71 start_transfer_buffer_size(kDefaultStartTransferBufferSize),
95 min_transfer_buffer_size(kDefaultMinTransferBufferSize), 72 min_transfer_buffer_size(kDefaultMinTransferBufferSize),
96 max_transfer_buffer_size(kDefaultMaxTransferBufferSize), 73 max_transfer_buffer_size(kDefaultMaxTransferBufferSize),
97 mapped_memory_reclaim_limit(gpu::gles2::GLES2Implementation::kNoLimit) {} 74 mapped_memory_reclaim_limit(gpu::gles2::GLES2Implementation::kNoLimit) {}
98 75
99 WebGraphicsContext3DCommandBufferImpl::ShareGroup::ShareGroup() { 76 WebGraphicsContext3DCommandBufferImpl::ShareGroup::ShareGroup() {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 << "Context dead on arrival. Last error: " 196 << "Context dead on arrival. Last error: "
220 << command_buffer_->GetLastError(); 197 << command_buffer_->GetLastError();
221 // Initialize the command buffer. 198 // Initialize the command buffer.
222 bool result = command_buffer_->Initialize(); 199 bool result = command_buffer_->Initialize();
223 LOG_IF(ERROR, !result) << "CommandBufferProxy::Initialize failed."; 200 LOG_IF(ERROR, !result) << "CommandBufferProxy::Initialize failed.";
224 return result; 201 return result;
225 } 202 }
226 203
227 bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) { 204 bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) {
228 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::CreateContext"); 205 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::CreateContext");
229 // Ensure the gles2 library is initialized first in a thread safe way.
230 g_gles2_initializer.Get();
231
232 scoped_refptr<gpu::gles2::ShareGroup> gles2_share_group; 206 scoped_refptr<gpu::gles2::ShareGroup> gles2_share_group;
233 207
234 scoped_ptr<base::AutoLock> share_group_lock; 208 scoped_ptr<base::AutoLock> share_group_lock;
235 bool add_to_share_group = false; 209 bool add_to_share_group = false;
236 if (!command_buffer_) { 210 if (!command_buffer_) {
237 WebGraphicsContext3DCommandBufferImpl* share_context = NULL; 211 WebGraphicsContext3DCommandBufferImpl* share_context = NULL;
238 212
239 share_group_lock.reset(new base::AutoLock(share_group_->lock())); 213 share_group_lock.reset(new base::AutoLock(share_group_->lock()));
240 share_context = share_group_->GetAnyContextLocked(); 214 share_context = share_group_->GetAnyContextLocked();
241 215
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 share_group_->AddContextLocked(this); 263 share_group_->AddContextLocked(this);
290 264
291 if (CommandLine::ForCurrentProcess()->HasSwitch( 265 if (CommandLine::ForCurrentProcess()->HasSwitch(
292 switches::kEnableGpuClientTracing)) { 266 switches::kEnableGpuClientTracing)) {
293 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface())); 267 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface()));
294 setGLInterface(trace_gl_.get()); 268 setGLInterface(trace_gl_.get());
295 } 269 }
296 return true; 270 return true;
297 } 271 }
298 272
299 bool WebGraphicsContext3DCommandBufferImpl::makeContextCurrent() { 273 bool WebGraphicsContext3DCommandBufferImpl::InitializeOnCurrentThread() {
300 if (!MaybeInitializeGL()) { 274 if (!MaybeInitializeGL()) {
301 DLOG(ERROR) << "Failed to initialize context."; 275 DLOG(ERROR) << "Failed to initialize context.";
302 return false; 276 return false;
303 } 277 }
304 gles2::SetGLContext(GetGLInterface());
305 if (gpu::error::IsError(command_buffer_->GetLastError())) { 278 if (gpu::error::IsError(command_buffer_->GetLastError())) {
306 LOG(ERROR) << "Context dead on arrival. Last error: " 279 LOG(ERROR) << "Context dead on arrival. Last error: "
307 << command_buffer_->GetLastError(); 280 << command_buffer_->GetLastError();
308 return false; 281 return false;
309 } 282 }
310 283
311 return true; 284 return true;
312 } 285 }
313 286
314 void WebGraphicsContext3DCommandBufferImpl::Destroy() { 287 void WebGraphicsContext3DCommandBufferImpl::Destroy() {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 share_group_->RemoveAllContexts(); 395 share_group_->RemoveAllContexts();
423 396
424 DCHECK(host_.get()); 397 DCHECK(host_.get());
425 { 398 {
426 base::AutoLock lock(g_default_share_groups_lock.Get()); 399 base::AutoLock lock(g_default_share_groups_lock.Get());
427 g_default_share_groups.Get().erase(host_.get()); 400 g_default_share_groups.Get().erase(host_.get());
428 } 401 }
429 } 402 }
430 403
431 } // namespace content 404 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698