OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "Benchmark.h" | 7 #include "Benchmark.h" |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkColorCubeFilter.h" | 9 #include "SkColorCubeFilter.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
11 | 11 |
12 class ColorCubeBench : public Benchmark { | 12 class ColorCubeBench : public Benchmark { |
13 SkISize fSize; | 13 SkISize fSize; |
14 int fCubeDimension; | 14 int fCubeDimension; |
15 SkData* fCubeData; | 15 SkData* fCubeData; |
16 SkBitmap fBitmap; | 16 SkBitmap fBitmap; |
17 | 17 |
18 public: | 18 public: |
19 ColorCubeBench() | 19 ColorCubeBench() |
20 : fCubeDimension(0) | 20 : fCubeDimension(0) |
21 , fCubeData(NULL) { | 21 , fCubeData(NULL) { |
22 fSize = SkISize::Make(2880, 1800); // 2014 Macbook Pro resolution | 22 fSize = SkISize::Make(2880, 1800); // 2014 Macbook Pro resolution |
23 } | 23 } |
24 | 24 |
25 ~ColorCubeBench() { | 25 ~ColorCubeBench() { |
26 SkSafeUnref(fCubeData); | 26 SkSafeUnref(fCubeData); |
27 } | 27 } |
28 | 28 |
29 protected: | 29 protected: |
30 virtual const char* onGetName() SK_OVERRIDE { | 30 const char* onGetName() SK_OVERRIDE { |
31 return "colorcube"; | 31 return "colorcube"; |
32 } | 32 } |
33 | 33 |
34 virtual void onPreDraw() SK_OVERRIDE { | 34 void onPreDraw() SK_OVERRIDE { |
35 if (!SkToBool(fCubeData)) { | 35 if (!SkToBool(fCubeData)) { |
36 this->makeCubeData(); | 36 this->makeCubeData(); |
37 this->make_bitmap(); | 37 this->make_bitmap(); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 41 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
42 this->test(loops, canvas); | 42 this->test(loops, canvas); |
43 } | 43 } |
44 | 44 |
45 virtual SkIPoint onGetSize() SK_OVERRIDE { | 45 SkIPoint onGetSize() SK_OVERRIDE { |
46 return SkIPoint::Make(fSize.width(), fSize.height()); | 46 return SkIPoint::Make(fSize.width(), fSize.height()); |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 static SkShader* MakeLinear(const SkISize& size) { | 50 static SkShader* MakeLinear(const SkISize& size) { |
51 const SkPoint pts[2] = { | 51 const SkPoint pts[2] = { |
52 { 0, 0 }, | 52 { 0, 0 }, |
53 { SkIntToScalar(size.width()), SkIntToScalar(size.height()) } | 53 { SkIntToScalar(size.width()), SkIntToScalar(size.height()) } |
54 }; | 54 }; |
55 static const SkColor colors[] = { SK_ColorYELLOW, SK_ColorBLUE }; | 55 static const SkColor colors[] = { SK_ColorYELLOW, SK_ColorBLUE }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 canvas->drawBitmap(fBitmap, 0, 0, &paint); | 102 canvas->drawBitmap(fBitmap, 0, 0, &paint); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 typedef Benchmark INHERITED; | 106 typedef Benchmark INHERITED; |
107 }; | 107 }; |
108 | 108 |
109 /////////////////////////////////////////////////////////////////////////////// | 109 /////////////////////////////////////////////////////////////////////////////// |
110 | 110 |
111 DEF_BENCH( return new ColorCubeBench(); ) | 111 DEF_BENCH( return new ColorCubeBench(); ) |
OLD | NEW |