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 SetUp()38 void SetUp() { 39 GLTest::SetUp(); 40 sp<IGraphicBufferProducer> producer; 41 BufferQueue::createBufferQueue(&producer, &mConsumer); 42 mST = new GLConsumer(mConsumer, TEX_ID, GLConsumer::TEXTURE_EXTERNAL, 43 true, false); 44 mSTC = new Surface(producer); 45 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 TearDown()52 void TearDown() { 53 mTextureRenderer.clear(); 54 mANW.clear(); 55 mSTC.clear(); 56 mST.clear(); 57 GLTest::TearDown(); 58 } 59 drawTexture()60 void drawTexture() { 61 mTextureRenderer->drawTexture(); 62 } 63 64 sp<IGraphicBufferConsumer> mConsumer; 65 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 75