OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 7 |
8 #include "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 SkColor fColors[PTS]; | 32 SkColor fColors[PTS]; |
33 uint16_t fIdx[IDX]; | 33 uint16_t fIdx[IDX]; |
34 | 34 |
35 static void load_2_tris(uint16_t idx[], int x, int y, int rb) { | 35 static void load_2_tris(uint16_t idx[], int x, int y, int rb) { |
36 int n = y * rb + x; | 36 int n = y * rb + x; |
37 idx[0] = n; idx[1] = n + 1; idx[2] = rb + n + 1; | 37 idx[0] = n; idx[1] = n + 1; idx[2] = rb + n + 1; |
38 idx[3] = n; idx[4] = rb + n + 1; idx[5] = n + rb; | 38 idx[3] = n; idx[4] = rb + n + 1; idx[5] = n + rb; |
39 } | 39 } |
40 | 40 |
41 public: | 41 public: |
42 VertBench(void* param) : INHERITED(param) { | 42 VertBench() { |
43 const SkScalar dx = SkIntToScalar(W) / COL; | 43 const SkScalar dx = SkIntToScalar(W) / COL; |
44 const SkScalar dy = SkIntToScalar(H) / COL; | 44 const SkScalar dy = SkIntToScalar(H) / COL; |
45 | 45 |
46 SkPoint* pts = fPts; | 46 SkPoint* pts = fPts; |
47 uint16_t* idx = fIdx; | 47 uint16_t* idx = fIdx; |
48 | 48 |
49 SkScalar yy = 0; | 49 SkScalar yy = 0; |
50 for (int y = 0; y <= ROW; y++) { | 50 for (int y = 0; y <= ROW; y++) { |
51 SkScalar xx = 0; | 51 SkScalar xx = 0; |
52 for (int x = 0; x <= COL; ++x) { | 52 for (int x = 0; x <= COL; ++x) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, PTS, | 85 canvas->drawVertices(SkCanvas::kTriangles_VertexMode, PTS, |
86 fPts, NULL, fColors, NULL, fIdx, IDX, paint); | 86 fPts, NULL, fColors, NULL, fIdx, IDX, paint); |
87 } | 87 } |
88 } | 88 } |
89 private: | 89 private: |
90 typedef SkBenchmark INHERITED; | 90 typedef SkBenchmark INHERITED; |
91 }; | 91 }; |
92 | 92 |
93 /////////////////////////////////////////////////////////////////////////////// | 93 /////////////////////////////////////////////////////////////////////////////// |
94 | 94 |
95 static SkBenchmark* Fact(void* p) { return SkNEW_ARGS(VertBench, (p)); } | 95 DEF_BENCH( return SkNEW_ARGS(VertBench, ()); ) |
96 | |
97 static BenchRegistry gReg(Fact); | |
OLD | NEW |