OLD | NEW |
---|---|
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 Loading... | |
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 ([self isAsynchronous]) { |
61 [self setNeedsDisplay]; | 61 needsDisplay_ = YES; |
62 [self setAsynchronous:YES]; | |
63 } else { | 62 } else { |
64 needsDisplay_ = YES; | 63 // Calls to setNeedsDisplay can sometimes be ignored, especially if issued |
64 // rapidly (e.g, with vsync off). This is unacceptable because the failure | |
65 // to ack a single frame will hang the renderer. Call setNeedsDisplay and | |
66 // displayIfNeeded in a loop to ensure the call goes through. | |
67 do { | |
68 [self setNeedsDisplay]; | |
69 [self displayIfNeeded]; | |
70 } while (needsDisplay_); | |
71 | |
72 // If vsync is disabled, don't bother trying to use the isAsynchronous | |
73 // property to ensure smooth animation. | |
74 if (!context_ || !context_->is_vsync_disabled()) { | |
75 [self setAsynchronous:YES]; | |
76 } | |
65 } | 77 } |
66 } | 78 } |
67 | 79 |
68 - (void)timerSinceGotNewFrameFired { | 80 - (void)timerSinceGotNewFrameFired { |
69 if (![self isAsynchronous]) | 81 if (![self isAsynchronous]) |
70 return; | 82 return; |
71 | 83 |
72 [self setAsynchronous:NO]; | 84 [self setAsynchronous:NO]; |
73 if (needsDisplay_) | 85 |
86 // If there was a pending frame, ensure that it goes through. | |
87 while (needsDisplay_) { | |
74 [self setNeedsDisplay]; | 88 [self setNeedsDisplay]; |
89 [self displayIfNeeded]; | |
90 } | |
75 } | 91 } |
76 | 92 |
77 - (void)waitForResizedFrameInContext:(CGLContextObj)glContext { | 93 - (void)waitForResizedFrameInContext:(CGLContextObj)glContext { |
78 // Cache a copy of renderWidgetHostView_ because it may be reset if | 94 // Cache a copy of renderWidgetHostView_ because it may be reset if |
79 // a software frame is received in GetBackingStore. | 95 // a software frame is received in GetBackingStore. |
80 content::RenderWidgetHostViewMac* cached_view = renderWidgetHostView_; | 96 content::RenderWidgetHostViewMac* cached_view = renderWidgetHostView_; |
81 if (!cached_view->render_widget_host_ || | 97 if (!cached_view->render_widget_host_ || |
82 cached_view->render_widget_host_->is_hidden()) { | 98 cached_view->render_widget_host_->is_hidden()) { |
83 return; | 99 return; |
84 } | 100 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 context_, | 187 context_, |
172 window_rect, | 188 window_rect, |
173 window_scale_factor, | 189 window_scale_factor, |
174 false)) { | 190 false)) { |
175 renderWidgetHostView_->GotAcceleratedCompositingError(); | 191 renderWidgetHostView_->GotAcceleratedCompositingError(); |
176 return; | 192 return; |
177 } | 193 } |
178 | 194 |
179 needsDisplay_ = NO; | 195 needsDisplay_ = NO; |
180 renderWidgetHostView_->SendPendingLatencyInfoToHost(); | 196 renderWidgetHostView_->SendPendingLatencyInfoToHost(); |
197 | |
ccameron
2014/02/20 10:42:59
This is to match the behavior of WebKit. The claim
| |
198 [super drawInCGLContext:glContext | |
199 pixelFormat:pixelFormat | |
200 forLayerTime:timeInterval | |
201 displayTime:timeStamp]; | |
181 } | 202 } |
182 | 203 |
183 @end | 204 @end |
OLD | NEW |