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

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

Issue 14069008: GPU: Reduce MakeCurrent calls to fix Orange San Diego (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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 | « content/gpu/gpu_info_collector_android.cc ('k') | 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 11 matching lines...) Expand all
22 } 22 }
23 23
24 gfx::Display* GLContextVirtual::display() { 24 gfx::Display* GLContextVirtual::display() {
25 return display_; 25 return display_;
26 } 26 }
27 27
28 bool GLContextVirtual::Initialize( 28 bool GLContextVirtual::Initialize(
29 gfx::GLSurface* compatible_surface, gfx::GpuPreference gpu_preference) { 29 gfx::GLSurface* compatible_surface, gfx::GpuPreference gpu_preference) {
30 display_ = static_cast<gfx::Display*>(compatible_surface->GetDisplay()); 30 display_ = static_cast<gfx::Display*>(compatible_surface->GetDisplay());
31 31
32 if (!shared_context_->MakeCurrent(compatible_surface)) 32 if (!IsCurrent(compatible_surface)) {
no sievers 2013/04/10 22:44:31 shared_context_->MakeCurrent() here is called to f
epennerAtGoogle 2013/04/11 03:23:43 Hmm, if you want to legitimately bind a pbuffer su
no sievers 2013/04/11 19:56:19 Discussed optimizing this by having the caller pas
epenner 2013/05/02 04:13:11 Sorry but that won't work. Initialize always need
33 return false; 33 if (!shared_context_->MakeCurrent(compatible_surface))
34 return false;
35 }
34 36
35 shared_context_->SetupForVirtualization(); 37 shared_context_->SetupForVirtualization();
36
37 shared_context_->ReleaseCurrent(compatible_surface);
no sievers 2013/04/10 22:44:31 This can probably just go away.
epennerAtGoogle 2013/04/11 03:23:43 Done.
epennerAtGoogle 2013/04/11 03:23:43 SGTM
38 return true; 38 return true;
39 } 39 }
40 40
41 void GLContextVirtual::Destroy() { 41 void GLContextVirtual::Destroy() {
42 shared_context_->OnDestroyVirtualContext(this); 42 shared_context_->OnDestroyVirtualContext(this);
43 shared_context_ = NULL; 43 shared_context_ = NULL;
44 display_ = NULL; 44 display_ = NULL;
45 } 45 }
46 46
47 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) { 47 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) {
48 if (decoder_.get() && decoder_->initialized()) 48 if (IsCurrent(surface) || (decoder_.get() && decoder_->initialized()))
49 shared_context_->MakeVirtuallyCurrent(this, surface); 49 shared_context_->MakeVirtuallyCurrent(this, surface);
50 else 50 else
51 shared_context_->MakeCurrent(surface); 51 shared_context_->MakeCurrent(surface);
52 return true; 52 return true;
53 } 53 }
54 54
55 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) { 55 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) {
56 if (IsCurrent(surface)) 56 // This is intentionally a no-op. When using virtual contexts
no sievers 2013/04/10 22:44:31 shared_context_->ReleaseCurrent() still needs to b
no sievers 2013/04/10 22:47:23 Or to generalize, ReleaseCurrent() would have to b
epennerAtGoogle 2013/04/11 03:23:43 Okay I see the problem there. That's a pretty nast
no sievers 2013/04/11 19:56:19 Discussed optimizing this by moving the call site
epenner 2013/05/02 04:13:11 To clarify, are you suggesting that every derived
57 shared_context_->ReleaseCurrent(surface); 57 // the shared context should always stay current.
58 } 58 }
59 59
60 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) { 60 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) {
61 bool context_current = shared_context_->IsCurrent(NULL); 61 bool context_current = shared_context_->IsCurrent(NULL);
62 if (!context_current) 62 if (!context_current)
63 return false; 63 return false;
64 64
65 if (!surface) 65 if (!surface)
66 return true; 66 return true;
67 67
(...skipping 26 matching lines...) Expand all
94 94
95 bool GLContextVirtual::WasAllocatedUsingRobustnessExtension() { 95 bool GLContextVirtual::WasAllocatedUsingRobustnessExtension() {
96 return shared_context_->WasAllocatedUsingRobustnessExtension(); 96 return shared_context_->WasAllocatedUsingRobustnessExtension();
97 } 97 }
98 98
99 GLContextVirtual::~GLContextVirtual() { 99 GLContextVirtual::~GLContextVirtual() {
100 Destroy(); 100 Destroy();
101 } 101 }
102 102
103 } // namespace gpu 103 } // namespace gpu
OLDNEW
« no previous file with comments | « content/gpu/gpu_info_collector_android.cc ('k') | ui/gl/gl_gl_api_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698