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