| 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 |  | 
 | 17 | #ifndef ANDROID_SURFACE_TEXTURE_GL_TO_GL_H | 
 | 18 | #define ANDROID_SURFACE_TEXTURE_GL_TO_GL_H | 
 | 19 |  | 
 | 20 | #include "SurfaceTextureGL.h" | 
 | 21 |  | 
 | 22 | namespace android { | 
 | 23 |  | 
 | 24 | /* | 
 | 25 |  * This test fixture is for testing GL -> GL texture streaming.  It creates an | 
 | 26 |  * EGLSurface and an EGLContext for the image producer to use. | 
 | 27 |  */ | 
 | 28 | class SurfaceTextureGLToGLTest : public SurfaceTextureGLTest { | 
 | 29 | protected: | 
 | 30 |     SurfaceTextureGLToGLTest(): | 
 | 31 |             mProducerEglSurface(EGL_NO_SURFACE), | 
 | 32 |             mProducerEglContext(EGL_NO_CONTEXT) { | 
 | 33 |     } | 
 | 34 |  | 
 | 35 |     virtual void SetUp() { | 
 | 36 |         SurfaceTextureGLTest::SetUp(); | 
| Pablo Ceballos | b687a28 | 2015-10-06 11:14:51 -0700 | [diff] [blame] | 37 |     } | 
| Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 38 |  | 
| Pablo Ceballos | b687a28 | 2015-10-06 11:14:51 -0700 | [diff] [blame] | 39 |     void SetUpWindowAndContext() { | 
| Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 40 |         mProducerEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig, | 
| Yi Kong | a03e044 | 2018-07-17 11:16:57 -0700 | [diff] [blame] | 41 |                 mANW.get(), nullptr); | 
| Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 42 |         ASSERT_EQ(EGL_SUCCESS, eglGetError()); | 
 | 43 |         ASSERT_NE(EGL_NO_SURFACE, mProducerEglSurface); | 
 | 44 |  | 
 | 45 |         mProducerEglContext = eglCreateContext(mEglDisplay, mGlConfig, | 
 | 46 |                 EGL_NO_CONTEXT, getContextAttribs()); | 
 | 47 |         ASSERT_EQ(EGL_SUCCESS, eglGetError()); | 
 | 48 |         ASSERT_NE(EGL_NO_CONTEXT, mProducerEglContext); | 
 | 49 |     } | 
 | 50 |  | 
 | 51 |     virtual void TearDown() { | 
 | 52 |         if (mProducerEglContext != EGL_NO_CONTEXT) { | 
 | 53 |             eglDestroyContext(mEglDisplay, mProducerEglContext); | 
 | 54 |         } | 
 | 55 |         if (mProducerEglSurface != EGL_NO_SURFACE) { | 
 | 56 |             eglDestroySurface(mEglDisplay, mProducerEglSurface); | 
 | 57 |         } | 
 | 58 |         SurfaceTextureGLTest::TearDown(); | 
 | 59 |     } | 
 | 60 |  | 
 | 61 |     EGLSurface mProducerEglSurface; | 
 | 62 |     EGLContext mProducerEglContext; | 
 | 63 | }; | 
 | 64 |  | 
 | 65 | } // namespace android | 
 | 66 |  | 
 | 67 | #endif |