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 "Benchmark.h" | 8 #include "Benchmark.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 , fProgram(0) | 29 , fProgram(0) |
30 , fVBO(0) | 30 , fVBO(0) |
31 , fAttribs(attribs) | 31 , fAttribs(attribs) |
32 , fStride(2 * sizeof(SkPoint) + fAttribs * sizeof(GrGLfloat) * 4) { | 32 , fStride(2 * sizeof(SkPoint) + fAttribs * sizeof(GrGLfloat) * 4) { |
33 fName.appendf("GLVertexAttributesBench_%d", fAttribs); | 33 fName.appendf("GLVertexAttributesBench_%d", fAttribs); |
34 } | 34 } |
35 | 35 |
36 protected: | 36 protected: |
37 const char* onGetName() override { return fName.c_str(); } | 37 const char* onGetName() override { return fName.c_str(); } |
38 void setup(const GrGLContext*) override; | 38 void setup(const GrGLContext*) override; |
39 void glDraw(const int loops, const GrGLContext*) override; | 39 void glDraw(int loops, const GrGLContext*) override; |
40 void teardown(const GrGLInterface*) override; | 40 void teardown(const GrGLInterface*) override; |
41 | 41 |
42 static const GrGLuint kScreenWidth = 800; | 42 static const GrGLuint kScreenWidth = 800; |
43 static const GrGLuint kScreenHeight = 600; | 43 static const GrGLuint kScreenHeight = 600; |
44 static const uint32_t kNumTri = 10000; | 44 static const uint32_t kNumTri = 10000; |
45 static const uint32_t kVerticesPerTri = 3; | 45 static const uint32_t kVerticesPerTri = 3; |
46 static const uint32_t kDrawMultiplier = 512; | 46 static const uint32_t kDrawMultiplier = 512; |
47 static const uint32_t kMaxAttribs = 7; | 47 static const uint32_t kMaxAttribs = 7; |
48 | 48 |
49 private: | 49 private: |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 fBuffers.push_back(fVBO); | 200 fBuffers.push_back(fVBO); |
201 | 201 |
202 // clear screen | 202 // clear screen |
203 GR_GL_CALL(gl, ClearColor(0.03f, 0.03f, 0.03f, 1.0f)); | 203 GR_GL_CALL(gl, ClearColor(0.03f, 0.03f, 0.03f, 1.0f)); |
204 GR_GL_CALL(gl, Clear(GR_GL_COLOR_BUFFER_BIT)); | 204 GR_GL_CALL(gl, Clear(GR_GL_COLOR_BUFFER_BIT)); |
205 | 205 |
206 // set us up to draw | 206 // set us up to draw |
207 GR_GL_CALL(gl, UseProgram(fProgram)); | 207 GR_GL_CALL(gl, UseProgram(fProgram)); |
208 } | 208 } |
209 | 209 |
210 void GLVertexAttributesBench::glDraw(const int loops, const GrGLContext* ctx) { | 210 void GLVertexAttributesBench::glDraw(int loops, const GrGLContext* ctx) { |
211 const GrGLInterface* gl = ctx->interface(); | 211 const GrGLInterface* gl = ctx->interface(); |
212 | 212 |
213 // upload vertex attributes | 213 // upload vertex attributes |
214 GR_GL_CALL(gl, BindBuffer(GR_GL_ARRAY_BUFFER, fVBO)); | 214 GR_GL_CALL(gl, BindBuffer(GR_GL_ARRAY_BUFFER, fVBO)); |
215 GR_GL_CALL(gl, EnableVertexAttribArray(0)); | 215 GR_GL_CALL(gl, EnableVertexAttribArray(0)); |
216 GR_GL_CALL(gl, VertexAttribPointer(0, 4, GR_GL_FLOAT, GR_GL_FALSE, (GrGLsize
i)fStride, | 216 GR_GL_CALL(gl, VertexAttribPointer(0, 4, GR_GL_FLOAT, GR_GL_FALSE, (GrGLsize
i)fStride, |
217 (GrGLvoid*)0)); | 217 (GrGLvoid*)0)); |
218 | 218 |
219 size_t runningStride = 2 * sizeof(SkPoint); | 219 size_t runningStride = 2 * sizeof(SkPoint); |
220 for (uint32_t i = 0; i < fAttribs; i++) { | 220 for (uint32_t i = 0; i < fAttribs; i++) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 DEF_BENCH( return new GLVertexAttributesBench(0) ) | 261 DEF_BENCH( return new GLVertexAttributesBench(0) ) |
262 DEF_BENCH( return new GLVertexAttributesBench(1) ) | 262 DEF_BENCH( return new GLVertexAttributesBench(1) ) |
263 DEF_BENCH( return new GLVertexAttributesBench(2) ) | 263 DEF_BENCH( return new GLVertexAttributesBench(2) ) |
264 DEF_BENCH( return new GLVertexAttributesBench(3) ) | 264 DEF_BENCH( return new GLVertexAttributesBench(3) ) |
265 DEF_BENCH( return new GLVertexAttributesBench(4) ) | 265 DEF_BENCH( return new GLVertexAttributesBench(4) ) |
266 DEF_BENCH( return new GLVertexAttributesBench(5) ) | 266 DEF_BENCH( return new GLVertexAttributesBench(5) ) |
267 DEF_BENCH( return new GLVertexAttributesBench(6) ) | 267 DEF_BENCH( return new GLVertexAttributesBench(6) ) |
268 DEF_BENCH( return new GLVertexAttributesBench(7) ) | 268 DEF_BENCH( return new GLVertexAttributesBench(7) ) |
269 #endif | 269 #endif |
OLD | NEW |