Index: remoting/client/ios/chromiumoting/example_view_controller.mm |
diff --git a/remoting/client/ios/chromiumoting/example_view_controller.mm b/remoting/client/ios/chromiumoting/example_view_controller.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..16535849b959acb3718ae12f23c3323d7cccfb66 |
--- /dev/null |
+++ b/remoting/client/ios/chromiumoting/example_view_controller.mm |
@@ -0,0 +1,86 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
+#import "remoting/client/ios/chromiumoting/example_view_controller.h" |
+ |
+#import "remoting/client/sys_opengl.h" |
+ |
+#include "base/message_loop/message_loop.h" |
+#include "remoting/protocol/frame_stats.h" |
+#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
+#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
+ |
+@interface ExampleViewController () |
+ |
+// Helper functions dealing with the GL Context. |
+- (void)setupGL; |
+- (void)tearDownGL; |
+ |
+@end |
+ |
+@implementation ExampleViewController |
+ |
+#pragma mark - UIViewController |
+ |
+- (void)viewDidLoad { |
+ [super viewDidLoad]; |
+ _gestures = [[ClientGestures alloc] initWithView:self.view]; |
+ _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; |
Yuwei
2016/12/19 23:26:09
The renderer has optimizations that are only for G
|
+ _runtime = new remoting::ios::AppRuntime(); |
+ static_cast<GLKView*>(self.view).context = _context; |
+ [self setupGL]; |
+} |
+ |
+- (void)viewDidUnload { |
+ [super viewDidUnload]; |
+ [self tearDownGL]; |
+ |
+ if ([EAGLContext currentContext] == _context) { |
+ [EAGLContext setCurrentContext:nil]; |
+ } |
+ _context = nil; |
+} |
+ |
+- (void)setupGL { |
+ displayHandler = [[GlDisplayHandler alloc] initWithRuntime:_runtime]; |
+ [displayHandler created]; |
+} |
+ |
+- (void)tearDownGL { |
+ // TODO(nicholss): Implement this in a real application. |
+} |
+ |
+- (void)viewWillAppear:(BOOL)animated { |
+ [super viewWillAppear:animated]; |
+} |
+ |
+- (void)viewDidAppear:(BOOL)animated { |
+ video_renderer_ = |
+ (remoting::SoftwareVideoRenderer*)[displayHandler CreateVideoRenderer] |
+ .get(); |
+} |
+ |
+- (void)viewWillDisappear:(BOOL)animated { |
+ [super viewWillDisappear:NO]; |
+} |
+ |
+- (void)viewDidLayoutSubviews { |
+ [super viewDidLayoutSubviews]; |
+} |
+ |
+#pragma mark - GLKViewDelegate |
+ |
+// In general, avoid expensive work in this function to maximize frame rate. |
+- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect { |
+ if (displayHandler) { |
+ [displayHandler glkView:view drawInRect:rect]; |
+ [displayHandler draw]; |
+ } |
+} |
+ |
+@end |