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

Side by Side Diff: ui/gl/gl_image_egl.cc

Issue 198703002: Add GL_TEXTURE_EXTERNAL_OES as supported texture target for CHROMIUM_map_image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nvidia work-around patch in gl_image_egl for android_webview Created 6 years, 9 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
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_shm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
11 11
12 GLImageEGL::GLImageEGL(gfx::Size size) 12 GLImageEGL::GLImageEGL(gfx::Size size)
13 : egl_image_(EGL_NO_IMAGE_KHR), 13 : egl_image_(EGL_NO_IMAGE_KHR),
14 size_(size), 14 size_(size),
15 release_after_use_(false), 15 release_after_use_(false),
16 in_use_(false), 16 in_use_(false),
17 target_(0) { 17 target_(0),
18 } 18 native_buffer_(0) {}
19 19
20 GLImageEGL::~GLImageEGL() { 20 GLImageEGL::~GLImageEGL() {
21 Destroy(); 21 Destroy();
22 } 22 }
23 23
24 bool GLImageEGL::Initialize(gfx::GpuMemoryBufferHandle buffer) { 24 bool GLImageEGL::Initialize(gfx::GpuMemoryBufferHandle buffer) {
25 DCHECK(buffer.native_buffer); 25 DCHECK(buffer.native_buffer);
26 native_buffer_ = buffer.native_buffer;
reveman 2014/03/19 18:17:30 are you sure buffer.native_buffer is a valid point
26 EGLint attrs[] = { 27 EGLint attrs[] = {
27 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, 28 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
28 EGL_NONE, 29 EGL_NONE,
29 }; 30 };
30 egl_image_ = eglCreateImageKHR( 31 egl_image_ = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
31 GLSurfaceEGL::GetHardwareDisplay(), 32 EGL_NO_CONTEXT,
32 EGL_NO_CONTEXT, 33 EGL_NATIVE_BUFFER_ANDROID,
33 EGL_NATIVE_BUFFER_ANDROID, 34 native_buffer_,
34 buffer.native_buffer, 35 attrs);
35 attrs);
36 36
37 if (egl_image_ == EGL_NO_IMAGE_KHR) { 37 if (egl_image_ == EGL_NO_IMAGE_KHR) {
38 EGLint error = eglGetError(); 38 EGLint error = eglGetError();
39 LOG(ERROR) << "Error creating EGLImage: " << error; 39 LOG(ERROR) << "Error creating EGLImage: " << error;
40 return false; 40 return false;
41 } 41 }
42 42
43 return true; 43 return true;
44 } 44 }
45 45
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 101 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
102 } 102 }
103 103
104 void GLImageEGL::DidUseTexImage() { 104 void GLImageEGL::DidUseTexImage() {
105 DCHECK(in_use_); 105 DCHECK(in_use_);
106 in_use_ = false; 106 in_use_ = false;
107 107
108 if (!release_after_use_) 108 if (!release_after_use_)
109 return; 109 return;
110 110
111 char zero[4] = { 0, }; 111 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, };
112 glTexImage2D(target_, 112 EGLImageKHR egl_image = eglCreateImageKHR(GLSurfaceEGL::GetHardwareDisplay(),
113 0, 113 EGL_NO_CONTEXT,
114 GL_RGBA, 114 EGL_NATIVE_BUFFER_ANDROID,
115 1, 115 native_buffer_,
116 1, 116 attrs);
117 0, 117 DCHECK_NE(EGL_NO_IMAGE_KHR, egl_image)
118 GL_RGBA, 118 << "Error creating EGLImage: " << eglGetError();
119 GL_UNSIGNED_BYTE, 119 glEGLImageTargetTexture2DOES(target_, egl_image);
reveman 2014/03/19 18:17:30 I don't understand why this would work. Binding th
120 &zero); 120 DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
121 EGLBoolean status =
122 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image);
boliu 2014/03/20 10:57:29 Currently this destroy fails.
123 if (status == EGL_FALSE) {
124 EGLint error = eglGetError();
125 LOG(ERROR) << "Error destroying EGLImage: " << error;
126 }
121 } 127 }
122 128
123 void GLImageEGL::WillModifyTexImage() { 129 void GLImageEGL::WillModifyTexImage() {
124 } 130 }
125 131
126 void GLImageEGL::DidModifyTexImage() { 132 void GLImageEGL::DidModifyTexImage() {
127 } 133 }
128 134
129 void GLImageEGL::SetReleaseAfterUse() { 135 void GLImageEGL::SetReleaseAfterUse() {
130 release_after_use_ = true; 136 release_after_use_ = true;
131 } 137 }
132 138
133 } // namespace gfx 139 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_egl.h ('k') | ui/gl/gl_image_shm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698