1 /* 2 * Copyright 2011, The Android Open Source Project 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef TextureInfo_h 27 #define TextureInfo_h 28 29 #include <EGL/egl.h> 30 #include <GLES2/gl2.h> 31 #include <jni.h> 32 #include <ui/GraphicBuffer.h> 33 #include <utils/RefBase.h> 34 #include "BaseTile.h" 35 using android::sp; 36 37 #define DEPRECATED_SURFACE_TEXTURE_MODE 0 38 39 namespace android { 40 class SurfaceTexture; 41 } 42 43 namespace WebCore { 44 45 static const GLuint GL_NO_TEXTURE = 0; 46 /** 47 * TextureInfo is a class that stores both the texture and metadata about the 48 * texture. 49 */ 50 enum SharedTextureMode { 51 EglImageMode, 52 SurfaceTextureMode 53 }; 54 55 class TextureInfo { 56 public: 57 58 TextureInfo(SharedTextureMode mode); 59 60 bool equalsAttributes(const TextureInfo* otherTexture); 61 void copyAttributes(const TextureInfo* sourceTexture); 62 63 SharedTextureMode getSharedTextureMode() { return m_sharedTextureMode; } 64 bool operator==(const TextureInfo& otherTexture); 65 66 GLuint m_textureId; 67 int32_t m_width; 68 int32_t m_height; 69 GLenum m_internalFormat; 70 71 // Surface Texture specific data 72 #if DEPRECATED_SURFACE_TEXTURE_MODE 73 sp<android::SurfaceTexture> m_surfaceTexture; 74 #endif 75 // TODO: Delete this after the Ganesh code path get fixed. 76 sp<ANativeWindow> m_ANW; 77 // The EGLSurface wraps the m_ANW to enable direct OpenGL rendering (e.g. Ganesh) 78 EGLSurface m_eglSurface; 79 80 int m_pictureCount; 81 private: 82 SharedTextureMode m_sharedTextureMode; 83 }; 84 85 } // namespace WebCore 86 87 #endif // TextureInfo_h 88