| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 void RenderWidget::OnResize(const gfx::Size& new_size, | 368 void RenderWidget::OnResize(const gfx::Size& new_size, |
| 369 const gfx::Rect& resizer_rect, | 369 const gfx::Rect& resizer_rect, |
| 370 bool is_fullscreen) { | 370 bool is_fullscreen) { |
| 371 Resize(new_size, resizer_rect, is_fullscreen, SEND_RESIZE_ACK); | 371 Resize(new_size, resizer_rect, is_fullscreen, SEND_RESIZE_ACK); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { | 374 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { |
| 375 if (resizer_rect_ != resizer_rect) { | 375 if (resizer_rect_ != resizer_rect) { |
| 376 gfx::Rect view_rect(size_); | 376 gfx::Rect view_rect(size_); |
| 377 | 377 |
| 378 gfx::Rect old_damage_rect = view_rect; | 378 gfx::Rect old_damage_rect = gfx::IntersectRects(view_rect, resizer_rect_); |
| 379 old_damage_rect.Intersect(resizer_rect_); | |
| 380 if (!old_damage_rect.IsEmpty()) | 379 if (!old_damage_rect.IsEmpty()) |
| 381 paint_aggregator_.InvalidateRect(old_damage_rect); | 380 paint_aggregator_.InvalidateRect(old_damage_rect); |
| 382 | 381 |
| 383 gfx::Rect new_damage_rect = view_rect; | 382 gfx::Rect new_damage_rect = gfx::IntersectRects(view_rect, resizer_rect); |
| 384 new_damage_rect.Intersect(resizer_rect); | |
| 385 if (!new_damage_rect.IsEmpty()) | 383 if (!new_damage_rect.IsEmpty()) |
| 386 paint_aggregator_.InvalidateRect(new_damage_rect); | 384 paint_aggregator_.InvalidateRect(new_damage_rect); |
| 387 | 385 |
| 388 resizer_rect_ = resizer_rect; | 386 resizer_rect_ = resizer_rect; |
| 389 | 387 |
| 390 if (webwidget_) | 388 if (webwidget_) |
| 391 webwidget_->didChangeWindowResizerRect(); | 389 webwidget_->didChangeWindowResizerRect(); |
| 392 } | 390 } |
| 393 } | 391 } |
| 394 | 392 |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 software_stats_.numAnimationFrames++; | 940 software_stats_.numAnimationFrames++; |
| 943 software_stats_.numFramesSentToScreen++; | 941 software_stats_.numFramesSentToScreen++; |
| 944 } | 942 } |
| 945 | 943 |
| 946 // OK, save the pending update to a local since painting may cause more | 944 // OK, save the pending update to a local since painting may cause more |
| 947 // invalidation. Some WebCore rendering objects only layout when painted. | 945 // invalidation. Some WebCore rendering objects only layout when painted. |
| 948 PaintAggregator::PendingUpdate update; | 946 PaintAggregator::PendingUpdate update; |
| 949 paint_aggregator_.PopPendingUpdate(&update); | 947 paint_aggregator_.PopPendingUpdate(&update); |
| 950 | 948 |
| 951 gfx::Rect scroll_damage = update.GetScrollDamage(); | 949 gfx::Rect scroll_damage = update.GetScrollDamage(); |
| 952 gfx::Rect bounds = update.GetPaintBounds(); | 950 gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), scroll_damage); |
| 953 bounds.Union(scroll_damage); | |
| 954 | 951 |
| 955 // Notify derived classes that we're about to initiate a paint. | 952 // Notify derived classes that we're about to initiate a paint. |
| 956 WillInitiatePaint(); | 953 WillInitiatePaint(); |
| 957 | 954 |
| 958 // A plugin may be able to do an optimized paint. First check this, in which | 955 // A plugin may be able to do an optimized paint. First check this, in which |
| 959 // case we can skip all of the bitmap generation and regular paint code. | 956 // case we can skip all of the bitmap generation and regular paint code. |
| 960 // This optimization allows PPAPI plugins that declare themselves on top of | 957 // This optimization allows PPAPI plugins that declare themselves on top of |
| 961 // the page (like a traditional windowed plugin) to be able to animate (think | 958 // the page (like a traditional windowed plugin) to be able to animate (think |
| 962 // movie playing) without repeatedly re-painting the page underneath, or | 959 // movie playing) without repeatedly re-painting the page underneath, or |
| 963 // copying the plugin backing store (since we can send the plugin's backing | 960 // copying the plugin backing store (since we can send the plugin's backing |
| (...skipping 25 matching lines...) Expand all Loading... |
| 989 &optimized_copy_rect, | 986 &optimized_copy_rect, |
| 990 &dib_scale_factor)) { | 987 &dib_scale_factor)) { |
| 991 // Only update the part of the plugin that actually changed. | 988 // Only update the part of the plugin that actually changed. |
| 992 optimized_copy_rect.Intersect(bounds); | 989 optimized_copy_rect.Intersect(bounds); |
| 993 pending_update_params_->bitmap = dib->id(); | 990 pending_update_params_->bitmap = dib->id(); |
| 994 pending_update_params_->bitmap_rect = optimized_copy_location; | 991 pending_update_params_->bitmap_rect = optimized_copy_location; |
| 995 pending_update_params_->copy_rects.push_back(optimized_copy_rect); | 992 pending_update_params_->copy_rects.push_back(optimized_copy_rect); |
| 996 pending_update_params_->scale_factor = dib_scale_factor; | 993 pending_update_params_->scale_factor = dib_scale_factor; |
| 997 } else if (!is_accelerated_compositing_active_) { | 994 } else if (!is_accelerated_compositing_active_) { |
| 998 // Compute a buffer for painting and cache it. | 995 // Compute a buffer for painting and cache it. |
| 999 gfx::RectF scaled_bounds = bounds; | 996 gfx::Rect pixel_bounds = gfx::ToFlooredRectDeprecated( |
| 1000 scaled_bounds.Scale(device_scale_factor_); | 997 gfx::ScaleRect(bounds, device_scale_factor_)); |
| 1001 gfx::Rect pixel_bounds = | |
| 1002 gfx::ToFlooredRectDeprecated(scaled_bounds); | |
| 1003 scoped_ptr<skia::PlatformCanvas> canvas( | 998 scoped_ptr<skia::PlatformCanvas> canvas( |
| 1004 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, | 999 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, |
| 1005 pixel_bounds)); | 1000 pixel_bounds)); |
| 1006 if (!canvas.get()) { | 1001 if (!canvas.get()) { |
| 1007 NOTREACHED(); | 1002 NOTREACHED(); |
| 1008 return; | 1003 return; |
| 1009 } | 1004 } |
| 1010 | 1005 |
| 1011 // We may get back a smaller canvas than we asked for. | 1006 // We may get back a smaller canvas than we asked for. |
| 1012 // TODO(darin): This seems like it could cause painting problems! | 1007 // TODO(darin): This seems like it could cause painting problems! |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 } | 1067 } |
| 1073 | 1068 |
| 1074 /////////////////////////////////////////////////////////////////////////////// | 1069 /////////////////////////////////////////////////////////////////////////////// |
| 1075 // WebWidgetClient | 1070 // WebWidgetClient |
| 1076 | 1071 |
| 1077 void RenderWidget::didInvalidateRect(const WebRect& rect) { | 1072 void RenderWidget::didInvalidateRect(const WebRect& rect) { |
| 1078 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", | 1073 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", |
| 1079 "width", rect.width, "height", rect.height); | 1074 "width", rect.width, "height", rect.height); |
| 1080 // The invalidated rect might be outside the bounds of the view. | 1075 // The invalidated rect might be outside the bounds of the view. |
| 1081 gfx::Rect view_rect(size_); | 1076 gfx::Rect view_rect(size_); |
| 1082 gfx::Rect damaged_rect = view_rect; | 1077 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect); |
| 1083 damaged_rect.Intersect(rect); | |
| 1084 if (damaged_rect.IsEmpty()) | 1078 if (damaged_rect.IsEmpty()) |
| 1085 return; | 1079 return; |
| 1086 | 1080 |
| 1087 paint_aggregator_.InvalidateRect(damaged_rect); | 1081 paint_aggregator_.InvalidateRect(damaged_rect); |
| 1088 | 1082 |
| 1089 // We may not need to schedule another call to DoDeferredUpdate. | 1083 // We may not need to schedule another call to DoDeferredUpdate. |
| 1090 if (invalidation_task_posted_) | 1084 if (invalidation_task_posted_) |
| 1091 return; | 1085 return; |
| 1092 if (!paint_aggregator_.HasPendingUpdate()) | 1086 if (!paint_aggregator_.HasPendingUpdate()) |
| 1093 return; | 1087 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1113 } | 1107 } |
| 1114 | 1108 |
| 1115 void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { | 1109 void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { |
| 1116 // Drop scrolls on the floor when we are in compositing mode. | 1110 // Drop scrolls on the floor when we are in compositing mode. |
| 1117 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. | 1111 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. |
| 1118 if (is_accelerated_compositing_active_) | 1112 if (is_accelerated_compositing_active_) |
| 1119 return; | 1113 return; |
| 1120 | 1114 |
| 1121 // The scrolled rect might be outside the bounds of the view. | 1115 // The scrolled rect might be outside the bounds of the view. |
| 1122 gfx::Rect view_rect(size_); | 1116 gfx::Rect view_rect(size_); |
| 1123 gfx::Rect damaged_rect = view_rect; | 1117 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect); |
| 1124 damaged_rect.Intersect(clip_rect); | |
| 1125 if (damaged_rect.IsEmpty()) | 1118 if (damaged_rect.IsEmpty()) |
| 1126 return; | 1119 return; |
| 1127 | 1120 |
| 1128 paint_aggregator_.ScrollRect(dx, dy, damaged_rect); | 1121 paint_aggregator_.ScrollRect(dx, dy, damaged_rect); |
| 1129 | 1122 |
| 1130 // We may not need to schedule another call to DoDeferredUpdate. | 1123 // We may not need to schedule another call to DoDeferredUpdate. |
| 1131 if (invalidation_task_posted_) | 1124 if (invalidation_task_posted_) |
| 1132 return; | 1125 return; |
| 1133 if (!paint_aggregator_.HasPendingUpdate()) | 1126 if (!paint_aggregator_.HasPendingUpdate()) |
| 1134 return; | 1127 return; |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 | 1918 |
| 1926 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1919 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1927 return false; | 1920 return false; |
| 1928 } | 1921 } |
| 1929 | 1922 |
| 1930 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1923 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1931 return false; | 1924 return false; |
| 1932 } | 1925 } |
| 1933 | 1926 |
| 1934 } // namespace content | 1927 } // namespace content |
| OLD | NEW |