diff options
author | 2015-07-01 12:39:07 -0700 | |
---|---|---|
committer | 2015-07-01 12:39:07 -0700 | |
commit | 74a07db2df189320d4f5804078dc2085b2d38d7c (patch) | |
tree | 9a32160bc17e7c26d70201bf336a7648b0ef8727 /bench/GLBench.h | |
parent | e9e3ee33f30c14c31afd5fc3fe4dda7f15783c75 (diff) |
cleanup GLBenches
BUG=skia:
Review URL: https://codereview.chromium.org/1214203004
Diffstat (limited to 'bench/GLBench.h')
-rw-r--r-- | bench/GLBench.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/bench/GLBench.h b/bench/GLBench.h new file mode 100644 index 0000000000..0755c4f1a8 --- /dev/null +++ b/bench/GLBench.h @@ -0,0 +1,51 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GLBench_DEFINED +#define GLBench_DEFINED + +#include "Benchmark.h" +#include "SkCanvas.h" +#include "SkImageEncoder.h" + +#if SK_SUPPORT_GPU +#include "gl/GrGLFunctions.h" + +class GrGLContext; +struct GrGLInterface; + +/* + * A virtual base class for microbenches which want to specifically test the performance of GL + */ + +class GLBench : public Benchmark { +public: + GLBench() {} + +protected: + const GrGLContext* getGLContext(SkCanvas*); + virtual const GrGLContext* onGetGLContext(const GrGLContext* ctx) { return ctx; } + void onPerCanvasPreDraw(SkCanvas* canvas) override; + virtual void setup(const GrGLContext*)=0; + void onPerCanvasPostDraw(SkCanvas* canvas) override; + virtual void teardown(const GrGLInterface*)=0; + void onDraw(const int loops, SkCanvas*) override; + virtual void glDraw(const int loops, const GrGLContext*)=0; + static GrGLuint CompileShader(const GrGLInterface*, const char* shaderSrc, GrGLenum type); + static GrGLuint CreateProgram(const GrGLInterface*, const char* vshader, const char* fshader); + static GrGLuint SetupFramebuffer(const GrGLInterface*, int screenWidth, int screenHeight); + static void DumpImage(const GrGLInterface* gl, uint32_t screenWidth, uint32_t screenHeight, + const char* filename); + + +private: + typedef Benchmark INHERITED; +}; + + +#endif +#endif |