blob: 53eb68cad8fc8b10514aa2877af6963cb70e0fe1 [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
20#include "GLTest.h"
21
22#include "FrameWaiter.h"
23#include "TextureRenderer.h"
24
25#include <gui/GLConsumer.h>
26#include <gui/Surface.h>
27
28namespace android {
29
30class FrameWaiter;
31class GLConsumer;
32class TextureRenderer;
33
34class SurfaceTextureGLTest : public GLTest {
35protected:
36 enum { TEX_ID = 123 };
37
38 void SetUp() {
39 GLTest::SetUp();
Dan Stoza5603a2f2014-04-07 13:41:37 -070040 sp<IGraphicBufferProducer> producer;
41 BufferQueue::createBufferQueue(&producer, &mConsumer);
Dan Stozae49ba8e2014-06-24 13:09:19 -070042 mST = new GLConsumer(mConsumer, TEX_ID, GLConsumer::TEXTURE_EXTERNAL,
43 true, false);
Dan Stoza5603a2f2014-04-07 13:41:37 -070044 mSTC = new Surface(producer);
Dan Stozacb1fcde2013-12-03 12:37:36 -080045 mANW = mSTC;
46 mTextureRenderer = new TextureRenderer(TEX_ID, mST);
47 ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
48 mFW = new FrameWaiter;
49 mST->setFrameAvailableListener(mFW);
50 }
51
52 void TearDown() {
53 mTextureRenderer.clear();
54 mANW.clear();
55 mSTC.clear();
56 mST.clear();
57 GLTest::TearDown();
58 }
59
60 void drawTexture() {
61 mTextureRenderer->drawTexture();
62 }
63
Dan Stoza5603a2f2014-04-07 13:41:37 -070064 sp<IGraphicBufferConsumer> mConsumer;
Dan Stozacb1fcde2013-12-03 12:37:36 -080065 sp<GLConsumer> mST;
66 sp<Surface> mSTC;
67 sp<ANativeWindow> mANW;
68 sp<TextureRenderer> mTextureRenderer;
69 sp<FrameWaiter> mFW;
70};
71
72} // namespace android
73
74#endif