OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkMatrix.h" | 8 #include "SkMatrix.h" |
9 #include "SkPoint.h" | 9 #include "SkPoint.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 , fProgram(0) { | 47 , fProgram(0) { |
48 fName = NumStagesSetupToStr(coverageSetup, numStages); | 48 fName = NumStagesSetupToStr(coverageSetup, numStages); |
49 } | 49 } |
50 | 50 |
51 protected: | 51 protected: |
52 const char* onGetName() override { | 52 const char* onGetName() override { |
53 return fName.c_str(); | 53 return fName.c_str(); |
54 } | 54 } |
55 | 55 |
56 void setup(const GrGLContext*) override; | 56 void setup(const GrGLContext*) override; |
57 void glDraw(const int loops, const GrGLContext*) override; | 57 void glDraw(int loops, const GrGLContext*) override; |
58 void teardown(const GrGLInterface*) override; | 58 void teardown(const GrGLInterface*) override; |
59 | 59 |
60 private: | 60 private: |
61 void setupSingleVbo(const GrGLInterface*, const SkMatrix*); | 61 void setupSingleVbo(const GrGLInterface*, const SkMatrix*); |
62 GrGLuint setupShader(const GrGLContext*); | 62 GrGLuint setupShader(const GrGLContext*); |
63 | 63 |
64 | 64 |
65 static SkString NumStagesSetupToStr(CoverageSetup coverageSetup, uint32_t nu
mStages) { | 65 static SkString NumStagesSetupToStr(CoverageSetup coverageSetup, uint32_t nu
mStages) { |
66 SkString name("GLVec4ScalarBench"); | 66 SkString name("GLVec4ScalarBench"); |
67 switch (coverageSetup) { | 67 switch (coverageSetup) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 int index = 0; | 255 int index = 0; |
256 SkMatrix viewMatrices[kNumTriPerDraw]; | 256 SkMatrix viewMatrices[kNumTriPerDraw]; |
257 setup_matrices(kNumTriPerDraw, [&index, &viewMatrices](const SkMatrix& m) { | 257 setup_matrices(kNumTriPerDraw, [&index, &viewMatrices](const SkMatrix& m) { |
258 viewMatrices[index++] = m; | 258 viewMatrices[index++] = m; |
259 }); | 259 }); |
260 this->setupSingleVbo(gl, viewMatrices); | 260 this->setupSingleVbo(gl, viewMatrices); |
261 | 261 |
262 GR_GL_CALL(gl, UseProgram(fProgram)); | 262 GR_GL_CALL(gl, UseProgram(fProgram)); |
263 } | 263 } |
264 | 264 |
265 void GLVec4ScalarBench::glDraw(const int loops, const GrGLContext* ctx) { | 265 void GLVec4ScalarBench::glDraw(int loops, const GrGLContext* ctx) { |
266 const GrGLInterface* gl = ctx->interface(); | 266 const GrGLInterface* gl = ctx->interface(); |
267 | 267 |
268 for (int i = 0; i < loops; i++) { | 268 for (int i = 0; i < loops; i++) { |
269 GR_GL_CALL(gl, DrawArrays(GR_GL_TRIANGLES, 0, kVerticesPerTri * kNumTriP
erDraw)); | 269 GR_GL_CALL(gl, DrawArrays(GR_GL_TRIANGLES, 0, kVerticesPerTri * kNumTriP
erDraw)); |
270 } | 270 } |
271 | 271 |
272 // using -w when running nanobench will not produce correct images; | 272 // using -w when running nanobench will not produce correct images; |
273 // changing this to #if 1 will write the correct images to the Skia folder. | 273 // changing this to #if 1 will write the correct images to the Skia folder. |
274 #if 0 | 274 #if 0 |
275 SkString filename("out"); | 275 SkString filename("out"); |
(...skipping 18 matching lines...) Expand all Loading... |
294 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 2) ) | 294 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 2) ) |
295 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 2) ) | 295 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 2) ) |
296 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 4) ) | 296 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 4) ) |
297 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 4) ) | 297 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 4) ) |
298 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 6) ) | 298 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 6) ) |
299 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 6) ) | 299 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 6) ) |
300 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 8) ) | 300 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseScalar_CoverageSe
tup, 8) ) |
301 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 8) ) | 301 DEF_BENCH( return new GLVec4ScalarBench(GLVec4ScalarBench::kUseVec4_CoverageSetu
p, 8) ) |
302 | 302 |
303 #endif | 303 #endif |
OLD | NEW |