diff options
author | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-21 15:27:49 +0000 |
---|---|---|
committer | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-21 15:27:49 +0000 |
commit | 0fb8e4229c1eb3fb943713da997d46ff7fdd033e (patch) | |
tree | 5b1657f1c77a0a2b2a66bd5ffc205c3641a4f31c /ui/gfx | |
parent | a749a946d9eaeff53419a1a65bf59021ba1acf51 (diff) | |
download | chromium_src-0fb8e4229c1eb3fb943713da997d46ff7fdd033e.zip chromium_src-0fb8e4229c1eb3fb943713da997d46ff7fdd033e.tar.gz chromium_src-0fb8e4229c1eb3fb943713da997d46ff7fdd033e.tar.bz2 |
Revert 93393 - Crashed Linux Touch build: http://build.chromium.org/p/chromium/builders/Linux%20Touch/builds/2649/steps/compile/logs/stdio
Allow creating a gpu channel that uses software rendering
Where supported (on ANGLE with EGL_ANGLE_software_display), allow for the creation of gpu channels that use software rendering instead of hardware rendering.
BUG=
TEST=trybots, other later tests
Review URL: http://codereview.chromium.org/7383004
TBR=jbauman@chromium.org
Review URL: http://codereview.chromium.org/7468030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/compositor/compositor_gl.cc | 2 | ||||
-rw-r--r-- | ui/gfx/gl/gl.gyp | 1 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_egl.cc | 18 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_egl.h | 4 | ||||
-rw-r--r-- | ui/gfx/gl/gl_implementation_win.cc | 11 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface.h | 2 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_egl.cc | 96 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_egl.h | 14 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_linux.cc | 12 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_mac.cc | 4 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_win.cc | 10 | ||||
-rw-r--r-- | ui/gfx/surface/accelerated_surface_linux.cc | 4 | ||||
-rw-r--r-- | ui/gfx/surface/accelerated_surface_mac.cc | 3 |
13 files changed, 37 insertions, 144 deletions
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc index 881c697..27b49b9 100644 --- a/ui/gfx/compositor/compositor_gl.cc +++ b/ui/gfx/compositor/compositor_gl.cc @@ -380,7 +380,7 @@ CompositorGL::CompositorGL(gfx::AcceleratedWidget widget, const gfx::Size& size) : size_(size), started_(false) { - gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, widget); + gl_surface_ = gfx::GLSurface::CreateViewGLSurface(widget); gl_context_ = SharedResources::GetInstance()-> CreateContext(gl_surface_.get()); gl_context_->MakeCurrent(gl_surface_.get()); diff --git a/ui/gfx/gl/gl.gyp b/ui/gfx/gl/gl.gyp index 5771682..f7c7879 100644 --- a/ui/gfx/gl/gl.gyp +++ b/ui/gfx/gl/gl.gyp @@ -20,7 +20,6 @@ 'gl_binding_output_dir': '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gl', }, 'include_dirs': [ - '<(DEPTH)/third_party/swiftshader/include', '<(DEPTH)/third_party/mesa/MesaLib/include', '<(gl_binding_output_dir)', ], diff --git a/ui/gfx/gl/gl_context_egl.cc b/ui/gfx/gl/gl_context_egl.cc index f18d59f..63f63e9 100644 --- a/ui/gfx/gl/gl_context_egl.cc +++ b/ui/gfx/gl/gl_context_egl.cc @@ -24,7 +24,7 @@ extern "C" { namespace gfx { std::string GLContextEGL::GetExtensions() { - const char* extensions = eglQueryString(display_, + const char* extensions = eglQueryString(GLSurfaceEGL::GetDisplay(), EGL_EXTENSIONS); if (!extensions) return GLContext::GetExtensions(); @@ -51,13 +51,9 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface) { EGL_NONE }; - GLSurfaceEGL* egl_surface = static_cast<GLSurfaceEGL*>(compatible_surface); - display_ = egl_surface->GetDisplay(); - config_ = egl_surface->GetConfig(); - context_ = eglCreateContext( - display_, - config_, + GLSurfaceEGL::GetDisplay(), + GLSurfaceEGL::GetConfig(), share_group() ? share_group()->GetHandle() : NULL, kContextAttributes); if (!context_) { @@ -72,7 +68,7 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface) { void GLContextEGL::Destroy() { if (context_) { - if (!eglDestroyContext(display_, context_)) { + if (!eglDestroyContext(GLSurfaceEGL::GetDisplay(), context_)) { LOG(ERROR) << "eglDestroyContext failed with error " << GetLastEGLErrorString(); } @@ -86,7 +82,7 @@ bool GLContextEGL::MakeCurrent(GLSurface* surface) { if (IsCurrent(surface)) return true; - if (!eglMakeCurrent(display_, + if (!eglMakeCurrent(GLSurfaceEGL::GetDisplay(), surface->GetHandle(), surface->GetHandle(), context_)) { @@ -102,7 +98,7 @@ void GLContextEGL::ReleaseCurrent(GLSurface* surface) { if (!IsCurrent(surface)) return; - eglMakeCurrent(display_, + eglMakeCurrent(GLSurfaceEGL::GetDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); @@ -127,7 +123,7 @@ void* GLContextEGL::GetHandle() { void GLContextEGL::SetSwapInterval(int interval) { DCHECK(IsCurrent(NULL)); - if (!eglSwapInterval(display_, interval)) { + if (!eglSwapInterval(GLSurfaceEGL::GetDisplay(), interval)) { LOG(ERROR) << "eglSwapInterval failed with error " << GetLastEGLErrorString(); } diff --git a/ui/gfx/gl/gl_context_egl.h b/ui/gfx/gl/gl_context_egl.h index 5a86f28..f1a8193 100644 --- a/ui/gfx/gl/gl_context_egl.h +++ b/ui/gfx/gl/gl_context_egl.h @@ -11,8 +11,6 @@ #include "ui/gfx/gl/gl_context.h" typedef void* EGLContext; -typedef void* EGLDisplay; -typedef void* EGLConfig; namespace gfx { @@ -36,8 +34,6 @@ class GLContextEGL : public GLContext { private: EGLContext context_; - EGLDisplay display_; - EGLConfig config_; DISALLOW_COPY_AND_ASSIGN(GLContextEGL); }; diff --git a/ui/gfx/gl/gl_implementation_win.cc b/ui/gfx/gl/gl_implementation_win.cc index 4d6fff7..9061bb3 100644 --- a/ui/gfx/gl/gl_implementation_win.cc +++ b/ui/gfx/gl/gl_implementation_win.cc @@ -12,10 +12,6 @@ #include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_implementation.h" -#if defined(ENABLE_SWIFTSHADER) -#include "software_renderer_d3d9.h" -#endif - namespace gfx { namespace { @@ -76,13 +72,6 @@ bool InitializeGLBindings(GLImplementation implementation) { if (!PathService::Get(base::DIR_MODULE, &module_path)) return false; -#if defined(ENABLE_SWIFTSHADER) - base::NativeLibrary swiftshader_library = base::LoadNativeLibrary( - module_path.Append(L"swiftshader_d3d9.dll"), NULL); - - SetupSoftwareRenderer(); -#endif - // Load libglesv2.dll before libegl.dll because the latter is dependent on // the former and if there is another version of libglesv2.dll in the dll // search path, it will get loaded. diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h index 7a89d5b..513f37d 100644 --- a/ui/gfx/gl/gl_surface.h +++ b/ui/gfx/gl/gl_surface.h @@ -50,13 +50,11 @@ class GLSurface : public base::RefCounted<GLSurface> { #if !defined(OS_MACOSX) // Create a GL surface that renders directly to a view. static scoped_refptr<GLSurface> CreateViewGLSurface( - bool software, gfx::PluginWindowHandle window); #endif // Create a GL surface used for offscreen rendering. static scoped_refptr<GLSurface> CreateOffscreenGLSurface( - bool software, const gfx::Size& size); protected: diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc index bf509bd..603cff4 100644 --- a/ui/gfx/gl/gl_surface_egl.cc +++ b/ui/gfx/gl/gl_surface_egl.cc @@ -8,7 +8,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" #include "ui/gfx/gl/egl_util.h" // This header must come after the above third-party include, as @@ -27,9 +26,6 @@ namespace { EGLConfig g_config; EGLDisplay g_display; EGLNativeDisplayType g_native_display; -EGLConfig g_software_config; -EGLDisplay g_software_display; -EGLNativeDisplayType g_software_native_display; } GLSurfaceEGL::GLSurfaceEGL() { @@ -89,84 +85,39 @@ bool GLSurfaceEGL::InitializeOneOff() { return false; } + scoped_array<EGLConfig> configs(new EGLConfig[num_configs]); if (!eglChooseConfig(g_display, kConfigAttribs, - &g_config, - 1, + configs.get(), + num_configs, &num_configs)) { LOG(ERROR) << "eglChooseConfig failed with error " << GetLastEGLErrorString(); return false; } - initialized = true; - -#if defined(USE_X11) - return true; -#else - g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE; -#endif - g_software_display = eglGetDisplay(g_software_native_display); - if (!g_software_display) { - return true; - } - - if (!eglInitialize(g_software_display, NULL, NULL)) { - return true; - } - - if (!eglChooseConfig(g_software_display, - kConfigAttribs, - NULL, - 0, - &num_configs)) { - g_software_display = NULL; - return true; - } - - if (num_configs == 0) { - g_software_display = NULL; - return true; - } - - if (!eglChooseConfig(g_software_display, - kConfigAttribs, - &g_software_config, - 1, - &num_configs)) { - g_software_display = NULL; - return false; - } + g_config = configs[0]; + initialized = true; return true; } EGLDisplay GLSurfaceEGL::GetDisplay() { - return software_ ? g_software_display : g_display; -} - -EGLConfig GLSurfaceEGL::GetConfig() { - return software_ ? g_software_config : g_config; -} - -EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { return g_display; } -EGLDisplay GLSurfaceEGL::GetSoftwareDisplay() { - return g_software_display; +EGLConfig GLSurfaceEGL::GetConfig() { + return g_config; } EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { return g_native_display; } -NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, - gfx::PluginWindowHandle window) +NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(gfx::PluginWindowHandle window) : window_(window), surface_(NULL) { - software_ = software; } NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { @@ -176,14 +127,9 @@ NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { bool NativeViewGLSurfaceEGL::Initialize() { DCHECK(!surface_); - if (!GetDisplay()) { - LOG(ERROR) << "Trying to create surface with invalid display."; - return false; - } - // Create a surface for the native window. - surface_ = eglCreateWindowSurface(GetDisplay(), - GetConfig(), + surface_ = eglCreateWindowSurface(g_display, + g_config, window_, NULL); @@ -199,7 +145,7 @@ bool NativeViewGLSurfaceEGL::Initialize() { void NativeViewGLSurfaceEGL::Destroy() { if (surface_) { - if (!eglDestroySurface(GetDisplay(), surface_)) { + if (!eglDestroySurface(g_display, surface_)) { LOG(ERROR) << "eglDestroySurface failed with error " << GetLastEGLErrorString(); } @@ -212,7 +158,7 @@ bool NativeViewGLSurfaceEGL::IsOffscreen() { } bool NativeViewGLSurfaceEGL::SwapBuffers() { - if (!eglSwapBuffers(GetDisplay(), surface_)) { + if (!eglSwapBuffers(g_display, surface_)) { VLOG(1) << "eglSwapBuffers failed with error " << GetLastEGLErrorString(); return false; @@ -224,8 +170,8 @@ bool NativeViewGLSurfaceEGL::SwapBuffers() { gfx::Size NativeViewGLSurfaceEGL::GetSize() { EGLint width; EGLint height; - if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || - !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { + if (!eglQuerySurface(g_display, surface_, EGL_WIDTH, &width) || + !eglQuerySurface(g_display, surface_, EGL_HEIGHT, &height)) { NOTREACHED() << "eglQuerySurface failed with error " << GetLastEGLErrorString(); return gfx::Size(); @@ -238,10 +184,9 @@ EGLSurface NativeViewGLSurfaceEGL::GetHandle() { return surface_; } -PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) +PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) : size_(size), surface_(NULL) { - software_ = software; } PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { @@ -251,19 +196,14 @@ PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { bool PbufferGLSurfaceEGL::Initialize() { DCHECK(!surface_); - if (!GetDisplay()) { - LOG(ERROR) << "Trying to create surface with invalid display."; - return false; - } - const EGLint pbuffer_attribs[] = { EGL_WIDTH, size_.width(), EGL_HEIGHT, size_.height(), EGL_NONE }; - surface_ = eglCreatePbufferSurface(GetDisplay(), - GetConfig(), + surface_ = eglCreatePbufferSurface(g_display, + g_config, pbuffer_attribs); if (!surface_) { LOG(ERROR) << "eglCreatePbufferSurface failed with error " @@ -277,7 +217,7 @@ bool PbufferGLSurfaceEGL::Initialize() { void PbufferGLSurfaceEGL::Destroy() { if (surface_) { - if (!eglDestroySurface(GetDisplay(), surface_)) { + if (!eglDestroySurface(g_display, surface_)) { LOG(ERROR) << "eglDestroySurface failed with error " << GetLastEGLErrorString(); } diff --git a/ui/gfx/gl/gl_surface_egl.h b/ui/gfx/gl/gl_surface_egl.h index 19e7f4f..2bf8f82 100644 --- a/ui/gfx/gl/gl_surface_egl.h +++ b/ui/gfx/gl/gl_surface_egl.h @@ -33,15 +33,10 @@ class GLSurfaceEGL : public GLSurface { virtual ~GLSurfaceEGL(); static bool InitializeOneOff(); - EGLDisplay GetDisplay(); - EGLConfig GetConfig(); - static EGLDisplay GetHardwareDisplay(); - static EGLDisplay GetSoftwareDisplay(); + static EGLDisplay GetDisplay(); + static EGLConfig GetConfig(); static EGLNativeDisplayType GetNativeDisplay(); -protected: - bool software_; - private: DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); }; @@ -49,8 +44,7 @@ protected: // Encapsulates an EGL surface bound to a view. class NativeViewGLSurfaceEGL : public GLSurfaceEGL { public: - explicit NativeViewGLSurfaceEGL(bool software, - gfx::PluginWindowHandle window); + explicit NativeViewGLSurfaceEGL(gfx::PluginWindowHandle window); virtual ~NativeViewGLSurfaceEGL(); // Implement GLSurface. @@ -71,7 +65,7 @@ class NativeViewGLSurfaceEGL : public GLSurfaceEGL { // Encapsulates a pbuffer EGL surface. class PbufferGLSurfaceEGL : public GLSurfaceEGL { public: - explicit PbufferGLSurfaceEGL(bool software, const gfx::Size& size); + explicit PbufferGLSurfaceEGL(const gfx::Size& size); virtual ~PbufferGLSurfaceEGL(); // Implement GLSurface. diff --git a/ui/gfx/gl/gl_surface_linux.cc b/ui/gfx/gl/gl_surface_linux.cc index 968ca618..fe96989 100644 --- a/ui/gfx/gl/gl_surface_linux.cc +++ b/ui/gfx/gl/gl_surface_linux.cc @@ -244,11 +244,7 @@ bool NativeViewGLSurfaceOSMesa::UpdateSize() { } scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( - bool software, gfx::PluginWindowHandle window) { - if (software) - return NULL; - switch (GetGLImplementation()) { case kGLImplementationOSMesaGL: { scoped_refptr<GLSurface> surface( @@ -260,7 +256,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( } case kGLImplementationEGLGLES2: { scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL( - false, window)); + window)); if (!surface->Initialize()) return NULL; @@ -283,11 +279,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( } scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( - bool software, const gfx::Size& size) { - if (software) - return NULL; - switch (GetGLImplementation()) { case kGLImplementationOSMesaGL: { scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, @@ -298,7 +290,7 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( return surface; } case kGLImplementationEGLGLES2: { - scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(false, size)); + scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); if (!surface->Initialize()) return NULL; diff --git a/ui/gfx/gl/gl_surface_mac.cc b/ui/gfx/gl/gl_surface_mac.cc index 440db41..2367679 100644 --- a/ui/gfx/gl/gl_surface_mac.cc +++ b/ui/gfx/gl/gl_surface_mac.cc @@ -79,11 +79,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( #endif scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( - bool software, const gfx::Size& size) { - if (software) - return NULL; - switch (GetGLImplementation()) { case kGLImplementationOSMesaGL: { scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, diff --git a/ui/gfx/gl/gl_surface_win.cc b/ui/gfx/gl/gl_surface_win.cc index 77810af..6b3ea8c 100644 --- a/ui/gfx/gl/gl_surface_win.cc +++ b/ui/gfx/gl/gl_surface_win.cc @@ -168,7 +168,6 @@ void NativeViewGLSurfaceOSMesa::UpdateSize() { } scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( - bool software, gfx::PluginWindowHandle window) { switch (GetGLImplementation()) { case kGLImplementationOSMesaGL: { @@ -180,7 +179,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( return surface; } case kGLImplementationEGLGLES2: { - scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(software, + scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL( window)); if (!surface->Initialize()) return NULL; @@ -188,8 +187,6 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( return surface; } case kGLImplementationDesktopGL: { - if (software) - return NULL; scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceWGL( window)); if (!surface->Initialize()) @@ -206,7 +203,6 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( } scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( - bool software, const gfx::Size& size) { switch (GetGLImplementation()) { case kGLImplementationOSMesaGL: { @@ -218,15 +214,13 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( return surface; } case kGLImplementationEGLGLES2: { - scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(software, size)); + scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); if (!surface->Initialize()) return NULL; return surface; } case kGLImplementationDesktopGL: { - if (software) - return NULL; scoped_refptr<GLSurface> surface(new PbufferGLSurfaceWGL(size)); if (!surface->Initialize()) return NULL; diff --git a/ui/gfx/surface/accelerated_surface_linux.cc b/ui/gfx/surface/accelerated_surface_linux.cc index a74ac5c..9a42c68 100644 --- a/ui/gfx/surface/accelerated_surface_linux.cc +++ b/ui/gfx/surface/accelerated_surface_linux.cc @@ -14,7 +14,7 @@ AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) : size_(size) { Display* dpy = gfx::GLSurfaceEGL::GetNativeDisplay(); - EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); + EGLDisplay edpy = gfx::GLSurfaceEGL::GetDisplay(); XID window = XDefaultRootWindow(dpy); XWindowAttributes gwa; @@ -42,6 +42,6 @@ AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) AcceleratedSurface::~AcceleratedSurface() { glDeleteTextures(1, &texture_); - eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_); + eglDestroyImageKHR(gfx::GLSurfaceEGL::GetDisplay(), image_); XFreePixmap(gfx::GLSurfaceEGL::GetNativeDisplay(), pixmap_); } diff --git a/ui/gfx/surface/accelerated_surface_mac.cc b/ui/gfx/surface/accelerated_surface_mac.cc index cbbee4b..e3e74cb 100644 --- a/ui/gfx/surface/accelerated_surface_mac.cc +++ b/ui/gfx/surface/accelerated_surface_mac.cc @@ -36,8 +36,7 @@ bool AcceleratedSurface::Initialize(gfx::GLContext* share_context, if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) return false; - gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( - false, gfx::Size(1, 1)); + gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); if (!gl_surface_.get()) { Destroy(); return false; |