skia2/bench/GLBench.h
mtklein a1ebeb25e9 Remove const from const int loops.
This drives me nuts, and prevents `while (loops --> 0)`.

BUG=skia:

Review URL: https://codereview.chromium.org/1379923005
2015-10-01 09:43:39 -07:00

52 lines
1.4 KiB
C++

/*
* 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 onPreDraw(SkCanvas*) override;
virtual void setup(const GrGLContext*)=0;
void onPostDraw(SkCanvas* canvas) override;
virtual void teardown(const GrGLInterface*)=0;
void onDraw(int loops, SkCanvas*) override;
virtual void glDraw(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