Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 311313003: DevTools: Fix for Page.captureScreenshot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for mac (again) Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <QuartzCore/QuartzCore.h> 8 #include <QuartzCore/QuartzCore.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 // calls to setNeedsDisplay and wait for their resulting display calls, 2057 // calls to setNeedsDisplay and wait for their resulting display calls,
2058 // before reporting that the frame has reached the screen. 2058 // before reporting that the frame has reached the screen.
2059 bool should_defer = false; 2059 bool should_defer = false;
2060 for (size_t i = 0; i < latency_info.size(); i++) { 2060 for (size_t i = 0; i < latency_info.size(); i++) {
2061 if (latency_info[i].FindLatency( 2061 if (latency_info[i].FindLatency(
2062 ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, 2062 ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
2063 render_widget_host_->GetLatencyComponentId(), 2063 render_widget_host_->GetLatencyComponentId(),
2064 NULL)) { 2064 NULL)) {
2065 should_defer = true; 2065 should_defer = true;
2066 } 2066 }
2067 if (latency_info[i].FindLatency(
2068 ui::WINDOW_OLD_SNAPSHOT_FRAME_NUMBER_COMPONENT,
2069 render_widget_host_->GetLatencyComponentId(),
2070 NULL)) {
2071 should_defer = true;
2072 }
2067 } 2073 }
2068 if (should_defer) { 2074 if (should_defer) {
2069 // Multiple pending screenshot requests will work, but if every frame 2075 // Multiple pending screenshot requests will work, but if every frame
2070 // requests a screenshot, then the delay will never expire. Assert this 2076 // requests a screenshot, then the delay will never expire. Assert this
2071 // here to avoid this. 2077 // here to avoid this.
2072 CHECK_EQ(pending_latency_info_delay_, 0u); 2078 CHECK_EQ(pending_latency_info_delay_, 0u);
2073 // Wait a fixed number of frames (calls to CALayer::display) before 2079 // Wait a fixed number of frames (calls to CALayer::display) before
2074 // claiming that the screenshot has reached the screen. This number 2080 // claiming that the screenshot has reached the screen. This number
2075 // comes from taking the first number where tests didn't fail (six), 2081 // comes from taking the first number where tests didn't fail (six),
2076 // and doubling it. 2082 // and doubling it.
(...skipping 24 matching lines...) Expand all
2101 2107
2102 void RenderWidgetHostViewMac::TickPendingLatencyInfoDelay() { 2108 void RenderWidgetHostViewMac::TickPendingLatencyInfoDelay() {
2103 if (compositing_iosurface_layer_) { 2109 if (compositing_iosurface_layer_) {
2104 // Keep calling gotNewFrame in a loop until enough display calls come in. 2110 // Keep calling gotNewFrame in a loop until enough display calls come in.
2105 // Each call will be separated by about a vsync. 2111 // Each call will be separated by about a vsync.
2106 base::MessageLoop::current()->PostTask( 2112 base::MessageLoop::current()->PostTask(
2107 FROM_HERE, 2113 FROM_HERE,
2108 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, 2114 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay,
2109 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr())); 2115 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()));
2110 [compositing_iosurface_layer_ gotNewFrame]; 2116 [compositing_iosurface_layer_ gotNewFrame];
2111 } 2117 } else {
2112 if (software_layer_) {
2113 // In software mode there is not an explicit setNeedsDisplay/display loop, 2118 // In software mode there is not an explicit setNeedsDisplay/display loop,
2114 // so just wait a pretend-vsync at 60 Hz. 2119 // so just wait a pretend-vsync at 60 Hz.
2115 base::MessageLoop::current()->PostDelayedTask( 2120 base::MessageLoop::current()->PostDelayedTask(
2116 FROM_HERE, 2121 FROM_HERE,
2117 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, 2122 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay,
2118 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()), 2123 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()),
2119 base::TimeDelta::FromMilliseconds(1000/60)); 2124 base::TimeDelta::FromMilliseconds(1000/60));
2120 SendPendingLatencyInfoToHost(); 2125 SendPendingLatencyInfoToHost();
2121 } 2126 }
2122 } 2127 }
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
3924 3929
3925 // "-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
3926 // regions that are not draggable. (See ControlRegionView in 3931 // regions that are not draggable. (See ControlRegionView in
3927 // 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
3928 // draggable by default. 3933 // draggable by default.
3929 - (BOOL)mouseDownCanMoveWindow { 3934 - (BOOL)mouseDownCanMoveWindow {
3930 return YES; 3935 return YES;
3931 } 3936 }
3932 3937
3933 @end 3938 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698