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_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 | 10 |
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 // calls to setNeedsDisplay and wait for their resulting display calls, | 2062 // calls to setNeedsDisplay and wait for their resulting display calls, |
2063 // before reporting that the frame has reached the screen. | 2063 // before reporting that the frame has reached the screen. |
2064 bool should_defer = false; | 2064 bool should_defer = false; |
2065 for (size_t i = 0; i < latency_info.size(); i++) { | 2065 for (size_t i = 0; i < latency_info.size(); i++) { |
2066 if (latency_info[i].FindLatency( | 2066 if (latency_info[i].FindLatency( |
2067 ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, | 2067 ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
2068 render_widget_host_->GetLatencyComponentId(), | 2068 render_widget_host_->GetLatencyComponentId(), |
2069 NULL)) { | 2069 NULL)) { |
2070 should_defer = true; | 2070 should_defer = true; |
2071 } | 2071 } |
2072 if (latency_info[i].FindLatency( | |
2073 ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT, | |
2074 render_widget_host_->GetLatencyComponentId(), | |
2075 NULL)) { | |
2076 should_defer = true; | |
2077 } | |
2078 } | 2072 } |
2079 if (should_defer) { | 2073 if (should_defer) { |
2080 // Multiple pending screenshot requests will work, but if every frame | 2074 // Multiple pending screenshot requests will work, but if every frame |
2081 // requests a screenshot, then the delay will never expire. Assert this | 2075 // requests a screenshot, then the delay will never expire. Assert this |
2082 // here to avoid this. | 2076 // here to avoid this. |
2083 CHECK_EQ(pending_latency_info_delay_, 0u); | 2077 CHECK_EQ(pending_latency_info_delay_, 0u); |
2084 // Wait a fixed number of frames (calls to CALayer::display) before | 2078 // Wait a fixed number of frames (calls to CALayer::display) before |
2085 // claiming that the screenshot has reached the screen. This number | 2079 // claiming that the screenshot has reached the screen. This number |
2086 // comes from taking the first number where tests didn't fail (six), | 2080 // comes from taking the first number where tests didn't fail (six), |
2087 // and doubling it. | 2081 // and doubling it. |
(...skipping 24 matching lines...) Expand all Loading... |
2112 | 2106 |
2113 void RenderWidgetHostViewMac::TickPendingLatencyInfoDelay() { | 2107 void RenderWidgetHostViewMac::TickPendingLatencyInfoDelay() { |
2114 if (compositing_iosurface_layer_) { | 2108 if (compositing_iosurface_layer_) { |
2115 // Keep calling gotNewFrame in a loop until enough display calls come in. | 2109 // Keep calling gotNewFrame in a loop until enough display calls come in. |
2116 // Each call will be separated by about a vsync. | 2110 // Each call will be separated by about a vsync. |
2117 base::MessageLoop::current()->PostTask( | 2111 base::MessageLoop::current()->PostTask( |
2118 FROM_HERE, | 2112 FROM_HERE, |
2119 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, | 2113 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, |
2120 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr())); | 2114 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr())); |
2121 [compositing_iosurface_layer_ gotNewFrame]; | 2115 [compositing_iosurface_layer_ gotNewFrame]; |
2122 } else { | 2116 } |
| 2117 if (software_layer_) { |
2123 // In software mode there is not an explicit setNeedsDisplay/display loop, | 2118 // In software mode there is not an explicit setNeedsDisplay/display loop, |
2124 // so just wait a pretend-vsync at 60 Hz. | 2119 // so just wait a pretend-vsync at 60 Hz. |
2125 base::MessageLoop::current()->PostDelayedTask( | 2120 base::MessageLoop::current()->PostDelayedTask( |
2126 FROM_HERE, | 2121 FROM_HERE, |
2127 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, | 2122 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, |
2128 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()), | 2123 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()), |
2129 base::TimeDelta::FromMilliseconds(1000/60)); | 2124 base::TimeDelta::FromMilliseconds(1000/60)); |
2130 SendPendingLatencyInfoToHost(); | 2125 SendPendingLatencyInfoToHost(); |
2131 } | 2126 } |
2132 } | 2127 } |
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3934 | 3929 |
3935 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3930 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3936 // regions that are not draggable. (See ControlRegionView in | 3931 // regions that are not draggable. (See ControlRegionView in |
3937 // native_app_window_cocoa.mm). This requires the render host view to be | 3932 // native_app_window_cocoa.mm). This requires the render host view to be |
3938 // draggable by default. | 3933 // draggable by default. |
3939 - (BOOL)mouseDownCanMoveWindow { | 3934 - (BOOL)mouseDownCanMoveWindow { |
3940 return YES; | 3935 return YES; |
3941 } | 3936 } |
3942 | 3937 |
3943 @end | 3938 @end |
OLD | NEW |