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
22namespace 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 */
28class SurfaceTextureGLToGLTest : public SurfaceTextureGLTest {
29protected:
30    SurfaceTextureGLToGLTest():
31            mProducerEglSurface(EGL_NO_SURFACE),
32            mProducerEglContext(EGL_NO_CONTEXT) {
33    }
34
35    virtual void SetUp() {
36        SurfaceTextureGLTest::SetUp();
37
38        mProducerEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
39                mANW.get(), NULL);
40        ASSERT_EQ(EGL_SUCCESS, eglGetError());
41        ASSERT_NE(EGL_NO_SURFACE, mProducerEglSurface);
42
43        mProducerEglContext = eglCreateContext(mEglDisplay, mGlConfig,
44                EGL_NO_CONTEXT, getContextAttribs());
45        ASSERT_EQ(EGL_SUCCESS, eglGetError());
46        ASSERT_NE(EGL_NO_CONTEXT, mProducerEglContext);
47    }
48
49    virtual void TearDown() {
50        if (mProducerEglContext != EGL_NO_CONTEXT) {
51            eglDestroyContext(mEglDisplay, mProducerEglContext);
52        }
53        if (mProducerEglSurface != EGL_NO_SURFACE) {
54            eglDestroySurface(mEglDisplay, mProducerEglSurface);
55        }
56        SurfaceTextureGLTest::TearDown();
57    }
58
59    EGLSurface mProducerEglSurface;
60    EGLContext mProducerEglContext;
61};
62
63} // namespace android
64
65#endif
66