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

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

Issue 15928002: GPU: Keep track of the last real context and real surface made current. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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 "ui/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/threading/thread_local.h" 14 #include "base/threading/thread_local.h"
15 #include "ui/gl/gl_context.h" 15 #include "ui/gl/gl_context.h"
16 #include "ui/gl/gl_implementation.h" 16 #include "ui/gl/gl_implementation.h"
17 17
18 namespace gfx { 18 namespace gfx {
19 19
20 namespace { 20 namespace {
21 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky 21 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky
22 current_surface_ = LAZY_INSTANCE_INITIALIZER; 22 current_surface_ = LAZY_INSTANCE_INITIALIZER;
23
24 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky
25 current_real_surface_ = LAZY_INSTANCE_INITIALIZER;
23 } // namespace 26 } // namespace
24 27
25 // static 28 // static
26 bool GLSurface::InitializeOneOff() { 29 bool GLSurface::InitializeOneOff() {
27 static bool initialized = false; 30 static bool initialized = false;
28 if (initialized) 31 if (initialized)
29 return true; 32 return true;
30 33
31 TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff"); 34 TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff");
32 35
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 150 }
148 151
149 VSyncProvider* GLSurface::GetVSyncProvider() { 152 VSyncProvider* GLSurface::GetVSyncProvider() {
150 return NULL; 153 return NULL;
151 } 154 }
152 155
153 GLSurface* GLSurface::GetCurrent() { 156 GLSurface* GLSurface::GetCurrent() {
154 return current_surface_.Pointer()->Get(); 157 return current_surface_.Pointer()->Get();
155 } 158 }
156 159
160 GLSurface* GLSurface::GetRealCurrent() {
161 return current_real_surface_.Pointer()->Get();
162 }
163
157 GLSurface::~GLSurface() { 164 GLSurface::~GLSurface() {
158 if (GetCurrent() == this) 165 if (GetCurrent() == this)
159 SetCurrent(NULL); 166 SetCurrent(NULL);
167
168 if (GetRealCurrent() == this)
169 SetRealCurrent(NULL);
160 } 170 }
161 171
162 void GLSurface::SetCurrent(GLSurface* surface) { 172 void GLSurface::SetCurrent(GLSurface* surface) {
163 current_surface_.Pointer()->Set(surface); 173 current_surface_.Pointer()->Set(surface);
164 } 174 }
165 175
176 void GLSurface::SetRealCurrent(GLSurface* surface) {
177 current_real_surface_.Pointer()->Set(surface);
178 }
179
166 bool GLSurface::ExtensionsContain(const char* c_extensions, const char* name) { 180 bool GLSurface::ExtensionsContain(const char* c_extensions, const char* name) {
167 DCHECK(name); 181 DCHECK(name);
168 if (!c_extensions) 182 if (!c_extensions)
169 return false; 183 return false;
170 std::string extensions(c_extensions); 184 std::string extensions(c_extensions);
171 extensions += " "; 185 extensions += " ";
172 186
173 std::string delimited_name(name); 187 std::string delimited_name(name);
174 delimited_name += " "; 188 delimited_name += " ";
175 189
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return surface_->GetFormat(); 268 return surface_->GetFormat();
255 } 269 }
256 270
257 VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { 271 VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() {
258 return surface_->GetVSyncProvider(); 272 return surface_->GetVSyncProvider();
259 } 273 }
260 274
261 GLSurfaceAdapter::~GLSurfaceAdapter() {} 275 GLSurfaceAdapter::~GLSurfaceAdapter() {}
262 276
263 } // namespace gfx 277 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698