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

Unified Diff: remoting/client/ios/app/host_view_controller.mm

Issue 2848143002: [Remoting iOS] Fix screen tearing and screen dimensions (Closed)
Patch Set: Add comments about not inheriting GLKViewController Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/ios/app/host_view_controller.h ('k') | remoting/client/ios/display/gl_display_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/ios/app/host_view_controller.mm
diff --git a/remoting/client/ios/app/host_view_controller.mm b/remoting/client/ios/app/host_view_controller.mm
index 17e1a45f1e61c6a886a9abbbcde7ab6325c1e602..4386fb5f1cf93e590b6361333d0b62e01d8ecb7e 100644
--- a/remoting/client/ios/app/host_view_controller.mm
+++ b/remoting/client/ios/app/host_view_controller.mm
@@ -8,6 +8,8 @@
#import "remoting/client/ios/app/host_view_controller.h"
+#import <GLKit/GLKit.h>
+
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
#import "remoting/client/ios/session/remoting_client.h"
@@ -15,6 +17,7 @@ static const CGFloat kFabInset = 15.f;
@interface HostViewController () {
RemotingClient* _client;
+ MDCFloatingButton* _floatingButton;
}
@end
@@ -30,25 +33,23 @@ static const CGFloat kFabInset = 15.f;
#pragma mark - UIViewController
+- (void)loadView {
+ self.view = [[GLKView alloc] initWithFrame:CGRectZero];
+}
+
- (void)viewDidLoad {
[super viewDidLoad];
- MDCFloatingButton* floatingButton =
+ _floatingButton =
[MDCFloatingButton floatingButtonWithShape:MDCFloatingButtonShapeMini];
- [floatingButton setTitle:@"+" forState:UIControlStateNormal];
- [floatingButton addTarget:self
- action:@selector(didTap:)
- forControlEvents:UIControlEventTouchUpInside];
+ [_floatingButton setTitle:@"+" forState:UIControlStateNormal];
+ [_floatingButton addTarget:self
+ action:@selector(didTap:)
+ forControlEvents:UIControlEventTouchUpInside];
UIImage* settingsImage = [UIImage imageNamed:@"Settings"];
- [floatingButton setImage:settingsImage forState:UIControlStateNormal];
- [floatingButton sizeToFit];
- CGSize btnSize = floatingButton.frame.size;
- floatingButton.frame =
- CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset,
- self.view.frame.size.height - btnSize.height - kFabInset,
- btnSize.width, btnSize.height);
-
- [self.view addSubview:floatingButton];
+ [_floatingButton setImage:settingsImage forState:UIControlStateNormal];
+ [_floatingButton sizeToFit];
+ [self.view addSubview:_floatingButton];
}
- (void)viewDidUnload {
@@ -62,18 +63,35 @@ static const CGFloat kFabInset = 15.f;
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
- GLKView* view = (GLKView*)self.view;
- view.context = [_client.displayHandler GetEAGLContext];
+ GLKView* glView = (GLKView*)self.view;
+ glView.context = [_client.displayHandler GetEAGLContext];
+ [_client.displayHandler onSurfaceCreated:glView];
+
+ // viewDidLayoutSubviews may be called before viewDidAppear, in which case
+ // the surface is not ready and onSurfaceChanged will be no-op.
+ // Call onSurfaceChanged here to cover that case.
+ [_client.displayHandler onSurfaceChanged:glView.frame];
+}
+
+- (void)viewWillAppear:(BOOL)animated {
+ [super viewWillAppear:animated];
+ ((GLKView*)self.view).enableSetNeedsDisplay = true;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
-#pragma mark - GLKViewDelegate
+- (void)viewDidLayoutSubviews {
+ [super viewDidLayoutSubviews];
+
+ [_client.displayHandler onSurfaceChanged:((GLKView*)self.view).frame];
-- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect {
- // Nothing to do that is synchronous yet.
+ const CGSize& btnSize = _floatingButton.frame.size;
+ _floatingButton.frame =
+ CGRectMake(self.view.frame.size.width - btnSize.width - kFabInset,
+ self.view.frame.size.height - btnSize.height - kFabInset,
+ btnSize.width, btnSize.height);
}
#pragma mark - Private
« no previous file with comments | « remoting/client/ios/app/host_view_controller.h ('k') | remoting/client/ios/display/gl_display_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698