| OLD | NEW |
| 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 // This include must be here so that the includes provided transitively | 5 // This include must be here so that the includes provided transitively |
| 6 // by gl_surface_egl.h don't make it impossible to compile this code. | 6 // by gl_surface_egl.h don't make it impossible to compile this code. |
| 7 #include "third_party/mesa/src/include/GL/osmesa.h" | 7 #include "third_party/mesa/src/include/GL/osmesa.h" |
| 8 | 8 |
| 9 #include "ui/gl/gl_surface_egl.h" | 9 #include "ui/gl/gl_surface_egl.h" |
| 10 | 10 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 356 |
| 357 static const EGLint egl_window_attributes_sub_buffer[] = { | 357 static const EGLint egl_window_attributes_sub_buffer[] = { |
| 358 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, | 358 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, |
| 359 EGL_NONE | 359 EGL_NONE |
| 360 }; | 360 }; |
| 361 | 361 |
| 362 // Create a surface for the native window. | 362 // Create a surface for the native window. |
| 363 surface_ = eglCreateWindowSurface( | 363 surface_ = eglCreateWindowSurface( |
| 364 GetDisplay(), | 364 GetDisplay(), |
| 365 GetConfig(), | 365 GetConfig(), |
| 366 window_, | 366 reinterpret_cast<EGLNativeWindowType>(window_), |
| 367 gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer ? | 367 gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer ? |
| 368 egl_window_attributes_sub_buffer : | 368 egl_window_attributes_sub_buffer : |
| 369 NULL); | 369 NULL); |
| 370 | 370 |
| 371 if (!surface_) { | 371 if (!surface_) { |
| 372 LOG(ERROR) << "eglCreateWindowSurface failed with error " | 372 LOG(ERROR) << "eglCreateWindowSurface failed with error " |
| 373 << GetLastEGLErrorString(); | 373 << GetLastEGLErrorString(); |
| 374 Destroy(); | 374 Destroy(); |
| 375 return false; | 375 return false; |
| 376 } | 376 } |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless(window)); | 804 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless(window)); |
| 805 if (!surface->Initialize()) | 805 if (!surface->Initialize()) |
| 806 return NULL; | 806 return NULL; |
| 807 return surface; | 807 return surface; |
| 808 } | 808 } |
| 809 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); | 809 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
| 810 if (window) { | 810 if (window) { |
| 811 scoped_refptr<NativeViewGLSurfaceEGL> surface; | 811 scoped_refptr<NativeViewGLSurfaceEGL> surface; |
| 812 scoped_ptr<VSyncProvider> sync_provider; | 812 scoped_ptr<VSyncProvider> sync_provider; |
| 813 #if defined(USE_OZONE) | 813 #if defined(USE_OZONE) |
| 814 COMPILE_ASSERT(sizeof(EGLNativeWindowType) >= |
| 815 sizeof(gfx::AcceleratedWidget), |
| 816 EGLNativeWindowType_wide_enough); |
| 814 window = gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( | 817 window = gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( |
| 815 window); | 818 window); |
| 816 sync_provider = | 819 sync_provider = |
| 817 gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider(window); | 820 gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider(window); |
| 818 #endif | 821 #endif |
| 819 surface = new NativeViewGLSurfaceEGL(window); | 822 surface = new NativeViewGLSurfaceEGL(window); |
| 820 if(surface->Initialize(sync_provider.Pass())) | 823 if(surface->Initialize(sync_provider.Pass())) |
| 821 return surface; | 824 return surface; |
| 822 } else { | 825 } else { |
| 823 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); | 826 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); |
| 824 if (surface->Initialize()) | 827 if (surface->Initialize()) |
| 825 return surface; | 828 return surface; |
| 826 } | 829 } |
| 827 return NULL; | 830 return NULL; |
| 828 } | 831 } |
| 829 | 832 |
| 830 // static | 833 // static |
| 831 scoped_refptr<GLSurface> | 834 scoped_refptr<GLSurface> |
| 832 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { | 835 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { |
| 833 switch (GetGLImplementation()) { | 836 switch (GetGLImplementation()) { |
| 834 case kGLImplementationOSMesaGL: { | 837 case kGLImplementationOSMesaGL: { |
| 835 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size)); | 838 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size)); |
| 836 if (!surface->Initialize()) | 839 if (!surface->Initialize()) |
| 837 return NULL; | 840 return NULL; |
| 838 | 841 |
| 839 return surface; | 842 return surface; |
| 840 } | 843 } |
| 841 case kGLImplementationEGLGLES2: { | 844 case kGLImplementationEGLGLES2: { |
| 842 scoped_refptr<GLSurface> surface; | 845 scoped_refptr<GLSurface> surface; |
| 843 if (g_egl_surfaceless_context_supported && | 846 if (g_egl_surfaceless_context_supported) { |
| 844 (size.width() == 0 && size.height() == 0)) { | |
| 845 surface = new SurfacelessEGL(size); | 847 surface = new SurfacelessEGL(size); |
| 846 } else | 848 } else |
| 847 surface = new PbufferGLSurfaceEGL(size); | 849 surface = new PbufferGLSurfaceEGL(size); |
| 848 | 850 |
| 849 if (!surface->Initialize()) | 851 if (!surface->Initialize()) |
| 850 return NULL; | 852 return NULL; |
| 851 return surface; | 853 return surface; |
| 852 } | 854 } |
| 853 default: | 855 default: |
| 854 NOTREACHED(); | 856 NOTREACHED(); |
| 855 return NULL; | 857 return NULL; |
| 856 } | 858 } |
| 857 } | 859 } |
| 858 | 860 |
| 859 #endif | 861 #endif |
| 860 | 862 |
| 861 } // namespace gfx | 863 } // namespace gfx |
| OLD | NEW |