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:
SurfaceTextureGLToGLTest()30     SurfaceTextureGLToGLTest():
31             mProducerEglSurface(EGL_NO_SURFACE),
32             mProducerEglContext(EGL_NO_CONTEXT) {
33     }
34 
SetUp()35     virtual void SetUp() {
36         SurfaceTextureGLTest::SetUp();
37     }
38 
SetUpWindowAndContext()39     void SetUpWindowAndContext() {
40         mProducerEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
41                 mANW.get(), nullptr);
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 
TearDown()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
68