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

Side by Side Diff: bench/DeferredSurfaceCopyBench.cpp

Issue 622063003: check for newSurface failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "Benchmark.h" 9 #include "Benchmark.h"
10 #include "SkDeferredCanvas.h" 10 #include "SkDeferredCanvas.h"
(...skipping 20 matching lines...) Expand all
31 "DeferredSurfaceCopy_nonDiscardable"; 31 "DeferredSurfaceCopy_nonDiscardable";
32 } 32 }
33 33
34 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 34 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
35 // The canvas is not actually used for this test except to provide 35 // The canvas is not actually used for this test except to provide
36 // configuration information: gpu, multisampling, size, etc? 36 // configuration information: gpu, multisampling, size, etc?
37 SkImageInfo info = SkImageInfo::MakeN32Premul(kSurfaceWidth, kSurfaceHei ght); 37 SkImageInfo info = SkImageInfo::MakeN32Premul(kSurfaceWidth, kSurfaceHei ght);
38 const SkRect fullCanvasRect = SkRect::MakeWH( 38 const SkRect fullCanvasRect = SkRect::MakeWH(
39 SkIntToScalar(kSurfaceWidth), SkIntToScalar(kSurfaceHeight)); 39 SkIntToScalar(kSurfaceWidth), SkIntToScalar(kSurfaceHeight));
40 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); 40 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
41
42 // newSurface() can return NULL for several reasons, so we need to check
43 if (NULL == surface.get()) {
44 return; // should we signal the caller that we hit an error?
mtklein 2014/10/02 19:43:08 Can't hurt to at least log it? SkDebugf("Surface
reed1 2014/10/02 19:53:27 Done.
45 }
46
41 SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(su rface)); 47 SkAutoTUnref<SkDeferredCanvas> drawingCanvas(SkDeferredCanvas::Create(su rface));
42 48
43 for (int iteration = 0; iteration < loops; iteration++) { 49 for (int iteration = 0; iteration < loops; iteration++) {
44 drawingCanvas->clear(0); 50 drawingCanvas->clear(0);
45 SkAutoTUnref<SkImage> image(drawingCanvas->newImageSnapshot()); 51 SkAutoTUnref<SkImage> image(drawingCanvas->newImageSnapshot());
46 SkPaint paint; 52 SkPaint paint;
47 if (!fDiscardableContents) { 53 if (!fDiscardableContents) {
48 // If paint is not opaque, prior canvas contents are 54 // If paint is not opaque, prior canvas contents are
49 // not discardable because they are needed for compositing. 55 // not discardable because they are needed for compositing.
50 paint.setAlpha(127); 56 paint.setAlpha(127);
51 } 57 }
52 drawingCanvas->drawRect(fullCanvasRect, paint); 58 drawingCanvas->drawRect(fullCanvasRect, paint);
53 // Trigger copy on write, which should be faster in the discardable case. 59 // Trigger copy on write, which should be faster in the discardable case.
54 drawingCanvas->flush(); 60 drawingCanvas->flush();
55 } 61 }
56 } 62 }
57 63
58 private: 64 private:
59 bool fDiscardableContents; 65 bool fDiscardableContents;
60 66
61 typedef Benchmark INHERITED; 67 typedef Benchmark INHERITED;
62 }; 68 };
63 69
64 ////////////////////////////////////////////////////////////////////////////// 70 //////////////////////////////////////////////////////////////////////////////
65 71
66 DEF_BENCH( return new DeferredSurfaceCopyBench(false); ) 72 DEF_BENCH( return new DeferredSurfaceCopyBench(false); )
67 DEF_BENCH( return new DeferredSurfaceCopyBench(true); ) 73 DEF_BENCH( return new DeferredSurfaceCopyBench(true); )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698