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 |
11 #if defined(OS_ANDROID) | 11 #if defined(OS_ANDROID) |
12 #include <android/native_window_jni.h> | 12 #include <android/native_window_jni.h> |
13 #endif | 13 #endif |
14 | 14 |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "ui/gl/egl_util.h" | 20 #include "ui/gl/egl_util.h" |
21 #include "ui/gl/gl_context.h" | 21 #include "ui/gl/gl_context.h" |
22 #include "ui/gl/gl_implementation.h" | 22 #include "ui/gl/gl_implementation.h" |
23 #include "ui/gl/gl_surface_osmesa.h" | 23 #include "ui/gl/gl_surface_osmesa.h" |
24 #include "ui/gl/gl_surface_stub.h" | 24 #include "ui/gl/gl_surface_stub.h" |
25 #include "ui/gl/gl_switches.h" | 25 #include "ui/gl/gl_switches.h" |
26 #include "ui/gl/scoped_make_current.h" | 26 #include "ui/gl/scoped_make_current.h" |
27 | 27 |
28 #if defined(OS_ANDROID) | |
29 #include "ui/gl/android/surface_factory_android.h" | |
30 #endif | |
31 | |
28 #if defined(USE_X11) | 32 #if defined(USE_X11) |
29 extern "C" { | 33 extern "C" { |
30 #include <X11/Xlib.h> | 34 #include <X11/Xlib.h> |
31 } | 35 } |
32 #endif | 36 #endif |
33 | 37 |
34 #if defined (USE_OZONE) | 38 #if defined (USE_OZONE) |
35 #include "ui/base/ozone/surface_factory_ozone.h" | 39 #include "ui/base/ozone/surface_factory_ozone.h" |
36 #endif | 40 #endif |
37 | 41 |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 #if defined(USE_OZONE) | 644 #if defined(USE_OZONE) |
641 window = ui::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( | 645 window = ui::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( |
642 window); | 646 window); |
643 sync_provider = | 647 sync_provider = |
644 ui::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window); | 648 ui::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window); |
645 #endif | 649 #endif |
646 surface = new NativeViewGLSurfaceEGL(window); | 650 surface = new NativeViewGLSurfaceEGL(window); |
647 if(surface->Initialize(sync_provider)) | 651 if(surface->Initialize(sync_provider)) |
648 return surface; | 652 return surface; |
649 } else { | 653 } else { |
650 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); | 654 scoped_refptr<GLSurface> surface; |
655 | |
656 #if defined(OS_ANDROID) | |
657 if (SurfaceFactoryAndroid* factory = SurfaceFactoryAndroid::GetInstance()) | |
658 surface = factory->CreateNonOwnedViewSurface(); | |
no sievers
2013/08/06 20:31:29
null check factory or tests will crash
boliu
2013/08/06 21:10:06
That's what the if is for :)
| |
659 #endif | |
660 | |
661 if (!surface) | |
662 surface = new GLSurfaceStub(); | |
651 if (surface->Initialize()) | 663 if (surface->Initialize()) |
652 return surface; | 664 return surface; |
653 } | 665 } |
654 return NULL; | 666 return NULL; |
655 } | 667 } |
656 | 668 |
657 // static | 669 // static |
658 scoped_refptr<GLSurface> | 670 scoped_refptr<GLSurface> |
659 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { | 671 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { |
660 switch (GetGLImplementation()) { | 672 switch (GetGLImplementation()) { |
(...skipping 13 matching lines...) Expand all Loading... | |
674 } | 686 } |
675 default: | 687 default: |
676 NOTREACHED(); | 688 NOTREACHED(); |
677 return NULL; | 689 return NULL; |
678 } | 690 } |
679 } | 691 } |
680 | 692 |
681 #endif | 693 #endif |
682 | 694 |
683 } // namespace gfx | 695 } // namespace gfx |
OLD | NEW |