FreeRDP/client/iOS/Views/RDPSessionView.m

59 lines
1.4 KiB
Mathematica
Raw Normal View History

/*
RDP Session View
2019-11-06 17:24:51 +03:00
2013-12-04 14:37:57 +04:00
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
2019-11-06 17:24:51 +03:00
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at
http://mozilla.org/MPL/2.0/.
*/
#import "RDPSessionView.h"
@implementation RDPSessionView
2019-11-06 17:24:51 +03:00
- (void)setSession:(RDPSession *)session
{
2019-11-06 17:24:51 +03:00
_session = session;
}
- (void)awakeFromNib
{
2019-11-06 17:24:51 +03:00
[super awakeFromNib];
_session = nil;
}
2019-11-06 17:24:51 +03:00
- (void)drawRect:(CGRect)rect
{
2019-11-06 17:24:51 +03:00
if (_session != nil && [_session bitmapContext])
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGImageRef cgImage = CGBitmapContextCreateImage([_session bitmapContext]);
2019-11-06 17:24:51 +03:00
CGContextTranslateCTM(context, 0, [self bounds].size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextClipToRect(context,
CGRectMake(rect.origin.x,
[self bounds].size.height - rect.origin.y - rect.size.height,
rect.size.width, rect.size.height));
CGContextDrawImage(context,
CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height),
cgImage);
CGImageRelease(cgImage);
}
else
{
// just clear the screen with black
[[UIColor blackColor] set];
UIRectFill([self bounds]);
}
}
2019-11-06 17:24:51 +03:00
- (void)dealloc
{
[super dealloc];
}
@end