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

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

Issue 171513012: Make --disable-gpu-vsync work with CoreAnimation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add swap ack scoped runner fix Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/compositing_iosurface_layer_mac.h" 5 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 9
10 #include "base/mac/sdk_forward_declarations.h" 10 #include "base/mac/sdk_forward_declarations.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return self; 50 return self;
51 } 51 }
52 52
53 - (void)disableCompositing{ 53 - (void)disableCompositing{
54 ScopedCAActionDisabler disabler; 54 ScopedCAActionDisabler disabler;
55 [self removeFromSuperlayer]; 55 [self removeFromSuperlayer];
56 renderWidgetHostView_ = nil; 56 renderWidgetHostView_ = nil;
57 } 57 }
58 58
59 - (void)gotNewFrame { 59 - (void)gotNewFrame {
60 if (![self isAsynchronous]) { 60 if (context_ && context_->is_vsync_disabled()) {
61 // If vsync is disabled, draw immediately and don't bother trying to use
62 // the isAsynchronous property to ensure smooth animation.
61 [self setNeedsDisplay]; 63 [self setNeedsDisplay];
62 [self setAsynchronous:YES]; 64 [self displayIfNeeded];
65
66 // Calls to setNeedsDisplay can sometimes be ignored, especially if issued
67 // rapidly (e.g, with vsync off). This is unacceptable because the failure
68 // to ack a single frame will hang the renderer. Ensure that the renderer
69 // not be blocked.
70 if (needsDisplay_)
71 renderWidgetHostView_->SendPendingSwapAck();
Ken Russell (switch to Gerrit) 2014/02/20 23:01:53 If we're mostly sending swap acks upon receiving n
ccameron 2014/02/21 00:48:23 CompositorSwapBuffers only does the ack if the fra
63 } else { 72 } else {
64 needsDisplay_ = YES; 73 needsDisplay_ = YES;
74 if (![self isAsynchronous])
75 [self setAsynchronous:YES];
65 } 76 }
66 } 77 }
67 78
68 - (void)timerSinceGotNewFrameFired { 79 - (void)timerSinceGotNewFrameFired {
69 if (![self isAsynchronous]) 80 if (![self isAsynchronous])
70 return; 81 return;
71 82
72 [self setAsynchronous:NO]; 83 [self setAsynchronous:NO];
84
85 // If there was a pending frame, ensure that it goes through.
86 if (needsDisplay_) {
87 [self setNeedsDisplay];
88 [self displayIfNeeded];
89 }
90 // If that fails then ensure that, at a minimum, the renderer is not blocked.
73 if (needsDisplay_) 91 if (needsDisplay_)
74 [self setNeedsDisplay]; 92 renderWidgetHostView_->SendPendingSwapAck();
75 } 93 }
76 94
77 - (void)waitForResizedFrameInContext:(CGLContextObj)glContext { 95 - (void)waitForResizedFrameInContext:(CGLContextObj)glContext {
78 // Cache a copy of renderWidgetHostView_ because it may be reset if 96 // Cache a copy of renderWidgetHostView_ because it may be reset if
79 // a software frame is received in GetBackingStore. 97 // a software frame is received in GetBackingStore.
80 content::RenderWidgetHostViewMac* cached_view = renderWidgetHostView_; 98 content::RenderWidgetHostViewMac* cached_view = renderWidgetHostView_;
81 if (!cached_view->render_widget_host_ || 99 if (!cached_view->render_widget_host_ ||
82 cached_view->render_widget_host_->is_hidden()) { 100 cached_view->render_widget_host_->is_hidden()) {
83 return; 101 return;
84 } 102 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 context_, 189 context_,
172 window_rect, 190 window_rect,
173 window_scale_factor, 191 window_scale_factor,
174 false)) { 192 false)) {
175 renderWidgetHostView_->GotAcceleratedCompositingError(); 193 renderWidgetHostView_->GotAcceleratedCompositingError();
176 return; 194 return;
177 } 195 }
178 196
179 needsDisplay_ = NO; 197 needsDisplay_ = NO;
180 renderWidgetHostView_->SendPendingLatencyInfoToHost(); 198 renderWidgetHostView_->SendPendingLatencyInfoToHost();
199
200 [super drawInCGLContext:glContext
201 pixelFormat:pixelFormat
202 forLayerTime:timeInterval
203 displayTime:timeStamp];
181 } 204 }
182 205
183 @end 206 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698