Home | History | Annotate | Download | only in android
      1 /*
      2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_OPENGLES20_H_
     12 #define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_OPENGLES20_H_
     13 
     14 #include "webrtc/modules/video_render/include/video_render_defines.h"
     15 
     16 #include <GLES2/gl2.h>
     17 #include <GLES2/gl2ext.h>
     18 
     19 namespace webrtc
     20 {
     21 
     22 class VideoRenderOpenGles20 {
     23  public:
     24   VideoRenderOpenGles20(int32_t id);
     25   ~VideoRenderOpenGles20();
     26 
     27   int32_t Setup(int32_t widht, int32_t height);
     28   int32_t Render(const I420VideoFrame& frameToRender);
     29   int32_t SetCoordinates(int32_t zOrder, const float left, const float top,
     30                          const float right, const float bottom);
     31 
     32  private:
     33   void printGLString(const char *name, GLenum s);
     34   void checkGlError(const char* op);
     35   GLuint loadShader(GLenum shaderType, const char* pSource);
     36   GLuint createProgram(const char* pVertexSource,
     37                        const char* pFragmentSource);
     38   void SetupTextures(const I420VideoFrame& frameToRender);
     39   void UpdateTextures(const I420VideoFrame& frameToRender);
     40 
     41   int32_t _id;
     42   GLuint _textureIds[3]; // Texture id of Y,U and V texture.
     43   GLuint _program;
     44   GLsizei _textureWidth;
     45   GLsizei _textureHeight;
     46 
     47   GLfloat _vertices[20];
     48   static const char g_indices[];
     49 
     50   static const char g_vertextShader[];
     51   static const char g_fragmentShader[];
     52 
     53 };
     54 
     55 }  // namespace webrtc
     56 
     57 #endif  // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_OPENGLES20_H_
     58