OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
6 | 6 |
7 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 last_frame_was_accelerated_ = true; | 877 last_frame_was_accelerated_ = true; |
878 plugin_container_manager_.SetSurfaceWasPaintedTo(params.window, | 878 plugin_container_manager_.SetSurfaceWasPaintedTo(params.window, |
879 params.surface_id); | 879 params.surface_id); |
880 | 880 |
881 // The surface is hidden until its first paint, to not show gargabe. | 881 // The surface is hidden until its first paint, to not show gargabe. |
882 if (plugin_container_manager_.SurfaceShouldBeVisible(params.window)) | 882 if (plugin_container_manager_.SurfaceShouldBeVisible(params.window)) |
883 [view setHidden:NO]; | 883 [view setHidden:NO]; |
884 [view drawView]; | 884 [view drawView]; |
885 } | 885 } |
886 | 886 |
887 if (params.renderer_id != 0 || params.route_id != 0) { | 887 if (params.route_id != 0) { |
888 AcknowledgeSwapBuffers(params.renderer_id, | 888 RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); |
889 params.route_id, | |
890 gpu_host_id); | |
891 } | 889 } |
892 } | 890 } |
893 | 891 |
| 892 void RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer( |
| 893 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
| 894 int gpu_host_id) { |
| 895 NOTIMPLEMENTED(); |
| 896 } |
| 897 |
894 void RenderWidgetHostViewMac::UpdateRootGpuViewVisibility( | 898 void RenderWidgetHostViewMac::UpdateRootGpuViewVisibility( |
895 bool show_gpu_widget) { | 899 bool show_gpu_widget) { |
896 // Plugins are destroyed on page navigate. The compositor layer on the other | 900 // Plugins are destroyed on page navigate. The compositor layer on the other |
897 // hand is created on demand and then stays alive until its renderer process | 901 // hand is created on demand and then stays alive until its renderer process |
898 // dies (usually on cross-domain navigation). Instead, only a flag | 902 // dies (usually on cross-domain navigation). Instead, only a flag |
899 // |is_accelerated_compositing_active()| is flipped when the compositor output | 903 // |is_accelerated_compositing_active()| is flipped when the compositor output |
900 // should be shown/hidden. | 904 // should be shown/hidden. |
901 // Show/hide the view belonging to the compositor here. | 905 // Show/hide the view belonging to the compositor here. |
902 plugin_container_manager_.set_gpu_rendering_active(show_gpu_widget); | 906 plugin_container_manager_.set_gpu_rendering_active(show_gpu_widget); |
903 | 907 |
904 gfx::PluginWindowHandle root_handle = | 908 gfx::PluginWindowHandle root_handle = |
905 plugin_container_manager_.root_container_handle(); | 909 plugin_container_manager_.root_container_handle(); |
906 if (root_handle != gfx::kNullPluginWindow) { | 910 if (root_handle != gfx::kNullPluginWindow) { |
907 AcceleratedPluginView* view = ViewForPluginWindowHandle(root_handle); | 911 AcceleratedPluginView* view = ViewForPluginWindowHandle(root_handle); |
908 DCHECK(view); | 912 DCHECK(view); |
909 bool visible = | 913 bool visible = |
910 plugin_container_manager_.SurfaceShouldBeVisible(root_handle); | 914 plugin_container_manager_.SurfaceShouldBeVisible(root_handle); |
911 [[view window] disableScreenUpdatesUntilFlush]; | 915 [[view window] disableScreenUpdatesUntilFlush]; |
912 [view setHidden:!visible]; | 916 [view setHidden:!visible]; |
913 } | 917 } |
914 } | 918 } |
915 | 919 |
916 void RenderWidgetHostViewMac::HandleDelayedGpuViewHiding() { | 920 void RenderWidgetHostViewMac::HandleDelayedGpuViewHiding() { |
917 if (needs_gpu_visibility_update_after_repaint_) { | 921 if (needs_gpu_visibility_update_after_repaint_) { |
918 UpdateRootGpuViewVisibility(false); | 922 UpdateRootGpuViewVisibility(false); |
919 needs_gpu_visibility_update_after_repaint_ = false; | 923 needs_gpu_visibility_update_after_repaint_ = false; |
920 } | 924 } |
921 } | 925 } |
922 | 926 |
923 void RenderWidgetHostViewMac::AcknowledgeSwapBuffers( | |
924 int renderer_id, | |
925 int32 route_id, | |
926 int gpu_host_id) { | |
927 TRACE_EVENT0("gpu", "RenderWidgetHostViewMac::AcknowledgeSwapBuffers"); | |
928 // Called on the display link thread. Hand actual work off to the IO thread, | |
929 // because |GpuProcessHost::Get()| can only be called there. | |
930 // Currently, this is never called for plugins. | |
931 if (render_widget_host_) { | |
932 DCHECK_EQ(render_widget_host_->process()->GetID(), renderer_id); | |
933 // |render_widget_host_->routing_id()| and |route_id| are usually not | |
934 // equal: The former identifies the channel from the RWH in the browser | |
935 // process to the corresponding render widget in the renderer process, while | |
936 // the latter identifies the channel from the GpuCommandBufferStub in the | |
937 // GPU process to the corresponding command buffer client in the renderer. | |
938 | |
939 render_widget_host_->AcknowledgeSwapBuffers(route_id, gpu_host_id); | |
940 } | |
941 } | |
942 | |
943 void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() { | 927 void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() { |
944 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 928 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
945 bool activated = GetRenderWidgetHost()->is_accelerated_compositing_active(); | 929 bool activated = GetRenderWidgetHost()->is_accelerated_compositing_active(); |
946 bool changed = accelerated_compositing_active_ != activated; | 930 bool changed = accelerated_compositing_active_ != activated; |
947 accelerated_compositing_active_ = activated; | 931 accelerated_compositing_active_ = activated; |
948 if (!changed) | 932 if (!changed) |
949 return; | 933 return; |
950 | 934 |
951 if (accelerated_compositing_active_) { | 935 if (accelerated_compositing_active_) { |
952 UpdateRootGpuViewVisibility(accelerated_compositing_active_); | 936 UpdateRootGpuViewVisibility(accelerated_compositing_active_); |
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 if (!string) return NO; | 2712 if (!string) return NO; |
2729 | 2713 |
2730 // If the user is currently using an IME, confirm the IME input, | 2714 // If the user is currently using an IME, confirm the IME input, |
2731 // and then insert the text from the service, the same as TextEdit and Safari. | 2715 // and then insert the text from the service, the same as TextEdit and Safari. |
2732 [self confirmComposition]; | 2716 [self confirmComposition]; |
2733 [self insertText:string]; | 2717 [self insertText:string]; |
2734 return YES; | 2718 return YES; |
2735 } | 2719 } |
2736 | 2720 |
2737 @end | 2721 @end |
OLD | NEW |