| 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" |
| 11 #include "ui/gl/gl_implementation.h" | 11 #include "ui/gl/gl_implementation.h" |
| 12 #include "ui/gl/gl_surface_egl.h" | 12 #include "ui/gl/gl_surface_egl.h" |
| 13 #include "ui/gl/gl_surface_osmesa.h" | 13 #include "ui/gl/gl_surface_osmesa.h" |
| 14 #include "ui/gl/gl_surface_stub.h" | 14 #include "ui/gl/gl_surface_stub.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gl { |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 bool GLSurface::InitializeOneOffInternal() { | 19 bool GLSurface::InitializeOneOffInternal() { |
| 20 switch (GetGLImplementation()) { | 20 switch (GetGLImplementation()) { |
| 21 case kGLImplementationEGLGLES2: | 21 case kGLImplementationEGLGLES2: |
| 22 if (!GLSurfaceEGL::InitializeOneOff()) { | 22 if (!GLSurfaceEGL::InitializeOneOff()) { |
| 23 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 23 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
| 24 return false; | 24 return false; |
| 25 } | 25 } |
| 26 default: | 26 default: |
| 27 break; | 27 break; |
| 28 } | 28 } |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 33 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| 34 gfx::AcceleratedWidget window) { | 34 gfx::AcceleratedWidget window) { |
| 35 CHECK_NE(kGLImplementationNone, GetGLImplementation()); | 35 CHECK_NE(kGLImplementationNone, GetGLImplementation()); |
| 36 if (GetGLImplementation() == kGLImplementationOSMesaGL) { | 36 if (GetGLImplementation() == kGLImplementationOSMesaGL) { |
| 37 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless()); | 37 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless()); |
| 38 if (!surface->Initialize()) | 38 if (!surface->Initialize()) |
| 39 return NULL; | 39 return NULL; |
| 40 return surface; | 40 return surface; |
| 41 } | 41 } |
| 42 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); | 42 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
| 43 if (window != kNullAcceleratedWidget) { | 43 if (window != gfx::kNullAcceleratedWidget) { |
| 44 scoped_refptr<GLSurface> surface = new NativeViewGLSurfaceEGL(window); | 44 scoped_refptr<GLSurface> surface = new NativeViewGLSurfaceEGL(window); |
| 45 if (surface->Initialize()) | 45 if (surface->Initialize()) |
| 46 return surface; | 46 return surface; |
| 47 } else { | 47 } else { |
| 48 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); | 48 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); |
| 49 if (surface->Initialize()) | 49 if (surface->Initialize()) |
| 50 return surface; | 50 return surface; |
| 51 } | 51 } |
| 52 return NULL; | 52 return NULL; |
| 53 } | 53 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 83 default: | 83 default: |
| 84 NOTREACHED(); | 84 NOTREACHED(); |
| 85 return NULL; | 85 return NULL; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 89 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
| 90 return EGL_DEFAULT_DISPLAY; | 90 return EGL_DEFAULT_DISPLAY; |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace gfx | 93 } // namespace gl |
| OLD | NEW |