xref: /aosp_15_r20/frameworks/native/libs/gui/tests/SurfaceTextureGL.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
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_H
18 #define ANDROID_SURFACE_TEXTURE_GL_H
19 
20 #include "Constants.h"
21 #include "GLTest.h"
22 
23 #include "FrameWaiter.h"
24 #include "TextureRenderer.h"
25 
26 #include <gui/GLConsumer.h>
27 #include <gui/Surface.h>
28 
29 namespace android {
30 
31 class FrameWaiter;
32 class GLConsumer;
33 class TextureRenderer;
34 
35 class SurfaceTextureGLTest : public GLTest {
36 protected:
37     enum { TEX_ID = 123 };
38 
SetUp()39     void SetUp() {
40         GLTest::SetUp();
41         mST = new GLConsumer(TEX_ID, GLConsumer::TEXTURE_EXTERNAL, true, false);
42         mSTC = mST->getSurface();
43         mANW = mSTC;
44         ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), TEST_PRODUCER_USAGE_BITS));
45         mTextureRenderer = new TextureRenderer(TEX_ID, mST);
46         ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
47         mFW = new FrameWaiter;
48         mST->setFrameAvailableListener(mFW);
49     }
50 
TearDown()51     void TearDown() {
52         mTextureRenderer.clear();
53         mANW.clear();
54         mSTC.clear();
55         mST.clear();
56         GLTest::TearDown();
57     }
58 
drawTexture()59     void drawTexture() {
60         mTextureRenderer->drawTexture();
61     }
62 
63     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
73