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

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: Use ScopedMakeCurrent. 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_cgl.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() {
(...skipping 50 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
96 GLContext* GLContext::GetRealCurrent() {
97 return current_real_context_.Pointer()->Get();
98 }
99
93 void GLContext::SetCurrent(GLContext* context, GLSurface* surface) { 100 void GLContext::SetCurrent(GLContext* context, GLSurface* surface) {
101 DCHECK_EQ(!context, !surface);
102 if (!context || !context->IsVirtualContext()) {
epenner 2013/05/28 21:33:53 One drive-by comment: If we keep keep track of th
jonathan.backer 2013/05/31 17:21:40 By only changing current_real_context_ when the re
103 current_real_context_.Pointer()->Set(context);
104 GLSurface::SetRealCurrent(surface);
105 }
94 current_context_.Pointer()->Set(context); 106 current_context_.Pointer()->Set(context);
95 GLSurface::SetCurrent(surface); 107 GLSurface::SetCurrent(surface);
96 } 108 }
97 109
98 GLStateRestorer* GLContext::GetGLStateRestorer() { 110 GLStateRestorer* GLContext::GetGLStateRestorer() {
99 return state_restorer_.get(); 111 return state_restorer_.get();
100 } 112 }
101 113
102 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) { 114 void GLContext::SetGLStateRestorer(GLStateRestorer* state_restorer) {
103 state_restorer_ = make_scoped_ptr(state_restorer); 115 state_restorer_ = make_scoped_ptr(state_restorer);
(...skipping 17 matching lines...) Expand all
121 void GLContext::SetupForVirtualization() { 133 void GLContext::SetupForVirtualization() {
122 if (!virtual_gl_api_) { 134 if (!virtual_gl_api_) {
123 virtual_gl_api_.reset(new VirtualGLApi()); 135 virtual_gl_api_.reset(new VirtualGLApi());
124 virtual_gl_api_->Initialize(&g_driver_gl, this); 136 virtual_gl_api_->Initialize(&g_driver_gl, this);
125 } 137 }
126 } 138 }
127 139
128 bool GLContext::MakeVirtuallyCurrent( 140 bool GLContext::MakeVirtuallyCurrent(
129 GLContext* virtual_context, GLSurface* surface) { 141 GLContext* virtual_context, GLSurface* surface) {
130 DCHECK(virtual_gl_api_); 142 DCHECK(virtual_gl_api_);
131 return virtual_gl_api_->MakeCurrent(virtual_context, surface); 143 bool result = virtual_gl_api_->MakeCurrent(virtual_context, surface);
144 if (result)
145 SetCurrent(virtual_context, surface);
146 return result;
132 } 147 }
133 148
134 void GLContext::OnDestroyVirtualContext(GLContext* virtual_context) { 149 void GLContext::OnDestroyVirtualContext(GLContext* virtual_context) {
135 if (virtual_gl_api_) 150 if (virtual_gl_api_)
136 virtual_gl_api_->OnDestroyVirtualContext(virtual_context); 151 virtual_gl_api_->OnDestroyVirtualContext(virtual_context);
137 } 152 }
138 153
139 void GLContext::SetRealGLApi() { 154 void GLContext::SetRealGLApi() {
140 SetGLToRealGLApi(); 155 SetGLToRealGLApi();
141 } 156 }
142 157
158 bool GLContext::IsVirtualContext() {
159 return false;
160 }
161
143 } // namespace gfx 162 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context.h ('k') | ui/gl/gl_context_cgl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698