1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 #ifndef RENDERER_H 15 #define RENDERER_H 16 17 #include <EGL/egl.h> 18 #include <GLES2/gl2.h> 19 #include <GLES2/gl2ext.h> 20 21 class Renderer { 22 public: 23 Renderer(EGLNativeWindowType window, bool offscreen); 24 virtual bool setUp(int workload); 25 virtual bool tearDown(); 26 bool eglSetUp(); 27 void eglTearDown(); 28 29 bool draw(); 30 virtual void drawWorkload() = 0; ~Renderer()31 virtual ~Renderer() {}; 32 static const int OFFSCREEN_INNER_FRAMES = 100; 33 static const int OFFSCREEN_GRID_SIZE = 10; 34 bool mOffscreen; 35 protected: 36 EGLDisplay mEglDisplay; 37 EGLSurface mEglSurface; 38 EGLContext mEglContext; 39 EGLConfig mGlConfig; 40 GLuint mProgramId; 41 EGLint mWidth; 42 EGLint mHeight; 43 int mFboWidth;// Frame buffer width 44 int mFboHeight;// Frame buffer height 45 GLuint mFboId;// Frame buffer id 46 GLuint mFboDepthId;// Depth buffer id 47 GLuint mFboTexId;// Frame buffer texture id 48 GLuint mFboProgId;// Frame buffer program id 49 GLuint mFboTexUniformHandle;// Frame buffer texture uniform handle 50 GLuint mFboXOffsetUniformHandle;// Frame buffer x offset uniform handle 51 GLuint mFboYOffsetUniformHandle;// Frame buffer y offset uniform handle 52 GLuint mFboPositionHandle;// Frame buffer position handle 53 GLuint mFboTexCoordHandle;// Frame buffer texture coordinate handle 54 private: 55 EGLNativeWindowType mWindow; 56 }; 57 #endif 58