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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 void GLContextVirtual::Destroy() { | 50 void GLContextVirtual::Destroy() { |
51 shared_context_->OnDestroyVirtualContext(this); | 51 shared_context_->OnDestroyVirtualContext(this); |
52 shared_context_ = NULL; | 52 shared_context_ = NULL; |
53 display_ = NULL; | 53 display_ = NULL; |
54 } | 54 } |
55 | 55 |
56 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) { | 56 bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) { |
57 // TODO(epenner): We should avoid bypassing MakeVirtuallyCurrent() below | |
58 // (return false or DCHECK when !decoder). To do this we must reorder | |
59 // tear-down in GpuCommandBufferStub::Destroy(). | |
60 if (decoder_.get()) | 57 if (decoder_.get()) |
61 shared_context_->MakeVirtuallyCurrent(this, surface); | 58 return shared_context_->MakeVirtuallyCurrent(this, surface); |
62 else if (!IsCurrent(surface)) | 59 |
63 shared_context_->MakeCurrent(surface); | 60 LOG(ERROR) << "Trying to make virtual context current without decoder."; |
epenner
2013/05/28 22:57:21
Me like.
| |
64 return true; | 61 return false; |
65 } | 62 } |
66 | 63 |
67 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) { | 64 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) { |
68 if (IsCurrent(surface)) | 65 shared_context_->ReleaseCurrent(surface); |
69 shared_context_->ReleaseCurrent(surface); | |
70 } | 66 } |
71 | 67 |
72 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) { | 68 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) { |
73 // If it's a real surface it needs to be current. | 69 // If it's a real surface it needs to be current. |
74 if (surface && | 70 if (surface && |
75 !surface->GetBackingFrameBufferObject() && | 71 !surface->GetBackingFrameBufferObject() && |
76 !surface->IsOffscreen()) | 72 !surface->IsOffscreen()) |
77 return shared_context_->IsCurrent(surface); | 73 return shared_context_->IsCurrent(surface); |
78 | 74 |
79 // Otherwise, only insure the context itself is current. | 75 // Otherwise, only insure the context itself is current. |
(...skipping 29 matching lines...) Expand all Loading... | |
109 | 105 |
110 void GLContextVirtual::SetUnbindFboOnMakeCurrent() { | 106 void GLContextVirtual::SetUnbindFboOnMakeCurrent() { |
111 shared_context_->SetUnbindFboOnMakeCurrent(); | 107 shared_context_->SetUnbindFboOnMakeCurrent(); |
112 } | 108 } |
113 | 109 |
114 GLContextVirtual::~GLContextVirtual() { | 110 GLContextVirtual::~GLContextVirtual() { |
115 Destroy(); | 111 Destroy(); |
116 } | 112 } |
117 | 113 |
118 } // namespace gpu | 114 } // namespace gpu |
OLD | NEW |