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

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

Issue 2456213002: WebVR: implement SetSurfaceHandleCHROMIUM extension for gvr_device.
Patch Set: Rebase, set dependency. Created 3 years, 11 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_context_egl.cc ('k') | ui/gl/init/gl_factory.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) 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 if (*num_configs == 0) { 236 if (*num_configs == 0) {
237 return false; 237 return false;
238 } 238 }
239 return true; 239 return true;
240 } 240 }
241 241
242 EGLConfig ChooseConfig(GLSurfaceFormat format) { 242 EGLConfig ChooseConfig(GLSurfaceFormat format) {
243 // Choose an EGL configuration. 243 // Choose an EGL configuration.
244 // On X this is only used for PBuffer surfaces. 244 // On X this is only used for PBuffer surfaces.
245
245 std::vector<EGLint> renderable_types; 246 std::vector<EGLint> renderable_types;
246 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 247 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
247 switches::kDisableES3GLContext)) { 248 switches::kDisableES3GLContext)) {
248 renderable_types.push_back(EGL_OPENGL_ES3_BIT); 249 renderable_types.push_back(EGL_OPENGL_ES3_BIT);
249 } 250 }
250 renderable_types.push_back(EGL_OPENGL_ES2_BIT); 251 renderable_types.push_back(EGL_OPENGL_ES2_BIT);
251 252
252 EGLint buffer_size = format.GetBufferSize(); 253 EGLint buffer_size = format.GetBufferSize();
253 EGLint alpha_size = 8; 254 EGLint alpha_size = 8;
254 bool want_rgb565 = buffer_size == 16; 255 bool want_rgb565 = buffer_size == 16;
256 EGLint depth_size = format.GetDepthBits();
257 EGLint stencil_size = format.GetStencilBits();
258 EGLint samples = format.GetSamples();
255 259
256 #if defined(USE_X11) && !defined(OS_CHROMEOS) 260 #if defined(USE_X11) && !defined(OS_CHROMEOS)
257 // If we're using ANGLE_NULL, we may not have a display, in which case we 261 // If we're using ANGLE_NULL, we may not have a display, in which case we
258 // can't use XVisualManager. 262 // can't use XVisualManager.
259 if (g_native_display) { 263 if (g_native_display) {
260 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( 264 ui::XVisualManager::GetInstance()->ChooseVisualForWindow(
261 true, nullptr, &buffer_size, nullptr, nullptr); 265 true, nullptr, &buffer_size, nullptr, nullptr);
262 alpha_size = buffer_size == 32 ? 8 : 0; 266 alpha_size = buffer_size == 32 ? 8 : 0;
263 } 267 }
264 #endif 268 #endif
265 269
266 EGLint surface_type = (format.IsSurfaceless() 270 EGLint surface_type = (format.IsSurfaceless()
267 ? EGL_DONT_CARE 271 ? EGL_DONT_CARE
268 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT); 272 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT);
269 273
270 for (auto renderable_type : renderable_types) { 274 for (auto renderable_type : renderable_types) {
271 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, 275 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE,
272 buffer_size, 276 buffer_size,
273 EGL_ALPHA_SIZE, 277 EGL_ALPHA_SIZE,
274 alpha_size, 278 alpha_size,
275 EGL_BLUE_SIZE, 279 EGL_BLUE_SIZE,
276 8, 280 8,
277 EGL_GREEN_SIZE, 281 EGL_GREEN_SIZE,
278 8, 282 8,
279 EGL_RED_SIZE, 283 EGL_RED_SIZE,
280 8, 284 8,
285 EGL_SAMPLES,
286 samples,
287 EGL_DEPTH_SIZE,
288 depth_size,
289 EGL_STENCIL_SIZE,
290 stencil_size,
281 EGL_RENDERABLE_TYPE, 291 EGL_RENDERABLE_TYPE,
282 renderable_type, 292 renderable_type,
283 EGL_SURFACE_TYPE, 293 EGL_SURFACE_TYPE,
284 surface_type, 294 surface_type,
285 EGL_NONE}; 295 EGL_NONE};
286 296
287 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE, 297 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE,
288 16, 298 16,
289 EGL_BLUE_SIZE, 299 EGL_BLUE_SIZE,
290 5, 300 5,
291 EGL_GREEN_SIZE, 301 EGL_GREEN_SIZE,
292 6, 302 6,
293 EGL_RED_SIZE, 303 EGL_RED_SIZE,
294 5, 304 5,
305 EGL_SAMPLES,
306 samples,
307 EGL_DEPTH_SIZE,
308 depth_size,
309 EGL_STENCIL_SIZE,
310 stencil_size,
295 EGL_RENDERABLE_TYPE, 311 EGL_RENDERABLE_TYPE,
296 renderable_type, 312 renderable_type,
297 EGL_SURFACE_TYPE, 313 EGL_SURFACE_TYPE,
298 surface_type, 314 surface_type,
299 EGL_NONE}; 315 EGL_NONE};
300 316
301 EGLint* choose_attributes = config_attribs_8888; 317 EGLint* choose_attributes = config_attribs_8888;
302 if (want_rgb565) { 318 if (want_rgb565) {
303 choose_attributes = config_attribs_565; 319 choose_attributes = config_attribs_565;
304 } 320 }
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 } 1257 }
1242 1258
1243 void* SurfacelessEGL::GetShareHandle() { 1259 void* SurfacelessEGL::GetShareHandle() {
1244 return NULL; 1260 return NULL;
1245 } 1261 }
1246 1262
1247 SurfacelessEGL::~SurfacelessEGL() { 1263 SurfacelessEGL::~SurfacelessEGL() {
1248 } 1264 }
1249 1265
1250 } // namespace gl 1266 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_context_egl.cc ('k') | ui/gl/init/gl_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698