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 4386fb5f1cf93e590b6361333d0b62e01d8ecb7e..a32180659029e536efb0f24ff3d656f38387cde6 100644 |
--- a/remoting/client/ios/app/host_view_controller.mm |
+++ b/remoting/client/ios/app/host_view_controller.mm |
@@ -9,8 +9,12 @@ |
#import "remoting/client/ios/app/host_view_controller.h" |
#import <GLKit/GLKit.h> |
+#include <memory> |
+#include "base/mac/bind_objc_block.h" |
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h" |
+#include "remoting/client/desktop_viewport.h" |
+#import "remoting/client/ios/client_gestures.h" |
#import "remoting/client/ios/session/remoting_client.h" |
static const CGFloat kFabInset = 15.f; |
@@ -18,6 +22,10 @@ static const CGFloat kFabInset = 15.f; |
@interface HostViewController () { |
RemotingClient* _client; |
MDCFloatingButton* _floatingButton; |
+ |
+ // DO NOT pass |_clientGestures| to other objects. |
+ ClientGestures* _clientGestures; |
+ std::unique_ptr<remoting::DesktopViewport> _viewport; |
} |
@end |
@@ -75,25 +83,49 @@ static const CGFloat kFabInset = 15.f; |
- (void)viewWillAppear:(BOOL)animated { |
[super viewWillAppear:animated]; |
- ((GLKView*)self.view).enableSetNeedsDisplay = true; |
+ |
+ _viewport.reset(new remoting::DesktopViewport()); |
nicholss
2017/05/03 15:33:50
I would rather see viewport be a part of the displ
Yuwei
2017/05/03 22:28:37
I created a C++ GestureInterpreter in RemotingClie
|
+ |
+ _viewport->RegisterOnTransformationChangedCallback( |
+ base::BindBlockArc(^(const remoting::ViewMatrix& matrix) { |
+ [_client.displayHandler onPixelTransformationChanged:matrix]; |
+ }), |
+ true); |
+ |
+ _client.displayHandler.delegate = self; |
+ |
+ _clientGestures = |
+ [[ClientGestures alloc] initWithView:self.view viewport:_viewport.get()]; |
} |
- (void)viewWillDisappear:(BOOL)animated { |
[super viewWillDisappear:animated]; |
+ |
+ // Explicitly free |client_gestures_| before |_viewport|. This only works if |
+ // |_clientGestures| is only owned by this. |
+ _clientGestures = nil; |
+ _viewport.reset(); |
} |
- (void)viewDidLayoutSubviews { |
[super viewDidLayoutSubviews]; |
- [_client.displayHandler onSurfaceChanged:((GLKView*)self.view).frame]; |
+ CGRect surfaceFrame = ((GLKView*)self.view).frame; |
nicholss
2017/05/03 15:33:50
No need to cast, frame comes from UIView.
Yuwei
2017/05/03 22:28:37
Done.
|
+ [_client.displayHandler onSurfaceChanged:surfaceFrame]; |
+ _viewport->SetSurfaceSize(surfaceFrame.size.width, surfaceFrame.size.height); |
- const CGSize& btnSize = _floatingButton.frame.size; |
+ 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 - GlDisplayHandlerDelegate |
+- (void)canvasSizeChanged:(CGSize)size { |
nicholss
2017/05/03 15:33:50
should have a space between the method and the pra
Yuwei
2017/05/03 22:28:37
Done.
|
+ _viewport->SetDesktopSize(size.width, size.height); |
+} |
+ |
#pragma mark - Private |
- (void)didTap:(id)sender { |