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

Side by Side Diff: ui/gl/gl_context.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: Nix unnecessary changes. Created 7 years, 6 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
« no previous file with comments | « ui/gl/gl_context.h ('k') | ui/gl/gl_context_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17
18 namespace gfx { 18 namespace gfx {
19 19
20 namespace { 20 namespace {
21 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky 21 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
22 current_context_ = LAZY_INSTANCE_INITIALIZER; 22 current_context_ = LAZY_INSTANCE_INITIALIZER;
23
24 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky
25 current_real_context_ = LAZY_INSTANCE_INITIALIZER;
23 } // namespace 26 } // namespace
24 27
25 GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { 28 GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) {
26 if (!share_group_.get()) 29 if (!share_group_.get())
27 share_group_ = new GLShareGroup; 30 share_group_ = new GLShareGroup;
28 31
29 share_group_->AddContext(this); 32 share_group_->AddContext(this);
30 } 33 }
31 34
32 GLContext::~GLContext() { 35 GLContext::~GLContext() {
33 share_group_->RemoveContext(this); 36 share_group_->RemoveContext(this);
34 if (GetCurrent() == this) { 37 if (GetCurrent() == this) {
35 SetCurrent(NULL, NULL); 38 SetCurrent(NULL);
36 } 39 }
37 } 40 }
38 41
39 bool GLContext::GetTotalGpuMemory(size_t* bytes) { 42 bool GLContext::GetTotalGpuMemory(size_t* bytes) {
40 DCHECK(bytes); 43 DCHECK(bytes);
41 *bytes = 0; 44 *bytes = 0;
42 return false; 45 return false;
43 } 46 }
44 47
45 void GLContext::SetSafeToForceGpuSwitch() { 48 void GLContext::SetSafeToForceGpuSwitch() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 default: 86 default:
84 NOTREACHED(); 87 NOTREACHED();
85 return true; 88 return true;
86 } 89 }
87 } 90 }
88 91
89 GLContext* GLContext::GetCurrent() { 92 GLContext* GLContext::GetCurrent() {
90 return current_context_.Pointer()->Get(); 93 return current_context_.Pointer()->Get();
91 } 94 }
92 95
93 void GLContext::SetCurrent(GLContext* context, GLSurface* surface) { 96 GLContext* GLContext::GetRealCurrent() {
94 current_context_.Pointer()->Set(context); 97 return current_real_context_.Pointer()->Get();
98 }
99
100 void GLContext::SetCurrent(GLSurface* surface) {
101 current_context_.Pointer()->Set(surface ? this : NULL);
95 GLSurface::SetCurrent(surface); 102 GLSurface::SetCurrent(surface);
96 } 103 }
97 104
98 GLStateRestorer* GLContext::GetGLStateRestorer() { 105 GLStateRestorer* GLContext::GetGLStateRestorer() {
99 return state_restorer_.get(); 106 return state_restorer_.get();
100 } 107 }
101 108
102 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { 109 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) {
103 state_restorer_ = make_scoped_ptr(state_restorer); 110 state_restorer_ = make_scoped_ptr(state_restorer);
104 } 111 }
(...skipping 28 matching lines...) Expand all
133 140
134 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { 141 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) {
135 if (virtual_gl_api_) 142 if (virtual_gl_api_)
136 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); 143 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context);
137 } 144 }
138 145
139 void GLContext::SetRealGLApi() { 146 void GLContext::SetRealGLApi() {
140 SetGLToRealGLApi(); 147 SetGLToRealGLApi();
141 } 148 }
142 149
150 GLContextReal::GLContextReal(GLShareGroup* share_group)
151 : GLContext(share_group) {}
152
153 GLContextReal::~GLContextReal() {}
154
155 void GLContextReal::SetCurrent(GLSurface* surface) {
156 GLContext::SetCurrent(surface);
157 current_real_context_.Pointer()->Set(surface ? this : NULL);
158 }
159
143 } // namespace gfx 160 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context.h ('k') | ui/gl/gl_context_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698