diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 01:37:31 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-06 01:37:31 +0000 |
commit | 111975c6ed2caac665ed17f876f86536af6c3d2f (patch) | |
tree | 80512760fdaffd6354b8152104686095d3d73148 | |
parent | 07ed535b5f4250e2030cd169fb1e9de050eea07e (diff) | |
download | chromium_src-111975c6ed2caac665ed17f876f86536af6c3d2f.zip chromium_src-111975c6ed2caac665ed17f876f86536af6c3d2f.tar.gz chromium_src-111975c6ed2caac665ed17f876f86536af6c3d2f.tar.bz2 |
Enable GPU acceleration for Aura on Windows
Use GpuTransportSurface and AcceleratedSurface for rendering on win aura.
Run with:
--open-ash --force-compositing-mode --enable-threaded-compositing
BUG=
Review URL: https://chromiumcodereview.appspot.com/10890046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155093 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 31 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.h | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/image_transport_factory.cc | 21 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface_win.cc | 58 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 6 | ||||
-rw-r--r-- | ui/surface/accelerated_surface_win.cc | 24 | ||||
-rw-r--r-- | ui/surface/accelerated_surface_win.h | 8 | ||||
-rw-r--r-- | ui/surface/surface.gyp | 8 |
8 files changed, 105 insertions, 54 deletions
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index 776ea00..e112bd9 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -42,7 +42,7 @@ #include "ui/gfx/gtk_native_view_id_manager.h" #endif -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) #include "ui/surface/accelerated_surface_win.h" #endif @@ -478,7 +478,7 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, OnAcceleratedSurfaceBuffersSwapped) #endif -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, OnAcceleratedSurfaceBuffersSwapped) IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, @@ -661,7 +661,7 @@ void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( } #endif // OS_MACOSX -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { @@ -674,12 +674,20 @@ void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( gfx::PluginWindowHandle handle = GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); + if (!handle) { - TRACE_EVENT1("gpu", "EarlyOut_SurfaceIDNotFound", + TRACE_EVENT1("gpu", "SurfaceIDNotFound_RoutingToUI", "surface_id", params.surface_id); +#if defined(USE_AURA) + // This is a content area swap, send it on to the UI thread. + scoped_completion_runner.Release(); + RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); +#endif return; } + // Otherwise it's the UI swap. + scoped_refptr<AcceleratedPresenter> presenter( AcceleratedPresenter::GetForWindow(handle)); if (!presenter) { @@ -709,8 +717,13 @@ void GpuProcessHost::OnAcceleratedSurfaceSuspend(int32 surface_id) { gfx::PluginWindowHandle handle = GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(surface_id); - if (!handle) + + if (!handle) { +#if defined(USE_AURA) + RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceSuspend(surface_id)); +#endif return; + } scoped_refptr<AcceleratedPresenter> presenter( AcceleratedPresenter::GetForWindow(handle)); @@ -726,8 +739,12 @@ void GpuProcessHost::OnAcceleratedSurfaceRelease( gfx::PluginWindowHandle handle = GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); - if (!handle) + if (!handle) { +#if defined(USE_AURA) + RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceRelease(params)); return; +#endif + } scoped_refptr<AcceleratedPresenter> presenter( AcceleratedPresenter::GetForWindow(handle)); @@ -737,7 +754,7 @@ void GpuProcessHost::OnAcceleratedSurfaceRelease( presenter->ReleaseSurface(); } -#endif // OS_WIN && !USE_AURA +#endif // OS_WIN void GpuProcessHost::OnProcessLaunched() { UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index 3e26692..f4b8341 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -125,7 +125,8 @@ class GpuProcessHost : public content::BrowserChildProcessHostDelegate, void OnAcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); #endif -#if defined(OS_WIN) && !defined(USE_AURA) + // Note: Different implementations depending on USE_AURA. +#if defined(OS_WIN) void OnAcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); void OnAcceleratedSurfacePostSubBuffer( diff --git a/content/browser/renderer_host/image_transport_factory.cc b/content/browser/renderer_host/image_transport_factory.cc index b7e4192..8430354 100644 --- a/content/browser/renderer_host/image_transport_factory.cc +++ b/content/browser/renderer_host/image_transport_factory.cc @@ -12,6 +12,7 @@ #include "base/memory/ref_counted.h" #include "base/observer_list.h" #include "content/browser/gpu/browser_gpu_channel_host_factory.h" +#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_surface_tracker.h" #include "content/common/gpu/client/gl_helper.h" #include "content/common/gpu/client/gpu_channel_host.h" @@ -27,6 +28,10 @@ #include "ui/gfx/native_widget_types.h" #include "ui/gfx/size.h" +#if defined(OS_WIN) +#include "ui/surface/accelerated_surface_win.h" +#endif + using content::BrowserGpuChannelHostFactory; using content::GLHelper; @@ -287,6 +292,9 @@ class GpuProcessTransportFactory : struct PerCompositorData { int surface_id; scoped_ptr<CompositorSwapClient> swap_client; +#if defined(OS_WIN) + scoped_ptr<AcceleratedSurface> accelerated_surface; +#endif }; PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor) { @@ -300,9 +308,18 @@ class GpuProcessTransportFactory : PerCompositorData* data = new PerCompositorData; data->surface_id = tracker->AddSurfaceForNativeWidget(widget); data->swap_client.reset(new CompositorSwapClient(compositor, this)); +#if defined(OS_WIN) + if (GpuDataManagerImpl::GetInstance()->IsUsingAcceleratedSurface()) + data->accelerated_surface.reset(new AcceleratedSurface(widget)); + tracker->SetSurfaceHandle( + data->surface_id, + gfx::GLSurfaceHandle(widget, true)); +#else tracker->SetSurfaceHandle( data->surface_id, gfx::GLSurfaceHandle(widget, false)); +#endif + per_compositor_data_[compositor] = data; return data; @@ -397,11 +414,7 @@ void ImageTransportFactory::Initialize() { content::WebKitPlatformSupportImpl::SetOffscreenContextFactoryForTest( CreateTestContext); } else { -#if defined(OS_WIN) - g_factory = new DefaultTransportFactory(); -#else g_factory = new GpuProcessTransportFactory(); -#endif } ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); } diff --git a/content/common/gpu/image_transport_surface_win.cc b/content/common/gpu/image_transport_surface_win.cc index a5f731a..9777e272 100644 --- a/content/common/gpu/image_transport_surface_win.cc +++ b/content/common/gpu/image_transport_surface_win.cc @@ -6,6 +6,9 @@ #include "content/common/gpu/image_transport_surface.h" +// Out of order because it has conflicts with other includes on Windows. +#include "third_party/angle/include/EGL/egl.h" + #include "base/bind.h" #include "base/command_line.h" #include "base/compiler_specific.h" @@ -14,7 +17,7 @@ #include "base/win/windows_version.h" #include "content/common/gpu/gpu_messages.h" #include "content/public/common/content_switches.h" -#include "third_party/angle/include/EGL/egl.h" +#include "content/common/gpu/texture_image_transport_surface.h" #include "ui/gfx/native_widget_types.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context.h" @@ -236,27 +239,44 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( const gfx::GLSurfaceHandle& handle) { scoped_refptr<gfx::GLSurface> surface; - if (handle.transport && - gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && - !CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableImageTransportSurface)) { - const char* extensions = eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), - EGL_EXTENSIONS); - if (strstr(extensions, "EGL_ANGLE_query_surface_pointer") && - strstr(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle")) { - surface = new PbufferImageTransportSurface(manager, stub); + if (!handle.handle) { + // If we don't have a valid handle with the transport flag set, then we're + // coming from a renderer and we want to render the webpage contents to a + // texture. + DCHECK(handle.transport); + DCHECK(handle.parent_client_id); + surface = new TextureImageTransportSurface(manager, stub, handle); + } else { + if (handle.transport && + gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableImageTransportSurface)) { + // This path handles two different cases. + // + // For post-Vista regular Windows, this surface will be used for + // renderer compositors. + // + // For Aura Windows, this will be the surface for the browser compositor + // (and the renderer compositors surface's will be + // TextureImageTransportSurface above). + const char* extensions = eglQueryString( + eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_EXTENSIONS); + if (strstr(extensions, "EGL_ANGLE_query_surface_pointer") && + strstr(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle")) { + surface = new PbufferImageTransportSurface(manager, stub); + } } - } - if (!surface.get()) { - surface = gfx::GLSurface::CreateViewGLSurface(false, handle.handle); - if (!surface.get()) - return NULL; + if (!surface.get()) { + surface = gfx::GLSurface::CreateViewGLSurface(false, handle.handle); + if (!surface.get()) + return NULL; - surface = new PassThroughImageTransportSurface(manager, - stub, - surface.get(), - handle.transport); + surface = new PassThroughImageTransportSurface(manager, + stub, + surface.get(), + handle.transport); + } } if (surface->Initialize()) diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 8dbb2ff..33381c5 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -8269,6 +8269,8 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers( // If offscreen then don't actually SwapBuffers to the display. Just copy // the rendered frame to another frame buffer. if (is_offscreen) { + TRACE_EVENT2("gpu", "Offscreen", + "width", offscreen_size_.width(), "height", offscreen_size_.height()); if (offscreen_size_ != offscreen_saved_color_texture_->size()) { // Workaround for NVIDIA driver bug on OS X; crbug.com/89557, // crbug.com/94163. TODO(kbr): figure out reproduction so Apple will @@ -8342,7 +8344,9 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers( return error::kNoError; } } else { - TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number); + TRACE_EVENT2("gpu", "Onscreen", + "width", surface_->GetSize().width(), + "height", surface_->GetSize().height()); if (!surface_->SwapBuffers()) { LOG(ERROR) << "Context lost because SwapBuffers failed."; return error::kLostContext; diff --git a/ui/surface/accelerated_surface_win.cc b/ui/surface/accelerated_surface_win.cc index ff3affa..74b8aec 100644 --- a/ui/surface/accelerated_surface_win.cc +++ b/ui/surface/accelerated_surface_win.cc @@ -229,12 +229,14 @@ class PresentThreadPool { class AcceleratedPresenterMap { public: AcceleratedPresenterMap(); - scoped_refptr<AcceleratedPresenter> CreatePresenter(gfx::NativeWindow window); + scoped_refptr<AcceleratedPresenter> CreatePresenter( + gfx::PluginWindowHandle window); void RemovePresenter(const scoped_refptr<AcceleratedPresenter>& presenter); - scoped_refptr<AcceleratedPresenter> GetPresenter(gfx::NativeWindow window); + scoped_refptr<AcceleratedPresenter> GetPresenter( + gfx::PluginWindowHandle window); private: base::Lock lock_; - typedef std::map<gfx::NativeWindow, AcceleratedPresenter*> PresenterMap; + typedef std::map<gfx::PluginWindowHandle, AcceleratedPresenter*> PresenterMap; PresenterMap presenters_; DISALLOW_COPY_AND_ASSIGN(AcceleratedPresenterMap); }; @@ -381,7 +383,7 @@ AcceleratedPresenterMap::AcceleratedPresenterMap() { } scoped_refptr<AcceleratedPresenter> AcceleratedPresenterMap::CreatePresenter( - gfx::NativeWindow window) { + gfx::PluginWindowHandle window) { scoped_refptr<AcceleratedPresenter> presenter( new AcceleratedPresenter(window)); @@ -408,7 +410,7 @@ void AcceleratedPresenterMap::RemovePresenter( } scoped_refptr<AcceleratedPresenter> AcceleratedPresenterMap::GetPresenter( - gfx::NativeWindow window) { + gfx::PluginWindowHandle window) { base::AutoLock locked(lock_); PresenterMap::iterator it = presenters_.find(window); if (it == presenters_.end()) @@ -417,7 +419,7 @@ scoped_refptr<AcceleratedPresenter> AcceleratedPresenterMap::GetPresenter( return it->second; } -AcceleratedPresenter::AcceleratedPresenter(gfx::NativeWindow window) +AcceleratedPresenter::AcceleratedPresenter(gfx::PluginWindowHandle window) : present_thread_(g_present_thread_pool.Pointer()->NextThread()), window_(window), event_(false, false), @@ -425,7 +427,7 @@ AcceleratedPresenter::AcceleratedPresenter(gfx::NativeWindow window) } scoped_refptr<AcceleratedPresenter> AcceleratedPresenter::GetForWindow( - gfx::NativeWindow window) { + gfx::PluginWindowHandle window) { return g_accelerated_presenter_map.Pointer()->GetPresenter(window); } @@ -676,8 +678,10 @@ void AcceleratedPresenter::DoPresentAndAcknowledge( const gfx::Size& size, int64 surface_handle, const CompletionTask& completion_task) { - TRACE_EVENT1( - "gpu", "DoPresentAndAcknowledge", "surface_handle", surface_handle); + TRACE_EVENT2( + "gpu", "DoPresentAndAcknowledge", + "width", size.width(), + "height", size.height()); HRESULT hr; @@ -920,7 +924,7 @@ bool AcceleratedPresenter::GetPresentationStats(base::TimeTicks* timebase, return true; } -AcceleratedSurface::AcceleratedSurface(gfx::NativeWindow window) +AcceleratedSurface::AcceleratedSurface(gfx::PluginWindowHandle window) : presenter_(g_accelerated_presenter_map.Pointer()->CreatePresenter( window)) { } diff --git a/ui/surface/accelerated_surface_win.h b/ui/surface/accelerated_surface_win.h index 6a19e81..1256909 100644 --- a/ui/surface/accelerated_surface_win.h +++ b/ui/surface/accelerated_surface_win.h @@ -29,13 +29,13 @@ class SURFACE_EXPORT AcceleratedPresenter base::TimeTicks, base::TimeDelta)> CompletionTask; - explicit AcceleratedPresenter(gfx::NativeWindow window); + explicit AcceleratedPresenter(gfx::PluginWindowHandle window); // Returns a thread safe reference to the presenter for the given window or // null is no such presenter exists. The thread safe refptr ensures the // presenter will not be destroyed. This can be called on any thread. static scoped_refptr<AcceleratedPresenter> GetForWindow( - gfx::NativeWindow window); + gfx::PluginWindowHandle window); // Schedule a frame to be presented. The completion callback will be invoked // when it is safe to write to the surface on another thread. The lock for @@ -96,7 +96,7 @@ class SURFACE_EXPORT AcceleratedPresenter PresentThread* const present_thread_; // The window that is presented to. - gfx::NativeWindow window_; + gfx::PluginWindowHandle window_; // The lock is taken while any thread is calling the object, except those that // simply post from the main thread to the present thread via the immutable @@ -130,7 +130,7 @@ class SURFACE_EXPORT AcceleratedPresenter class SURFACE_EXPORT AcceleratedSurface { public: - AcceleratedSurface(gfx::NativeWindow window); + AcceleratedSurface(gfx::PluginWindowHandle window); ~AcceleratedSurface(); // Synchronously present a frame with no acknowledgement. diff --git a/ui/surface/surface.gyp b/ui/surface/surface.gyp index 4858b54..80a70b4 100644 --- a/ui/surface/surface.gyp +++ b/ui/surface/surface.gyp @@ -44,14 +44,6 @@ 'defines': [ 'SURFACE_IMPLEMENTATION', ], - 'conditions': [ - ['use_aura==1', { - 'sources/': [ - ['exclude', 'accelerated_surface_win.cc'], - ['exclude', 'accelerated_surface_win.h'], - ], - }], - ], }, ], } |