| Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright 2013 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  */ | 
 | 16 |  | 
| Dan Stoza | f3730fb | 2013-11-26 15:10:10 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_GL_TEST_H | 
 | 18 | #define ANDROID_GL_TEST_H | 
 | 19 |  | 
 | 20 | #include <gtest/gtest.h> | 
 | 21 |  | 
 | 22 | #include <gui/SurfaceComposerClient.h> | 
 | 23 |  | 
 | 24 | #include <EGL/egl.h> | 
 | 25 | #include <GLES/gl.h> | 
 | 26 |  | 
 | 27 | namespace android { | 
 | 28 |  | 
 | 29 | class GLTest : public ::testing::Test { | 
| Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 30 | public: | 
 | 31 |     static void loadShader(GLenum shaderType, const char* pSource, | 
 | 32 |             GLuint* outShader); | 
 | 33 |     static void createProgram(const char* pVertexSource, | 
 | 34 |             const char* pFragmentSource, GLuint* outPgm); | 
 | 35 |  | 
| Dan Stoza | f3730fb | 2013-11-26 15:10:10 -0800 | [diff] [blame] | 36 | protected: | 
 | 37 |     GLTest() : | 
| Pablo Ceballos | 53390e1 | 2015-08-04 11:25:59 -0700 | [diff] [blame] | 38 |             mDisplaySecs(0), | 
| Dan Stoza | f3730fb | 2013-11-26 15:10:10 -0800 | [diff] [blame] | 39 |             mEglDisplay(EGL_NO_DISPLAY), | 
 | 40 |             mEglSurface(EGL_NO_SURFACE), | 
| Pablo Ceballos | 53390e1 | 2015-08-04 11:25:59 -0700 | [diff] [blame] | 41 |             mEglContext(EGL_NO_CONTEXT), | 
| Yi Kong | a03e044 | 2018-07-17 11:16:57 -0700 | [diff] [blame] | 42 |             mGlConfig(nullptr) { | 
| Dan Stoza | f3730fb | 2013-11-26 15:10:10 -0800 | [diff] [blame] | 43 |     } | 
 | 44 |  | 
 | 45 |     virtual void SetUp(); | 
 | 46 |     virtual void TearDown(); | 
 | 47 |  | 
 | 48 |     virtual EGLint const* getConfigAttribs(); | 
 | 49 |     virtual EGLint const* getContextAttribs(); | 
 | 50 |     virtual EGLint getSurfaceWidth(); | 
 | 51 |     virtual EGLint getSurfaceHeight(); | 
 | 52 |     virtual EGLSurface createWindowSurface(EGLDisplay display, EGLConfig config, | 
 | 53 |                                            sp<ANativeWindow>& window) const; | 
 | 54 |  | 
 | 55 |     ::testing::AssertionResult checkPixel(int x, int y, | 
 | 56 |             int r, int g, int b, int a, int tolerance = 2); | 
 | 57 |     ::testing::AssertionResult assertRectEq(const Rect &r1, const Rect &r2, | 
 | 58 |             int tolerance = 1); | 
 | 59 |  | 
| Dan Stoza | f3730fb | 2013-11-26 15:10:10 -0800 | [diff] [blame] | 60 |     int mDisplaySecs; | 
 | 61 |     sp<SurfaceComposerClient> mComposerClient; | 
 | 62 |     sp<SurfaceControl> mSurfaceControl; | 
 | 63 |  | 
 | 64 |     EGLDisplay mEglDisplay; | 
 | 65 |     EGLSurface mEglSurface; | 
 | 66 |     EGLContext mEglContext; | 
 | 67 |     EGLConfig  mGlConfig; | 
 | 68 | }; | 
 | 69 |  | 
 | 70 | } // namespace android | 
 | 71 |  | 
 | 72 | #endif |