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

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

Issue 408103004: Mac: Fix bad framerate when capturing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 25 matching lines...) Expand all
36 this, 36 this,
37 &CompositingIOSurfaceLayerHelper::TimerFired) {} 37 &CompositingIOSurfaceLayerHelper::TimerFired) {}
38 38
39 CompositingIOSurfaceLayerHelper::~CompositingIOSurfaceLayerHelper() { 39 CompositingIOSurfaceLayerHelper::~CompositingIOSurfaceLayerHelper() {
40 // Any acks that were waiting on this layer to draw will not occur, so ack 40 // Any acks that were waiting on this layer to draw will not occur, so ack
41 // them now to prevent blocking the renderer. 41 // them now to prevent blocking the renderer.
42 AckPendingFrame(true); 42 AckPendingFrame(true);
43 } 43 }
44 44
45 void CompositingIOSurfaceLayerHelper::GotNewFrame() { 45 void CompositingIOSurfaceLayerHelper::GotNewFrame() {
46 // A trace value of 2 indicates that there is a pending swap ack. See
47 // canDrawInCGLContext for other value meanings.
48 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 2);
49
46 has_pending_frame_ = true; 50 has_pending_frame_ = true;
47 needs_display_ = true; 51 needs_display_ = true;
48 timer_.Reset(); 52 timer_.Reset();
49 53
50 if ([layer_ context] && [layer_ context]->is_vsync_disabled()) { 54 // If reqested, draw immediately and don't bother trying to use the
51 // If vsync is disabled, draw immediately and don't bother trying to use 55 // isAsynchronous property to ensure smooth animation.
52 // the isAsynchronous property to ensure smooth animation. 56 if (client_->AcceleratedLayerShouldAckImmediately()) {
53 ImmediatelyForceDisplayAndAck(); 57 ImmediatelyForceDisplayAndAck();
54 } else { 58 } else {
55 needs_display_ = YES;
56 if (![layer_ isAsynchronous]) 59 if (![layer_ isAsynchronous])
57 [layer_ setAsynchronous:YES]; 60 [layer_ setAsynchronous:YES];
58 } 61 }
59
60 // A trace value of 2 indicates that there is a pending swap ack. See
61 // canDrawInCGLContext for other value meanings.
62 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 2);
63 } 62 }
64 63
65 void CompositingIOSurfaceLayerHelper::SetNeedsDisplay() { 64 void CompositingIOSurfaceLayerHelper::SetNeedsDisplay() {
66 needs_display_ = true; 65 needs_display_ = true;
67 } 66 }
68 67
69 bool CompositingIOSurfaceLayerHelper::CanDraw() { 68 bool CompositingIOSurfaceLayerHelper::CanDraw() {
70 // If we return NO 30 times in a row, switch to being synchronous to avoid 69 // If we return NO 30 times in a row, switch to being synchronous to avoid
71 // burning CPU cycles on this callback. 70 // burning CPU cycles on this callback.
72 if (needs_display_) { 71 if (needs_display_) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 if (helper_) 230 if (helper_)
232 helper_->DidDraw(draw_succeeded); 231 helper_->DidDraw(draw_succeeded);
233 232
234 [super drawInCGLContext:glContext 233 [super drawInCGLContext:glContext
235 pixelFormat:pixelFormat 234 pixelFormat:pixelFormat
236 forLayerTime:timeInterval 235 forLayerTime:timeInterval
237 displayTime:timeStamp]; 236 displayTime:timeStamp];
238 } 237 }
239 238
240 @end 239 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698