Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_win.cc |
| =================================================================== |
| --- content/browser/renderer_host/render_widget_host_view_win.cc (revision 108480) |
| +++ content/browser/renderer_host/render_widget_host_view_win.cc (working copy) |
| @@ -6,6 +6,7 @@ |
| #include <algorithm> |
| +#include "base/bind.h" |
| #include "base/command_line.h" |
| #include "base/i18n/rtl.h" |
| #include "base/metrics/histogram.h" |
| @@ -19,11 +20,14 @@ |
| #include "content/browser/accessibility/browser_accessibility_manager.h" |
| #include "content/browser/accessibility/browser_accessibility_state.h" |
| #include "content/browser/accessibility/browser_accessibility_win.h" |
| +#include "content/browser/gpu/gpu_process_host.h" |
| +#include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| #include "content/browser/plugin_process_host.h" |
| #include "content/browser/renderer_host/backing_store.h" |
| #include "content/browser/renderer_host/backing_store_win.h" |
| #include "content/browser/renderer_host/render_process_host.h" |
| #include "content/browser/renderer_host/render_widget_host.h" |
| +#include "content/common/gpu/gpu_messages.h" |
| #include "content/common/plugin_messages.h" |
| #include "content/common/view_messages.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -54,6 +58,8 @@ |
| #include "webkit/plugins/npapi/webplugin.h" |
| #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| +#pragma comment(lib, "d3d9.lib") |
| + |
| using base::TimeDelta; |
| using base::TimeTicks; |
| using content::BrowserThread; |
| @@ -203,6 +209,21 @@ |
| return ::DefWindowProc(window, message, wparam, lparam); |
| } |
| +void SendToGpuProcessHost(int gpu_host_id, IPC::Message* message) { |
| + GpuProcessHost* gpu_process_host = GpuProcessHost::FromID(gpu_host_id); |
| + if (!gpu_process_host) { |
| + delete message; |
| + return; |
| + } |
| + |
| + gpu_process_host->Send(message); |
| +} |
| + |
|
jonathan.backer
2011/11/03 23:09:07
isn't this in gpu_process_host_ui_shim.cc?
apatrick_chromium
2011/11/07 20:40:04
That one sends to the GpuProcessHostUIShim rather
|
| +void PostTaskOnIOThread(const tracked_objects::Location& from_here, |
| + base::Closure task) { |
| + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task); |
| +} |
| + |
| bool DecodeZoomGesture(HWND hwnd, const GESTUREINFO& gi, |
| content::PageZoom* zoom, |
| POINT* zoom_center) { |
| @@ -324,6 +345,9 @@ |
| RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
| UnlockMouse(); |
| ResetTooltip(); |
| + |
| + if (accelerated_surface_) |
| + accelerated_surface_->Destroy(); |
| } |
| void RenderWidgetHostViewWin::CreateWnd(HWND parent) { |
| @@ -1750,8 +1774,14 @@ |
| } |
| void RenderWidgetHostViewWin::ScheduleComposite() { |
| - if (render_widget_host_) |
| - render_widget_host_->ScheduleComposite(); |
| + // If we have a previous frame then present it immediately. Otherwise request |
| + // a new frame be composited. |
| + if (accelerated_surface_.get()) { |
| + accelerated_surface_->Present(); |
| + } else { |
| + if (render_widget_host_) |
| + render_widget_host_->ScheduleComposite(); |
| + } |
| } |
| // Creates a HWND within the RenderWidgetHostView that will serve as a host |
| @@ -1846,6 +1876,27 @@ |
| } |
| } |
| +void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( |
| + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| + int gpu_host_id) { |
| + if (!accelerated_surface_.get() && compositor_host_window_) { |
| + accelerated_surface_ = new AcceleratedSurface(compositor_host_window_); |
| + accelerated_surface_->Initialize(); |
| + } |
| + |
| + base::Closure acknowledge_task = |
|
jonathan.backer
2011/11/03 23:09:07
Should be able to simplify with call to GpuProcess
apatrick_chromium
2011/11/07 20:40:04
This one's going direct to the IO thread.
|
| + base::Bind(SendToGpuProcessHost, |
| + gpu_host_id, |
| + new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); |
| + |
| + accelerated_surface_->AsyncPresentAndAcknowledge( |
| + params.size, |
| + params.surface_id, |
| + base::Bind(PostTaskOnIOThread, |
| + FROM_HERE, |
| + acknowledge_task)); |
| +} |
| + |
| void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { |
| if (!render_widget_host_) |
| return; |