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/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" |
6 | 6 |
7 #include <cairo/cairo.h> | |
8 #include <gdk/gdk.h> | |
9 #include <gdk/gdkkeysyms.h> | |
10 #include <gdk/gdkx.h> | |
11 #include <gtk/gtk.h> | |
12 | |
13 #include <algorithm> | 7 #include <algorithm> |
14 #include <string> | 8 #include <string> |
15 | 9 |
16 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
17 #include "base/command_line.h" | 11 #include "base/command_line.h" |
18 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
19 #include "base/logging.h" | 13 #include "base/logging.h" |
20 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
21 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
22 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/utf_offset_string_conversions.h" | 17 #include "base/strings/utf_offset_string_conversions.h" |
24 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
25 #include "base/time/time.h" | 19 #include "base/time/time.h" |
26 #include "content/browser/accessibility/browser_accessibility_gtk.h" | 20 #include "content/browser/accessibility/browser_accessibility_gtk.h" |
27 #include "content/browser/accessibility/browser_accessibility_manager_gtk.h" | 21 #include "content/browser/accessibility/browser_accessibility_manager_gtk.h" |
| 22 #include "content/browser/gpu/gpu_process_host.h" |
| 23 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
28 #include "content/browser/renderer_host/backing_store_gtk.h" | 24 #include "content/browser/renderer_host/backing_store_gtk.h" |
29 #include "content/browser/renderer_host/gtk_im_context_wrapper.h" | 25 #include "content/browser/renderer_host/gtk_im_context_wrapper.h" |
30 #include "content/browser/renderer_host/gtk_key_bindings_handler.h" | 26 #include "content/browser/renderer_host/gtk_key_bindings_handler.h" |
31 #include "content/browser/renderer_host/gtk_window_utils.h" | 27 #include "content/browser/renderer_host/gtk_window_utils.h" |
32 #include "content/browser/renderer_host/input/web_input_event_builders_gtk.h" | 28 #include "content/browser/renderer_host/input/web_input_event_builders_gtk.h" |
33 #include "content/browser/renderer_host/render_view_host_delegate.h" | 29 #include "content/browser/renderer_host/render_view_host_delegate.h" |
34 #include "content/browser/renderer_host/render_view_host_impl.h" | 30 #include "content/browser/renderer_host/render_view_host_impl.h" |
35 #include "content/common/gpu/gpu_messages.h" | 31 #include "content/common/gpu/gpu_messages.h" |
36 #include "content/common/input_messages.h" | 32 #include "content/common/input_messages.h" |
37 #include "content/common/view_messages.h" | 33 #include "content/common/view_messages.h" |
38 #include "content/common/webplugin_geometry.h" | 34 #include "content/common/webplugin_geometry.h" |
39 #include "content/public/browser/native_web_keyboard_event.h" | 35 #include "content/public/browser/native_web_keyboard_event.h" |
40 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
41 #include "skia/ext/platform_canvas.h" | 37 #include "skia/ext/platform_canvas.h" |
42 #include "third_party/WebKit/public/web/WebInputEvent.h" | 38 #include "third_party/WebKit/public/web/WebInputEvent.h" |
43 #include "third_party/WebKit/public/web/WebScreenInfo.h" | 39 #include "third_party/WebKit/public/web/WebScreenInfo.h" |
44 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 40 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
45 #include "ui/base/x/active_window_watcher_x.h" | 41 #include "ui/base/x/active_window_watcher_x.h" |
46 #include "ui/base/x/x11_util.h" | 42 #include "ui/base/x/x11_util.h" |
47 #include "ui/gfx/gtk_compat.h" | 43 #include "ui/gfx/gtk_compat.h" |
48 #include "ui/gfx/gtk_native_view_id_manager.h" | 44 #include "ui/gfx/gtk_native_view_id_manager.h" |
49 #include "ui/gfx/gtk_preserve_window.h" | 45 #include "ui/gfx/gtk_preserve_window.h" |
50 #include "ui/gfx/text_elider.h" | 46 #include "ui/gfx/text_elider.h" |
51 #include "webkit/common/cursors/webcursor_gtk_data.h" | 47 #include "webkit/common/cursors/webcursor_gtk_data.h" |
52 | 48 |
| 49 #include <cairo/cairo.h> |
| 50 #include <gdk/gdk.h> |
| 51 #include <gdk/gdkkeysyms.h> |
| 52 #include <gdk/gdkx.h> |
| 53 #include <gtk/gtk.h> |
| 54 |
53 using WebKit::WebMouseWheelEvent; | 55 using WebKit::WebMouseWheelEvent; |
54 using WebKit::WebScreenInfo; | 56 using WebKit::WebScreenInfo; |
55 | 57 |
56 namespace content { | 58 namespace content { |
57 namespace { | 59 namespace { |
58 | 60 |
59 // Paint rects on Linux are bounded by the maximum size of a shared memory | 61 // Paint rects on Linux are bounded by the maximum size of a shared memory |
60 // region. By default that's 32MB, but many distros increase it significantly | 62 // region. By default that's 32MB, but many distros increase it significantly |
61 // (i.e. to 256MB). | 63 // (i.e. to 256MB). |
62 // | 64 // |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 is_popup_first_mouse_release_(true), | 549 is_popup_first_mouse_release_(true), |
548 was_imcontext_focused_before_grab_(false), | 550 was_imcontext_focused_before_grab_(false), |
549 do_x_grab_(false), | 551 do_x_grab_(false), |
550 is_fullscreen_(false), | 552 is_fullscreen_(false), |
551 made_active_(false), | 553 made_active_(false), |
552 mouse_is_being_warped_to_unlocked_position_(false), | 554 mouse_is_being_warped_to_unlocked_position_(false), |
553 destroy_handler_id_(0), | 555 destroy_handler_id_(0), |
554 dragged_at_horizontal_edge_(0), | 556 dragged_at_horizontal_edge_(0), |
555 dragged_at_vertical_edge_(0), | 557 dragged_at_vertical_edge_(0), |
556 compositing_surface_(gfx::kNullPluginWindow), | 558 compositing_surface_(gfx::kNullPluginWindow), |
| 559 last_frame_was_composited_(false), |
557 last_mouse_down_(NULL) { | 560 last_mouse_down_(NULL) { |
558 host_->SetView(this); | 561 host_->SetView(this); |
559 if (host_->is_hidden()) | 562 if (host_->is_hidden()) |
560 WasHidden(); | 563 WasHidden(); |
561 } | 564 } |
562 | 565 |
563 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { | 566 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { |
564 UnlockMouse(); | 567 UnlockMouse(); |
565 set_last_mouse_down(NULL); | 568 set_last_mouse_down(NULL); |
566 view_.Destroy(); | 569 view_.Destroy(); |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 } | 1063 } |
1061 | 1064 |
1062 void RenderWidgetHostViewGtk::AcceleratedSurfaceBuffersSwapped( | 1065 void RenderWidgetHostViewGtk::AcceleratedSurfaceBuffersSwapped( |
1063 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 1066 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
1064 int gpu_host_id) { | 1067 int gpu_host_id) { |
1065 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1068 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
1066 ack_params.sync_point = 0; | 1069 ack_params.sync_point = 0; |
1067 RenderWidgetHostImpl::AcknowledgeBufferPresent( | 1070 RenderWidgetHostImpl::AcknowledgeBufferPresent( |
1068 params.route_id, gpu_host_id, ack_params); | 1071 params.route_id, gpu_host_id, ack_params); |
1069 host_->FrameSwapped(params.latency_info); | 1072 host_->FrameSwapped(params.latency_info); |
| 1073 |
| 1074 if (!last_frame_was_composited_ && |
| 1075 compositing_surface_ != gfx::kNullPluginWindow) { |
| 1076 GpuProcessHostUIShim* host = GpuProcessHostUIShim::GetOneInstance(); |
| 1077 int32 surface_id = compositing_surface_; |
| 1078 if (host) { |
| 1079 bool compositing_active = true; |
| 1080 host->AcceleratedCompositingStateChange(surface_id, compositing_active); |
| 1081 } |
| 1082 last_frame_was_composited_ = true; |
| 1083 } |
1070 } | 1084 } |
1071 | 1085 |
1072 void RenderWidgetHostViewGtk::AcceleratedSurfacePostSubBuffer( | 1086 void RenderWidgetHostViewGtk::AcceleratedSurfacePostSubBuffer( |
1073 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 1087 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
1074 int gpu_host_id) { | 1088 int gpu_host_id) { |
1075 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1089 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
1076 ack_params.sync_point = 0; | 1090 ack_params.sync_point = 0; |
1077 RenderWidgetHostImpl::AcknowledgeBufferPresent( | 1091 RenderWidgetHostImpl::AcknowledgeBufferPresent( |
1078 params.route_id, gpu_host_id, ack_params); | 1092 params.route_id, gpu_host_id, ack_params); |
1079 host_->FrameSwapped(params.latency_info); | 1093 host_->FrameSwapped(params.latency_info); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 dragged_at_vertical_edge_ = new_dragged_at_vertical_edge; | 1165 dragged_at_vertical_edge_ = new_dragged_at_vertical_edge; |
1152 } | 1166 } |
1153 | 1167 |
1154 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { | 1168 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { |
1155 TRACE_EVENT0("ui::gtk", "RenderWidgetHostViewGtk::Paint"); | 1169 TRACE_EVENT0("ui::gtk", "RenderWidgetHostViewGtk::Paint"); |
1156 | 1170 |
1157 // If the GPU process is rendering directly into the View, | 1171 // If the GPU process is rendering directly into the View, |
1158 // call the compositor directly. | 1172 // call the compositor directly. |
1159 RenderWidgetHostImpl* render_widget_host = | 1173 RenderWidgetHostImpl* render_widget_host = |
1160 RenderWidgetHostImpl::From(GetRenderWidgetHost()); | 1174 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
| 1175 |
1161 if (render_widget_host->is_accelerated_compositing_active()) { | 1176 if (render_widget_host->is_accelerated_compositing_active()) { |
1162 host_->ScheduleComposite(); | 1177 host_->ScheduleComposite(); |
1163 return; | 1178 return; |
1164 } | 1179 } |
1165 | 1180 |
1166 GdkWindow* window = gtk_widget_get_window(view_.get()); | 1181 GdkWindow* window = gtk_widget_get_window(view_.get()); |
1167 DCHECK(!about_to_validate_and_paint_); | 1182 DCHECK(!about_to_validate_and_paint_); |
1168 | 1183 |
1169 invalid_rect_ = damage_rect; | 1184 invalid_rect_ = damage_rect; |
1170 about_to_validate_and_paint_ = true; | 1185 about_to_validate_and_paint_ = true; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 } | 1223 } |
1209 software_latency_info_.swap_timestamp = base::TimeTicks::HighResNow(); | 1224 software_latency_info_.swap_timestamp = base::TimeTicks::HighResNow(); |
1210 render_widget_host->FrameSwapped(software_latency_info_); | 1225 render_widget_host->FrameSwapped(software_latency_info_); |
1211 software_latency_info_.Clear(); | 1226 software_latency_info_.Clear(); |
1212 } else { | 1227 } else { |
1213 if (window) | 1228 if (window) |
1214 gdk_window_clear(window); | 1229 gdk_window_clear(window); |
1215 if (whiteout_start_time_.is_null()) | 1230 if (whiteout_start_time_.is_null()) |
1216 whiteout_start_time_ = base::TimeTicks::Now(); | 1231 whiteout_start_time_ = base::TimeTicks::Now(); |
1217 } | 1232 } |
| 1233 |
| 1234 if (last_frame_was_composited_ && |
| 1235 compositing_surface_ != gfx::kNullPluginWindow) { |
| 1236 GpuProcessHostUIShim* host = GpuProcessHostUIShim::GetOneInstance(); |
| 1237 int32 surface_id = compositing_surface_; |
| 1238 if (host) { |
| 1239 bool compositing_active = false; |
| 1240 host->AcceleratedCompositingStateChange(surface_id, compositing_active); |
| 1241 } |
| 1242 last_frame_was_composited_ = false; |
| 1243 } |
1218 } | 1244 } |
1219 | 1245 |
1220 void RenderWidgetHostViewGtk::ShowCurrentCursor() { | 1246 void RenderWidgetHostViewGtk::ShowCurrentCursor() { |
1221 // The widget may not have a window. If that's the case, abort mission. This | 1247 // The widget may not have a window. If that's the case, abort mission. This |
1222 // is the same issue as that explained above in Paint(). | 1248 // is the same issue as that explained above in Paint(). |
1223 if (!gtk_widget_get_window(view_.get())) | 1249 if (!gtk_widget_get_window(view_.get())) |
1224 return; | 1250 return; |
1225 | 1251 |
1226 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is | 1252 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is |
1227 // that calling gdk_window_set_cursor repeatedly is expensive. We should | 1253 // that calling gdk_window_set_cursor repeatedly is expensive. We should |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 gfx::PluginWindowHandle id) { | 1598 gfx::PluginWindowHandle id) { |
1573 plugin_container_manager_.CreatePluginContainer(id); | 1599 plugin_container_manager_.CreatePluginContainer(id); |
1574 } | 1600 } |
1575 | 1601 |
1576 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( | 1602 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( |
1577 gfx::PluginWindowHandle id) { | 1603 gfx::PluginWindowHandle id) { |
1578 plugin_container_manager_.DestroyPluginContainer(id); | 1604 plugin_container_manager_.DestroyPluginContainer(id); |
1579 } | 1605 } |
1580 | 1606 |
1581 } // namespace content | 1607 } // namespace content |
OLD | NEW |