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

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

Issue 2461803002: Enable creation of offscreen contexts which own their backing surface. (Closed)
Patch Set: Drop unnecessary dependent patch Created 4 years, 1 month 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
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // On X this is only used for PBuffer surfaces. 234 // On X this is only used for PBuffer surfaces.
235 std::vector<EGLint> renderable_types; 235 std::vector<EGLint> renderable_types;
236 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 236 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
237 switches::kDisableES3GLContext)) { 237 switches::kDisableES3GLContext)) {
238 renderable_types.push_back(EGL_OPENGL_ES3_BIT); 238 renderable_types.push_back(EGL_OPENGL_ES3_BIT);
239 } 239 }
240 renderable_types.push_back(EGL_OPENGL_ES2_BIT); 240 renderable_types.push_back(EGL_OPENGL_ES2_BIT);
241 241
242 EGLint buffer_size = 32; 242 EGLint buffer_size = 32;
243 EGLint alpha_size = 8; 243 EGLint alpha_size = 8;
244 EGLint depth_size = EGL_DONT_CARE;
245
246 if (format == GLSurface::SURFACE_ARGB8888_DEPTH24) {
247 depth_size = 24;
248 format = GLSurface::SURFACE_ARGB8888;
249 } else if (format == GLSurface::SURFACE_RGB565_DEPTH24) {
250 depth_size = 24;
251 format = GLSurface::SURFACE_RGB565;
252 }
244 253
245 #if defined(USE_X11) && !defined(OS_CHROMEOS) 254 #if defined(USE_X11) && !defined(OS_CHROMEOS)
246 ui::XVisualManager::GetInstance()->ChooseVisualForWindow( 255 ui::XVisualManager::GetInstance()->ChooseVisualForWindow(
247 true, nullptr, &buffer_size, nullptr, nullptr); 256 true, nullptr, &buffer_size, nullptr, nullptr);
248 alpha_size = buffer_size == 32 ? 8 : 0; 257 alpha_size = buffer_size == 32 ? 8 : 0;
249 #endif 258 #endif
250 259
251 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS) 260 EGLint surface_type = (format == GLSurface::SURFACE_SURFACELESS)
252 ? EGL_DONT_CARE 261 ? EGL_DONT_CARE
253 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT; 262 : EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
254 263
255 for (auto renderable_type : renderable_types) { 264 for (auto renderable_type : renderable_types) {
256 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE, 265 EGLint config_attribs_8888[] = {EGL_BUFFER_SIZE,
257 buffer_size, 266 buffer_size,
258 EGL_ALPHA_SIZE, 267 EGL_ALPHA_SIZE,
259 alpha_size, 268 alpha_size,
260 EGL_BLUE_SIZE, 269 EGL_BLUE_SIZE,
261 8, 270 8,
262 EGL_GREEN_SIZE, 271 EGL_GREEN_SIZE,
263 8, 272 8,
264 EGL_RED_SIZE, 273 EGL_RED_SIZE,
265 8, 274 8,
275 EGL_DEPTH_SIZE,
276 depth_size,
266 EGL_RENDERABLE_TYPE, 277 EGL_RENDERABLE_TYPE,
267 renderable_type, 278 renderable_type,
268 EGL_SURFACE_TYPE, 279 EGL_SURFACE_TYPE,
269 surface_type, 280 surface_type,
270 EGL_NONE}; 281 EGL_NONE};
271 282
272 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE, 283 EGLint config_attribs_565[] = {EGL_BUFFER_SIZE,
273 16, 284 16,
274 EGL_BLUE_SIZE, 285 EGL_BLUE_SIZE,
275 5, 286 5,
276 EGL_GREEN_SIZE, 287 EGL_GREEN_SIZE,
277 6, 288 6,
278 EGL_RED_SIZE, 289 EGL_RED_SIZE,
279 5, 290 5,
291 EGL_DEPTH_SIZE,
292 depth_size,
280 EGL_RENDERABLE_TYPE, 293 EGL_RENDERABLE_TYPE,
281 renderable_type, 294 renderable_type,
282 EGL_SURFACE_TYPE, 295 EGL_SURFACE_TYPE,
283 surface_type, 296 surface_type,
284 EGL_NONE}; 297 EGL_NONE};
285 298
286 EGLint* choose_attributes = config_attribs_8888; 299 EGLint* choose_attributes = config_attribs_8888;
287 if (format == GLSurface::SURFACE_RGB565) { 300 if (format == GLSurface::SURFACE_RGB565) {
288 choose_attributes = config_attribs_565; 301 choose_attributes = config_attribs_565;
289 } 302 }
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 } 1229 }
1217 1230
1218 void* SurfacelessEGL::GetShareHandle() { 1231 void* SurfacelessEGL::GetShareHandle() {
1219 return NULL; 1232 return NULL;
1220 } 1233 }
1221 1234
1222 SurfacelessEGL::~SurfacelessEGL() { 1235 SurfacelessEGL::~SurfacelessEGL() {
1223 } 1236 }
1224 1237
1225 } // namespace gl 1238 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698