| 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 "ui/accelerated_widget_mac/io_surface_layer.h" | 5 #include "ui/accelerated_widget_mac/io_surface_layer.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #include <OpenGL/CGLIOSurface.h> | 8 #include <OpenGL/CGLIOSurface.h> |
| 9 #include <OpenGL/CGLRenderers.h> | 9 #include <OpenGL/CGLRenderers.h> |
| 10 #include <OpenGL/gl.h> | 10 #include <OpenGL/gl.h> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // If we return NO 30 times in a row, switch to being synchronous to avoid | 73 // If we return NO 30 times in a row, switch to being synchronous to avoid |
| 74 // burning CPU cycles on this callback. | 74 // burning CPU cycles on this callback. |
| 75 if (needs_display_) { | 75 if (needs_display_) { |
| 76 did_not_draw_counter_ = 0; | 76 did_not_draw_counter_ = 0; |
| 77 } else { | 77 } else { |
| 78 did_not_draw_counter_ += 1; | 78 did_not_draw_counter_ += 1; |
| 79 if (did_not_draw_counter_ == 30) | 79 if (did_not_draw_counter_ == 30) |
| 80 [layer_ setAsynchronous:NO]; | 80 [layer_ setAsynchronous:NO]; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Add an instantaneous blip to the PendingSwapAck state to indicate | 83 if (needs_display_) { |
| 84 // that CoreAnimation asked if a frame is ready. A blip up to to 3 (usually | 84 // If there is a draw pending then increase the signal from 2 to 3, to |
| 85 // from 2, indicating that a swap ack is pending) indicates that we | 85 // indicate that we are in the state where there is a swap pending and |
| 86 // requested a draw. A blip up to 1 (usually from 0, indicating there is no | 86 // CoreAnimation has been committed to draw it. |
| 87 // pending swap ack) indicates that we did not request a draw. This would | 87 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 3); |
| 88 // be more natural to do with a tracing pseudo-thread | 88 } else { |
| 89 // http://crbug.com/366300 | 89 // If there is not a draw pending, then give an instantaneous blip up from |
| 90 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, needs_display_ ? 3 : 1); | 90 // 0 to 1, indicating that CoreAnimation was ready to draw a frame but we |
| 91 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, | 91 // were not (or didn't have new content to draw). |
| 92 has_pending_frame_ ? 2 : 0); | 92 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 1); |
| 93 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 0); |
| 94 } |
| 93 | 95 |
| 94 return needs_display_; | 96 return needs_display_; |
| 95 } | 97 } |
| 96 | 98 |
| 97 void IOSurfaceLayerHelper::DidDraw(bool success) { | 99 void IOSurfaceLayerHelper::DidDraw(bool success) { |
| 98 needs_display_ = false; | 100 needs_display_ = false; |
| 99 AckPendingFrame(success); | 101 AckPendingFrame(success); |
| 100 } | 102 } |
| 101 | 103 |
| 102 void IOSurfaceLayerHelper::AckPendingFrame(bool success) { | 104 void IOSurfaceLayerHelper::AckPendingFrame(bool success) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 if (helper_) | 293 if (helper_) |
| 292 helper_->DidDraw(draw_succeeded); | 294 helper_->DidDraw(draw_succeeded); |
| 293 | 295 |
| 294 [super drawInCGLContext:glContext | 296 [super drawInCGLContext:glContext |
| 295 pixelFormat:pixelFormat | 297 pixelFormat:pixelFormat |
| 296 forLayerTime:timeInterval | 298 forLayerTime:timeInterval |
| 297 displayTime:timeStamp]; | 299 displayTime:timeStamp]; |
| 298 } | 300 } |
| 299 | 301 |
| 300 @end | 302 @end |
| OLD | NEW |