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

Side by Side Diff: gpu/command_buffer/service/gl_context_virtual.cc

Issue 15841002: gpu: Fix corrupted state due to virtual MakeCurrent race. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « no previous file | ui/gl/gl_gl_api_implementation.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 "gpu/command_buffer/service/gl_context_virtual.h" 5 #include "gpu/command_buffer/service/gl_context_virtual.h"
6 6
7 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 7 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
8 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 8 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
9 #include "ui/gl/gl_surface.h" 9 #include "ui/gl/gl_surface.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return true; 46 return true;
47 } 47 }
48 48
49 void GLContextVirtual::Destroy() { 49 void GLContextVirtual::Destroy() {
50 shared_context_->OnDestroyVirtualContext(this); 50 shared_context_->OnDestroyVirtualContext(this);
51 shared_context_ = NULL; 51 shared_context_ = NULL;
52 display_ = NULL; 52 display_ = NULL;
53 } 53 }
54 54
55 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) { 55 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) {
56 if (decoder_.get() && decoder_->initialized()) 56 if (decoder_.get() && decoder_->initialized())
greggman 2013/05/24 00:56:47 nit: if there's braces on one if clause there shou
57 shared_context_->MakeVirtuallyCurrent(this, surface); 57 shared_context_->MakeVirtuallyCurrent(this, surface);
58 else 58 else {
59 shared_context_->MakeCurrent(surface); 59 // We can't restore our state yet, so unset the current virtual context,
60 // so that the next context (if it isn't this) will still know to restore.
61 shared_context_->MakeVirtuallyCurrent(NULL, NULL);
no sievers 2013/05/23 15:58:36 Hmm I don't understand how current_context_ in the
no sievers 2013/05/23 16:04:43 Actually I don't understand the comment either. We
no sievers 2013/05/23 17:04:34 Ok I think I get it now after reading your log fro
epenner 2013/05/23 18:00:03 If it was added for cleanup calls, those clean up
62
63 // But still make the real context current, if needed.
64 if (!IsCurrent(surface))
65 shared_context_->MakeCurrent(surface);
66 }
60 return true; 67 return true;
61 } 68 }
62 69
63 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) { 70 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) {
64 if (IsCurrent(surface)) 71 if (IsCurrent(surface))
65 shared_context_->ReleaseCurrent(surface); 72 shared_context_->ReleaseCurrent(surface);
66 } 73 }
67 74
68 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) { 75 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) {
69 // If it's a real surface it needs to be current. 76 // If it's a real surface it needs to be current.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 112
106 void GLContextVirtual::SetUnbindFboOnMakeCurrent() { 113 void GLContextVirtual::SetUnbindFboOnMakeCurrent() {
107 shared_context_->SetUnbindFboOnMakeCurrent(); 114 shared_context_->SetUnbindFboOnMakeCurrent();
108 } 115 }
109 116
110 GLContextVirtual::~GLContextVirtual() { 117 GLContextVirtual::~GLContextVirtual() {
111 Destroy(); 118 Destroy();
112 } 119 }
113 120
114 } // namespace gpu 121 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | ui/gl/gl_gl_api_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698