blob: 3bff192a9c567f2ee346fa334dcbb6dbc148db34 [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);
42 mST = new GLConsumer(mConsumer, TEX_ID);
43 mSTC = new Surface(producer);
Dan Stozacb1fcde2013-12-03 12:37:36 -080044 mANW = mSTC;
45 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 Stoza5603a2f2014-04-07 13:41:37 -070063 sp<IGraphicBufferConsumer> mConsumer;
Dan Stozacb1fcde2013-12-03 12:37:36 -080064 sp<GLConsumer> mST;
65 sp<Surface> mSTC;
66 sp<ANativeWindow> mANW;
67 sp<TextureRenderer> mTextureRenderer;
68 sp<FrameWaiter> mFW;
69};
70
71} // namespace android
72
73#endif