Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/gl/gl_image_shm.h" | 5 #include "ui/gl/gl_image_shm.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/process/process_handle.h" | 8 #include "base/process/process_handle.h" |
| 9 #include "ui/gl/gl_context.h" | |
| 9 #include "ui/gl/scoped_binders.h" | 10 #include "ui/gl/scoped_binders.h" |
| 10 | 11 |
| 11 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ | 12 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ |
| 12 defined(USE_OZONE) | 13 defined(USE_OZONE) |
| 13 #include "ui/gl/gl_surface_egl.h" | 14 #include "ui/gl/gl_surface_egl.h" |
| 14 #endif | 15 #endif |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 return true; | 106 return true; |
| 106 } | 107 } |
| 107 | 108 |
| 108 void GLImageShm::Destroy() { | 109 void GLImageShm::Destroy() { |
| 109 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ | 110 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ |
| 110 defined(USE_OZONE) | 111 defined(USE_OZONE) |
| 111 if (egl_image_ != EGL_NO_IMAGE_KHR) { | 112 if (egl_image_ != EGL_NO_IMAGE_KHR) { |
| 112 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); | 113 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); |
| 113 egl_image_ = EGL_NO_IMAGE_KHR; | 114 egl_image_ = EGL_NO_IMAGE_KHR; |
| 114 } | 115 } |
| 115 | 116 GLContext* current_context = GLContext::GetCurrent(); |
| 116 if (egl_texture_id_) { | 117 if (egl_texture_id_ && |
| 118 (current_context && current_context->IsCurrent(NULL))) { | |
| 117 glDeleteTextures(1, &egl_texture_id_); | 119 glDeleteTextures(1, &egl_texture_id_); |
| 118 egl_texture_id_ = 0u; | 120 egl_texture_id_ = 0u; |
| 119 } | 121 } |
|
sohanjg
2014/05/28 10:16:00
Wouldnt we end up leaking the texture if current_c
no sievers
2014/05/28 18:55:32
I think we should rather pass through the flag fro
reveman
2014/05/28 20:23:33
I think the problem is that GLImages are ref count
no sievers
2014/05/28 21:02:39
Should a gpu::gles2::Texture also call ReleaseTexI
reveman
2014/05/28 21:14:56
I don't think it does but it seems like a good ide
| |
| 120 #endif | 122 #endif |
| 121 } | 123 } |
| 122 | 124 |
| 123 gfx::Size GLImageShm::GetSize() { return size_; } | 125 gfx::Size GLImageShm::GetSize() { return size_; } |
| 124 | 126 |
| 125 bool GLImageShm::BindTexImage(unsigned target) { | 127 bool GLImageShm::BindTexImage(unsigned target) { |
| 126 TRACE_EVENT0("gpu", "GLImageShm::BindTexImage"); | 128 TRACE_EVENT0("gpu", "GLImageShm::BindTexImage"); |
| 127 DCHECK(shared_memory_); | 129 DCHECK(shared_memory_); |
| 128 DCHECK(ValidFormat(internalformat_)); | 130 DCHECK(ValidFormat(internalformat_)); |
| 129 | 131 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 0, // border | 204 0, // border |
| 203 DataFormat(internalformat_), | 205 DataFormat(internalformat_), |
| 204 DataType(internalformat_), | 206 DataType(internalformat_), |
| 205 shared_memory_->memory()); | 207 shared_memory_->memory()); |
| 206 | 208 |
| 207 shared_memory_->Unmap(); | 209 shared_memory_->Unmap(); |
| 208 return true; | 210 return true; |
| 209 } | 211 } |
| 210 | 212 |
| 211 } // namespace gfx | 213 } // namespace gfx |
| OLD | NEW |