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

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

Issue 2848143002: [Remoting iOS] Fix screen tearing and screen dimensions (Closed)
Patch Set: Request first frame Created 3 years, 7 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 2017 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/app/host_view_controller.h" 9 #import "remoting/client/ios/app/host_view_controller.h"
10 10
11 #import <GLKit/GLKit.h>
12
11 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
12 #import "remoting/client/ios/session/remoting_client.h" 14 #import "remoting/client/ios/session/remoting_client.h"
13 15
14 static const CGFloat kFabInset = 15.f; 16 static const CGFloat kFabInset = 15.f;
15 17
16 @interface HostViewController () { 18 @interface HostViewController () {
17 RemotingClient* _client; 19 RemotingClient* _client;
20 GLKView* _gl_view;
nicholss 2017/05/01 16:20:14 Why do you need the gl view to be subview and not
Yuwei 2017/05/01 20:58:08 I just thought it is easier to reuse the UIViewCon
18 } 21 }
19 @end 22 @end
20 23
21 @implementation HostViewController 24 @implementation HostViewController
22 25
23 - (id)initWithClient:(RemotingClient*)client { 26 - (id)initWithClient:(RemotingClient*)client {
24 self = [super init]; 27 self = [super init];
25 if (self) { 28 if (self) {
26 _client = client; 29 _client = client;
27 } 30 }
(...skipping 13 matching lines...) Expand all
41 44
42 UIImage* settingsImage = [UIImage imageNamed:@"Settings"]; 45 UIImage* settingsImage = [UIImage imageNamed:@"Settings"];
43 [floatingButton setImage:settingsImage forState:UIControlStateNormal]; 46 [floatingButton setImage:settingsImage forState:UIControlStateNormal];
44 [floatingButton sizeToFit]; 47 [floatingButton sizeToFit];
45 CGSize btnSize = floatingButton.frame.size; 48 CGSize btnSize = floatingButton.frame.size;
46 floatingButton.frame = 49 floatingButton.frame =
47 CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset, 50 CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset,
48 self.view.frame.size.height - btnSize.height - kFabInset, 51 self.view.frame.size.height - btnSize.height - kFabInset,
49 btnSize.width, btnSize.height); 52 btnSize.width, btnSize.height);
50 53
54 _gl_view = [[GLKView alloc] initWithFrame:self.view.bounds];
nicholss 2017/05/01 16:20:14 Views in init should be created with CGRectZero an
Yuwei 2017/05/01 20:58:08 Done. I also needed to fix floatingButton by doing
55 _gl_view.enableSetNeedsDisplay = true;
nicholss 2017/05/01 16:20:14 This should move out of the init, you do not know
Yuwei 2017/05/01 20:58:08 Done.
56 [self.view addSubview:_gl_view];
51 [self.view addSubview:floatingButton]; 57 [self.view addSubview:floatingButton];
52 } 58 }
53 59
54 - (void)viewDidUnload { 60 - (void)viewDidUnload {
55 [super viewDidUnload]; 61 [super viewDidUnload];
56 // TODO(nicholss): There needs to be a hook to tell the client we are done. 62 // TODO(nicholss): There needs to be a hook to tell the client we are done.
57 } 63 }
58 64
59 - (BOOL)prefersStatusBarHidden { 65 - (BOOL)prefersStatusBarHidden {
60 return YES; 66 return YES;
61 } 67 }
62 68
63 - (void)viewDidAppear:(BOOL)animated { 69 - (void)viewDidAppear:(BOOL)animated {
64 [super viewDidAppear:animated]; 70 [super viewDidAppear:animated];
65 GLKView* view = (GLKView*)self.view; 71 _gl_view.context = [_client.displayHandler GetEAGLContext];
66 view.context = [_client.displayHandler GetEAGLContext]; 72 [_client.displayHandler onSurfaceCreated:_gl_view];
73
74 // TODO(yuweih): Hande new frame when screen rotated.
75 [_client.displayHandler onSurfaceChanged:_gl_view.frame];
67 } 76 }
68 77
69 - (void)viewWillDisappear:(BOOL)animated { 78 - (void)viewWillDisappear:(BOOL)animated {
70 [super viewWillDisappear:animated]; 79 [super viewWillDisappear:animated];
71 } 80 }
72 81
73 #pragma mark - GLKViewDelegate
74
75 - (void)glkView:(GLKView*)view drawInRect:(CGRect)rect {
76 // Nothing to do that is synchronous yet.
77 }
78
79 #pragma mark - Private 82 #pragma mark - Private
80 83
81 - (void)didTap:(id)sender { 84 - (void)didTap:(id)sender {
82 // TODO(nicholss): The FAB is being used to close the window at the moment 85 // TODO(nicholss): The FAB is being used to close the window at the moment
83 // just as a demo as the integration continues. This will not be the case 86 // just as a demo as the integration continues. This will not be the case
84 // in the final app. 87 // in the final app.
85 [self dismissViewControllerAnimated:YES completion:nil]; 88 [self dismissViewControllerAnimated:YES completion:nil];
86 } 89 }
87 90
88 @end 91 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698