Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 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 "GLTest.h" |
| 21 | |
| 22 | #include "FrameWaiter.h" |
| 23 | #include "TextureRenderer.h" |
| 24 | |
| 25 | #include <gui/GLConsumer.h> |
| 26 | #include <gui/Surface.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | class FrameWaiter; |
| 31 | class GLConsumer; |
| 32 | class TextureRenderer; |
| 33 | |
| 34 | class SurfaceTextureGLTest : public GLTest { |
| 35 | protected: |
| 36 | enum { TEX_ID = 123 }; |
| 37 | |
| 38 | void SetUp() { |
| 39 | GLTest::SetUp(); |
Dan Stoza | 5603a2f | 2014-04-07 13:41:37 -0700 | [diff] [blame^] | 40 | sp<IGraphicBufferProducer> producer; |
| 41 | BufferQueue::createBufferQueue(&producer, &mConsumer); |
| 42 | mST = new GLConsumer(mConsumer, TEX_ID); |
| 43 | mSTC = new Surface(producer); |
Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 44 | 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 Stoza | 5603a2f | 2014-04-07 13:41:37 -0700 | [diff] [blame^] | 63 | sp<IGraphicBufferConsumer> mConsumer; |
Dan Stoza | cb1fcde | 2013-12-03 12:37:36 -0800 | [diff] [blame] | 64 | 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 |