| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_egl.h" | 5 #include "ui/gl/gl_image_egl.h" |
| 6 | 6 |
| 7 #include "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
| 8 #include "ui/gl/gl_surface_egl.h" | 8 #include "ui/gl/gl_surface_egl.h" |
| 9 | 9 |
| 10 namespace gfx { | 10 namespace gfx { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // Defer ImageTargetTexture2D if not currently in use. | 69 // Defer ImageTargetTexture2D if not currently in use. |
| 70 if (!in_use_) | 70 if (!in_use_) |
| 71 return true; | 71 return true; |
| 72 | 72 |
| 73 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); | 73 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); |
| 74 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 74 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void GLImageEGL::ReleaseTexImage() { | 78 void GLImageEGL::ReleaseTexImage() { |
| 79 // Nothing to do here as image is released after each use. | 79 // Nothing to do here as image is released after each use or there is no need |
| 80 // to release tex image. |
| 80 } | 81 } |
| 81 | 82 |
| 82 void GLImageEGL::WillUseTexImage() { | 83 void GLImageEGL::WillUseTexImage() { |
| 83 DCHECK(egl_image_); | 84 DCHECK(egl_image_); |
| 84 DCHECK(!in_use_); | 85 DCHECK(!in_use_); |
| 85 in_use_ = true; | 86 in_use_ = true; |
| 86 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); | 87 glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image_); |
| 87 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 88 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void GLImageEGL::DidUseTexImage() { | 91 void GLImageEGL::DidUseTexImage(bool release_tex_image) { |
| 91 DCHECK(in_use_); | 92 DCHECK(in_use_); |
| 92 in_use_ = false; | 93 in_use_ = false; |
| 94 |
| 95 if (!release_tex_image) |
| 96 return; |
| 97 |
| 93 char zero[4] = { 0, }; | 98 char zero[4] = { 0, }; |
| 94 glTexImage2D(GL_TEXTURE_2D, | 99 glTexImage2D(GL_TEXTURE_2D, |
| 95 0, | 100 0, |
| 96 GL_RGBA, | 101 GL_RGBA, |
| 97 1, | 102 1, |
| 98 1, | 103 1, |
| 99 0, | 104 0, |
| 100 GL_RGBA, | 105 GL_RGBA, |
| 101 GL_UNSIGNED_BYTE, | 106 GL_UNSIGNED_BYTE, |
| 102 &zero); | 107 &zero); |
| 103 } | 108 } |
| 104 | 109 |
| 105 } // namespace gfx | 110 } // namespace gfx |
| OLD | NEW |