blob: 9d8af5d0f57628e1e9e656a6f84e00e5f4cff968 [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();
Dan Stoza5603a2f2014-04-07 13:41:37 -070041 sp<IGraphicBufferProducer> producer;
42 BufferQueue::createBufferQueue(&producer, &mConsumer);
Dan Stozae49ba8e2014-06-24 13:09:19 -070043 mST = new GLConsumer(mConsumer, TEX_ID, GLConsumer::TEXTURE_EXTERNAL,
44 true, false);
Dan Stoza5603a2f2014-04-07 13:41:37 -070045 mSTC = new Surface(producer);
Dan Stozacb1fcde2013-12-03 12:37:36 -080046 mANW = mSTC;
Nolan Scobie9c427942023-05-01 16:41:28 -040047 ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), TEST_PRODUCER_USAGE_BITS));
Dan Stozacb1fcde2013-12-03 12:37:36 -080048 mTextureRenderer = new TextureRenderer(TEX_ID, mST);
49 ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
50 mFW = new FrameWaiter;
51 mST->setFrameAvailableListener(mFW);
52 }
53
54 void TearDown() {
55 mTextureRenderer.clear();
56 mANW.clear();
57 mSTC.clear();
58 mST.clear();
59 GLTest::TearDown();
60 }
61
62 void drawTexture() {
63 mTextureRenderer->drawTexture();
64 }
65
Dan Stoza5603a2f2014-04-07 13:41:37 -070066 sp<IGraphicBufferConsumer> mConsumer;
Dan Stozacb1fcde2013-12-03 12:37:36 -080067 sp<GLConsumer> mST;
68 sp<Surface> mSTC;
69 sp<ANativeWindow> mANW;
70 sp<TextureRenderer> mTextureRenderer;
71 sp<FrameWaiter> mFW;
72};
73
74} // namespace android
75
76#endif