• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         std::tie(mST, mSTC) = GLConsumer::create(TEX_ID, GLConsumer::TEXTURE_EXTERNAL, true, false);
42         mANW = mSTC;
43         ASSERT_EQ(NO_ERROR, native_window_set_usage(mANW.get(), TEST_PRODUCER_USAGE_BITS));
44         mTextureRenderer = new TextureRenderer(TEX_ID, mST);
45         ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
46         mFW = new FrameWaiter;
47         mST->setFrameAvailableListener(mFW);
48     }
49 
TearDown()50     void TearDown() {
51         mTextureRenderer.clear();
52         mANW.clear();
53         mSTC.clear();
54         mST.clear();
55         GLTest::TearDown();
56     }
57 
drawTexture()58     void drawTexture() {
59         mTextureRenderer->drawTexture();
60     }
61 
62     sp<GLConsumer> mST;
63     sp<Surface> mSTC;
64     sp<ANativeWindow> mANW;
65     sp<TextureRenderer> mTextureRenderer;
66     sp<FrameWaiter> mFW;
67 };
68 
69 } // namespace android
70 
71 #endif
72