OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 | 827 |
828 CleanupCompositorWindow(); | 828 CleanupCompositorWindow(); |
829 | 829 |
830 ResetTooltip(); | 830 ResetTooltip(); |
831 TrackMouseLeave(false); | 831 TrackMouseLeave(false); |
832 } | 832 } |
833 | 833 |
834 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { | 834 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { |
835 DCHECK(render_widget_host_->process()->HasConnection()); | 835 DCHECK(render_widget_host_->process()->HasConnection()); |
836 | 836 |
837 // If the GPU process is rendering directly into the View, | 837 // If the GPU process is rendering directly into the View, compositing is |
838 // call the compositor directly. | 838 // already triggered by damage to compositor_host_window_, so all we need to |
839 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); | 839 // do here is clear borders during resize. |
840 if (render_widget_host->is_accelerated_compositing_active()) { | 840 if (render_widget_host_ && |
841 render_widget_host_->is_accelerated_compositing_active()) { | |
841 // We initialize paint_dc here so that BeginPaint()/EndPaint() | 842 // We initialize paint_dc here so that BeginPaint()/EndPaint() |
842 // get called to validate the region. | 843 // get called to validate the region. |
843 CPaintDC paint_dc(m_hWnd); | 844 CPaintDC paint_dc(m_hWnd); |
844 render_widget_host_->ScheduleComposite(); | 845 RECT host_rect, child_rect; |
846 GetClientRect(&host_rect); | |
847 if (::GetClientRect(compositor_host_window_, &child_rect) && | |
848 (child_rect.right < host_rect.right || | |
849 child_rect.bottom < host_rect.bottom)) { | |
850 paint_dc.FillRect(&host_rect, | |
851 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); | |
852 } | |
845 return; | 853 return; |
846 } | 854 } |
847 | 855 |
848 about_to_validate_and_paint_ = true; | 856 about_to_validate_and_paint_ = true; |
849 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( | 857 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( |
850 render_widget_host_->GetBackingStore(true)); | 858 render_widget_host_->GetBackingStore(true)); |
851 | 859 |
852 // We initialize |paint_dc| (and thus call BeginPaint()) after calling | 860 // We initialize |paint_dc| (and thus call BeginPaint()) after calling |
853 // GetBackingStore(), so that if it updates the invalid rect we'll catch the | 861 // GetBackingStore(), so that if it updates the invalid rect we'll catch the |
854 // changes and repaint them. | 862 // changes and repaint them. |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1472 // If it was our RenderProcessHost that posted the notification, | 1480 // If it was our RenderProcessHost that posted the notification, |
1473 // clear the BrowserAccessibilityManager, because the renderer is | 1481 // clear the BrowserAccessibilityManager, because the renderer is |
1474 // dead and any accessibility information we have is now stale. | 1482 // dead and any accessibility information we have is now stale. |
1475 browser_accessibility_manager_.reset(NULL); | 1483 browser_accessibility_manager_.reset(NULL); |
1476 } | 1484 } |
1477 | 1485 |
1478 static void PaintCompositorHostWindow(HWND hWnd) { | 1486 static void PaintCompositorHostWindow(HWND hWnd) { |
1479 PAINTSTRUCT paint; | 1487 PAINTSTRUCT paint; |
1480 BeginPaint(hWnd, &paint); | 1488 BeginPaint(hWnd, &paint); |
1481 | 1489 |
1490 RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>( | |
1491 ui::GetWindowUserData(hWnd)); | |
Ben Goodger (Google)
2011/05/27 19:22:27
quick nit: hwnd instead of hWnd.
| |
1492 // Trigger composite to rerender window. | |
1493 if (win) | |
1494 win->ScheduleComposite(); | |
1495 | |
1482 EndPaint(hWnd, &paint); | 1496 EndPaint(hWnd, &paint); |
1483 } | 1497 } |
1484 | 1498 |
1485 // WndProc for the compositor host window. We use this instead of Default so | 1499 // WndProc for the compositor host window. We use this instead of Default so |
1486 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor. | 1500 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor. |
1487 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, | 1501 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, |
1488 WPARAM wParam, LPARAM lParam) { | 1502 WPARAM wParam, LPARAM lParam) { |
1489 switch (message) { | 1503 switch (message) { |
1490 case WM_ERASEBKGND: | 1504 case WM_ERASEBKGND: |
1491 return 0; | 1505 return 0; |
1492 case WM_DESTROY: | 1506 case WM_DESTROY: |
1493 return 0; | 1507 return 0; |
1494 case WM_PAINT: | 1508 case WM_PAINT: |
1495 PaintCompositorHostWindow(hWnd); | 1509 PaintCompositorHostWindow(hWnd); |
1496 return 0; | 1510 return 0; |
1497 default: | 1511 default: |
1498 return DefWindowProc(hWnd, message, wParam, lParam); | 1512 return DefWindowProc(hWnd, message, wParam, lParam); |
1499 } | 1513 } |
1500 } | 1514 } |
1501 | 1515 |
1516 void RenderWidgetHostViewWin::ScheduleComposite() { | |
1517 if (render_widget_host_) | |
1518 render_widget_host_->ScheduleComposite(); | |
1519 } | |
1520 | |
1502 // Creates a HWND within the RenderWidgetHostView that will serve as a host | 1521 // Creates a HWND within the RenderWidgetHostView that will serve as a host |
1503 // for a HWND that the GPU process will create. The host window is used | 1522 // for a HWND that the GPU process will create. The host window is used |
1504 // to Z-position the GPU's window relative to other plugin windows. | 1523 // to Z-position the GPU's window relative to other plugin windows. |
1505 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { | 1524 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
1506 // If the window has been created, don't recreate it a second time | 1525 // If the window has been created, don't recreate it a second time |
1507 if (compositor_host_window_) | 1526 if (compositor_host_window_) |
1508 return compositor_host_window_; | 1527 return compositor_host_window_; |
1509 | 1528 |
1510 static ATOM window_class = 0; | 1529 static ATOM window_class = 0; |
1511 if (!window_class) { | 1530 if (!window_class) { |
(...skipping 20 matching lines...) Expand all Loading... | |
1532 int width = currentRect.right - currentRect.left; | 1551 int width = currentRect.right - currentRect.left; |
1533 int height = currentRect.bottom - currentRect.top; | 1552 int height = currentRect.bottom - currentRect.top; |
1534 | 1553 |
1535 compositor_host_window_ = CreateWindowEx( | 1554 compositor_host_window_ = CreateWindowEx( |
1536 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, | 1555 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
1537 MAKEINTATOM(window_class), 0, | 1556 MAKEINTATOM(window_class), 0, |
1538 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, | 1557 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, |
1539 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0); | 1558 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0); |
1540 ui::CheckWindowCreated(compositor_host_window_); | 1559 ui::CheckWindowCreated(compositor_host_window_); |
1541 | 1560 |
1561 ui::SetWindowUserData(compositor_host_window_, this); | |
1562 | |
1542 return static_cast<gfx::PluginWindowHandle>(compositor_host_window_); | 1563 return static_cast<gfx::PluginWindowHandle>(compositor_host_window_); |
1543 } | 1564 } |
1544 | 1565 |
1545 void RenderWidgetHostViewWin::ShowCompositorHostWindow(bool show) { | 1566 void RenderWidgetHostViewWin::ShowCompositorHostWindow(bool show) { |
1546 // When we first create the compositor, we will get a show request from | 1567 // When we first create the compositor, we will get a show request from |
1547 // the renderer before we have gotten the create request from the GPU. In this | 1568 // the renderer before we have gotten the create request from the GPU. In this |
1548 // case, simply ignore the show request. | 1569 // case, simply ignore the show request. |
1549 if (compositor_host_window_ == NULL) | 1570 if (compositor_host_window_ == NULL) |
1550 return; | 1571 return; |
1551 | 1572 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1776 } | 1797 } |
1777 | 1798 |
1778 // static | 1799 // static |
1779 RenderWidgetHostView* | 1800 RenderWidgetHostView* |
1780 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1801 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1781 gfx::NativeView native_view) { | 1802 gfx::NativeView native_view) { |
1782 return ::IsWindow(native_view) ? | 1803 return ::IsWindow(native_view) ? |
1783 reinterpret_cast<RenderWidgetHostView*>( | 1804 reinterpret_cast<RenderWidgetHostView*>( |
1784 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; | 1805 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; |
1785 } | 1806 } |
OLD | NEW |