Chromium Code Reviews| Index: chrome/browser/renderer_host/render_widget_host_view_win.cc |
| diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc |
| index 407bc1d3c418727a58f42e1a1e2d9563efeefa03..e8c35ceec0bfbb9e51fd325da3209e4e3b4b4ed9 100644 |
| --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc |
| +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc |
| @@ -70,6 +70,8 @@ const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; |
| namespace { |
| +const char* kRenderWidgetHVWPropStr = "RWHVW_P"; |
|
vangelis
2011/05/26 19:21:53
A quick look through the code indicates that we do
jbates
2011/05/26 20:14:47
Done.
|
| + |
| // Tooltips will wrap after this width. Yes, wrap. Imagine that! |
| const int kTooltipMaxWidthPixels = 300; |
| @@ -221,6 +223,7 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
| RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) |
| : render_widget_host_(widget), |
| compositor_host_window_(NULL), |
| + was_compositing_just_scheduled_(false), |
| hide_compositor_window_at_next_paint_(false), |
| track_mouse_leave_(false), |
| ime_notification_(false), |
| @@ -232,6 +235,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) |
| tooltip_hwnd_(NULL), |
| tooltip_showing_(false), |
| shutdown_factory_(this), |
| + method_factory_(this), |
| parent_hwnd_(NULL), |
| is_loading_(false), |
| overlay_color_(0), |
| @@ -839,7 +843,7 @@ void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { |
| // We initialize paint_dc here so that BeginPaint()/EndPaint() |
| // get called to validate the region. |
| CPaintDC paint_dc(m_hWnd); |
| - render_widget_host_->ScheduleComposite(); |
| + ScheduleCompositeIfNeeded(); |
| return; |
| } |
| @@ -1477,6 +1481,11 @@ static void PaintCompositorHostWindow(HWND hWnd) { |
| PAINTSTRUCT paint; |
| BeginPaint(hWnd, &paint); |
| + RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>( |
| + GetPropA(hWnd, kRenderWidgetHVWPropStr)); |
| + // May block unless parent window already did this. |
| + win->ScheduleCompositeIfNeeded(); |
| + |
| EndPaint(hWnd, &paint); |
| } |
| @@ -1488,6 +1497,7 @@ static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, |
| case WM_ERASEBKGND: |
| return 0; |
| case WM_DESTROY: |
| + RemovePropA(hWnd, kRenderWidgetHVWPropStr); |
| return 0; |
| case WM_PAINT: |
| PaintCompositorHostWindow(hWnd); |
| @@ -1497,6 +1507,22 @@ static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, |
| } |
| } |
| +void RenderWidgetHostViewWin::ScheduleCompositeIfNeeded() { |
| + // Call ScheduleComposite unless it has already occured during this set of |
| + // Windows events. |
| + if (!was_compositing_just_scheduled_) { |
| + was_compositing_just_scheduled_ = true; |
| + render_widget_host_->ScheduleComposite(); |
| + MessageLoop::current()->PostTask(FROM_HERE, |
| + method_factory_.NewRunnableMethod( |
| + &RenderWidgetHostViewWin::ResetWasCompositingJustCompleted)); |
| + } |
| +} |
| + |
| +void RenderWidgetHostViewWin::ResetWasCompositingJustCompleted() { |
|
vangelis
2011/05/26 19:21:53
Should be renamed to *JustScheduled for consistenc
jbates
2011/05/26 20:14:47
Done.
|
| + was_compositing_just_scheduled_ = false; |
| +} |
| + |
| // Creates a HWND within the RenderWidgetHostView that will serve as a host |
| // for a HWND that the GPU process will create. The host window is used |
| // to Z-position the GPU's window relative to other plugin windows. |
| @@ -1537,6 +1563,8 @@ gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
| 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0); |
| ui::CheckWindowCreated(compositor_host_window_); |
| + SetPropA(compositor_host_window_, kRenderWidgetHVWPropStr, this); |
| + |
| return static_cast<gfx::PluginWindowHandle>(compositor_host_window_); |
| } |