| 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_->OnReleaseVirtuallyCurrent(this); | 51 shared_context_->OnReleaseVirtuallyCurrent(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(). |
| 57 if (decoder_.get()) | 60 if (decoder_.get()) |
| 58 return shared_context_->MakeVirtuallyCurrent(this, surface); | 61 shared_context_->MakeVirtuallyCurrent(this, surface); |
| 59 | 62 else if (!IsCurrent(surface)) |
| 60 LOG(ERROR) << "Trying to make virtual context current without decoder."; | 63 shared_context_->MakeCurrent(surface); |
| 61 return false; | 64 return true; |
| 62 } | 65 } |
| 63 | 66 |
| 64 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) { | 67 void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) { |
| 65 if (IsCurrent(surface)) { | 68 if (IsCurrent(surface)) { |
| 66 shared_context_->OnReleaseVirtuallyCurrent(this); | 69 shared_context_->OnReleaseVirtuallyCurrent(this); |
| 67 shared_context_->ReleaseCurrent(surface); | 70 shared_context_->ReleaseCurrent(surface); |
| 68 } | 71 } |
| 69 } | 72 } |
| 70 | 73 |
| 71 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) { | 74 bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 111 |
| 109 void GLContextVirtual::SetUnbindFboOnMakeCurrent() { | 112 void GLContextVirtual::SetUnbindFboOnMakeCurrent() { |
| 110 shared_context_->SetUnbindFboOnMakeCurrent(); | 113 shared_context_->SetUnbindFboOnMakeCurrent(); |
| 111 } | 114 } |
| 112 | 115 |
| 113 GLContextVirtual::~GLContextVirtual() { | 116 GLContextVirtual::~GLContextVirtual() { |
| 114 Destroy(); | 117 Destroy(); |
| 115 } | 118 } |
| 116 | 119 |
| 117 } // namespace gpu | 120 } // namespace gpu |
| OLD | NEW |