diff options
30 files changed, 187 insertions, 59 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index e69d197..e83320d 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -27,13 +27,15 @@ GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, GpuWatchdog* watchdog, - int renderer_id) + int renderer_id, + bool software) : gpu_channel_manager_(gpu_channel_manager), renderer_id_(renderer_id), renderer_process_(base::kNullProcessHandle), renderer_pid_(base::kNullProcessId), share_group_(new gfx::GLShareGroup), - watchdog_(watchdog) { + watchdog_(watchdog), + software_(software) { DCHECK(gpu_channel_manager); DCHECK(renderer_id); const CommandLine* command_line = CommandLine::ForCurrentProcess(); @@ -164,7 +166,7 @@ void GpuChannel::CreateViewCommandBuffer( this, window, gfx::Size(), disallowed_extensions_, init_params.allowed_extensions, init_params.attribs, *route_id, renderer_id_, render_view_id, - watchdog_)); + watchdog_, software_)); router_.AddRoute(*route_id, stub.get()); stubs_.AddWithID(stub.release(), *route_id); #endif // ENABLE_GPU @@ -274,7 +276,8 @@ void GpuChannel::OnCreateOffscreenCommandBuffer( init_params.allowed_extensions, init_params.attribs, *route_id, - 0, 0, watchdog_)); + 0, 0, watchdog_, + software_)); router_.AddRoute(*route_id, stub.get()); stubs_.AddWithID(stub.release(), *route_id); TRACE_EVENT1("gpu", "GpuChannel::OnCreateOffscreenCommandBuffer", @@ -306,7 +309,7 @@ void GpuChannel::OnCreateOffscreenSurface(const gfx::Size& size, #if defined(ENABLE_GPU) scoped_refptr<gfx::GLSurface> surface( - gfx::GLSurface::CreateOffscreenGLSurface(size)); + gfx::GLSurface::CreateOffscreenGLSurface(software_, size)); if (!surface.get()) return; diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h index 7344496..2b5ad1f 100644 --- a/content/common/gpu/gpu_channel.h +++ b/content/common/gpu/gpu_channel.h @@ -48,7 +48,8 @@ class GpuChannel : public IPC::Channel::Listener, // Takes ownership of the renderer process handle. GpuChannel(GpuChannelManager* gpu_channel_manager, GpuWatchdog* watchdog, - int renderer_id); + int renderer_id, + bool software); virtual ~GpuChannel(); bool Init(base::MessageLoopProxy* io_message_loop, @@ -187,6 +188,7 @@ class GpuChannel : public IPC::Channel::Listener, bool log_messages_; // True if we should log sent and received messages. gpu::gles2::DisallowedExtensions disallowed_extensions_; GpuWatchdog* watchdog_; + bool software_; DISALLOW_COPY_AND_ASSIGN(GpuChannel); }; diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc index a0b520c..c2ef865 100644 --- a/content/common/gpu/gpu_channel_manager.cc +++ b/content/common/gpu/gpu_channel_manager.cc @@ -71,7 +71,7 @@ void GpuChannelManager::OnEstablishChannel(int renderer_id) { GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); if (iter == gpu_channels_.end()) - channel = new GpuChannel(this, watchdog_, renderer_id); + channel = new GpuChannel(this, watchdog_, renderer_id, false); else channel = iter->second; diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 8034372..6de811d 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -36,7 +36,8 @@ GpuCommandBufferStub::GpuCommandBufferStub( int32 route_id, int32 renderer_id, int32 render_view_id, - GpuWatchdog* watchdog) + GpuWatchdog* watchdog, + bool software) : channel_(channel), handle_(handle), initial_size_(size), @@ -44,6 +45,7 @@ GpuCommandBufferStub::GpuCommandBufferStub( allowed_extensions_(allowed_extensions), requested_attribs_(attribs), route_id_(route_id), + software_(software), last_flush_count_(0), renderer_id_(renderer_id), render_view_id_(render_view_id), @@ -148,6 +150,7 @@ void GpuCommandBufferStub::OnInitialize( if (scheduler_->Initialize( handle_, initial_size_, + software_, disallowed_extensions_, allowed_extensions_.c_str(), requested_attribs_, diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 6766d87..902ec9b 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -41,7 +41,8 @@ class GpuCommandBufferStub int32 route_id, int32 renderer_id, int32 render_view_id, - GpuWatchdog* watchdog); + GpuWatchdog* watchdog, + bool software); virtual ~GpuCommandBufferStub(); @@ -155,6 +156,7 @@ class GpuCommandBufferStub std::string allowed_extensions_; std::vector<int32> requested_attribs_; int32 route_id_; + bool software_; uint32 last_flush_count_; // The following two fields are used on Mac OS X to identify the window diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc index 93cd767..cd0918c 100644 --- a/content/gpu/gpu_info_collector.cc +++ b/content/gpu/gpu_info_collector.cc @@ -20,7 +20,7 @@ namespace { scoped_refptr<gfx::GLSurface> InitializeGLSurface() { scoped_refptr<gfx::GLSurface> surface( - gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1))); + gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1))); if (!surface.get()) { LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed"; return NULL; diff --git a/content/gpu/gpu_info_collector_win.cc b/content/gpu/gpu_info_collector_win.cc index 4e32805..dfae814 100644 --- a/content/gpu/gpu_info_collector_win.cc +++ b/content/gpu/gpu_info_collector_win.cc @@ -72,7 +72,7 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { // Need to handle the case when running on top of real EGL/GLES2 drivers. egl::Display* display = static_cast<egl::Display*>( - gfx::GLSurfaceEGL::GetDisplay()); + gfx::GLSurfaceEGL::GetHardwareDisplay()); if (!display) { LOG(ERROR) << "gfx::BaseEGLContext::GetDisplay() failed"; return false; diff --git a/gpu/command_buffer/client/gles2_demo.cc b/gpu/command_buffer/client/gles2_demo.cc index c9595df..f981b1b 100644 --- a/gpu/command_buffer/client/gles2_demo.cc +++ b/gpu/command_buffer/client/gles2_demo.cc @@ -61,6 +61,7 @@ bool GLES2Demo::Setup(void* hwnd, int32 size) { NULL); if (!gpu_scheduler->Initialize(reinterpret_cast<HWND>(hwnd), gfx::Size(), + false, gpu::gles2::DisallowedExtensions(), NULL, std::vector<int32>(), diff --git a/gpu/command_buffer/service/gpu_scheduler.h b/gpu/command_buffer/service/gpu_scheduler.h index eedae30..d34e67f 100644 --- a/gpu/command_buffer/service/gpu_scheduler.h +++ b/gpu/command_buffer/service/gpu_scheduler.h @@ -63,6 +63,7 @@ class GpuScheduler : public CommandBufferEngine { // Perform platform specific and common initialization. bool Initialize(gfx::PluginWindowHandle hwnd, const gfx::Size& size, + bool software, const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, diff --git a/gpu/command_buffer/service/gpu_scheduler_linux.cc b/gpu/command_buffer/service/gpu_scheduler_linux.cc index 1c6c8e9..fcbbd65 100644 --- a/gpu/command_buffer/service/gpu_scheduler_linux.cc +++ b/gpu/command_buffer/service/gpu_scheduler_linux.cc @@ -21,6 +21,7 @@ namespace gpu { bool GpuScheduler::Initialize( gfx::PluginWindowHandle window, const gfx::Size& size, + bool software, const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, @@ -28,12 +29,13 @@ bool GpuScheduler::Initialize( // Create either a view or pbuffer based GLSurface. scoped_refptr<gfx::GLSurface> surface; #if defined(TOUCH_UI) - surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); + surface = gfx::GLSurface::CreateOffscreenGLSurface(software, gfx::Size(1, 1)); #else if (window) - surface = gfx::GLSurface::CreateViewGLSurface(window); + surface = gfx::GLSurface::CreateViewGLSurface(software, window); else - surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); + surface = gfx::GLSurface::CreateOffscreenGLSurface(software, + gfx::Size(1, 1)); #endif if (!surface.get()) { diff --git a/gpu/command_buffer/service/gpu_scheduler_mac.cc b/gpu/command_buffer/service/gpu_scheduler_mac.cc index 2835088..cfa0d5c 100644 --- a/gpu/command_buffer/service/gpu_scheduler_mac.cc +++ b/gpu/command_buffer/service/gpu_scheduler_mac.cc @@ -14,12 +14,13 @@ namespace gpu { bool GpuScheduler::Initialize( gfx::PluginWindowHandle window, const gfx::Size& size, + bool software, const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, gfx::GLShareGroup* share_group) { scoped_refptr<gfx::GLSurface> surface( - gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1))); + gfx::GLSurface::CreateOffscreenGLSurface(software, gfx::Size(1, 1))); if (!surface.get()) { LOG(ERROR) << "CreateOffscreenGLSurface failed.\n"; Destroy(); diff --git a/gpu/command_buffer/service/gpu_scheduler_win.cc b/gpu/command_buffer/service/gpu_scheduler_win.cc index 20e5382..84f2b83 100644 --- a/gpu/command_buffer/service/gpu_scheduler_win.cc +++ b/gpu/command_buffer/service/gpu_scheduler_win.cc @@ -16,6 +16,7 @@ namespace gpu { bool GpuScheduler::Initialize( gfx::PluginWindowHandle window, const gfx::Size& size, + bool software, const gles2::DisallowedExtensions& disallowed_extensions, const char* allowed_extensions, const std::vector<int32>& attribs, @@ -23,9 +24,10 @@ bool GpuScheduler::Initialize( // Create either a view or pbuffer based GLSurface. scoped_refptr<gfx::GLSurface> surface; if (window) { - surface = gfx::GLSurface::CreateViewGLSurface(window); + surface = gfx::GLSurface::CreateViewGLSurface(software, window); } else { - surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); + surface = gfx::GLSurface::CreateOffscreenGLSurface(software, + gfx::Size(1, 1)); } if (!surface.get()) { diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc index 30ba86c..f609a55 100644 --- a/gpu/demos/framework/window.cc +++ b/gpu/demos/framework/window.cc @@ -61,7 +61,7 @@ bool Window::CreateRenderContext(gfx::PluginWindowHandle hwnd) { GpuScheduler* gpu_scheduler( new GpuScheduler(command_buffer.get(), NULL, NULL)); - if (!gpu_scheduler->Initialize(hwnd, gfx::Size(), + if (!gpu_scheduler->Initialize(hwnd, gfx::Size(), false, gpu::gles2::DisallowedExtensions(), NULL, std::vector<int32>(), NULL)) { diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc index cfadf0f..63604b9 100644 --- a/gpu/gles2_conform_support/egl/display.cc +++ b/gpu/gles2_conform_support/egl/display.cc @@ -111,7 +111,7 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config, scoped_ptr<GpuScheduler> gpu_scheduler( new GpuScheduler(command_buffer_.get(), NULL, NULL)); if (!gpu_scheduler->Initialize( - win, gfx::Size(), gpu::gles2::DisallowedExtensions(), NULL, + win, gfx::Size(), false, gpu::gles2::DisallowedExtensions(), NULL, attribs, NULL)) return EGL_NO_SURFACE; diff --git a/media/tools/shader_bench/shader_bench.cc b/media/tools/shader_bench/shader_bench.cc index 88905e9..fd4adc5 100644 --- a/media/tools/shader_bench/shader_bench.cc +++ b/media/tools/shader_bench/shader_bench.cc @@ -132,7 +132,7 @@ int main(int argc, char** argv) { gfx::GLSurface::InitializeOneOff(); scoped_ptr<media::Window> window(new media::Window(width, height)); gfx::GLSurface* surface = - gfx::GLSurface::CreateViewGLSurface(window->PluginWindow()); + gfx::GLSurface::CreateViewGLSurface(false, window->PluginWindow()); gfx::GLContext* context = gfx::GLContext::CreateGLContext(NULL, surface); context->MakeCurrent(surface); // This sets D3DPRESENT_INTERVAL_IMMEDIATE on Windows. diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc index 27b49b9..881c697 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(widget); + gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, 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 f7c7879..5771682 100644 --- a/ui/gfx/gl/gl.gyp +++ b/ui/gfx/gl/gl.gyp @@ -20,6 +20,7 @@ '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 63f63e9..f18d59f 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(GLSurfaceEGL::GetDisplay(), + const char* extensions = eglQueryString(display_, EGL_EXTENSIONS); if (!extensions) return GLContext::GetExtensions(); @@ -51,9 +51,13 @@ 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( - GLSurfaceEGL::GetDisplay(), - GLSurfaceEGL::GetConfig(), + display_, + config_, share_group() ? share_group()->GetHandle() : NULL, kContextAttributes); if (!context_) { @@ -68,7 +72,7 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface) { void GLContextEGL::Destroy() { if (context_) { - if (!eglDestroyContext(GLSurfaceEGL::GetDisplay(), context_)) { + if (!eglDestroyContext(display_, context_)) { LOG(ERROR) << "eglDestroyContext failed with error " << GetLastEGLErrorString(); } @@ -82,7 +86,7 @@ bool GLContextEGL::MakeCurrent(GLSurface* surface) { if (IsCurrent(surface)) return true; - if (!eglMakeCurrent(GLSurfaceEGL::GetDisplay(), + if (!eglMakeCurrent(display_, surface->GetHandle(), surface->GetHandle(), context_)) { @@ -98,7 +102,7 @@ void GLContextEGL::ReleaseCurrent(GLSurface* surface) { if (!IsCurrent(surface)) return; - eglMakeCurrent(GLSurfaceEGL::GetDisplay(), + eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); @@ -123,7 +127,7 @@ void* GLContextEGL::GetHandle() { void GLContextEGL::SetSwapInterval(int interval) { DCHECK(IsCurrent(NULL)); - if (!eglSwapInterval(GLSurfaceEGL::GetDisplay(), interval)) { + if (!eglSwapInterval(display_, 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 f1a8193..5a86f28 100644 --- a/ui/gfx/gl/gl_context_egl.h +++ b/ui/gfx/gl/gl_context_egl.h @@ -11,6 +11,8 @@ #include "ui/gfx/gl/gl_context.h" typedef void* EGLContext; +typedef void* EGLDisplay; +typedef void* EGLConfig; namespace gfx { @@ -34,6 +36,8 @@ 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 9061bb3..4d6fff7 100644 --- a/ui/gfx/gl/gl_implementation_win.cc +++ b/ui/gfx/gl/gl_implementation_win.cc @@ -12,6 +12,10 @@ #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 { @@ -72,6 +76,13 @@ 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 513f37d..7a89d5b 100644 --- a/ui/gfx/gl/gl_surface.h +++ b/ui/gfx/gl/gl_surface.h @@ -50,11 +50,13 @@ 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 603cff4..bf509bd 100644 --- a/ui/gfx/gl/gl_surface_egl.cc +++ b/ui/gfx/gl/gl_surface_egl.cc @@ -8,6 +8,7 @@ #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 @@ -26,6 +27,9 @@ 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() { @@ -85,39 +89,84 @@ bool GLSurfaceEGL::InitializeOneOff() { return false; } - scoped_array<EGLConfig> configs(new EGLConfig[num_configs]); if (!eglChooseConfig(g_display, kConfigAttribs, - configs.get(), - num_configs, + &g_config, + 1, &num_configs)) { LOG(ERROR) << "eglChooseConfig failed with error " << GetLastEGLErrorString(); return false; } - g_config = configs[0]; - 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; + } + return true; } EGLDisplay GLSurfaceEGL::GetDisplay() { - return g_display; + return software_ ? g_software_display : g_display; } EGLConfig GLSurfaceEGL::GetConfig() { - return g_config; + return software_ ? g_software_config : g_config; +} + +EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { + return g_display; +} + +EGLDisplay GLSurfaceEGL::GetSoftwareDisplay() { + return g_software_display; } EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { return g_native_display; } -NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(gfx::PluginWindowHandle window) +NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, + gfx::PluginWindowHandle window) : window_(window), surface_(NULL) { + software_ = software; } NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { @@ -127,9 +176,14 @@ 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(g_display, - g_config, + surface_ = eglCreateWindowSurface(GetDisplay(), + GetConfig(), window_, NULL); @@ -145,7 +199,7 @@ bool NativeViewGLSurfaceEGL::Initialize() { void NativeViewGLSurfaceEGL::Destroy() { if (surface_) { - if (!eglDestroySurface(g_display, surface_)) { + if (!eglDestroySurface(GetDisplay(), surface_)) { LOG(ERROR) << "eglDestroySurface failed with error " << GetLastEGLErrorString(); } @@ -158,7 +212,7 @@ bool NativeViewGLSurfaceEGL::IsOffscreen() { } bool NativeViewGLSurfaceEGL::SwapBuffers() { - if (!eglSwapBuffers(g_display, surface_)) { + if (!eglSwapBuffers(GetDisplay(), surface_)) { VLOG(1) << "eglSwapBuffers failed with error " << GetLastEGLErrorString(); return false; @@ -170,8 +224,8 @@ bool NativeViewGLSurfaceEGL::SwapBuffers() { gfx::Size NativeViewGLSurfaceEGL::GetSize() { EGLint width; EGLint height; - if (!eglQuerySurface(g_display, surface_, EGL_WIDTH, &width) || - !eglQuerySurface(g_display, surface_, EGL_HEIGHT, &height)) { + if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || + !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { NOTREACHED() << "eglQuerySurface failed with error " << GetLastEGLErrorString(); return gfx::Size(); @@ -184,9 +238,10 @@ EGLSurface NativeViewGLSurfaceEGL::GetHandle() { return surface_; } -PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) +PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) : size_(size), surface_(NULL) { + software_ = software; } PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { @@ -196,14 +251,19 @@ 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(g_display, - g_config, + surface_ = eglCreatePbufferSurface(GetDisplay(), + GetConfig(), pbuffer_attribs); if (!surface_) { LOG(ERROR) << "eglCreatePbufferSurface failed with error " @@ -217,7 +277,7 @@ bool PbufferGLSurfaceEGL::Initialize() { void PbufferGLSurfaceEGL::Destroy() { if (surface_) { - if (!eglDestroySurface(g_display, surface_)) { + if (!eglDestroySurface(GetDisplay(), 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 2bf8f82..19e7f4f 100644 --- a/ui/gfx/gl/gl_surface_egl.h +++ b/ui/gfx/gl/gl_surface_egl.h @@ -33,10 +33,15 @@ class GLSurfaceEGL : public GLSurface { virtual ~GLSurfaceEGL(); static bool InitializeOneOff(); - static EGLDisplay GetDisplay(); - static EGLConfig GetConfig(); + EGLDisplay GetDisplay(); + EGLConfig GetConfig(); + static EGLDisplay GetHardwareDisplay(); + static EGLDisplay GetSoftwareDisplay(); static EGLNativeDisplayType GetNativeDisplay(); +protected: + bool software_; + private: DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL); }; @@ -44,7 +49,8 @@ class GLSurfaceEGL : public GLSurface { // Encapsulates an EGL surface bound to a view. class NativeViewGLSurfaceEGL : public GLSurfaceEGL { public: - explicit NativeViewGLSurfaceEGL(gfx::PluginWindowHandle window); + explicit NativeViewGLSurfaceEGL(bool software, + gfx::PluginWindowHandle window); virtual ~NativeViewGLSurfaceEGL(); // Implement GLSurface. @@ -65,7 +71,7 @@ class NativeViewGLSurfaceEGL : public GLSurfaceEGL { // Encapsulates a pbuffer EGL surface. class PbufferGLSurfaceEGL : public GLSurfaceEGL { public: - explicit PbufferGLSurfaceEGL(const gfx::Size& size); + explicit PbufferGLSurfaceEGL(bool software, 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 fe96989..968ca618 100644 --- a/ui/gfx/gl/gl_surface_linux.cc +++ b/ui/gfx/gl/gl_surface_linux.cc @@ -244,7 +244,11 @@ 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( @@ -256,7 +260,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( } case kGLImplementationEGLGLES2: { scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL( - window)); + false, window)); if (!surface->Initialize()) return NULL; @@ -279,7 +283,11 @@ 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, @@ -290,7 +298,7 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( return surface; } case kGLImplementationEGLGLES2: { - scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); + scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(false, 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 2367679..440db41 100644 --- a/ui/gfx/gl/gl_surface_mac.cc +++ b/ui/gfx/gl/gl_surface_mac.cc @@ -79,7 +79,11 @@ 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 6b3ea8c..77810af 100644 --- a/ui/gfx/gl/gl_surface_win.cc +++ b/ui/gfx/gl/gl_surface_win.cc @@ -168,6 +168,7 @@ void NativeViewGLSurfaceOSMesa::UpdateSize() { } scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( + bool software, gfx::PluginWindowHandle window) { switch (GetGLImplementation()) { case kGLImplementationOSMesaGL: { @@ -179,7 +180,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( return surface; } case kGLImplementationEGLGLES2: { - scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL( + scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(software, window)); if (!surface->Initialize()) return NULL; @@ -187,6 +188,8 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( return surface; } case kGLImplementationDesktopGL: { + if (software) + return NULL; scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceWGL( window)); if (!surface->Initialize()) @@ -203,6 +206,7 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( } scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( + bool software, const gfx::Size& size) { switch (GetGLImplementation()) { case kGLImplementationOSMesaGL: { @@ -214,13 +218,15 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( return surface; } case kGLImplementationEGLGLES2: { - scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); + scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(software, 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 9a42c68..a74ac5c 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::GetDisplay(); + EGLDisplay edpy = gfx::GLSurfaceEGL::GetHardwareDisplay(); XID window = XDefaultRootWindow(dpy); XWindowAttributes gwa; @@ -42,6 +42,6 @@ AcceleratedSurface::AcceleratedSurface(const gfx::Size& size) AcceleratedSurface::~AcceleratedSurface() { glDeleteTextures(1, &texture_); - eglDestroyImageKHR(gfx::GLSurfaceEGL::GetDisplay(), image_); + eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), 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 e3e74cb..cbbee4b 100644 --- a/ui/gfx/surface/accelerated_surface_mac.cc +++ b/ui/gfx/surface/accelerated_surface_mac.cc @@ -36,7 +36,8 @@ bool AcceleratedSurface::Initialize(gfx::GLContext* share_context, if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) return false; - gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); + gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( + false, gfx::Size(1, 1)); if (!gl_surface_.get()) { Destroy(); return false; diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 0b623cc..a45e78c 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -586,6 +586,7 @@ bool GLInProcessContext::Initialize(bool onscreen, } else { if (!gpu_scheduler_->Initialize(render_surface, gfx::Size(), + false, ::gpu::gles2::DisallowedExtensions(), allowed_extensions, attribs, @@ -597,6 +598,7 @@ bool GLInProcessContext::Initialize(bool onscreen, } else { if (!gpu_scheduler_->Initialize(render_surface, size, + false, ::gpu::gles2::DisallowedExtensions(), allowed_extensions, attribs, diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc index e7d5757..cc6f69a 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc @@ -135,7 +135,8 @@ bool WebGraphicsContext3DInProcessImpl::initialize( // and from there to the window, and WebViewImpl::paint already // correctly handles the case where the compositor is active but // the output needs to go to a WebCanvas. - gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); + gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, + gfx::Size(1, 1)); if (!gl_surface_.get()) { if (!is_gles2_) return false; @@ -149,7 +150,8 @@ bool WebGraphicsContext3DInProcessImpl::initialize( // necessary. webView->mainFrame()->collectGarbage(); - gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); + gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, + gfx::Size(1, 1)); if (!gl_surface_.get()) return false; } |