Lingfeng Yang | 0e6868f | 2020-11-03 12:32:59 -0800 | [diff] [blame] | 1 | // Copyright (C) 2017 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // 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 |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | #pragma once |
| 15 | |
| 16 | #include "OpenGLESDispatch/OpenGLDispatchLoader.h" |
| 17 | |
| 18 | // gtest has its own definitions for None and Bool |
| 19 | #ifdef None |
| 20 | #undef None |
| 21 | #endif |
| 22 | #ifdef Bool |
| 23 | #undef Bool |
| 24 | #endif |
| 25 | #include <gtest/gtest.h> |
| 26 | |
| 27 | #include <EGL/egl.h> |
| 28 | #include <GLES2/gl2.h> |
| 29 | #include <GLES3/gl31.h> |
| 30 | |
Jason Macnak | ed0c9e6 | 2023-03-30 15:58:24 -0700 | [diff] [blame] | 31 | namespace gfxstream { |
| 32 | namespace gl { |
Lingfeng Yang | 0e6868f | 2020-11-03 12:32:59 -0800 | [diff] [blame] | 33 | |
| 34 | // Dimensions for test surface |
| 35 | static const int kTestSurfaceSize[] = {32, 32}; |
| 36 | |
| 37 | EGLDisplay getDisplay(); |
| 38 | EGLConfig createConfig(EGLDisplay dpy, EGLint r, EGLint g, EGLint b, EGLint a, EGLint d, EGLint s, EGLint ms); |
| 39 | EGLSurface pbufferSurface(EGLDisplay dpy, ::EGLConfig config, EGLint w, EGLint h); |
| 40 | EGLContext createContext(EGLDisplay dpy, EGLConfig config, EGLint maj, EGLint min); |
| 41 | void destroyContext(EGLDisplay dpy, EGLContext cxt); |
| 42 | void destroySurface(EGLDisplay dpy, EGLSurface surface); |
| 43 | void destroyDisplay(EGLDisplay dpy); |
| 44 | |
| 45 | class GLTest : public ::testing::Test { |
| 46 | protected: |
Joshua Duong | d38ac30 | 2022-06-01 10:50:21 -0700 | [diff] [blame] | 47 | static void SetUpTestSuite(); |
Lingfeng Yang | 0e6868f | 2020-11-03 12:32:59 -0800 | [diff] [blame] | 48 | virtual void SetUp(); |
| 49 | virtual void TearDown(); |
| 50 | |
Doug Horn | fb0ba20 | 2022-05-19 14:09:21 -0700 | [diff] [blame] | 51 | const GLESv1Dispatch* gles1; |
Lingfeng Yang | 0e6868f | 2020-11-03 12:32:59 -0800 | [diff] [blame] | 52 | const GLESv2Dispatch* gl; |
| 53 | EGLDisplay m_display; |
| 54 | EGLConfig m_config; |
| 55 | EGLSurface m_surface; |
| 56 | EGLContext m_context; |
| 57 | }; |
| 58 | |
Hailin zhang | b70bf5b | 2022-05-12 07:22:12 +0000 | [diff] [blame] | 59 | |
| 60 | #define EMUGL_SKIP_TEST_IF(COND) \ |
| 61 | do \ |
| 62 | { \ |
| 63 | if (COND) \ |
| 64 | { \ |
| 65 | GTEST_SKIP() << "Test skipped: " #COND "."; \ |
| 66 | return; \ |
| 67 | } \ |
| 68 | } while (0) |
Jason Macnak | ed0c9e6 | 2023-03-30 15:58:24 -0700 | [diff] [blame] | 69 | |
| 70 | } // namespace gl |
| 71 | } // namespace gfxstream |