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

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

Issue 447113004: Fix crash in GotAcceleratedIOSurfaceFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 void CompositingIOSurfaceLayerHelper::DidDraw(bool success) { 96 void CompositingIOSurfaceLayerHelper::DidDraw(bool success) {
97 needs_display_ = false; 97 needs_display_ = false;
98 AckPendingFrame(success); 98 AckPendingFrame(success);
99 } 99 }
100 100
101 void CompositingIOSurfaceLayerHelper::AckPendingFrame(bool success) { 101 void CompositingIOSurfaceLayerHelper::AckPendingFrame(bool success) {
102 if (!has_pending_frame_) 102 if (!has_pending_frame_)
103 return; 103 return;
104 has_pending_frame_ = false; 104 has_pending_frame_ = false;
105 client_->AcceleratedLayerDidDrawFrame(success); 105 if (success)
106 client_->AcceleratedLayerDidDrawFrame();
107 else
108 client_->AcceleratedLayerHitError();
106 // A trace value of 0 indicates that there is no longer a pending swap ack. 109 // A trace value of 0 indicates that there is no longer a pending swap ack.
107 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 0); 110 TRACE_COUNTER_ID1("browser", "PendingSwapAck", this, 0);
108 } 111 }
109 112
110 void CompositingIOSurfaceLayerHelper::SetNeedsDisplayAndDisplayAndAck() { 113 void CompositingIOSurfaceLayerHelper::SetNeedsDisplayAndDisplayAndAck() {
111 // Drawing using setNeedsDisplay and displayIfNeeded will result in 114 // Drawing using setNeedsDisplay and displayIfNeeded will result in
112 // subsequent canDrawInCGLContext callbacks getting dropped, and jerky 115 // subsequent canDrawInCGLContext callbacks getting dropped, and jerky
113 // animation. Disable asynchronous drawing before issuing these calls as a 116 // animation. Disable asynchronous drawing before issuing these calls as a
114 // workaround. 117 // workaround.
115 // http://crbug.com/395827 118 // http://crbug.com/395827
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 170 }
168 171
169 - (content::CompositingIOSurfaceContext*)context { 172 - (content::CompositingIOSurfaceContext*)context {
170 return context_.get(); 173 return context_.get();
171 } 174 }
172 175
173 - (id)initWithIOSurface:(scoped_refptr<content::CompositingIOSurfaceMac>) 176 - (id)initWithIOSurface:(scoped_refptr<content::CompositingIOSurfaceMac>)
174 iosurface 177 iosurface
175 withScaleFactor:(float)scale_factor 178 withScaleFactor:(float)scale_factor
176 withClient:(content::CompositingIOSurfaceLayerClient*)client { 179 withClient:(content::CompositingIOSurfaceLayerClient*)client {
180 DCHECK(iosurface);
177 if (self = [super init]) { 181 if (self = [super init]) {
178 helper_.reset(new content::CompositingIOSurfaceLayerHelper(client, self)); 182 helper_.reset(new content::CompositingIOSurfaceLayerHelper(client, self));
179 183
180 iosurface_ = iosurface; 184 iosurface_ = iosurface;
181 context_ = content::CompositingIOSurfaceContext::Get( 185 context_ = content::CompositingIOSurfaceContext::Get(
182 content::CompositingIOSurfaceContext::kCALayerContextWindowNumber); 186 content::CompositingIOSurfaceContext::kCALayerContextWindowNumber);
183 DCHECK(context_); 187 if (!context_) {
188 LOG(ERROR) << "Failed create CompositingIOSurfaceContext";
Ken Russell (switch to Gerrit) 2014/08/07 22:11:44 I wonder whether here and throughout these classes
ccameron 2014/08/07 22:28:24 If anything, I'd like to make these errors more vi
189 [self resetClient];
190 [self release];
191 return nil;
192 }
184 193
185 [self setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; 194 [self setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
186 [self setAnchorPoint:CGPointMake(0, 0)]; 195 [self setAnchorPoint:CGPointMake(0, 0)];
187 // Setting contents gravity is necessary to prevent the layer from being 196 // Setting contents gravity is necessary to prevent the layer from being
188 // scaled during dyanmic resizes (especially with devtools open). 197 // scaled during dyanmic resizes (especially with devtools open).
189 [self setContentsGravity:kCAGravityTopLeft]; 198 [self setContentsGravity:kCAGravityTopLeft];
190 if ([self respondsToSelector:(@selector(setContentsScale:))]) { 199 if ([self respondsToSelector:(@selector(setContentsScale:))]) {
191 [self setContentsScale:scale_factor]; 200 [self setContentsScale:scale_factor];
192 } 201 }
193 } 202 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 if (helper_) 291 if (helper_)
283 helper_->DidDraw(draw_succeeded); 292 helper_->DidDraw(draw_succeeded);
284 293
285 [super drawInCGLContext:glContext 294 [super drawInCGLContext:glContext
286 pixelFormat:pixelFormat 295 pixelFormat:pixelFormat
287 forLayerTime:timeInterval 296 forLayerTime:timeInterval
288 displayTime:timeStamp]; 297 displayTime:timeStamp];
289 } 298 }
290 299
291 @end 300 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698