Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: content/common/gpu/media/gles2_texture_to_egl_image_translator.cc

Issue 9346012: Video decode in hardware on ARM platform. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/gles2_texture_to_egl_image_translator.cc
===================================================================
--- content/common/gpu/media/gles2_texture_to_egl_image_translator.cc (revision 120554)
+++ content/common/gpu/media/gles2_texture_to_egl_image_translator.cc (working copy)
@@ -13,12 +13,17 @@
static PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr =
reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(
eglGetProcAddress("eglDestroyImageKHR"));
+static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glegl_image_targettexture_2does =
+ reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(
+ eglGetProcAddress("glEGLImageTargetTexture2DOES"));
static bool AreEGLExtensionsInitialized() {
return (egl_create_image_khr && egl_destroy_image_khr);
}
-Gles2TextureToEglImageTranslator::Gles2TextureToEglImageTranslator() {
+Gles2TextureToEglImageTranslator::Gles2TextureToEglImageTranslator(
+ Display* x_display)
+ : x_display_(x_display) {
if (!AreEGLExtensionsInitialized()) {
LOG(DFATAL) << "Failed to get EGL extensions";
return;
@@ -31,19 +36,47 @@
}
EGLImageKHR Gles2TextureToEglImageTranslator::TranslateToEglImage(
- EGLDisplay egl_display, EGLContext egl_context, uint32 texture) {
- EGLint attrib = EGL_NONE;
+ EGLDisplay egl_display, EGLContext egl_context,
+ uint32 texture,
+ int width, int height) {
if (!egl_create_image_khr)
return EGL_NO_IMAGE_KHR;
- // Create an EGLImage
- EGLImageKHR hEglImage = egl_create_image_khr(
- egl_display,
- egl_context,
- EGL_GL_TEXTURE_2D_KHR,
- reinterpret_cast<EGLClientBuffer>(texture),
- &attrib);
- CHECK(hEglImage) << "Failed to eglCreateImageKHR for " << texture
- << ", error: 0x" << std::hex << eglGetError();
+ EGLImageKHR hEglImage;
+ if (x_display_) {
Ami GONE FROM CHROMIUM 2012/02/18 00:00:25 This seems like a strange way to indicate which co
+ if (!glegl_image_targettexture_2does)
+ return EGL_NO_IMAGE_KHR;
+
+ EGLint image_attrs[] = { EGL_IMAGE_PRESERVED_KHR, 1 , EGL_NONE };
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, texture);
+
+ Pixmap pixmap = XCreatePixmap(x_display_, RootWindow(x_display_, 0),
+ width, height, 32);
+
+ hEglImage = egl_create_image_khr(egl_display,
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)pixmap,
+ image_attrs);
+ CHECK(hEglImage) << "Failed to eglCreateImageKHR for " << texture
+ << ", error: 0x" << std::hex << eglGetError();
+
+ glegl_image_targettexture_2does(GL_TEXTURE_2D, hEglImage);
+ eglimage_pixmap_.insert(std::make_pair(hEglImage, pixmap));
Ami GONE FROM CHROMIUM 2012/02/18 00:00:25 If you expect no collisions, the standard idiom is
+
+ } else {
+ EGLint attrib = EGL_NONE;
+ // Create an EGLImage
+ hEglImage = egl_create_image_khr(egl_display,
+ egl_context,
+ EGL_GL_TEXTURE_2D_KHR,
+ reinterpret_cast<EGLClientBuffer>(texture),
+ &attrib);
+ CHECK(hEglImage) << "Failed to eglCreateImageKHR for " << texture
Ami GONE FROM CHROMIUM 2012/02/18 00:00:25 This CHECK and the one at l.62 can be coallesced
+ << ", error: 0x" << std::hex << eglGetError();
+
+ }
return hEglImage;
}
@@ -65,4 +98,12 @@
return;
}
egl_destroy_image_khr(egl_display, egl_image);
+
+ if (x_display_) {
+ ImagePixmap::iterator it = eglimage_pixmap_.find(egl_image);
+ CHECK(it != eglimage_pixmap_.end());
+ Pixmap pixmap = it->second;
Ami GONE FROM CHROMIUM 2012/02/18 00:00:25 Also eglimage_pixmap_.erase(it); ?
+ if (pixmap)
Ami GONE FROM CHROMIUM 2012/02/18 00:00:25 When will this test be false?
+ XFreePixmap(x_display_, pixmap);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698