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 "base/callback.h" | 7 #include "base/callback.h" |
8 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" | 8 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
10 #include "ui/gl/gl_gl_api_implementation.h" | 10 #include "ui/gl/gl_gl_api_implementation.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 if (IsCurrent(surface)) { | 44 if (IsCurrent(surface)) { |
45 shared_context_->OnReleaseVirtuallyCurrent(this); | 45 shared_context_->OnReleaseVirtuallyCurrent(this); |
46 shared_context_->ReleaseCurrent(surface); | 46 shared_context_->ReleaseCurrent(surface); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 bool GLContextVirtual::IsCurrent(gl::GLSurface* surface) { | 50 bool GLContextVirtual::IsCurrent(gl::GLSurface* surface) { |
51 // If it's a real surface it needs to be current. | 51 // If it's a real surface it needs to be current. |
52 if (surface && | 52 if (surface && |
53 !surface->IsOffscreen()) | 53 !surface->IsOffscreen()) |
54 return shared_context_->IsCurrent(surface); | 54 return shared_context_->IsCurrent(surface) && |
55 shared_context_->current_virtual_context_ == this; | |
55 | 56 |
56 // Otherwise, only insure the context itself is current. | 57 // Otherwise, only insure the context itself is current. |
57 return shared_context_->IsCurrent(NULL); | 58 return shared_context_->IsCurrent(NULL) && |
59 shared_context_->current_virtual_context_ == this; | |
piman
2017/05/03 19:47:41
One feature of this code is to avoid calling eglMa
Zhenyao Mo
2017/05/03 22:21:34
Thanks for pointing this out, although this design
| |
58 } | 60 } |
59 | 61 |
60 void* GLContextVirtual::GetHandle() { | 62 void* GLContextVirtual::GetHandle() { |
61 return shared_context_->GetHandle(); | 63 return shared_context_->GetHandle(); |
62 } | 64 } |
63 | 65 |
64 scoped_refptr<gl::GPUTimingClient> GLContextVirtual::CreateGPUTimingClient() { | 66 scoped_refptr<gl::GPUTimingClient> GLContextVirtual::CreateGPUTimingClient() { |
65 return shared_context_->CreateGPUTimingClient(); | 67 return shared_context_->CreateGPUTimingClient(); |
66 } | 68 } |
67 | 69 |
(...skipping 30 matching lines...) Expand all Loading... | |
98 | 100 |
99 gl::YUVToRGBConverter* GLContextVirtual::GetYUVToRGBConverter() { | 101 gl::YUVToRGBConverter* GLContextVirtual::GetYUVToRGBConverter() { |
100 return shared_context_->GetYUVToRGBConverter(); | 102 return shared_context_->GetYUVToRGBConverter(); |
101 } | 103 } |
102 | 104 |
103 GLContextVirtual::~GLContextVirtual() { | 105 GLContextVirtual::~GLContextVirtual() { |
104 Destroy(); | 106 Destroy(); |
105 } | 107 } |
106 | 108 |
107 } // namespace gpu | 109 } // namespace gpu |
OLD | NEW |