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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
12 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
13 #include "ui/gl/gl_implementation.h" | 13 #include "ui/gl/gl_implementation.h" |
14 #include "ui/gl/gl_surface.h" | 14 #include "ui/gl/gl_surface.h" |
15 #include "ui/gl/gl_switches.h" | 15 #include "ui/gl/gl_switches.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 | 18 |
19 namespace { | 19 namespace { |
20 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky | 20 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky |
21 current_context_ = LAZY_INSTANCE_INITIALIZER; | 21 current_context_ = LAZY_INSTANCE_INITIALIZER; |
22 } // namespace | 22 } // namespace |
23 | 23 |
| 24 int g_contextCount = 0; |
| 25 |
24 GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { | 26 GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { |
| 27 g_contextCount += 1; |
| 28 printf("In GPU process: GLContext::GLContext (%d contexts exist)\n", g_context
Count); |
25 if (!share_group_.get()) | 29 if (!share_group_.get()) |
26 share_group_ = new GLShareGroup; | 30 share_group_ = new GLShareGroup; |
27 | 31 |
28 share_group_->AddContext(this); | 32 share_group_->AddContext(this); |
29 } | 33 } |
30 | 34 |
31 GLContext::~GLContext() { | 35 GLContext::~GLContext() { |
32 share_group_->RemoveContext(this); | 36 share_group_->RemoveContext(this); |
33 if (GetCurrent() == this) { | 37 if (GetCurrent() == this) { |
34 SetCurrent(NULL, NULL); | 38 SetCurrent(NULL, NULL); |
35 } | 39 } |
| 40 g_contextCount -= 1; |
| 41 printf("In GPU process: GLContext::~GLContext (%d contexts exist)\n", g_contex
tCount); |
36 } | 42 } |
37 | 43 |
38 std::string GLContext::GetExtensions() { | 44 std::string GLContext::GetExtensions() { |
39 DCHECK(IsCurrent(NULL)); | 45 DCHECK(IsCurrent(NULL)); |
40 const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); | 46 const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); |
41 return std::string(ext ? ext : ""); | 47 return std::string(ext ? ext : ""); |
42 } | 48 } |
43 | 49 |
44 bool GLContext::HasExtension(const char* name) { | 50 bool GLContext::HasExtension(const char* name) { |
45 std::string extensions = GetExtensions(); | 51 std::string extensions = GetExtensions(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 static bool initialized = false; | 96 static bool initialized = false; |
91 if (initialized) | 97 if (initialized) |
92 return initialized; | 98 return initialized; |
93 initialized = InitializeGLExtensionBindings(GetGLImplementation(), this); | 99 initialized = InitializeGLExtensionBindings(GetGLImplementation(), this); |
94 if (!initialized) | 100 if (!initialized) |
95 LOG(ERROR) << "Could not initialize extension bindings."; | 101 LOG(ERROR) << "Could not initialize extension bindings."; |
96 return initialized; | 102 return initialized; |
97 } | 103 } |
98 | 104 |
99 } // namespace gfx | 105 } // namespace gfx |
OLD | NEW |