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

Side by Side Diff: ui/gl/gl_context.cc

Issue 937263006: Refactored GLContext to own GPUTiming which spawn GPUTimingClients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 <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_gl_api_implementation.h" 13 #include "ui/gl/gl_gl_api_implementation.h"
14 #include "ui/gl/gl_implementation.h" 14 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_surface.h" 15 #include "ui/gl/gl_surface.h"
16 #include "ui/gl/gl_switches.h" 16 #include "ui/gl/gl_switches.h"
17 #include "ui/gl/gl_version_info.h" 17 #include "ui/gl/gl_version_info.h"
18 #include "ui/gl/gpu_timing.h"
18 19
19 namespace gfx { 20 namespace gfx {
20 21
21 namespace { 22 namespace {
22 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky 23 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
23 current_context_ = LAZY_INSTANCE_INITIALIZER; 24 current_context_ = LAZY_INSTANCE_INITIALIZER;
24 25
25 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky 26 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
26 current_real_context_ = LAZY_INSTANCE_INITIALIZER; 27 current_real_context_ = LAZY_INSTANCE_INITIALIZER;
27 } // namespace 28 } // namespace
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 const GLVersionInfo* GLContext::GetVersionInfo() { 106 const GLVersionInfo* GLContext::GetVersionInfo() {
106 if(!version_info_) { 107 if(!version_info_) {
107 std::string version = GetGLVersion(); 108 std::string version = GetGLVersion();
108 std::string renderer = GetGLRenderer(); 109 std::string renderer = GetGLRenderer();
109 version_info_ = 110 version_info_ =
110 make_scoped_ptr(new GLVersionInfo(version.c_str(), renderer.c_str())); 111 make_scoped_ptr(new GLVersionInfo(version.c_str(), renderer.c_str()));
111 } 112 }
112 return version_info_.get(); 113 return version_info_.get();
113 } 114 }
114 115
116 gpu::GPUTiming* GLContext::GetGPUTiming() {
117 if (!gpu_timing_) {
118 gpu_timing_ = make_scoped_ptr(new gpu::GPUTiming(this));
119 }
120 return gpu_timing_.get();
121 }
122
115 GLShareGroup* GLContext::share_group() { 123 GLShareGroup* GLContext::share_group() {
116 return share_group_.get(); 124 return share_group_.get();
117 } 125 }
118 126
119 bool GLContext::LosesAllContextsOnContextLost() { 127 bool GLContext::LosesAllContextsOnContextLost() {
120 switch (GetGLImplementation()) { 128 switch (GetGLImplementation()) {
121 case kGLImplementationDesktopGL: 129 case kGLImplementationDesktopGL:
122 return false; 130 return false;
123 case kGLImplementationEGLGLES2: 131 case kGLImplementationEGLGLES2:
124 return true; 132 return true;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 : GLContext(share_group) {} 221 : GLContext(share_group) {}
214 222
215 GLContextReal::~GLContextReal() {} 223 GLContextReal::~GLContextReal() {}
216 224
217 void GLContextReal::SetCurrent(GLSurface* surface) { 225 void GLContextReal::SetCurrent(GLSurface* surface) {
218 GLContext::SetCurrent(surface); 226 GLContext::SetCurrent(surface);
219 current_real_context_.Pointer()->Set(surface ? this : NULL); 227 current_real_context_.Pointer()->Set(surface ? this : NULL);
220 } 228 }
221 229
222 } // namespace gfx 230 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698