This class consolidates the logic of scaling between the view controller’s coordinate system and the display’s coordinate system.
The main goal of using scaling is to align different screens and use a common range of “points per inch”. This allows showing assets with a similar size on different screen resolutions.
The scaling factor the app should use to change the size of the projecting view.
@property (nonatomic) float scale;
var scale: Float { get set }
The screen resolution of the connected display. The units are pixels.
@property (nonatomic) CGSize displayViewportResolution;
var displayViewportResolution: CGSize { get set }
The frame of the app’s projecting view. This is calculated by dividing the display’s viewport resolution by the scale. The units are points.
@property (nonatomic, readonly) CGRect appViewportFrame;
var appViewportFrame: CGRect { get }
Creates a default streaming video scale manager. The scale value will be set to 1.0 and the displayViewportResolution will be set to {0, 0}.
- (nonnull instancetype)init;
init()
A SDLStreamingVideoScaleManager object
Convenience init for creating the manager with a scale and connected display viewport resolution.
- (nonnull instancetype)initWithScale:(float)scale
displayViewportResolution:(CGSize)displayViewportResolution;
init(scale: Float, displayViewportResolution: CGSize)
The scaling factor the app should use to change the size of the projecting view
The current screen resolution of the connected display
A SDLStreamingVideoScaleManager object
Scales the coordinates of an OnTouchEvent
from the display’s coordinate system to the app’s viewport coordinate system. If the scale value is less than 1.0, the touch events will be returned without being scaled.
- (nonnull SDLOnTouchEvent *)scaleTouchEventCoordinates:
(nonnull SDLOnTouchEvent *)onTouchEvent;
func scaleTouchEventCoordinates(_ onTouchEvent: SDLOnTouchEvent) -> SDLOnTouchEvent
A touch event with coordinates
The touch event coordinates in the app’s viewport coordinate system
Scales a haptic rectangle from the app’s viewport coordinate system to the display’s coordinate system. If the scale value is less than 1.0, the haptic rectangle will be returned without being scaled.
- (nonnull SDLHapticRect *)scaleHapticRect:(nonnull SDLHapticRect *)hapticRect;
func scale(_ hapticRect: SDLHapticRect) -> SDLHapticRect
A haptic rectangle
The position of the haptic rectangle in the display’s coordinate system
Create and return the current display resolution respecting the scale factor
- (nonnull SDLImageResolution *)makeScaledResolution;
func makeScaledResolution() -> SDLImageResolution
A new created object of type SDLImageResolution
Stops the manager. This method is used internally.
- (void)stop;
func stop()
Calculate a new size based on the given size and the scale factor
+ (CGSize)scale:(float)scale size:(CGSize)size;
class func scale(_ scale: Float, size: CGSize) -> CGSize
The scale factor to apply
The size struct to apply the scale to
A new created and inited struct of type CGSize