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

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

Issue 10815041: Make NativeViewGLSurfaceEGL directly usable on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« no previous file with comments | « ui/gfx/native_widget_types.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_surface_egl.h" 5 #include "ui/gl/gl_surface_egl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, 165 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software,
166 gfx::AcceleratedWidget window) 166 gfx::AcceleratedWidget window)
167 : window_(window), 167 : window_(window),
168 surface_(NULL), 168 surface_(NULL),
169 supports_post_sub_buffer_(false), 169 supports_post_sub_buffer_(false),
170 config_(NULL) { 170 config_(NULL) {
171 software_ = software; 171 software_ = software;
172 } 172 }
173 173
174 bool NativeViewGLSurfaceEGL::Initialize() { 174 bool NativeViewGLSurfaceEGL::Initialize() {
175 #if defined(OS_ANDROID)
176 NOTREACHED();
177 return false;
178 #else
179 DCHECK(!surface_); 175 DCHECK(!surface_);
180 176
181 if (!GetDisplay()) { 177 if (!GetDisplay()) {
182 LOG(ERROR) << "Trying to create surface with invalid display."; 178 LOG(ERROR) << "Trying to create surface with invalid display.";
183 return false; 179 return false;
184 } 180 }
185 181
186 static const EGLint egl_window_attributes_sub_buffer[] = { 182 static const EGLint egl_window_attributes_sub_buffer[] = {
183 #if defined(EGL_NV_post_sub_buffer)
no sievers 2012/07/20 20:31:59 Is this good? This is not defined in the Android S
piman 2012/07/20 20:44:08 bleh... we have 3 sets of includes: the ones in th
no sievers 2012/07/20 21:11:06 Word. Especially, since this file is explicit abou
187 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, 184 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE,
185 #endif
188 EGL_NONE 186 EGL_NONE
189 }; 187 };
190 188
191 // Create a surface for the native window. 189 // Create a surface for the native window.
192 surface_ = eglCreateWindowSurface(GetDisplay(), 190 surface_ = eglCreateWindowSurface(GetDisplay(),
193 GetConfig(), 191 GetConfig(),
194 window_, 192 window_,
195 gfx::g_EGL_NV_post_sub_buffer ? 193 gfx::g_EGL_NV_post_sub_buffer ?
196 egl_window_attributes_sub_buffer : 194 egl_window_attributes_sub_buffer :
197 NULL); 195 NULL);
198 196
199 if (!surface_) { 197 if (!surface_) {
200 LOG(ERROR) << "eglCreateWindowSurface failed with error " 198 LOG(ERROR) << "eglCreateWindowSurface failed with error "
201 << GetLastEGLErrorString(); 199 << GetLastEGLErrorString();
202 Destroy(); 200 Destroy();
203 return false; 201 return false;
204 } 202 }
205 203
204 #if defined(EGL_NV_post_sub_buffer)
206 EGLint surfaceVal; 205 EGLint surfaceVal;
207 EGLBoolean retVal = eglQuerySurface(GetDisplay(), 206 EGLBoolean retVal = eglQuerySurface(GetDisplay(),
208 surface_, 207 surface_,
209 EGL_POST_SUB_BUFFER_SUPPORTED_NV, 208 EGL_POST_SUB_BUFFER_SUPPORTED_NV,
210 &surfaceVal); 209 &surfaceVal);
211 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; 210 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
211 #endif
212 212
213 return true; 213 return true;
214 #endif
215 } 214 }
216 215
217 void NativeViewGLSurfaceEGL::Destroy() { 216 void NativeViewGLSurfaceEGL::Destroy() {
218 if (surface_) { 217 if (surface_) {
219 if (!eglDestroySurface(GetDisplay(), surface_)) { 218 if (!eglDestroySurface(GetDisplay(), surface_)) {
220 LOG(ERROR) << "eglDestroySurface failed with error " 219 LOG(ERROR) << "eglDestroySurface failed with error "
221 << GetLastEGLErrorString(); 220 << GetLastEGLErrorString();
222 } 221 }
223 surface_ = NULL; 222 surface_ = NULL;
224 } 223 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 476
478 return handle; 477 return handle;
479 #endif 478 #endif
480 } 479 }
481 480
482 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { 481 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {
483 Destroy(); 482 Destroy();
484 } 483 }
485 484
486 } // namespace gfx 485 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/native_widget_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698