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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 static const EGLint egl_window_attributes_sub_buffer[] = { | 270 static const EGLint egl_window_attributes_sub_buffer[] = { |
271 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, | 271 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE, |
272 EGL_NONE | 272 EGL_NONE |
273 }; | 273 }; |
274 | 274 |
275 // Create a surface for the native window. | 275 // Create a surface for the native window. |
276 surface_ = eglCreateWindowSurface( | 276 surface_ = eglCreateWindowSurface( |
277 GetDisplay(), | 277 GetDisplay(), |
278 GetConfig(), | 278 GetConfig(), |
279 window_, | 279 reinterpret_cast<EGLNativeWindowType>(window_), |
280 gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer ? | 280 gfx::g_driver_egl.ext.b_EGL_NV_post_sub_buffer ? |
281 egl_window_attributes_sub_buffer : | 281 egl_window_attributes_sub_buffer : |
282 NULL); | 282 NULL); |
283 | 283 |
284 if (!surface_) { | 284 if (!surface_) { |
285 LOG(ERROR) << "eglCreateWindowSurface failed with error " | 285 LOG(ERROR) << "eglCreateWindowSurface failed with error " |
286 << GetLastEGLErrorString(); | 286 << GetLastEGLErrorString(); |
287 Destroy(); | 287 Destroy(); |
288 return false; | 288 return false; |
289 } | 289 } |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless(window)); | 713 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless(window)); |
714 if (!surface->Initialize()) | 714 if (!surface->Initialize()) |
715 return NULL; | 715 return NULL; |
716 return surface; | 716 return surface; |
717 } | 717 } |
718 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); | 718 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
719 if (window) { | 719 if (window) { |
720 scoped_refptr<NativeViewGLSurfaceEGL> surface; | 720 scoped_refptr<NativeViewGLSurfaceEGL> surface; |
721 VSyncProvider* sync_provider = NULL; | 721 VSyncProvider* sync_provider = NULL; |
722 #if defined(USE_OZONE) | 722 #if defined(USE_OZONE) |
| 723 COMPILE_ASSERT(sizeof(EGLNativeWindowType) >= |
| 724 sizeof(gfx::AcceleratedWidget), |
| 725 EGLNativeWindowType_wide_enough); |
723 window = gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( | 726 window = gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( |
724 window); | 727 window); |
725 sync_provider = | 728 sync_provider = |
726 gfx::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window); | 729 gfx::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window); |
727 #endif | 730 #endif |
728 surface = new NativeViewGLSurfaceEGL(window); | 731 surface = new NativeViewGLSurfaceEGL(window); |
729 if(surface->Initialize(sync_provider)) | 732 if(surface->Initialize(sync_provider)) |
730 return surface; | 733 return surface; |
731 } else { | 734 } else { |
732 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); | 735 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); |
733 if (surface->Initialize()) | 736 if (surface->Initialize()) |
734 return surface; | 737 return surface; |
735 } | 738 } |
736 return NULL; | 739 return NULL; |
737 } | 740 } |
738 | 741 |
739 // static | 742 // static |
740 scoped_refptr<GLSurface> | 743 scoped_refptr<GLSurface> |
741 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { | 744 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { |
742 switch (GetGLImplementation()) { | 745 switch (GetGLImplementation()) { |
743 case kGLImplementationOSMesaGL: { | 746 case kGLImplementationOSMesaGL: { |
744 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size)); | 747 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size)); |
745 if (!surface->Initialize()) | 748 if (!surface->Initialize()) |
746 return NULL; | 749 return NULL; |
747 | 750 |
748 return surface; | 751 return surface; |
749 } | 752 } |
750 case kGLImplementationEGLGLES2: { | 753 case kGLImplementationEGLGLES2: { |
751 scoped_refptr<GLSurface> surface; | 754 scoped_refptr<GLSurface> surface; |
752 if (g_egl_surfaceless_context_supported && | 755 if (g_egl_surfaceless_context_supported) { |
753 (size.width() == 0 && size.height() == 0)) { | |
754 surface = new SurfacelessEGL(size); | 756 surface = new SurfacelessEGL(size); |
755 } else | 757 } else |
756 surface = new PbufferGLSurfaceEGL(size); | 758 surface = new PbufferGLSurfaceEGL(size); |
757 | 759 |
758 if (!surface->Initialize()) | 760 if (!surface->Initialize()) |
759 return NULL; | 761 return NULL; |
760 return surface; | 762 return surface; |
761 } | 763 } |
762 default: | 764 default: |
763 NOTREACHED(); | 765 NOTREACHED(); |
764 return NULL; | 766 return NULL; |
765 } | 767 } |
766 } | 768 } |
767 | 769 |
768 #endif | 770 #endif |
769 | 771 |
770 } // namespace gfx | 772 } // namespace gfx |
OLD | NEW |