Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: remoting/client/ios/app/example_view_controller.mm

Issue 2555803002: Adding the iOS app and integration example with GlRenderer. (Closed)
Patch Set: Cleaning up gl_display_handler for chromium. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if !defined(__has_feature) || !__has_feature(objc_arc) 5 #if !defined(__has_feature) || !__has_feature(objc_arc)
6 #error "This file requires ARC support." 6 #error "This file requires ARC support."
7 #endif 7 #endif
8 8
9 #import "remoting/client/ios/example_view_controller.h" 9 #import "remoting/client/ios/app/example_view_controller.h"
10 10
11 #import "remoting/client/display/sys_opengl.h" 11 #import "remoting/client/display/sys_opengl.h"
12 12
13 @interface ExampleViewController() 13 #include "base/message_loop/message_loop.h"
14 #include "remoting/protocol/frame_stats.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
16 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
17
18 @interface ExampleViewController ()
14 19
15 // Helper functions dealing with the GL Context. 20 // Helper functions dealing with the GL Context.
16 - (void)setupGL; 21 - (void)setupGL;
17 - (void)tearDownGL; 22 - (void)tearDownGL;
18 23
19 @end 24 @end
20 25
21 @implementation ExampleViewController 26 @implementation ExampleViewController
22 27
23 #pragma mark - UIViewController 28 #pragma mark - UIViewController
24 29
25 - (void)viewDidLoad { 30 - (void)viewDidLoad {
26 [super viewDidLoad]; 31 [super viewDidLoad];
27 32 _gestures = [[ClientGestures alloc] initWithView:self.view];
28 _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; 33 _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
Yuwei 2017/01/23 21:56:15 Are you establishing the EGL context on the main t
Yuwei 2017/01/23 21:56:15 Does this handle the case if ES3 context is not su
nicholss 2017/01/26 18:00:16 ES3 is not supported for <=iPhone5. Not sure how m
Jamie 2017/01/26 18:06:12 Drive-by: We might be able to get this information
nicholss 2017/01/26 18:28:40 Looks like the iphone5 just makes the cut at conti
34 _runtime = new remoting::ios::AppRuntime();
29 static_cast<GLKView*>(self.view).context = _context; 35 static_cast<GLKView*>(self.view).context = _context;
30
31 [self setupGL]; 36 [self setupGL];
32 } 37 }
33 38
34 - (void)viewDidUnload { 39 - (void)viewDidUnload {
35 [super viewDidUnload]; 40 [super viewDidUnload];
36 [self tearDownGL]; 41 [self tearDownGL];
37 42
38 if ([EAGLContext currentContext] == _context) { 43 if ([EAGLContext currentContext] == _context) {
39 [EAGLContext setCurrentContext:nil]; 44 [EAGLContext setCurrentContext:nil];
40 } 45 }
41 _context = nil; 46 _context = nil;
42 } 47 }
43 48
44 - (void)setupGL { 49 - (void)setupGL {
45 [EAGLContext setCurrentContext:_context]; 50 displayHandler = [[GlDisplayHandler alloc] initWithRuntime:_runtime];
51 [displayHandler created];
46 } 52 }
47 53
48 - (void)tearDownGL { 54 - (void)tearDownGL {
49 [EAGLContext setCurrentContext:_context]; 55 // TODO(nicholss): Implement this in a real application.
50 } 56 }
51 57
52 - (void)viewWillAppear:(BOOL)animated { 58 - (void)viewWillAppear:(BOOL)animated {
53 [super viewWillAppear:animated]; 59 [super viewWillAppear:animated];
54 } 60 }
55 61
56 - (void)viewDidAppear:(BOOL)animated { 62 - (void)viewDidAppear:(BOOL)animated {
63 video_renderer_ =
64 (remoting::SoftwareVideoRenderer*)[displayHandler CreateVideoRenderer]
65 .get();
57 } 66 }
58 67
59 - (void)viewWillDisappear:(BOOL)animated { 68 - (void)viewWillDisappear:(BOOL)animated {
60 [super viewWillDisappear:NO]; 69 [super viewWillDisappear:NO];
61 } 70 }
62 71
63 - (void)viewDidLayoutSubviews { 72 - (void)viewDidLayoutSubviews {
64 [super viewDidLayoutSubviews]; 73 [super viewDidLayoutSubviews];
65 } 74 }
66 75
67 #pragma mark - GLKViewDelegate 76 #pragma mark - GLKViewDelegate
68 77
69 // In general, avoid expensive work in this function to maximize frame rate. 78 // In general, avoid expensive work in this function to maximize frame rate.
70 - (void)glkView:(GLKView*)view drawInRect:(CGRect)rect { 79 - (void)glkView:(GLKView*)view drawInRect:(CGRect)rect {
71 // Clear to give the background color. 80 if (displayHandler) {
72 glClearColor(0.0, 40.0, 0.0, 1.0); 81 [displayHandler glkView:view drawInRect:rect];
73 glClear(GL_COLOR_BUFFER_BIT); 82 }
74 } 83 }
75 84
76 @end 85 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698