| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/gfx/gl/gl_context_egl.h" | 5 #include "ui/gfx/gl/gl_context_egl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "third_party/angle/include/EGL/egl.h" | 10 #include "third_party/angle/include/EGL/egl.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 surface_->GetHandle(), | 104 surface_->GetHandle(), |
| 105 context_)) { | 105 context_)) { |
| 106 VLOG(1) << "eglMakeCurrent failed with error " | 106 VLOG(1) << "eglMakeCurrent failed with error " |
| 107 << GetLastEGLErrorString(); | 107 << GetLastEGLErrorString(); |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void GLContextEGL::ReleaseCurrent() { |
| 115 if (!IsCurrent()) |
| 116 return; |
| 117 |
| 118 eglMakeCurrent(GLSurfaceEGL::GetDisplay(), |
| 119 EGL_NO_SURFACE, |
| 120 EGL_NO_SURFACE, |
| 121 EGL_NO_CONTEXT); |
| 122 } |
| 123 |
| 114 bool GLContextEGL::IsCurrent() { | 124 bool GLContextEGL::IsCurrent() { |
| 115 DCHECK(context_); | 125 DCHECK(context_); |
| 116 return context_ == eglGetCurrentContext(); | 126 return context_ == eglGetCurrentContext() && |
| 127 surface_->GetHandle() == eglGetCurrentSurface(EGL_DRAW); |
| 117 } | 128 } |
| 118 | 129 |
| 119 bool GLContextEGL::IsOffscreen() { | 130 bool GLContextEGL::IsOffscreen() { |
| 120 // TODO(apatrick): remove this from GLContext interface. | 131 // TODO(apatrick): remove this from GLContext interface. |
| 121 return surface_->IsOffscreen(); | 132 return surface_->IsOffscreen(); |
| 122 } | 133 } |
| 123 | 134 |
| 124 bool GLContextEGL::SwapBuffers() { | 135 bool GLContextEGL::SwapBuffers() { |
| 125 // TODO(apatrick): remove this from GLContext interface. | 136 // TODO(apatrick): remove this from GLContext interface. |
| 126 return surface_->SwapBuffers(); | 137 return surface_->SwapBuffers(); |
| 127 } | 138 } |
| 128 | 139 |
| 129 gfx::Size GLContextEGL::GetSize() { | 140 gfx::Size GLContextEGL::GetSize() { |
| 130 // TODO(apatrick): remove this from GLContext interface. | 141 // TODO(apatrick): remove this from GLContext interface. |
| 131 return surface_->GetSize(); | 142 return surface_->GetSize(); |
| 132 } | 143 } |
| 133 | 144 |
| 145 GLSurface* GLContextEGL::GetSurface() { |
| 146 // TODO(apatrick): remove this from GLContext interface. |
| 147 return surface_.get(); |
| 148 } |
| 149 |
| 134 void* GLContextEGL::GetHandle() { | 150 void* GLContextEGL::GetHandle() { |
| 135 return context_; | 151 return context_; |
| 136 } | 152 } |
| 137 | 153 |
| 138 void GLContextEGL::SetSwapInterval(int interval) { | 154 void GLContextEGL::SetSwapInterval(int interval) { |
| 139 DCHECK(IsCurrent()); | 155 DCHECK(IsCurrent()); |
| 140 if (!eglSwapInterval(GLSurfaceEGL::GetDisplay(), interval)) { | 156 if (!eglSwapInterval(GLSurfaceEGL::GetDisplay(), interval)) { |
| 141 LOG(ERROR) << "eglSwapInterval failed with error " | 157 LOG(ERROR) << "eglSwapInterval failed with error " |
| 142 << GetLastEGLErrorString(); | 158 << GetLastEGLErrorString(); |
| 143 } | 159 } |
| 144 } | 160 } |
| 145 | 161 |
| 146 } // namespace gfx | 162 } // namespace gfx |
| OLD | NEW |