| 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 void RenderWidget::OnResize(const gfx::Size& new_size, | 366 void RenderWidget::OnResize(const gfx::Size& new_size, |
| 367 const gfx::Rect& resizer_rect, | 367 const gfx::Rect& resizer_rect, |
| 368 bool is_fullscreen) { | 368 bool is_fullscreen) { |
| 369 Resize(new_size, resizer_rect, is_fullscreen, SEND_RESIZE_ACK); | 369 Resize(new_size, resizer_rect, is_fullscreen, SEND_RESIZE_ACK); |
| 370 } | 370 } |
| 371 | 371 |
| 372 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { | 372 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { |
| 373 if (resizer_rect_ != resizer_rect) { | 373 if (resizer_rect_ != resizer_rect) { |
| 374 gfx::Rect view_rect(size_); | 374 gfx::Rect view_rect(size_); |
| 375 | 375 |
| 376 gfx::Rect old_damage_rect = view_rect; | 376 gfx::Rect old_damage_rect = gfx::Intersection(view_rect, resizer_rect_); |
| 377 old_damage_rect.Intersect(resizer_rect_); | |
| 378 if (!old_damage_rect.IsEmpty()) | 377 if (!old_damage_rect.IsEmpty()) |
| 379 paint_aggregator_.InvalidateRect(old_damage_rect); | 378 paint_aggregator_.InvalidateRect(old_damage_rect); |
| 380 | 379 |
| 381 gfx::Rect new_damage_rect = view_rect; | 380 gfx::Rect new_damage_rect = gfx::Intersection(view_rect, resizer_rect); |
| 382 new_damage_rect.Intersect(resizer_rect); | |
| 383 if (!new_damage_rect.IsEmpty()) | 381 if (!new_damage_rect.IsEmpty()) |
| 384 paint_aggregator_.InvalidateRect(new_damage_rect); | 382 paint_aggregator_.InvalidateRect(new_damage_rect); |
| 385 | 383 |
| 386 resizer_rect_ = resizer_rect; | 384 resizer_rect_ = resizer_rect; |
| 387 | 385 |
| 388 if (webwidget_) | 386 if (webwidget_) |
| 389 webwidget_->didChangeWindowResizerRect(); | 387 webwidget_->didChangeWindowResizerRect(); |
| 390 } | 388 } |
| 391 } | 389 } |
| 392 | 390 |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 software_stats_.numAnimationFrames++; | 928 software_stats_.numAnimationFrames++; |
| 931 software_stats_.numFramesSentToScreen++; | 929 software_stats_.numFramesSentToScreen++; |
| 932 } | 930 } |
| 933 | 931 |
| 934 // OK, save the pending update to a local since painting may cause more | 932 // OK, save the pending update to a local since painting may cause more |
| 935 // invalidation. Some WebCore rendering objects only layout when painted. | 933 // invalidation. Some WebCore rendering objects only layout when painted. |
| 936 PaintAggregator::PendingUpdate update; | 934 PaintAggregator::PendingUpdate update; |
| 937 paint_aggregator_.PopPendingUpdate(&update); | 935 paint_aggregator_.PopPendingUpdate(&update); |
| 938 | 936 |
| 939 gfx::Rect scroll_damage = update.GetScrollDamage(); | 937 gfx::Rect scroll_damage = update.GetScrollDamage(); |
| 940 gfx::Rect bounds = update.GetPaintBounds(); | 938 gfx::Rect bounds = gfx::Union(update.GetPaintBounds(), scroll_damage); |
| 941 bounds.Union(scroll_damage); | |
| 942 | 939 |
| 943 // Notify derived classes that we're about to initiate a paint. | 940 // Notify derived classes that we're about to initiate a paint. |
| 944 WillInitiatePaint(); | 941 WillInitiatePaint(); |
| 945 | 942 |
| 946 // A plugin may be able to do an optimized paint. First check this, in which | 943 // A plugin may be able to do an optimized paint. First check this, in which |
| 947 // case we can skip all of the bitmap generation and regular paint code. | 944 // case we can skip all of the bitmap generation and regular paint code. |
| 948 // This optimization allows PPAPI plugins that declare themselves on top of | 945 // This optimization allows PPAPI plugins that declare themselves on top of |
| 949 // the page (like a traditional windowed plugin) to be able to animate (think | 946 // the page (like a traditional windowed plugin) to be able to animate (think |
| 950 // movie playing) without repeatedly re-painting the page underneath, or | 947 // movie playing) without repeatedly re-painting the page underneath, or |
| 951 // copying the plugin backing store (since we can send the plugin's backing | 948 // copying the plugin backing store (since we can send the plugin's backing |
| (...skipping 25 matching lines...) Expand all Loading... |
| 977 &optimized_copy_rect, | 974 &optimized_copy_rect, |
| 978 &dib_scale_factor)) { | 975 &dib_scale_factor)) { |
| 979 // Only update the part of the plugin that actually changed. | 976 // Only update the part of the plugin that actually changed. |
| 980 optimized_copy_rect.Intersect(bounds); | 977 optimized_copy_rect.Intersect(bounds); |
| 981 pending_update_params_->bitmap = dib->id(); | 978 pending_update_params_->bitmap = dib->id(); |
| 982 pending_update_params_->bitmap_rect = optimized_copy_location; | 979 pending_update_params_->bitmap_rect = optimized_copy_location; |
| 983 pending_update_params_->copy_rects.push_back(optimized_copy_rect); | 980 pending_update_params_->copy_rects.push_back(optimized_copy_rect); |
| 984 pending_update_params_->scale_factor = dib_scale_factor; | 981 pending_update_params_->scale_factor = dib_scale_factor; |
| 985 } else if (!is_accelerated_compositing_active_) { | 982 } else if (!is_accelerated_compositing_active_) { |
| 986 // Compute a buffer for painting and cache it. | 983 // Compute a buffer for painting and cache it. |
| 987 gfx::RectF scaled_bounds = bounds; | 984 gfx::Rect pixel_bounds = gfx::ToEnclosingRect( |
| 988 scaled_bounds.Scale(device_scale_factor_); | 985 gfx::Scale(bounds, device_scale_factor_)); |
| 989 gfx::Rect pixel_bounds = gfx::ToEnclosingRect(scaled_bounds); | |
| 990 scoped_ptr<skia::PlatformCanvas> canvas( | 986 scoped_ptr<skia::PlatformCanvas> canvas( |
| 991 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, | 987 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, |
| 992 pixel_bounds)); | 988 pixel_bounds)); |
| 993 if (!canvas.get()) { | 989 if (!canvas.get()) { |
| 994 NOTREACHED(); | 990 NOTREACHED(); |
| 995 return; | 991 return; |
| 996 } | 992 } |
| 997 | 993 |
| 998 // We may get back a smaller canvas than we asked for. | 994 // We may get back a smaller canvas than we asked for. |
| 999 // TODO(darin): This seems like it could cause painting problems! | 995 // TODO(darin): This seems like it could cause painting problems! |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 if (!is_accelerated_compositing_active_) | 1053 if (!is_accelerated_compositing_active_) |
| 1058 DidInitiatePaint(); | 1054 DidInitiatePaint(); |
| 1059 } | 1055 } |
| 1060 | 1056 |
| 1061 /////////////////////////////////////////////////////////////////////////////// | 1057 /////////////////////////////////////////////////////////////////////////////// |
| 1062 // WebWidgetClient | 1058 // WebWidgetClient |
| 1063 | 1059 |
| 1064 void RenderWidget::didInvalidateRect(const WebRect& rect) { | 1060 void RenderWidget::didInvalidateRect(const WebRect& rect) { |
| 1065 // The invalidated rect might be outside the bounds of the view. | 1061 // The invalidated rect might be outside the bounds of the view. |
| 1066 gfx::Rect view_rect(size_); | 1062 gfx::Rect view_rect(size_); |
| 1067 gfx::Rect damaged_rect = view_rect; | 1063 gfx::Rect damaged_rect = gfx::Intersection(view_rect, rect); |
| 1068 damaged_rect.Intersect(rect); | |
| 1069 if (damaged_rect.IsEmpty()) | 1064 if (damaged_rect.IsEmpty()) |
| 1070 return; | 1065 return; |
| 1071 | 1066 |
| 1072 paint_aggregator_.InvalidateRect(damaged_rect); | 1067 paint_aggregator_.InvalidateRect(damaged_rect); |
| 1073 | 1068 |
| 1074 // We may not need to schedule another call to DoDeferredUpdate. | 1069 // We may not need to schedule another call to DoDeferredUpdate. |
| 1075 if (invalidation_task_posted_) | 1070 if (invalidation_task_posted_) |
| 1076 return; | 1071 return; |
| 1077 if (!paint_aggregator_.HasPendingUpdate()) | 1072 if (!paint_aggregator_.HasPendingUpdate()) |
| 1078 return; | 1073 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1098 } | 1093 } |
| 1099 | 1094 |
| 1100 void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { | 1095 void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { |
| 1101 // Drop scrolls on the floor when we are in compositing mode. | 1096 // Drop scrolls on the floor when we are in compositing mode. |
| 1102 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. | 1097 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. |
| 1103 if (is_accelerated_compositing_active_) | 1098 if (is_accelerated_compositing_active_) |
| 1104 return; | 1099 return; |
| 1105 | 1100 |
| 1106 // The scrolled rect might be outside the bounds of the view. | 1101 // The scrolled rect might be outside the bounds of the view. |
| 1107 gfx::Rect view_rect(size_); | 1102 gfx::Rect view_rect(size_); |
| 1108 gfx::Rect damaged_rect = view_rect; | 1103 gfx::Rect damaged_rect = gfx::Intersection(view_rect, clip_rect); |
| 1109 damaged_rect.Intersect(clip_rect); | |
| 1110 if (damaged_rect.IsEmpty()) | 1104 if (damaged_rect.IsEmpty()) |
| 1111 return; | 1105 return; |
| 1112 | 1106 |
| 1113 paint_aggregator_.ScrollRect(dx, dy, damaged_rect); | 1107 paint_aggregator_.ScrollRect(dx, dy, damaged_rect); |
| 1114 | 1108 |
| 1115 // We may not need to schedule another call to DoDeferredUpdate. | 1109 // We may not need to schedule another call to DoDeferredUpdate. |
| 1116 if (invalidation_task_posted_) | 1110 if (invalidation_task_posted_) |
| 1117 return; | 1111 return; |
| 1118 if (!paint_aggregator_.HasPendingUpdate()) | 1112 if (!paint_aggregator_.HasPendingUpdate()) |
| 1119 return; | 1113 return; |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 | 1896 |
| 1903 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1897 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1904 return false; | 1898 return false; |
| 1905 } | 1899 } |
| 1906 | 1900 |
| 1907 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1901 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1908 return false; | 1902 return false; |
| 1909 } | 1903 } |
| 1910 | 1904 |
| 1911 } // namespace content | 1905 } // namespace content |
| OLD | NEW |