Chromium Code Reviews| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 bool GLSurfaceEGL::HasEGLExtension(const char* name) { | 323 bool GLSurfaceEGL::HasEGLExtension(const char* name) { |
| 324 return ExtensionsContain(GetEGLExtensions(), name); | 324 return ExtensionsContain(GetEGLExtensions(), name); |
| 325 } | 325 } |
| 326 | 326 |
| 327 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { | 327 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { |
| 328 return g_egl_create_context_robustness_supported; | 328 return g_egl_create_context_robustness_supported; |
| 329 } | 329 } |
| 330 | 330 |
| 331 GLSurfaceEGL::~GLSurfaceEGL() {} | 331 GLSurfaceEGL::~GLSurfaceEGL() {} |
| 332 | 332 |
| 333 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(gfx::AcceleratedWidget window) | 333 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(EGLNativeWindowType window) |
| 334 : window_(window), | 334 : window_(window), |
| 335 surface_(NULL), | 335 surface_(NULL), |
| 336 supports_post_sub_buffer_(false), | 336 supports_post_sub_buffer_(false), |
| 337 config_(NULL), | 337 config_(NULL), |
| 338 size_(1, 1) { | 338 size_(1, 1) { |
| 339 #if defined(OS_ANDROID) | 339 #if defined(OS_ANDROID) |
| 340 if (window) | 340 if (window) |
| 341 ANativeWindow_acquire(window); | 341 ANativeWindow_acquire(window); |
| 342 #endif | 342 #endif |
| 343 } | 343 } |
| 344 | 344 |
| 345 bool NativeViewGLSurfaceEGL::Initialize() { | 345 bool NativeViewGLSurfaceEGL::Initialize() { |
| 346 return Initialize(scoped_ptr<VSyncProvider>()); | 346 return Initialize(scoped_ptr<VSyncProvider>()); |
| 347 } | 347 } |
| 348 | 348 |
| 349 bool NativeViewGLSurfaceEGL::Initialize( | 349 bool NativeViewGLSurfaceEGL::Initialize( |
| 350 scoped_ptr<VSyncProvider> sync_provider) { | 350 scoped_ptr<VSyncProvider> sync_provider) { |
| 351 DCHECK(!surface_); | 351 DCHECK(!surface_); |
| 352 | 352 |
| 353 if (window_ == kNullAcceleratedWidget) { | |
|
rjkroege
2014/03/20 17:52:04
why did you take this out?
spang
2014/03/20 19:06:44
I don't believe there is a NULL value for EGLNativ
| |
| 354 LOG(ERROR) << "Trying to create surface without window."; | |
| 355 return false; | |
| 356 } | |
| 357 | |
| 358 if (!GetDisplay()) { | 353 if (!GetDisplay()) { |
| 359 LOG(ERROR) << "Trying to create surface with invalid display."; | 354 LOG(ERROR) << "Trying to create surface with invalid display."; |
| 360 return false; | 355 return false; |
| 361 } | 356 } |
| 362 | 357 |
| 363 std::vector<EGLint> egl_window_attributes; | 358 std::vector<EGLint> egl_window_attributes; |
| 364 | 359 |
| 365 if (g_egl_window_fixed_size_supported) { | 360 if (g_egl_window_fixed_size_supported) { |
| 366 egl_window_attributes.push_back(EGL_FIXED_SIZE_ANGLE); | 361 egl_window_attributes.push_back(EGL_FIXED_SIZE_ANGLE); |
| 367 egl_window_attributes.push_back(EGL_TRUE); | 362 egl_window_attributes.push_back(EGL_TRUE); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 SurfacelessEGL::~SurfacelessEGL() { | 761 SurfacelessEGL::~SurfacelessEGL() { |
| 767 } | 762 } |
| 768 | 763 |
| 769 #if defined(ANDROID) || defined(USE_OZONE) | 764 #if defined(ANDROID) || defined(USE_OZONE) |
| 770 | 765 |
| 771 // A thin subclass of |GLSurfaceOSMesa| that can be used in place | 766 // A thin subclass of |GLSurfaceOSMesa| that can be used in place |
| 772 // of a native hardware-provided surface when a native surface | 767 // of a native hardware-provided surface when a native surface |
| 773 // provider is not available. | 768 // provider is not available. |
| 774 class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { | 769 class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { |
| 775 public: | 770 public: |
| 776 explicit GLSurfaceOSMesaHeadless(gfx::AcceleratedWidget window); | 771 explicit GLSurfaceOSMesaHeadless(); |
|
rjkroege
2014/03/20 17:52:04
why not EGLNativeWindow?
spang
2014/03/20 19:06:44
We could, but why pass a value that is not used?
| |
| 777 | 772 |
| 778 virtual bool IsOffscreen() OVERRIDE; | 773 virtual bool IsOffscreen() OVERRIDE; |
| 779 virtual bool SwapBuffers() OVERRIDE; | 774 virtual bool SwapBuffers() OVERRIDE; |
| 780 | 775 |
| 781 protected: | 776 protected: |
| 782 virtual ~GLSurfaceOSMesaHeadless(); | 777 virtual ~GLSurfaceOSMesaHeadless(); |
| 783 | 778 |
| 784 private: | 779 private: |
| 785 | 780 |
| 786 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); | 781 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOSMesaHeadless); |
| 787 }; | 782 }; |
| 788 | 783 |
| 789 bool GLSurfaceOSMesaHeadless::IsOffscreen() { return false; } | 784 bool GLSurfaceOSMesaHeadless::IsOffscreen() { return false; } |
| 790 | 785 |
| 791 bool GLSurfaceOSMesaHeadless::SwapBuffers() { return true; } | 786 bool GLSurfaceOSMesaHeadless::SwapBuffers() { return true; } |
| 792 | 787 |
| 793 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless(gfx::AcceleratedWidget window) | 788 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless() |
| 794 : GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)) { | 789 : GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)) {} |
| 795 DCHECK(window); | |
| 796 } | |
| 797 | 790 |
| 798 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); } | 791 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); } |
| 799 | 792 |
| 800 // static | 793 // static |
| 801 bool GLSurface::InitializeOneOffInternal() { | 794 bool GLSurface::InitializeOneOffInternal() { |
| 802 switch (GetGLImplementation()) { | 795 switch (GetGLImplementation()) { |
| 803 case kGLImplementationEGLGLES2: | 796 case kGLImplementationEGLGLES2: |
| 804 if (!GLSurfaceEGL::InitializeOneOff()) { | 797 if (!GLSurfaceEGL::InitializeOneOff()) { |
| 805 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 798 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
| 806 return false; | 799 return false; |
| 807 } | 800 } |
| 808 default: | 801 default: |
| 809 break; | 802 break; |
| 810 } | 803 } |
| 811 return true; | 804 return true; |
| 812 } | 805 } |
| 813 | 806 |
| 814 // static | 807 // static |
| 815 scoped_refptr<GLSurface> | 808 scoped_refptr<GLSurface> |
| 816 GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window) { | 809 GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window) { |
| 817 | 810 |
| 818 if (GetGLImplementation() == kGLImplementationOSMesaGL) { | 811 if (GetGLImplementation() == kGLImplementationOSMesaGL) { |
| 819 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless(window)); | 812 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless()); |
| 820 if (!surface->Initialize()) | 813 if (!surface->Initialize()) |
| 821 return NULL; | 814 return NULL; |
| 822 return surface; | 815 return surface; |
| 823 } | 816 } |
| 824 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); | 817 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); |
| 825 if (window) { | 818 if (window != kNullAcceleratedWidget) { |
| 819 EGLNativeWindowType egl_window; | |
| 826 scoped_refptr<NativeViewGLSurfaceEGL> surface; | 820 scoped_refptr<NativeViewGLSurfaceEGL> surface; |
| 827 scoped_ptr<VSyncProvider> sync_provider; | 821 scoped_ptr<VSyncProvider> sync_provider; |
| 828 #if defined(USE_OZONE) | 822 #if defined(USE_OZONE) |
| 829 window = gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( | 823 egl_window = |
| 830 window); | 824 gfx::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( |
| 825 window); | |
| 831 sync_provider = | 826 sync_provider = |
| 832 gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider(window); | 827 gfx::SurfaceFactoryOzone::GetInstance()->CreateVSyncProvider( |
| 828 egl_window); | |
| 829 #else | |
| 830 egl_window = window; | |
| 833 #endif | 831 #endif |
| 834 surface = new NativeViewGLSurfaceEGL(window); | 832 surface = new NativeViewGLSurfaceEGL(egl_window); |
| 835 if(surface->Initialize(sync_provider.Pass())) | 833 if(surface->Initialize(sync_provider.Pass())) |
| 836 return surface; | 834 return surface; |
| 837 } else { | 835 } else { |
| 838 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); | 836 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); |
| 839 if (surface->Initialize()) | 837 if (surface->Initialize()) |
| 840 return surface; | 838 return surface; |
| 841 } | 839 } |
| 842 return NULL; | 840 return NULL; |
| 843 } | 841 } |
| 844 | 842 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 867 } | 865 } |
| 868 default: | 866 default: |
| 869 NOTREACHED(); | 867 NOTREACHED(); |
| 870 return NULL; | 868 return NULL; |
| 871 } | 869 } |
| 872 } | 870 } |
| 873 | 871 |
| 874 #endif | 872 #endif |
| 875 | 873 |
| 876 } // namespace gfx | 874 } // namespace gfx |
| OLD | NEW |