OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |