Commit cf2df380 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

vout_ios: We do use 4 spaces indentation and not TABS.

parent e4b731d9
...@@ -73,10 +73,10 @@ vlc_module_end () ...@@ -73,10 +73,10 @@ vlc_module_end ()
@interface VLCOpenGLESVideoView : UIView @interface VLCOpenGLESVideoView : UIView
{ {
vout_display_t * _vd; vout_display_t * _vd;
EAGLContext * _context; EAGLContext * _context;
GLuint _defaultFramebuffer; GLuint _defaultFramebuffer;
GLuint _colorRenderbuffer; GLuint _colorRenderbuffer;
BOOL _framebufferDirty; BOOL _framebufferDirty;
} }
- (id)initWithFrame:(CGRect)frame andVOutDisplay:(vout_display_t *)vd; - (id)initWithFrame:(CGRect)frame andVOutDisplay:(vout_display_t *)vd;
@property (readonly) EAGLContext * context; @property (readonly) EAGLContext * context;
...@@ -129,15 +129,15 @@ static int Open(vlc_object_t *this) ...@@ -129,15 +129,15 @@ static int Open(vlc_object_t *this)
/* Get our main view*/ /* Get our main view*/
nsPool = [[NSAutoreleasePool alloc] init]; nsPool = [[NSAutoreleasePool alloc] init];
msg_Dbg(vd, "Creating VLCOpenGLESVideoView"); msg_Dbg(vd, "Creating VLCOpenGLESVideoView");
sys->glView = [[VLCOpenGLESVideoView alloc] initWithFrame:[container bounds] andVOutDisplay:vd]; sys->glView = [[VLCOpenGLESVideoView alloc] initWithFrame:[container bounds] andVOutDisplay:vd];
if (!sys->glView) if (!sys->glView)
goto error; goto error;
/* We don't wait, that means that we'll have to be careful about releasing /* We don't wait, that means that we'll have to be careful about releasing
* container. * container.
* That's why we'll release on main thread in Close(). */ * That's why we'll release on main thread in Close(). */
[container performSelectorOnMainThread:@selector(addSubview:) withObject:sys->glView waitUntilDone:NO]; [container performSelectorOnMainThread:@selector(addSubview:) withObject:sys->glView waitUntilDone:NO];
[nsPool drain]; [nsPool drain];
nsPool = nil; nsPool = nil;
...@@ -269,15 +269,15 @@ static int Control (vout_display_t *vd, int query, va_list ap) ...@@ -269,15 +269,15 @@ static int Control (vout_display_t *vd, int query, va_list ap)
static int OpenglClean(vout_opengl_t *gl) { static int OpenglClean(vout_opengl_t *gl) {
vout_display_sys_t *sys = gl->sys; vout_display_sys_t *sys = gl->sys;
[sys->glView cleanFramebuffer]; [sys->glView cleanFramebuffer];
return 0; return 0;
} }
static void OpenglSwap(vout_opengl_t *gl) static void OpenglSwap(vout_opengl_t *gl)
{ {
vout_display_sys_t *sys = gl->sys; vout_display_sys_t *sys = gl->sys;
EAGLContext *context = [sys->glView context]; EAGLContext *context = [sys->glView context];
[context presentRenderbuffer:GL_RENDERBUFFER_OES]; [context presentRenderbuffer:GL_RENDERBUFFER_OES];
} }
/***************************************************************************** /*****************************************************************************
...@@ -304,28 +304,28 @@ static void OpenglSwap(vout_opengl_t *gl) ...@@ -304,28 +304,28 @@ static void OpenglSwap(vout_opengl_t *gl)
*/ */
- (id)initWithFrame:(CGRect)frame andVOutDisplay:(vout_display_t *)vd { - (id)initWithFrame:(CGRect)frame andVOutDisplay:(vout_display_t *)vd {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
_vd = vd; _vd = vd;
CAEAGLLayer * eaglLayer = (CAEAGLLayer *)self.layer; CAEAGLLayer * eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = TRUE; eaglLayer.opaque = TRUE;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
// [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, // [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat,
nil]; nil];
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
NSAssert(_context && [EAGLContext setCurrentContext:_context], @"Creating context"); NSAssert(_context && [EAGLContext setCurrentContext:_context], @"Creating context");
// This shouldn't need to be done on the main thread. // This shouldn't need to be done on the main thread.
// Indeed, it works just fine from the render thread on iOS 3.2 to 4.1 // Indeed, it works just fine from the render thread on iOS 3.2 to 4.1
// However, if you don't call it from the main thread, it doesn't work on iOS 4.2 beta 1 // However, if you don't call it from the main thread, it doesn't work on iOS 4.2 beta 1
[self performSelectorOnMainThread:@selector(_createFramebuffer) withObject:nil waitUntilDone:YES]; [self performSelectorOnMainThread:@selector(_createFramebuffer) withObject:nil waitUntilDone:YES];
_framebufferDirty = NO; _framebufferDirty = NO;
[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
} }
return self; return self;
} }
...@@ -351,82 +351,82 @@ static void OpenglSwap(vout_opengl_t *gl) ...@@ -351,82 +351,82 @@ static void OpenglSwap(vout_opengl_t *gl)
* Method called by UIKit when we have been resized * Method called by UIKit when we have been resized
*/ */
- (void)layoutSubviews { - (void)layoutSubviews {
// CAUTION : This is called from the main thread // CAUTION : This is called from the main thread
_framebufferDirty = YES; _framebufferDirty = YES;
} }
- (void)cleanFramebuffer { - (void)cleanFramebuffer {
if (_framebufferDirty) { if (_framebufferDirty) {
[self _destroyFramebuffer]; [self _destroyFramebuffer];
[self _createFramebuffer]; [self _createFramebuffer];
_framebufferDirty = NO; _framebufferDirty = NO;
} }
} }
@end @end
@implementation VLCOpenGLESVideoView (Private) @implementation VLCOpenGLESVideoView (Private)
- (void)_createFramebuffer { - (void)_createFramebuffer {
msg_Dbg(_vd, "Creating framebuffer for layer %p with bounds (%.1f,%.1f,%.1f,%.1f)", self.layer, self.layer.bounds.origin.x, self.layer.bounds.origin.y, self.layer.bounds.size.width, self.layer.bounds.size.height); msg_Dbg(_vd, "Creating framebuffer for layer %p with bounds (%.1f,%.1f,%.1f,%.1f)", self.layer, self.layer.bounds.origin.x, self.layer.bounds.origin.y, self.layer.bounds.size.width, self.layer.bounds.size.height);
[EAGLContext setCurrentContext:_context]; [EAGLContext setCurrentContext:_context];
// Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer
glGenFramebuffersOES(1, &_defaultFramebuffer); // Generate one framebuffer, store it in _defaultFrameBuffer glGenFramebuffersOES(1, &_defaultFramebuffer); // Generate one framebuffer, store it in _defaultFrameBuffer
glGenRenderbuffersOES(1, &_colorRenderbuffer); glGenRenderbuffersOES(1, &_colorRenderbuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, _defaultFramebuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, _defaultFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, _colorRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, _colorRenderbuffer);
// This call associates the storage for the current render buffer with the EAGLDrawable (our CAEAGLLayer) // This call associates the storage for the current render buffer with the EAGLDrawable (our CAEAGLLayer)
// allowing us to draw into a buffer that will later be rendered to screen wherever the layer is (which corresponds with our view). // allowing us to draw into a buffer that will later be rendered to screen wherever the layer is (which corresponds with our view).
[_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer]; [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _colorRenderbuffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _colorRenderbuffer);
GLuint backingWidth, backingHeight; GLuint backingWidth, backingHeight;
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
msg_Err(_vd, "Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); msg_Err(_vd, "Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
} }
[self _updateViewportWithBackingWitdh:backingWidth andBackingHeight:backingHeight]; [self _updateViewportWithBackingWitdh:backingWidth andBackingHeight:backingHeight];
} }
- (void)_updateViewportWithBackingWitdh:(GLuint)backingWidth andBackingHeight:(GLuint)backingHeight { - (void)_updateViewportWithBackingWitdh:(GLuint)backingWidth andBackingHeight:(GLuint)backingHeight {
msg_Dbg(_vd, "Reshaping to %dx%d", backingWidth, backingHeight); msg_Dbg(_vd, "Reshaping to %dx%d", backingWidth, backingHeight);
CGFloat width = (CGFloat)backingWidth; CGFloat width = (CGFloat)backingWidth;
CGFloat height = (CGFloat)backingHeight; CGFloat height = (CGFloat)backingHeight;
GLint x = width, y = height; GLint x = width, y = height;
if (_vd) { if (_vd) {
CGFloat videoHeight = _vd->source.i_visible_height; CGFloat videoHeight = _vd->source.i_visible_height;
CGFloat videoWidth = _vd->source.i_visible_width; CGFloat videoWidth = _vd->source.i_visible_width;
GLint sarNum = _vd->source.i_sar_num; GLint sarNum = _vd->source.i_sar_num;
GLint sarDen = _vd->source.i_sar_den; GLint sarDen = _vd->source.i_sar_den;
if (height * videoWidth * sarNum < width * videoHeight * sarDen) if (height * videoWidth * sarNum < width * videoHeight * sarDen)
{ {
x = (height * videoWidth * sarNum) / (videoHeight * sarDen); x = (height * videoWidth * sarNum) / (videoHeight * sarDen);
y = height; y = height;
} }
else else
{ {
x = width; x = width;
y = (width * videoHeight * sarDen) / (videoWidth * sarNum); y = (width * videoHeight * sarDen) / (videoWidth * sarNum);
} }
} }
[EAGLContext setCurrentContext:_context]; [EAGLContext setCurrentContext:_context];
glViewport((width - x) / 2, (height - y) / 2, x, y); glViewport((width - x) / 2, (height - y) / 2, x, y);
} }
- (void)_destroyFramebuffer { - (void)_destroyFramebuffer {
[EAGLContext setCurrentContext:_context]; [EAGLContext setCurrentContext:_context];
glDeleteFramebuffersOES(1, &_defaultFramebuffer); glDeleteFramebuffersOES(1, &_defaultFramebuffer);
_defaultFramebuffer = 0; _defaultFramebuffer = 0;
glDeleteRenderbuffersOES(1, &_colorRenderbuffer); glDeleteRenderbuffersOES(1, &_colorRenderbuffer);
_colorRenderbuffer = 0; _colorRenderbuffer = 0;
} }
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment