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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 input_method_is_active_(false), | 98 input_method_is_active_(false), |
99 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 99 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
100 can_compose_inline_(true), | 100 can_compose_inline_(true), |
101 popup_type_(popup_type), | 101 popup_type_(popup_type), |
102 pending_window_rect_count_(0), | 102 pending_window_rect_count_(0), |
103 suppress_next_char_events_(false), | 103 suppress_next_char_events_(false), |
104 is_accelerated_compositing_active_(false), | 104 is_accelerated_compositing_active_(false), |
105 animation_update_pending_(false), | 105 animation_update_pending_(false), |
106 invalidation_task_posted_(false), | 106 invalidation_task_posted_(false), |
107 screen_info_(screen_info), | 107 screen_info_(screen_info), |
| 108 device_scale_factor_(1), |
108 invert_(false) { | 109 invert_(false) { |
109 if (!swapped_out) | 110 if (!swapped_out) |
110 RenderProcess::current()->AddRefProcess(); | 111 RenderProcess::current()->AddRefProcess(); |
111 DCHECK(RenderThread::Get()); | 112 DCHECK(RenderThread::Get()); |
112 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 113 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
113 switches::kDisableGpuVsync); | 114 switches::kDisableGpuVsync); |
| 115 #if defined(OS_CHROMEOS) |
| 116 device_scale_factor_ = screen_info.verticalDPI / 160; |
| 117 #endif |
114 } | 118 } |
115 | 119 |
116 RenderWidget::~RenderWidget() { | 120 RenderWidget::~RenderWidget() { |
117 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 121 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
118 STLDeleteElements(&updates_pending_swap_); | 122 STLDeleteElements(&updates_pending_swap_); |
119 if (current_paint_buf_) { | 123 if (current_paint_buf_) { |
120 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 124 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
121 current_paint_buf_ = NULL; | 125 current_paint_buf_ = NULL; |
122 } | 126 } |
123 // If we are swapped out, we have released already. | 127 // If we are swapped out, we have released already. |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 !is_accelerated_compositing_active_ && | 930 !is_accelerated_compositing_active_ && |
927 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, | 931 GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, |
928 &optimized_copy_rect)) { | 932 &optimized_copy_rect)) { |
929 // Only update the part of the plugin that actually changed. | 933 // Only update the part of the plugin that actually changed. |
930 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); | 934 optimized_copy_rect = optimized_copy_rect.Intersect(bounds); |
931 pending_update_params_->bitmap = dib->id(); | 935 pending_update_params_->bitmap = dib->id(); |
932 pending_update_params_->bitmap_rect = optimized_copy_location; | 936 pending_update_params_->bitmap_rect = optimized_copy_location; |
933 pending_update_params_->copy_rects.push_back(optimized_copy_rect); | 937 pending_update_params_->copy_rects.push_back(optimized_copy_rect); |
934 } else if (!is_accelerated_compositing_active_) { | 938 } else if (!is_accelerated_compositing_active_) { |
935 // Compute a buffer for painting and cache it. | 939 // Compute a buffer for painting and cache it. |
| 940 gfx::Rect pixel_bounds = bounds.Scale(device_scale_factor_); |
936 scoped_ptr<skia::PlatformCanvas> canvas( | 941 scoped_ptr<skia::PlatformCanvas> canvas( |
937 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, | 942 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, |
938 bounds)); | 943 pixel_bounds)); |
939 if (!canvas.get()) { | 944 if (!canvas.get()) { |
940 NOTREACHED(); | 945 NOTREACHED(); |
941 return; | 946 return; |
942 } | 947 } |
943 | 948 |
944 // We may get back a smaller canvas than we asked for. | 949 // We may get back a smaller canvas than we asked for. |
945 // TODO(darin): This seems like it could cause painting problems! | 950 // TODO(darin): This seems like it could cause painting problems! |
946 DCHECK_EQ(bounds.width(), canvas->getDevice()->width()); | 951 DCHECK_EQ(pixel_bounds.width(), canvas->getDevice()->width()); |
947 DCHECK_EQ(bounds.height(), canvas->getDevice()->height()); | 952 DCHECK_EQ(pixel_bounds.height(), canvas->getDevice()->height()); |
948 bounds.set_width(canvas->getDevice()->width()); | 953 pixel_bounds.set_width(canvas->getDevice()->width()); |
949 bounds.set_height(canvas->getDevice()->height()); | 954 pixel_bounds.set_height(canvas->getDevice()->height()); |
| 955 bounds.set_width(pixel_bounds.width() / device_scale_factor_); |
| 956 bounds.set_height(pixel_bounds.height() / device_scale_factor_); |
950 | 957 |
951 HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size()); | 958 HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size()); |
952 | 959 |
953 pending_update_params_->bitmap = current_paint_buf_->id(); | 960 pending_update_params_->bitmap = current_paint_buf_->id(); |
954 pending_update_params_->bitmap_rect = bounds; | 961 pending_update_params_->bitmap_rect = bounds; |
955 | 962 |
956 std::vector<gfx::Rect>& copy_rects = pending_update_params_->copy_rects; | 963 std::vector<gfx::Rect>& copy_rects = pending_update_params_->copy_rects; |
957 // The scroll damage is just another rectangle to paint and copy. | 964 // The scroll damage is just another rectangle to paint and copy. |
958 copy_rects.swap(update.paint_rects); | 965 copy_rects.swap(update.paint_rects); |
959 if (!scroll_damage.IsEmpty()) | 966 if (!scroll_damage.IsEmpty()) |
960 copy_rects.push_back(scroll_damage); | 967 copy_rects.push_back(scroll_damage); |
961 | 968 |
962 for (size_t i = 0; i < copy_rects.size(); ++i) | 969 for (size_t i = 0; i < copy_rects.size(); ++i) |
963 PaintRect(copy_rects[i], bounds.origin(), canvas.get()); | 970 PaintRect(copy_rects[i], pixel_bounds.origin(), canvas.get()); |
964 | 971 |
965 // Software FPS tick for performance tests. The accelerated path traces the | 972 // Software FPS tick for performance tests. The accelerated path traces the |
966 // frame events in didCommitAndDrawCompositorFrame. See throughput_tests.cc. | 973 // frame events in didCommitAndDrawCompositorFrame. See throughput_tests.cc. |
967 // NOTE: Tests may break if this event is renamed or moved. | 974 // NOTE: Tests may break if this event is renamed or moved. |
968 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickSW"); | 975 UNSHIPPED_TRACE_EVENT_INSTANT0("test_fps", "TestFrameTickSW"); |
969 } else { // Accelerated compositing path | 976 } else { // Accelerated compositing path |
970 // Begin painting. | 977 // Begin painting. |
971 // If painting is done via the gpu process then we don't set any damage | 978 // If painting is done via the gpu process then we don't set any damage |
972 // rects to save the browser process from doing unecessary work. | 979 // rects to save the browser process from doing unecessary work. |
973 pending_update_params_->bitmap_rect = bounds; | 980 pending_update_params_->bitmap_rect = bounds; |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 } | 1727 } |
1721 } | 1728 } |
1722 | 1729 |
1723 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1730 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
1724 return false; | 1731 return false; |
1725 } | 1732 } |
1726 | 1733 |
1727 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1734 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
1728 return false; | 1735 return false; |
1729 } | 1736 } |
OLD | NEW |