OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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.h" | 5 #include "ui/gl/gl_surface.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "third_party/khronos/EGL/egl.h" | 9 #include "third_party/khronos/EGL/egl.h" |
10 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 LOG(ERROR) | 29 LOG(ERROR) |
30 << "Unknown GL implementation returned from GetGLImplementation: " | 30 << "Unknown GL implementation returned from GetGLImplementation: " |
31 << implementation; | 31 << implementation; |
32 return false; | 32 return false; |
33 } | 33 } |
34 return true; | 34 return true; |
35 } | 35 } |
36 | 36 |
37 // static | 37 // static |
38 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 38 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
39 gfx::AcceleratedWidget window) { | 39 gfx::AcceleratedWidget window, |
| 40 SurfaceConfiguration requested_configuration) { |
40 CHECK_NE(kGLImplementationNone, GetGLImplementation()); | 41 CHECK_NE(kGLImplementationNone, GetGLImplementation()); |
41 if (GetGLImplementation() == kGLImplementationOSMesaGL) { | 42 if (GetGLImplementation() == kGLImplementationOSMesaGL) { |
42 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless()); | 43 scoped_refptr<GLSurface> surface( |
| 44 new GLSurfaceOSMesaHeadless(SurfaceConfiguration())); |
43 if (!surface->Initialize()) | 45 if (!surface->Initialize()) |
44 return NULL; | 46 return NULL; |
45 return surface; | 47 return surface; |
46 } | 48 } |
47 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); | 49 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
48 if (window != kNullAcceleratedWidget) { | 50 if (window != kNullAcceleratedWidget) { |
49 scoped_refptr<GLSurface> surface = new NativeViewGLSurfaceEGL(window); | 51 scoped_refptr<GLSurface> surface = |
| 52 new NativeViewGLSurfaceEGL(window, requested_configuration); |
50 if (surface->Initialize()) | 53 if (surface->Initialize()) |
51 return surface; | 54 return surface; |
52 } else { | 55 } else { |
53 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); | 56 scoped_refptr<GLSurface> surface = |
| 57 new GLSurfaceStub(requested_configuration); |
54 if (surface->Initialize()) | 58 if (surface->Initialize()) |
55 return surface; | 59 return surface; |
56 } | 60 } |
57 return NULL; | 61 return NULL; |
58 } | 62 } |
59 | 63 |
60 // static | 64 // static |
61 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( | 65 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( |
62 const gfx::Size& size) { | 66 const gfx::Size& size, |
| 67 gfx::SurfaceConfiguration requested_configuration) { |
63 CHECK_NE(kGLImplementationNone, GetGLImplementation()); | 68 CHECK_NE(kGLImplementationNone, GetGLImplementation()); |
64 switch (GetGLImplementation()) { | 69 switch (GetGLImplementation()) { |
65 case kGLImplementationOSMesaGL: { | 70 case kGLImplementationOSMesaGL: { |
66 scoped_refptr<GLSurface> surface( | 71 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa( |
67 new GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, size)); | 72 OSMesaSurfaceFormatBGRA, size, requested_configuration)); |
68 if (!surface->Initialize()) | 73 if (!surface->Initialize()) |
69 return NULL; | 74 return NULL; |
70 | 75 |
71 return surface; | 76 return surface; |
72 } | 77 } |
73 case kGLImplementationEGLGLES2: { | 78 case kGLImplementationEGLGLES2: { |
74 scoped_refptr<GLSurface> surface; | 79 scoped_refptr<GLSurface> surface; |
75 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && | 80 if (GLSurfaceEGL::IsEGLSurfacelessContextSupported() && |
76 (size.width() == 0 && size.height() == 0)) { | 81 (size.width() == 0 && size.height() == 0)) { |
77 surface = new SurfacelessEGL(size); | 82 surface = new SurfacelessEGL(size, requested_configuration); |
78 } else { | 83 } else { |
79 surface = new PbufferGLSurfaceEGL(size); | 84 surface = new PbufferGLSurfaceEGL(size, requested_configuration); |
80 } | 85 } |
81 | 86 |
82 if (!surface->Initialize()) | 87 if (!surface->Initialize()) |
83 return NULL; | 88 return NULL; |
84 return surface; | 89 return surface; |
85 } | 90 } |
86 default: | 91 default: |
87 NOTREACHED(); | 92 NOTREACHED(); |
88 return NULL; | 93 return NULL; |
89 } | 94 } |
90 } | 95 } |
91 | 96 |
92 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 97 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
93 return EGL_DEFAULT_DISPLAY; | 98 return EGL_DEFAULT_DISPLAY; |
94 } | 99 } |
95 | 100 |
96 } // namespace gfx | 101 } // namespace gfx |
OLD | NEW |