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

Side by Side Diff: content/common/gpu/media/gles2_texture_to_egl_image_translator.cc

Issue 7200033: Fix crashes when loading gles2.cc on browser startup, and during playback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/common/gpu/media/gles2_texture_to_egl_image_translator.h" 5 #include "content/common/gpu/media/gles2_texture_to_egl_image_translator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 // Get EGL extension functions. 9 // Get EGL extension functions.
10 static PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr = 10 static PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr =
11 reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>( 11 reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(
12 eglGetProcAddress("eglCreateImageKHR")); 12 eglGetProcAddress("eglCreateImageKHR"));
13 static PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr = 13 static PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr =
14 reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>( 14 reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(
15 eglGetProcAddress("eglDestroyImageKHR")); 15 eglGetProcAddress("eglDestroyImageKHR"));
16 16
17 static bool AreEGLExtensionsInitialized() { 17 static bool AreEGLExtensionsInitialized() {
18 return (egl_create_image_khr && egl_destroy_image_khr); 18 return (egl_create_image_khr && egl_destroy_image_khr);
19 } 19 }
20 20
21 Gles2TextureToEglImageTranslator::Gles2TextureToEglImageTranslator() { 21 Gles2TextureToEglImageTranslator::Gles2TextureToEglImageTranslator() {
22 if (!AreEGLExtensionsInitialized()) { 22 if (!AreEGLExtensionsInitialized()) {
23 LOG(DFATAL) << "Failed to get EGL extensions"; 23 LOG(DFATAL) << "Failed to get EGL extensions";
24 return; 24 return;
25 } 25 }
26 CHECK_EQ(eglGetError(), EGL_SUCCESS);
26 } 27 }
27 28
28 29
29 Gles2TextureToEglImageTranslator::~Gles2TextureToEglImageTranslator() { 30 Gles2TextureToEglImageTranslator::~Gles2TextureToEglImageTranslator() {
30 } 31 }
31 32
32 EGLImageKHR Gles2TextureToEglImageTranslator::TranslateToEglImage( 33 EGLImageKHR Gles2TextureToEglImageTranslator::TranslateToEglImage(
33 EGLDisplay egl_display, EGLContext egl_context, uint32 texture) { 34 EGLDisplay egl_display, EGLContext egl_context, uint32 texture) {
34 EGLint attrib = EGL_NONE; 35 EGLint attrib = EGL_NONE;
35 if (!egl_create_image_khr) 36 if (!egl_create_image_khr)
36 return EGL_NO_IMAGE_KHR; 37 return EGL_NO_IMAGE_KHR;
37 // Create an EGLImage 38 // Create an EGLImage
38 EGLImageKHR hEglImage = egl_create_image_khr( 39 EGLImageKHR hEglImage = egl_create_image_khr(
39 egl_display, 40 egl_display,
40 egl_context, 41 egl_context,
41 EGL_GL_TEXTURE_2D_KHR, 42 EGL_GL_TEXTURE_2D_KHR,
42 reinterpret_cast<EGLClientBuffer>(texture), 43 reinterpret_cast<EGLClientBuffer>(texture),
43 &attrib); 44 &attrib);
44 CHECK(hEglImage); 45 CHECK(hEglImage) << eglGetError();
45 return hEglImage; 46 return hEglImage;
46 } 47 }
47 48
48 uint32 Gles2TextureToEglImageTranslator::TranslateToTexture( 49 uint32 Gles2TextureToEglImageTranslator::TranslateToTexture(
49 EGLImageKHR egl_image) { 50 EGLImageKHR egl_image) {
50 // TODO(vhiremath@nvidia.com) 51 // TODO(vhiremath@nvidia.com)
51 // Fill in the appropriate implementation. 52 // Fill in the appropriate implementation.
52 GLuint texture = 0; 53 GLuint texture = 0;
53 NOTIMPLEMENTED(); 54 NOTIMPLEMENTED();
54 return texture; 55 return texture;
55 } 56 }
56 57
57 void Gles2TextureToEglImageTranslator::DestroyEglImage( 58 void Gles2TextureToEglImageTranslator::DestroyEglImage(
58 EGLDisplay egl_display, EGLImageKHR egl_image) { 59 EGLDisplay egl_display, EGLImageKHR egl_image) {
59 // Clients of this class will call this method for each EGLImage handle. 60 // Clients of this class will call this method for each EGLImage handle.
60 // Actual destroying of the handles is done here. 61 // Actual destroying of the handles is done here.
61 if (!egl_destroy_image_khr) { 62 if (!egl_destroy_image_khr) {
62 LOG(ERROR) << "egl_destroy_image_khr failed"; 63 LOG(ERROR) << "egl_destroy_image_khr failed";
63 return; 64 return;
64 } 65 }
65 egl_destroy_image_khr(egl_display, egl_image); 66 egl_destroy_image_khr(egl_display, egl_image);
66 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698