blob: 5d43a48898866361902e00b2de24471d419d6bda [file] [log] [blame]
Dan Stozacb1fcde2013-12-03 12:37:36 -08001/*
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();
Pablo Ceballosb687a282015-10-06 11:14:51 -070037 }
Dan Stozacb1fcde2013-12-03 12:37:36 -080038
Pablo Ceballosb687a282015-10-06 11:14:51 -070039 void SetUpWindowAndContext() {
Dan Stozacb1fcde2013-12-03 12:37:36 -080040 mProducerEglSurface = eglCreateWindowSurface(mEglDisplay, mGlConfig,
41 mANW.get(), NULL);
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