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_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "cc/compositor_frame.h" |
20 #include "content/browser/gpu/gpu_process_host.h" | 21 #include "content/browser/gpu/gpu_process_host.h" |
21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 22 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
22 #include "content/browser/gpu/gpu_surface_tracker.h" | 23 #include "content/browser/gpu/gpu_surface_tracker.h" |
23 #include "content/browser/renderer_host/backing_store.h" | 24 #include "content/browser/renderer_host/backing_store.h" |
24 #include "content/browser/renderer_host/backing_store_manager.h" | 25 #include "content/browser/renderer_host/backing_store_manager.h" |
25 #include "content/browser/renderer_host/gesture_event_filter.h" | 26 #include "content/browser/renderer_host/gesture_event_filter.h" |
26 #include "content/browser/renderer_host/overscroll_controller.h" | 27 #include "content/browser/renderer_host/overscroll_controller.h" |
27 #include "content/browser/renderer_host/render_process_host_impl.h" | 28 #include "content/browser/renderer_host/render_process_host_impl.h" |
28 #include "content/browser/renderer_host/render_view_host_impl.h" | 29 #include "content/browser/renderer_host/render_view_host_impl.h" |
29 #include "content/browser/renderer_host/render_widget_helper.h" | 30 #include "content/browser/renderer_host/render_widget_helper.h" |
(...skipping 17 matching lines...) Expand all Loading... |
47 #include "skia/ext/image_operations.h" | 48 #include "skia/ext/image_operations.h" |
48 #include "skia/ext/platform_canvas.h" | 49 #include "skia/ext/platform_canvas.h" |
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli
ne.h" |
50 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
51 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFact
ory.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFact
ory.h" |
52 #endif | 53 #endif |
53 #include "ui/base/events/event.h" | 54 #include "ui/base/events/event.h" |
54 #include "ui/base/keycodes/keyboard_codes.h" | 55 #include "ui/base/keycodes/keyboard_codes.h" |
55 #include "ui/gfx/size_conversions.h" | 56 #include "ui/gfx/size_conversions.h" |
56 #include "ui/gfx/skbitmap_operations.h" | 57 #include "ui/gfx/skbitmap_operations.h" |
| 58 #include "ui/gfx/vector2d_conversions.h" |
57 #include "webkit/glue/webcursor.h" | 59 #include "webkit/glue/webcursor.h" |
58 #include "webkit/glue/webpreferences.h" | 60 #include "webkit/glue/webpreferences.h" |
59 #include "webkit/plugins/npapi/webplugin.h" | 61 #include "webkit/plugins/npapi/webplugin.h" |
60 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 62 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
61 | 63 |
62 #if defined(TOOLKIT_GTK) | 64 #if defined(TOOLKIT_GTK) |
63 #include "content/browser/renderer_host/backing_store_gtk.h" | 65 #include "content/browser/renderer_host/backing_store_gtk.h" |
64 #elif defined(OS_MACOSX) | 66 #elif defined(OS_MACOSX) |
65 #include "content/browser/renderer_host/backing_store_mac.h" | 67 #include "content/browser/renderer_host/backing_store_mac.h" |
66 #endif | 68 #endif |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) | 326 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) |
325 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) | 327 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) |
326 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) | 328 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) |
327 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, | 329 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateScreenRects_ACK, |
328 OnMsgUpdateScreenRectsAck) | 330 OnMsgUpdateScreenRectsAck) |
329 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) | 331 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) |
330 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | 332 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) |
331 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck) | 333 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck) |
332 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, | 334 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, |
333 OnCompositorSurfaceBuffersSwapped) | 335 OnCompositorSurfaceBuffersSwapped) |
| 336 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapCompositorFrame, |
| 337 OnMsgSwapCompositorFrame) |
334 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect) | 338 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect) |
335 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnMsgUpdateIsDelayed) | 339 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnMsgUpdateIsDelayed) |
336 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck) | 340 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck) |
337 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginSmoothScroll, OnMsgBeginSmoothScroll) | 341 IPC_MESSAGE_HANDLER(ViewHostMsg_BeginSmoothScroll, OnMsgBeginSmoothScroll) |
338 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectRange_ACK, OnMsgSelectRangeAck) | 342 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectRange_ACK, OnMsgSelectRangeAck) |
339 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) | 343 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) |
340 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) | 344 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) |
341 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 345 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
342 OnMsgHasTouchEventHandlers) | 346 OnMsgHasTouchEventHandlers) |
343 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) | 347 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 #if defined(OS_MACOSX) | 1506 #if defined(OS_MACOSX) |
1503 // Compositor window is always gfx::kNullPluginWindow. | 1507 // Compositor window is always gfx::kNullPluginWindow. |
1504 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no | 1508 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no |
1505 // plugin windows. | 1509 // plugin windows. |
1506 gpu_params.window = gfx::kNullPluginWindow; | 1510 gpu_params.window = gfx::kNullPluginWindow; |
1507 #endif | 1511 #endif |
1508 view_->AcceleratedSurfaceBuffersSwapped(gpu_params, | 1512 view_->AcceleratedSurfaceBuffersSwapped(gpu_params, |
1509 gpu_process_host_id); | 1513 gpu_process_host_id); |
1510 } | 1514 } |
1511 | 1515 |
| 1516 void RenderWidgetHostImpl::OnMsgSwapCompositorFrame( |
| 1517 const cc::CompositorFrame& frame) { |
| 1518 #if defined(OS_ANDROID) |
| 1519 gfx::Vector2dF scroll_offset = ScaleVector2d( |
| 1520 frame.metadata.root_scroll_offset, frame.metadata.page_scale_factor); |
| 1521 gfx::SizeF content_size = ScaleSize( |
| 1522 frame.metadata.root_layer_size, frame.metadata.page_scale_factor); |
| 1523 |
| 1524 if (view_) { |
| 1525 view_->UpdateFrameInfo( |
| 1526 gfx::ToRoundedVector2d(scroll_offset), |
| 1527 frame.metadata.page_scale_factor, |
| 1528 frame.metadata.min_page_scale_factor, |
| 1529 frame.metadata.max_page_scale_factor, |
| 1530 gfx::ToCeiledSize(content_size)); |
| 1531 } |
| 1532 #endif |
| 1533 } |
| 1534 |
1512 void RenderWidgetHostImpl::OnMsgUpdateRect( | 1535 void RenderWidgetHostImpl::OnMsgUpdateRect( |
1513 const ViewHostMsg_UpdateRect_Params& params) { | 1536 const ViewHostMsg_UpdateRect_Params& params) { |
1514 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgUpdateRect"); | 1537 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnMsgUpdateRect"); |
1515 TimeTicks paint_start = TimeTicks::Now(); | 1538 TimeTicks paint_start = TimeTicks::Now(); |
1516 | 1539 |
1517 // Update our knowledge of the RenderWidget's size. | 1540 // Update our knowledge of the RenderWidget's size. |
1518 current_size_ = params.view_size; | 1541 current_size_ = params.view_size; |
1519 // Update our knowledge of the RenderWidget's scroll offset. | 1542 // Update our knowledge of the RenderWidget's scroll offset. |
1520 last_scroll_offset_ = params.scroll_offset; | 1543 last_scroll_offset_ = params.scroll_offset; |
1521 | 1544 |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2309 return; | 2332 return; |
2310 | 2333 |
2311 OnRenderAutoResized(new_size); | 2334 OnRenderAutoResized(new_size); |
2312 } | 2335 } |
2313 | 2336 |
2314 void RenderWidgetHostImpl::DetachDelegate() { | 2337 void RenderWidgetHostImpl::DetachDelegate() { |
2315 delegate_ = NULL; | 2338 delegate_ = NULL; |
2316 } | 2339 } |
2317 | 2340 |
2318 } // namespace content | 2341 } // namespace content |
OLD | NEW |