blob: 1309635afd9cd5fa7518904564910caf53d6b8ae [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_H
18#define ANDROID_SURFACE_TEXTURE_GL_H
19
Nolan Scobie9c427942023-05-01 16:41:28 -040020#include "Constants.h"
Dan Stozacb1fcde2013-12-03 12:37:36 -080021#include "GLTest.h"
22
23#include "FrameWaiter.h"
24#include "TextureRenderer.h"
25
26#include <gui/GLConsumer.h>
27#include <gui/Surface.h>
28
29namespace android {
30
31class FrameWaiter;
32class GLConsumer;
33class TextureRenderer;
34
35class SurfaceTextureGLTest : public GLTest {
36protected:
37 enum { TEX_ID = 123 };
38
39 void SetUp() {
40 GLTest::SetUp();
Jim Shargod30823a2024-07-27 02:49:39 +000041 mST = new GLConsumer(TEX_ID, GLConsumer::TEXTURE_EXTERNAL, true, false);
42 mSTC = mST->getSurface();
Dan Stozacb1fcde2013-12-03 12:37:36 -080043 mANW = mSTC;
Nolan Scobie9c427942023-05-01 16:41:28 -040044 ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), TEST_PRODUCER_USAGE_BITS));
Dan Stozacb1fcde2013-12-03 12:37:36 -080045 mTextureRenderer = new TextureRenderer(TEX_ID, mST);
46 ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
47 mFW = new FrameWaiter;
48 mST->setFrameAvailableListener(mFW);
49 }
50
51 void TearDown() {
52 mTextureRenderer.clear();
53 mANW.clear();
54 mSTC.clear();
55 mST.clear();
56 GLTest::TearDown();
57 }
58
59 void drawTexture() {
60 mTextureRenderer->drawTexture();
61 }
62
Dan Stozacb1fcde2013-12-03 12:37:36 -080063 sp<GLConsumer> mST;
64 sp<Surface> mSTC;
65 sp<ANativeWindow> mANW;
66 sp<TextureRenderer> mTextureRenderer;
67 sp<FrameWaiter> mFW;
68};
69
70} // namespace android
71
72#endif