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