2015-07-01 19:39:07 +00:00
|
|
|
/*
|
|
|
|
* 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; }
|
2015-09-30 19:11:07 +00:00
|
|
|
void onPreDraw(SkCanvas*) override;
|
2015-07-01 19:39:07 +00:00
|
|
|
virtual void setup(const GrGLContext*)=0;
|
2015-09-30 19:11:07 +00:00
|
|
|
void onPostDraw(SkCanvas* canvas) override;
|
2015-07-01 19:39:07 +00:00
|
|
|
virtual void teardown(const GrGLInterface*)=0;
|
2015-10-01 16:43:39 +00:00
|
|
|
void onDraw(int loops, SkCanvas*) override;
|
|
|
|
virtual void glDraw(int loops, const GrGLContext*)=0;
|
2016-10-12 13:39:56 +00:00
|
|
|
static GrGLuint CompileShader(const GrGLContext*, const char* shaderSrc, GrGLenum type);
|
|
|
|
static GrGLuint CreateProgram(const GrGLContext*, const char* vshader, const char* fshader);
|
2015-07-01 19:39:07 +00:00
|
|
|
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
|