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 <android/native_window.h> 18 19 #include <EGL/egl.h> 20 #include <GLES2/gl2.h> 21 #include <GLES2/gl2ext.h> 22 23 class Renderer { 24 public: 25 Renderer(ANativeWindow* window, bool offscreen, int workload); 26 virtual bool setUp(); 27 virtual bool tearDown(); 28 bool draw(); 29 virtual void drawWorkload() = 0; 30 virtual ~Renderer() {}; 31 static const int OFFSCREEN_INNER_FRAMES = 100; 32 static const int OFFSCREEN_GRID_SIZE = 10; 33 bool mOffscreen; 34 protected: 35 ANativeWindow* mWindow; 36 EGLDisplay mEglDisplay; 37 EGLSurface mEglSurface; 38 EGLContext mEglContext; 39 EGLConfig mGlConfig; 40 GLuint mProgramId; 41 EGLint mWidth; 42 EGLint mHeight; 43 int mWorkload; 44 int mFboWidth;// Frame buffer width 45 int mFboHeight;// Frame buffer height 46 GLuint mFboId;// Frame buffer id 47 GLuint mFboDepthId;// Depth buffer id 48 GLuint mFboTexId;// Frame buffer texture id 49 GLuint mFboProgId;// Frame buffer program id 50 GLuint mFboTexUniformHandle;// Frame buffer texture uniform handle 51 GLuint mFboXOffsetUniformHandle;// Frame buffer x offset uniform handle 52 GLuint mFboYOffsetUniformHandle;// Frame buffer y offset uniform handle 53 GLuint mFboPositionHandle;// Frame buffer position handle 54 GLuint mFboTexCoordHandle;// Frame buffer texture coordinate handle 55 }; 56 #endif 57