提交 7038898e 编写于 作者: B bbcallen

ios: GLView: support scale mode switch

上级 d8de1b30
...@@ -200,6 +200,29 @@ ...@@ -200,6 +200,29 @@
return self.currentPlaybackTime + ((NSTimeInterval)_bufferingTime) / 1000; return self.currentPlaybackTime + ((NSTimeInterval)_bufferingTime) / 1000;
} }
- (void)setScalingMode: (MPMovieScalingMode) aScalingMode
{
MPMovieScalingMode newScalingMode = aScalingMode;
switch (aScalingMode) {
case MPMovieScalingModeNone:
[_view setContentMode:UIViewContentModeCenter];
break;
case MPMovieScalingModeAspectFit:
[_view setContentMode:UIViewContentModeScaleAspectFit];
break;
case MPMovieScalingModeAspectFill:
[_view setContentMode:UIViewContentModeScaleAspectFill];
break;
case MPMovieScalingModeFill:
[_view setContentMode:UIViewContentModeScaleToFill];
break;
default:
newScalingMode = _scalingMode;
}
_scalingMode = newScalingMode;
}
// deprecated, for MPMoviePlayerController compatiable // deprecated, for MPMoviePlayerController compatiable
- (UIImage *)thumbnailImageAtTime:(NSTimeInterval)playbackTime timeOption:(MPMovieTimeOption)option - (UIImage *)thumbnailImageAtTime:(NSTimeInterval)playbackTime timeOption:(MPMovieTimeOption)option
{ {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#import "IJKSDLGLShader.h" #import "IJKSDLGLShader.h"
#import "IJKSDLGLRender.h" #import "IJKSDLGLRender.h"
#import "IJKSDLGLRenderI420.h" #import "IJKSDLGLRenderI420.h"
#import "IJKMediaModule.h" #import "IJKMediaPlayer/IJKMediaModule.h"
static NSString *const g_vertexShaderString = IJK_SHADER_STRING static NSString *const g_vertexShaderString = IJK_SHADER_STRING
( (
...@@ -374,23 +374,42 @@ exit: ...@@ -374,23 +374,42 @@ exit:
- (void)updateVertices - (void)updateVertices
{ {
const BOOL fit = (self.contentMode == UIViewContentModeScaleAspectFit);
const float width = _frameWidth; const float width = _frameWidth;
const float height = _frameHeight; const float height = _frameHeight;
const float dH = (float)_backingHeight / height;
const float dW = (float)_backingWidth / width; const float dW = (float)_backingWidth / width;
const float dd = fit ? MIN(dH, dW) : MAX(dH, dW); const float dH = (float)_backingHeight / height;
const float h = (height * dd / (float)_backingHeight); float dd = 1.0f;
const float w = (width * dd / (float)_backingWidth ); float nW = 1.0f;
float nH = 1.0f;
_vertices[0] = - w;
_vertices[1] = - h; switch (self.contentMode) {
_vertices[2] = w; case UIViewContentModeScaleToFill:
_vertices[3] = - h; break;
_vertices[4] = - w; case UIViewContentModeCenter:
_vertices[5] = h; nW = 1.0f / dW / [UIScreen mainScreen].scale;
_vertices[6] = w; nH = 1.0f / dH / [UIScreen mainScreen].scale;
_vertices[7] = h; break;
case UIViewContentModeScaleAspectFill:
dd = MAX(dW, dH);
nW = (width * dd / (float)_backingWidth );
nH = (height * dd / (float)_backingHeight);
break;
case UIViewContentModeScaleAspectFit:
default:
dd = MIN(dW, dH);
nW = (width * dd / (float)_backingWidth );
nH = (height * dd / (float)_backingHeight);
break;
}
_vertices[0] = - nW;
_vertices[1] = - nH;
_vertices[2] = nW;
_vertices[3] = - nH;
_vertices[4] = - nW;
_vertices[5] = nH;
_vertices[6] = nW;
_vertices[7] = nH;
} }
- (void)display: (SDL_VoutOverlay *) overlay - (void)display: (SDL_VoutOverlay *) overlay
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册