OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <InputScope.h> | 8 #include <InputScope.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 // everything again when we become selected again. | 479 // everything again when we become selected again. |
480 is_hidden_ = true; | 480 is_hidden_ = true; |
481 | 481 |
482 ResetTooltip(); | 482 ResetTooltip(); |
483 | 483 |
484 // If we have a renderer, then inform it that we are being hidden so it can | 484 // If we have a renderer, then inform it that we are being hidden so it can |
485 // reduce its resource utilization. | 485 // reduce its resource utilization. |
486 if (render_widget_host_) | 486 if (render_widget_host_) |
487 render_widget_host_->WasHidden(); | 487 render_widget_host_->WasHidden(); |
488 | 488 |
489 if (accelerated_surface_.get()) | 489 if (accelerated_surface_) |
490 accelerated_surface_->WasHidden(); | 490 accelerated_surface_->WasHidden(); |
491 | 491 |
492 if (GetBrowserAccessibilityManager()) | 492 if (GetBrowserAccessibilityManager()) |
493 GetBrowserAccessibilityManager()->WasHidden(); | 493 GetBrowserAccessibilityManager()->WasHidden(); |
494 } | 494 } |
495 | 495 |
496 void RenderWidgetHostViewWin::SetSize(const gfx::Size& size) { | 496 void RenderWidgetHostViewWin::SetSize(const gfx::Size& size) { |
497 SetBounds(gfx::Rect(GetPixelBounds().origin(), size)); | 497 SetBounds(gfx::Rect(GetPixelBounds().origin(), size)); |
498 } | 498 } |
499 | 499 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 const gfx::Size& size) { | 854 const gfx::Size& size) { |
855 return new BackingStoreWin(render_widget_host_, size); | 855 return new BackingStoreWin(render_widget_host_, size); |
856 } | 856 } |
857 | 857 |
858 void RenderWidgetHostViewWin::CopyFromCompositingSurface( | 858 void RenderWidgetHostViewWin::CopyFromCompositingSurface( |
859 const gfx::Rect& src_subrect, | 859 const gfx::Rect& src_subrect, |
860 const gfx::Size& dst_size, | 860 const gfx::Size& dst_size, |
861 const base::Callback<void(bool, const SkBitmap&)>& callback) { | 861 const base::Callback<void(bool, const SkBitmap&)>& callback) { |
862 base::ScopedClosureRunner scoped_callback_runner( | 862 base::ScopedClosureRunner scoped_callback_runner( |
863 base::Bind(callback, false, SkBitmap())); | 863 base::Bind(callback, false, SkBitmap())); |
864 if (!accelerated_surface_.get()) | 864 if (!accelerated_surface_) |
865 return; | 865 return; |
866 | 866 |
867 if (dst_size.IsEmpty() || src_subrect.IsEmpty()) | 867 if (dst_size.IsEmpty() || src_subrect.IsEmpty()) |
868 return; | 868 return; |
869 | 869 |
870 scoped_callback_runner.Release(); | 870 scoped_callback_runner.Release(); |
871 accelerated_surface_->AsyncCopyTo(src_subrect, dst_size, callback); | 871 accelerated_surface_->AsyncCopyTo(src_subrect, dst_size, callback); |
872 } | 872 } |
873 | 873 |
874 void RenderWidgetHostViewWin::CopyFromCompositingSurfaceToVideoFrame( | 874 void RenderWidgetHostViewWin::CopyFromCompositingSurfaceToVideoFrame( |
875 const gfx::Rect& src_subrect, | 875 const gfx::Rect& src_subrect, |
876 const scoped_refptr<media::VideoFrame>& target, | 876 const scoped_refptr<media::VideoFrame>& target, |
877 const base::Callback<void(bool)>& callback) { | 877 const base::Callback<void(bool)>& callback) { |
878 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); | 878 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); |
879 if (!accelerated_surface_.get()) | 879 if (!accelerated_surface_) |
880 return; | 880 return; |
881 | 881 |
882 if (!target || target->format() != media::VideoFrame::YV12) | 882 if (!target || target->format() != media::VideoFrame::YV12) |
883 return; | 883 return; |
884 | 884 |
885 if (src_subrect.IsEmpty()) | 885 if (src_subrect.IsEmpty()) |
886 return; | 886 return; |
887 | 887 |
888 scoped_callback_runner.Release(); | 888 scoped_callback_runner.Release(); |
889 accelerated_surface_->AsyncCopyToVideoFrame(src_subrect, target, callback); | 889 accelerated_surface_->AsyncCopyToVideoFrame(src_subrect, target, callback); |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 PaintCompositorHostWindow(hWnd); | 2417 PaintCompositorHostWindow(hWnd); |
2418 return 0; | 2418 return 0; |
2419 default: | 2419 default: |
2420 return DefWindowProc(hWnd, message, wParam, lParam); | 2420 return DefWindowProc(hWnd, message, wParam, lParam); |
2421 } | 2421 } |
2422 } | 2422 } |
2423 | 2423 |
2424 void RenderWidgetHostViewWin::AcceleratedPaint(HDC dc) { | 2424 void RenderWidgetHostViewWin::AcceleratedPaint(HDC dc) { |
2425 if (render_widget_host_) | 2425 if (render_widget_host_) |
2426 render_widget_host_->ScheduleComposite(); | 2426 render_widget_host_->ScheduleComposite(); |
2427 if (accelerated_surface_.get()) | 2427 if (accelerated_surface_) |
2428 accelerated_surface_->Present(dc); | 2428 accelerated_surface_->Present(dc); |
2429 } | 2429 } |
2430 | 2430 |
2431 void RenderWidgetHostViewWin::GetScreenInfo(WebKit::WebScreenInfo* results) { | 2431 void RenderWidgetHostViewWin::GetScreenInfo(WebKit::WebScreenInfo* results) { |
2432 GetScreenInfoForWindow(results, GetNativeViewId()); | 2432 GetScreenInfoForWindow(results, GetNativeViewId()); |
2433 } | 2433 } |
2434 | 2434 |
2435 gfx::Rect RenderWidgetHostViewWin::GetBoundsInRootWindow() { | 2435 gfx::Rect RenderWidgetHostViewWin::GetBoundsInRootWindow() { |
2436 RECT window_rect = {0}; | 2436 RECT window_rect = {0}; |
2437 HWND root_window = GetAncestor(m_hWnd, GA_ROOT); | 2437 HWND root_window = GetAncestor(m_hWnd, GA_ROOT); |
(...skipping 16 matching lines...) Expand all Loading... |
2454 // for a HWND that the GPU process will create. The host window is used | 2454 // for a HWND that the GPU process will create. The host window is used |
2455 // to Z-position the GPU's window relative to other plugin windows. | 2455 // to Z-position the GPU's window relative to other plugin windows. |
2456 gfx::GLSurfaceHandle RenderWidgetHostViewWin::GetCompositingSurface() { | 2456 gfx::GLSurfaceHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
2457 // If the window has been created, don't recreate it a second time | 2457 // If the window has been created, don't recreate it a second time |
2458 if (compositor_host_window_) | 2458 if (compositor_host_window_) |
2459 return gfx::GLSurfaceHandle(compositor_host_window_, gfx::NATIVE_TRANSPORT); | 2459 return gfx::GLSurfaceHandle(compositor_host_window_, gfx::NATIVE_TRANSPORT); |
2460 | 2460 |
2461 // On Vista and later we present directly to the view window rather than a | 2461 // On Vista and later we present directly to the view window rather than a |
2462 // child window. | 2462 // child window. |
2463 if (GpuDataManagerImpl::GetInstance()->IsUsingAcceleratedSurface()) { | 2463 if (GpuDataManagerImpl::GetInstance()->IsUsingAcceleratedSurface()) { |
2464 if (!accelerated_surface_.get()) | 2464 if (!accelerated_surface_) |
2465 accelerated_surface_.reset(new AcceleratedSurface(m_hWnd)); | 2465 accelerated_surface_.reset(new AcceleratedSurface(m_hWnd)); |
2466 return gfx::GLSurfaceHandle(m_hWnd, gfx::NATIVE_TRANSPORT); | 2466 return gfx::GLSurfaceHandle(m_hWnd, gfx::NATIVE_TRANSPORT); |
2467 } | 2467 } |
2468 | 2468 |
2469 // On XP we need a child window that can be resized independently of the | 2469 // On XP we need a child window that can be resized independently of the |
2470 // parent. | 2470 // parent. |
2471 static ATOM atom = 0; | 2471 static ATOM atom = 0; |
2472 static HMODULE instance = NULL; | 2472 static HMODULE instance = NULL; |
2473 if (!atom) { | 2473 if (!atom) { |
2474 WNDCLASSEX window_class; | 2474 WNDCLASSEX window_class; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 next = plugin_windows[i+1]; | 2544 next = plugin_windows[i+1]; |
2545 else | 2545 else |
2546 next = compositor_host_window_; | 2546 next = compositor_host_window_; |
2547 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, | 2547 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, |
2548 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); | 2548 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); |
2549 } | 2549 } |
2550 } else { | 2550 } else { |
2551 // Drop the backing store for the accelerated surface when the accelerated | 2551 // Drop the backing store for the accelerated surface when the accelerated |
2552 // compositor is disabled. Otherwise, a flash of the last presented frame | 2552 // compositor is disabled. Otherwise, a flash of the last presented frame |
2553 // could appear when it is next enabled. | 2553 // could appear when it is next enabled. |
2554 if (accelerated_surface_.get()) | 2554 if (accelerated_surface_) |
2555 accelerated_surface_->Suspend(); | 2555 accelerated_surface_->Suspend(); |
2556 hide_compositor_window_at_next_paint_ = true; | 2556 hide_compositor_window_at_next_paint_ = true; |
2557 } | 2557 } |
2558 } | 2558 } |
2559 | 2559 |
2560 void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( | 2560 void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( |
2561 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 2561 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
2562 int gpu_host_id) { | 2562 int gpu_host_id) { |
2563 NOTREACHED(); | 2563 NOTREACHED(); |
2564 } | 2564 } |
2565 | 2565 |
2566 void RenderWidgetHostViewWin::AcceleratedSurfacePostSubBuffer( | 2566 void RenderWidgetHostViewWin::AcceleratedSurfacePostSubBuffer( |
2567 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 2567 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
2568 int gpu_host_id) { | 2568 int gpu_host_id) { |
2569 NOTREACHED(); | 2569 NOTREACHED(); |
2570 } | 2570 } |
2571 | 2571 |
2572 void RenderWidgetHostViewWin::AcceleratedSurfaceSuspend() { | 2572 void RenderWidgetHostViewWin::AcceleratedSurfaceSuspend() { |
2573 if (!accelerated_surface_.get()) | 2573 if (!accelerated_surface_) |
2574 return; | 2574 return; |
2575 | 2575 |
2576 accelerated_surface_->Suspend(); | 2576 accelerated_surface_->Suspend(); |
2577 } | 2577 } |
2578 | 2578 |
2579 void RenderWidgetHostViewWin::AcceleratedSurfaceRelease() { | 2579 void RenderWidgetHostViewWin::AcceleratedSurfaceRelease() { |
2580 } | 2580 } |
2581 | 2581 |
2582 bool RenderWidgetHostViewWin::HasAcceleratedSurface( | 2582 bool RenderWidgetHostViewWin::HasAcceleratedSurface( |
2583 const gfx::Size& desired_size) { | 2583 const gfx::Size& desired_size) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2701 delete this; | 2701 delete this; |
2702 } | 2702 } |
2703 | 2703 |
2704 LRESULT RenderWidgetHostViewWin::OnSessionChange(UINT message, | 2704 LRESULT RenderWidgetHostViewWin::OnSessionChange(UINT message, |
2705 WPARAM wparam, | 2705 WPARAM wparam, |
2706 LPARAM lparam, | 2706 LPARAM lparam, |
2707 BOOL& handled) { | 2707 BOOL& handled) { |
2708 handled = FALSE; | 2708 handled = FALSE; |
2709 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnSessionChange"); | 2709 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnSessionChange"); |
2710 | 2710 |
2711 if (!accelerated_surface_.get()) | 2711 if (!accelerated_surface_) |
2712 return 0; | 2712 return 0; |
2713 | 2713 |
2714 switch (wparam) { | 2714 switch (wparam) { |
2715 case WTS_SESSION_LOCK: | 2715 case WTS_SESSION_LOCK: |
2716 accelerated_surface_->SetIsSessionLocked(true); | 2716 accelerated_surface_->SetIsSessionLocked(true); |
2717 break; | 2717 break; |
2718 case WTS_SESSION_UNLOCK: | 2718 case WTS_SESSION_UNLOCK: |
2719 // Force a repaint to update the window contents. | 2719 // Force a repaint to update the window contents. |
2720 if (!is_hidden_) | 2720 if (!is_hidden_) |
2721 InvalidateRect(NULL, FALSE); | 2721 InvalidateRect(NULL, FALSE); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3133 return new RenderWidgetHostViewWin(widget); | 3133 return new RenderWidgetHostViewWin(widget); |
3134 } | 3134 } |
3135 | 3135 |
3136 // static | 3136 // static |
3137 void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 3137 void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
3138 WebKit::WebScreenInfo* results) { | 3138 WebKit::WebScreenInfo* results) { |
3139 GetScreenInfoForWindow(results, 0); | 3139 GetScreenInfoForWindow(results, 0); |
3140 } | 3140 } |
3141 | 3141 |
3142 } // namespace content | 3142 } // namespace content |
OLD | NEW |