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

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: Removed debug hook 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 <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
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 }
2072 } 2078 }
2073 if (should_defer) { 2079 if (should_defer) {
2074 // Multiple pending screenshot requests will work, but if every frame 2080 // Multiple pending screenshot requests will work, but if every frame
2075 // requests a screenshot, then the delay will never expire. Assert this 2081 // requests a screenshot, then the delay will never expire. Assert this
2076 // here to avoid this. 2082 // here to avoid this.
2077 CHECK_EQ(pending_latency_info_delay_, 0u); 2083 CHECK_EQ(pending_latency_info_delay_, 0u);
2078 // Wait a fixed number of frames (calls to CALayer::display) before 2084 // Wait a fixed number of frames (calls to CALayer::display) before
2079 // claiming that the screenshot has reached the screen. This number 2085 // claiming that the screenshot has reached the screen. This number
2080 // comes from taking the first number where tests didn't fail (six), 2086 // comes from taking the first number where tests didn't fail (six),
2081 // and doubling it. 2087 // and doubling it.
(...skipping 24 matching lines...) Expand all
2106 2112
2107 void RenderWidgetHostViewMac::TickPendingLatencyInfoDelay() { 2113 void RenderWidgetHostViewMac::TickPendingLatencyInfoDelay() {
2108 if (compositing_iosurface_layer_) { 2114 if (compositing_iosurface_layer_) {
2109 // Keep calling gotNewFrame in a loop until enough display calls come in. 2115 // Keep calling gotNewFrame in a loop until enough display calls come in.
2110 // Each call will be separated by about a vsync. 2116 // Each call will be separated by about a vsync.
2111 base::MessageLoop::current()->PostTask( 2117 base::MessageLoop::current()->PostTask(
2112 FROM_HERE, 2118 FROM_HERE,
2113 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, 2119 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay,
2114 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr())); 2120 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()));
2115 [compositing_iosurface_layer_ gotNewFrame]; 2121 [compositing_iosurface_layer_ gotNewFrame];
2116 } 2122 } else {
2117 if (software_layer_) {
2118 // In software mode there is not an explicit setNeedsDisplay/display loop, 2123 // In software mode there is not an explicit setNeedsDisplay/display loop,
2119 // so just wait a pretend-vsync at 60 Hz. 2124 // so just wait a pretend-vsync at 60 Hz.
2120 base::MessageLoop::current()->PostDelayedTask( 2125 base::MessageLoop::current()->PostDelayedTask(
2121 FROM_HERE, 2126 FROM_HERE,
2122 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay, 2127 base::Bind(&RenderWidgetHostViewMac::TickPendingLatencyInfoDelay,
2123 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()), 2128 pending_latency_info_delay_weak_ptr_factory_.GetWeakPtr()),
2124 base::TimeDelta::FromMilliseconds(1000/60)); 2129 base::TimeDelta::FromMilliseconds(1000/60));
2125 SendPendingLatencyInfoToHost(); 2130 SendPendingLatencyInfoToHost();
2126 } 2131 }
2127 } 2132 }
(...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 3934
3930 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3935 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3931 // regions that are not draggable. (See ControlRegionView in 3936 // regions that are not draggable. (See ControlRegionView in
3932 // native_app_window_cocoa.mm). This requires the render host view to be 3937 // native_app_window_cocoa.mm). This requires the render host view to be
3933 // draggable by default. 3938 // draggable by default.
3934 - (BOOL)mouseDownCanMoveWindow { 3939 - (BOOL)mouseDownCanMoveWindow {
3935 return YES; 3940 return YES;
3936 } 3941 }
3937 3942
3938 @end 3943 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698