1 /* 2 * Copyright (c) 2013 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_IOS_VIDEO_RENDER_IOS_GLES20_H_ 12 #define WEBRTC_MODULES_VIDEO_RENDER_IOS_VIDEO_RENDER_IOS_GLES20_H_ 13 14 #include <list> 15 #include <map> 16 17 #include "webrtc/modules/video_render/ios/video_render_ios_channel.h" 18 #include "webrtc/modules/video_render/ios/video_render_ios_view.h" 19 #include "webrtc/system_wrappers/interface/scoped_ptr.h" 20 21 namespace webrtc { 22 23 class CriticalSectionWrapper; 24 class EventWrapper; 25 class ThreadWrapper; 26 27 class VideoRenderIosGles20 { 28 public: 29 VideoRenderIosGles20(VideoRenderIosView* view, 30 bool full_screen, 31 int render_id); 32 virtual ~VideoRenderIosGles20(); 33 34 int Init(); 35 VideoRenderIosChannel* CreateEaglChannel(int channel, 36 int z_order, 37 float left, 38 float top, 39 float right, 40 float bottom); 41 int DeleteEaglChannel(int channel); 42 bool HasChannel(int channel); 43 bool ScreenUpdateProcess(); 44 int GetWindowRect(Rect& rect); // NOLINT 45 46 int GetScreenResolution(uint& screen_width, uint& screen_height); // NOLINT 47 int SetStreamCropping(const uint stream_id, 48 const float left, 49 const float top, 50 const float right, 51 const float bottom); 52 53 int ChangeWindow(void* new_window); 54 int ChangeUniqueID(int unique_id); 55 int StartRender(); 56 int StopRender(); 57 58 protected: 59 static bool ScreenUpdateThreadProc(void* obj); 60 61 private: 62 bool RenderOffScreenBuffers(); 63 int SwapAndDisplayBuffers(); 64 65 private: 66 scoped_ptr<CriticalSectionWrapper> gles_crit_sec_; 67 EventWrapper* screen_update_event_; 68 ThreadWrapper* screen_update_thread_; 69 70 VideoRenderIosView* view_; 71 Rect window_rect_; 72 int window_width_; 73 int window_height_; 74 bool is_full_screen_; 75 GLint backing_width_; 76 GLint backing_height_; 77 GLuint view_renderbuffer_; 78 GLuint view_framebuffer_; 79 GLuint depth_renderbuffer_; 80 std::map<int, VideoRenderIosChannel*> agl_channels_; 81 std::multimap<int, int> z_order_to_channel_; 82 EAGLContext* gles_context_; 83 bool is_rendering_; 84 int id_; 85 }; 86 } // namespace webrtc 87 88 #endif // WEBRTC_MODULES_VIDEO_RENDER_IOS_VIDEO_RENDER_IOS_GLES20_H_ 89