check for newSurface failure

BUG=skia:

Review URL: https://codereview.chromium.org/622063003
This commit is contained in:
reed 2014-10-02 12:58:48 -07:00 committed by Commit bot
parent d1f0ebd0e2
commit 337c2dd420

View File

@ -38,6 +38,13 @@ protected:
const SkRect fullCanvasRect = SkRect::MakeWH( const SkRect fullCanvasRect = SkRect::MakeWH(
SkIntToScalar(kSurfaceWidth), SkIntToScalar(kSurfaceHeight)); SkIntToScalar(kSurfaceWidth), SkIntToScalar(kSurfaceHeight));
SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
// newSurface() can return NULL for several reasons, so we need to check
if (NULL == surface.get()) {
SkDebugf("DeferredSurfaceCopyBench newSurface failed, bench results are meaningless\n");
return; // should we signal the caller that we hit an error?
}
SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(surface)); SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(surface));
for (int iteration = 0; iteration < loops; iteration++) { for (int iteration = 0; iteration < loops; iteration++) {