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

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

Issue 196403008: gl: Move platform-specific EGL code into separate files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gl/gl_surface.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h"
9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gfx/ozone/surface_factory_ozone.h"
11 #include "ui/gl/gl_implementation.h"
12 #include "ui/gl/gl_surface_egl.h"
13 #include "ui/gl/gl_surface_osmesa.h"
14 #include "ui/gl/gl_surface_stub.h"
15
16 namespace gfx {
17
18 namespace {
19
20 EGLNativeDisplayType GetEGLDisplay() {
rjkroege 2014/03/24 15:27:25 per other comment: you've already done what I sugg
spang 2014/03/24 18:17:08 Move to GetPlatformDefaultEGLNativeDisplay().
21 return SurfaceFactoryOzone::GetInstance()->GetNativeDisplay();
22 }
23 };
24
25 // static
26 bool GLSurface::InitializeOneOffInternal() {
27 switch (GetGLImplementation()) {
28 case kGLImplementationEGLGLES2:
29 if (!GLSurfaceEGL::InitializeOneOff(GetEGLDisplay())) {
30 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
31 return false;
32 }
33 default:
34 break;
35 }
36 return true;
37 }
38
39 // static
40 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
41 gfx::AcceleratedWidget window) {
42 if (GetGLImplementation() == kGLImplementationOSMesaGL) {
43 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless());
44 if (!surface->Initialize())
45 return NULL;
46 return surface;
47 }
48 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
49 if (window != kNullAcceleratedWidget) {
50 EGLNativeWindowType egl_window =
51 gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget(
52 window);
53 scoped_ptr<VSyncProvider> sync_provider =
54 gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider(
55 egl_window);
56 scoped_refptr<NativeViewGLSurfaceEGL> surface =
57 new NativeViewGLSurfaceEGL(egl_window);
58 if (surface->Initialize(sync_provider.Pass()))
59 return surface;
60 } else {
61 scoped_refptr<GLSurface> surface = new GLSurfaceStub();
62 if (surface->Initialize())
63 return surface;
64 }
65 return NULL;
66 }
67
68 // static
69 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
70 const gfx::Size& size) {
71 switch (GetGLImplementation()) {
72 case kGLImplementationOSMesaGL: {
73 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size));
74 if (!surface->Initialize())
75 return NULL;
76
77 return surface;
78 }
79 case kGLImplementationEGLGLES2: {
80 scoped_refptr<GLSurface> surface;
81 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() &&
82 (size.width() == 0 && size.height() == 0)) {
83 surface = new SurfacelessEGL(size);
84 } else
85 surface = new PbufferGLSurfaceEGL(size);
86
87 if (!surface->Initialize())
88 return NULL;
89 return surface;
90 }
91 default:
92 NOTREACHED();
93 return NULL;
94 }
95 }
96
97 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698