OLD | NEW |
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" |
11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkImage.h" | 12 #include "SkImage.h" |
13 #include "SkSurface.h" | 13 #include "SkSurface.h" |
14 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
16 #endif | 16 #endif |
17 | 17 |
18 class DeferredSurfaceCopyBench : public Benchmark { | 18 class DeferredSurfaceCopyBench : public Benchmark { |
19 enum { | 19 enum { |
20 kSurfaceWidth = 1000, | 20 kSurfaceWidth = 1000, |
21 kSurfaceHeight = 1000, | 21 kSurfaceHeight = 1000, |
22 }; | 22 }; |
23 public: | 23 public: |
24 DeferredSurfaceCopyBench(bool discardableContents) { | 24 DeferredSurfaceCopyBench(bool discardableContents) { |
25 fDiscardableContents = discardableContents; | 25 fDiscardableContents = discardableContents; |
26 } | 26 } |
27 | 27 |
28 protected: | 28 protected: |
29 const char* onGetName() SK_OVERRIDE { | 29 const char* onGetName() override { |
30 return fDiscardableContents ? "DeferredSurfaceCopy_discardable" : | 30 return fDiscardableContents ? "DeferredSurfaceCopy_discardable" : |
31 "DeferredSurfaceCopy_nonDiscardable"; | 31 "DeferredSurfaceCopy_nonDiscardable"; |
32 } | 32 } |
33 | 33 |
34 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 34 void onDraw(const int loops, SkCanvas* canvas) 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 | 41 |
42 // newSurface() can return NULL for several reasons, so we need to check | 42 // newSurface() can return NULL for several reasons, so we need to check |
43 if (NULL == surface.get()) { | 43 if (NULL == surface.get()) { |
44 SkDebugf("DeferredSurfaceCopyBench newSurface failed, bench results
are meaningless\n"); | 44 SkDebugf("DeferredSurfaceCopyBench newSurface failed, bench results
are meaningless\n"); |
(...skipping 20 matching lines...) Expand all Loading... |
65 private: | 65 private: |
66 bool fDiscardableContents; | 66 bool fDiscardableContents; |
67 | 67 |
68 typedef Benchmark INHERITED; | 68 typedef Benchmark INHERITED; |
69 }; | 69 }; |
70 | 70 |
71 ////////////////////////////////////////////////////////////////////////////// | 71 ////////////////////////////////////////////////////////////////////////////// |
72 | 72 |
73 DEF_BENCH( return new DeferredSurfaceCopyBench(false); ) | 73 DEF_BENCH( return new DeferredSurfaceCopyBench(false); ) |
74 DEF_BENCH( return new DeferredSurfaceCopyBench(true); ) | 74 DEF_BENCH( return new DeferredSurfaceCopyBench(true); ) |
OLD | NEW |