| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/common/gpu/gles2_texture_to_egl_image_translator.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 // Get EGL extension functions. | |
| 10 static PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr = | |
| 11 reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>( | |
| 12 eglGetProcAddress("eglCreateImageKHR")); | |
| 13 static PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr = | |
| 14 reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>( | |
| 15 eglGetProcAddress("eglDestroyImageKHR")); | |
| 16 | |
| 17 static bool AreEGLExtensionsInitialized() { | |
| 18 return (egl_create_image_khr && egl_destroy_image_khr); | |
| 19 } | |
| 20 | |
| 21 Gles2TextureToEglImageTranslator::Gles2TextureToEglImageTranslator( | |
| 22 Display* display, | |
| 23 int32 gles2_context_id) | |
| 24 : size_(320, 240), | |
| 25 egl_display_((EGLDisplay)0x1/*display*/), | |
| 26 egl_context_((EGLContext)0x368b8001/*gles2_context_id*/) { | |
| 27 // TODO(vhiremath@nvidia.com) | |
| 28 // Replace the above hard coded values with appropriate variables. | |
| 29 // size_/egl_display_/egl_context_. | |
| 30 // These should be initiated from the App. | |
| 31 if (!AreEGLExtensionsInitialized()) { | |
| 32 LOG(DFATAL) << "Failed to get EGL extensions"; | |
| 33 return; | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 | |
| 38 Gles2TextureToEglImageTranslator::~Gles2TextureToEglImageTranslator() { | |
| 39 } | |
| 40 | |
| 41 EGLImageKHR Gles2TextureToEglImageTranslator::TranslateToEglImage( | |
| 42 uint32 texture) { | |
| 43 EGLint attrib = EGL_NONE; | |
| 44 if (!egl_create_image_khr) | |
| 45 return EGL_NO_IMAGE_KHR; | |
| 46 // Create an EGLImage | |
| 47 EGLImageKHR hEglImage = egl_create_image_khr( | |
| 48 egl_display_, | |
| 49 egl_context_, | |
| 50 EGL_GL_TEXTURE_2D_KHR, | |
| 51 reinterpret_cast<EGLClientBuffer>(texture), | |
| 52 &attrib); | |
| 53 return hEglImage; | |
| 54 } | |
| 55 | |
| 56 uint32 Gles2TextureToEglImageTranslator::TranslateToTexture( | |
| 57 EGLImageKHR egl_image) { | |
| 58 // TODO(vhiremath@nvidia.com) | |
| 59 // Fill in the appropriate implementation. | |
| 60 GLuint texture = 0; | |
| 61 NOTIMPLEMENTED(); | |
| 62 return texture; | |
| 63 } | |
| 64 | |
| 65 void Gles2TextureToEglImageTranslator::DestroyEglImage(EGLImageKHR egl_image) { | |
| 66 // Clients of this class will call this method for each EGLImage handle. | |
| 67 // Actual destroying of the handles is done here. | |
| 68 if (!egl_destroy_image_khr) { | |
| 69 LOG(ERROR) << "egl_destroy_image_khr failed"; | |
| 70 return; | |
| 71 } | |
| 72 egl_destroy_image_khr(egl_display_, egl_image); | |
| 73 } | |
| OLD | NEW |