| 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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 // we don't accidentally clear other update rects. | 661 // we don't accidentally clear other update rects. |
| 662 canvas->save(); | 662 canvas->save(); |
| 663 canvas->clipRect(gfx::RectToSkRect(rect)); | 663 canvas->clipRect(gfx::RectToSkRect(rect)); |
| 664 canvas->drawPaint(paint); | 664 canvas->drawPaint(paint); |
| 665 canvas->restore(); | 665 canvas->restore(); |
| 666 } | 666 } |
| 667 | 667 |
| 668 // First see if this rect is a plugin that can paint itself faster. | 668 // First see if this rect is a plugin that can paint itself faster. |
| 669 TransportDIB* optimized_dib = NULL; | 669 TransportDIB* optimized_dib = NULL; |
| 670 gfx::Rect optimized_copy_rect, optimized_copy_location; | 670 gfx::Rect optimized_copy_rect, optimized_copy_location; |
| 671 float dib_scale_factor; |
| 671 webkit::ppapi::PluginInstance* optimized_instance = | 672 webkit::ppapi::PluginInstance* optimized_instance = |
| 672 GetBitmapForOptimizedPluginPaint(rect, &optimized_dib, | 673 GetBitmapForOptimizedPluginPaint(rect, &optimized_dib, |
| 673 &optimized_copy_location, | 674 &optimized_copy_location, |
| 674 &optimized_copy_rect); | 675 &optimized_copy_rect, |
| 676 &dib_scale_factor); |
| 675 if (optimized_instance) { | 677 if (optimized_instance) { |
| 676 // This plugin can be optimize-painted and we can just ask it to paint | 678 // This plugin can be optimize-painted and we can just ask it to paint |
| 677 // itself. We don't actually need the TransportDIB in this case. | 679 // itself. We don't actually need the TransportDIB in this case. |
| 678 // | 680 // |
| 679 // This is an optimization for PPAPI plugins that know they're on top of | 681 // This is an optimization for PPAPI plugins that know they're on top of |
| 680 // the page content. If this rect is inside such a plugin, we can save some | 682 // the page content. If this rect is inside such a plugin, we can save some |
| 681 // time and avoid re-rendering the page content which we know will be | 683 // time and avoid re-rendering the page content which we know will be |
| 682 // covered by the plugin later (this time can be significant, especially | 684 // covered by the plugin later (this time can be significant, especially |
| 683 // for a playing movie that is invalidating a lot). | 685 // for a playing movie that is invalidating a lot). |
| 684 // | 686 // |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 // the page (like a traditional windowed plugin) to be able to animate (think | 926 // the page (like a traditional windowed plugin) to be able to animate (think |
| 925 // movie playing) without repeatedly re-painting the page underneath, or | 927 // movie playing) without repeatedly re-painting the page underneath, or |
| 926 // copying the plugin backing store (since we can send the plugin's backing | 928 // copying the plugin backing store (since we can send the plugin's backing |
| 927 // store directly to the browser). | 929 // store directly to the browser). |
| 928 // | 930 // |
| 929 // This optimization only works when the entire invalid region is contained | 931 // This optimization only works when the entire invalid region is contained |
| 930 // within the plugin. There is a related optimization in PaintRect for the | 932 // within the plugin. There is a related optimization in PaintRect for the |
| 931 // case where there may be multiple invalid regions. | 933 // case where there may be multiple invalid regions. |
| 932 TransportDIB* dib = NULL; | 934 TransportDIB* dib = NULL; |
| 933 gfx::Rect optimized_copy_rect, optimized_copy_location; | 935 gfx::Rect optimized_copy_rect, optimized_copy_location; |
| 936 float dib_scale_factor = 1; |
| 934 DCHECK(!pending_update_params_.get()); | 937 DCHECK(!pending_update_params_.get()); |
| 935 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); | 938 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); |
| 936 pending_update_params_->dx = update.scroll_delta.x(); | 939 pending_update_params_->dx = update.scroll_delta.x(); |
| 937 pending_update_params_->dy = update.scroll_delta.y(); | 940 pending_update_params_->dy = update.scroll_delta.y(); |
| 938 pending_update_params_->scroll_rect = update.scroll_rect; | 941 pending_update_params_->scroll_rect = update.scroll_rect; |
| 939 pending_update_params_->view_size = size_; | 942 pending_update_params_->view_size = size_; |
| 940 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); | 943 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); |
| 941 pending_update_params_->flags = next_paint_flags_; | 944 pending_update_params_->flags = next_paint_flags_; |
| 942 pending_update_params_->scroll_offset = GetScrollOffset(); | 945 pending_update_params_->scroll_offset = GetScrollOffset(); |
| 943 pending_update_params_->needs_ack = true; | 946 pending_update_params_->needs_ack = true; |
| 944 pending_update_params_->scale_factor = device_scale_factor_; | 947 pending_update_params_->scale_factor = device_scale_factor_; |
| 945 next_paint_flags_ = 0; | 948 next_paint_flags_ = 0; |
| 946 need_update_rect_for_auto_resize_ = false; | 949 need_update_rect_for_auto_resize_ = false; |
| 947 | 950 |
| 948 if (update.scroll_rect.IsEmpty() && | 951 if (update.scroll_rect.IsEmpty() && |
| 949 !is_accelerated_compositing_active_ && | 952 !is_accelerated_compositing_active_ && |
| 950 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, | 953 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, |
| 951 &optimized_copy_rect)) { | 954 &optimized_copy_rect, |
| 955 &dib_scale_factor)) { |
| 952 // Only update the part of the plugin that actually changed. | 956 // Only update the part of the plugin that actually changed. |
| 953 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); | 957 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); |
| 954 pending_update_params_->bitmap = dib->id(); | 958 pending_update_params_->bitmap = dib->id(); |
| 955 pending_update_params_->bitmap_rect = optimized_copy_location; | 959 pending_update_params_->bitmap_rect = optimized_copy_location; |
| 956 pending_update_params_->copy_rects.push_back(optimized_copy_rect); | 960 pending_update_params_->copy_rects.push_back(optimized_copy_rect); |
| 961 pending_update_params_->scale_factor = dib_scale_factor; |
| 957 } else if (!is_accelerated_compositing_active_) { | 962 } else if (!is_accelerated_compositing_active_) { |
| 958 // Compute a buffer for painting and cache it. | 963 // Compute a buffer for painting and cache it. |
| 959 gfx::Rect pixel_bounds = bounds.Scale(device_scale_factor_); | 964 gfx::Rect pixel_bounds = bounds.Scale(device_scale_factor_); |
| 960 scoped_ptr<skia::PlatformCanvas> canvas( | 965 scoped_ptr<skia::PlatformCanvas> canvas( |
| 961 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, | 966 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, |
| 962 pixel_bounds)); | 967 pixel_bounds)); |
| 963 if (!canvas.get()) { | 968 if (!canvas.get()) { |
| 964 NOTREACHED(); | 969 NOTREACHED(); |
| 965 return; | 970 return; |
| 966 } | 971 } |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 | 1555 |
| 1551 void RenderWidget::OnScreenInfoChanged( | 1556 void RenderWidget::OnScreenInfoChanged( |
| 1552 const WebKit::WebScreenInfo& screen_info) { | 1557 const WebKit::WebScreenInfo& screen_info) { |
| 1553 screen_info_ = screen_info; | 1558 screen_info_ = screen_info; |
| 1554 } | 1559 } |
| 1555 | 1560 |
| 1556 webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint( | 1561 webkit::ppapi::PluginInstance* RenderWidget::GetBitmapForOptimizedPluginPaint( |
| 1557 const gfx::Rect& paint_bounds, | 1562 const gfx::Rect& paint_bounds, |
| 1558 TransportDIB** dib, | 1563 TransportDIB** dib, |
| 1559 gfx::Rect* location, | 1564 gfx::Rect* location, |
| 1560 gfx::Rect* clip) { | 1565 gfx::Rect* clip, |
| 1566 float* scale_factor) { |
| 1561 // Bare RenderWidgets don't support optimized plugin painting. | 1567 // Bare RenderWidgets don't support optimized plugin painting. |
| 1562 return NULL; | 1568 return NULL; |
| 1563 } | 1569 } |
| 1564 | 1570 |
| 1565 gfx::Point RenderWidget::GetScrollOffset() { | 1571 gfx::Point RenderWidget::GetScrollOffset() { |
| 1566 // Bare RenderWidgets don't support scroll offset. | 1572 // Bare RenderWidgets don't support scroll offset. |
| 1567 return gfx::Point(0, 0); | 1573 return gfx::Point(0, 0); |
| 1568 } | 1574 } |
| 1569 | 1575 |
| 1570 void RenderWidget::SetHidden(bool hidden) { | 1576 void RenderWidget::SetHidden(bool hidden) { |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 pending_smooth_scroll_gestures_.insert(std::make_pair(id, callback)); | 1840 pending_smooth_scroll_gestures_.insert(std::make_pair(id, callback)); |
| 1835 } | 1841 } |
| 1836 | 1842 |
| 1837 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1843 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1838 return false; | 1844 return false; |
| 1839 } | 1845 } |
| 1840 | 1846 |
| 1841 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1847 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1842 return false; | 1848 return false; |
| 1843 } | 1849 } |
| OLD | NEW |