📄 voutagl.m
字号:
p_vout->p_sys->viewBounds = viewBounds; } } } return VLC_SUCCESS; } case VOUT_REDRAW_RECT: { vout_thread_t * p_parent; Rect areaBounds; areaBounds.top = va_arg( args, int); areaBounds.left = va_arg( args, int); areaBounds.bottom = va_arg( args, int); areaBounds.right = va_arg( args, int); /* Ask the opengl module to redraw */ p_parent = (vout_thread_t *) p_vout->p_parent; if( p_parent && p_parent->pf_display ) { p_parent->pf_display( p_parent, NULL ); } return VLC_SUCCESS; } case VOUT_REPARENT: { AGLDrawable drawable = (AGLDrawable)va_arg( args, int); if( !p_vout->b_fullscreen && drawable != p_vout->p_sys->agl_drawable ) { p_vout->p_sys->agl_drawable = drawable; aglSetDrawable(p_vout->p_sys->agl_ctx, drawable); } return VLC_SUCCESS; } default: return vout_vaControlDefault( p_vout, i_query, args ); }}void aglSwap( vout_thread_t * p_vout ){ if( ! p_vout->p_sys->b_clipped_out ) { p_vout->p_sys->b_got_frame = true; aglSwapBuffers(p_vout->p_sys->agl_ctx); } else { /* drop frame */ glFlush(); }}/* Enter this function with the p_vout locked */static void aglSetViewport( vout_thread_t *p_vout, Rect viewBounds, Rect clipBounds ){ // mozilla plugin provides coordinates based on port bounds // however AGL coordinates are based on window structure region // and are vertically flipped GLint rect[4]; CGrafPtr port = (CGrafPtr)p_vout->p_sys->agl_drawable; Rect winBounds, clientBounds; GetWindowBounds(GetWindowFromPort(port), kWindowStructureRgn, &winBounds); GetWindowBounds(GetWindowFromPort(port), kWindowContentRgn, &clientBounds); /* update video clipping bounds in drawable */ rect[0] = (clientBounds.left-winBounds.left) + clipBounds.left; // from window left edge rect[1] = (winBounds.bottom-winBounds.top) - (clientBounds.top-winBounds.top) - clipBounds.bottom; // from window bottom edge rect[2] = clipBounds.right-clipBounds.left; // width rect[3] = clipBounds.bottom-clipBounds.top; // height aglSetInteger(p_vout->p_sys->agl_ctx, AGL_BUFFER_RECT, rect); aglEnable(p_vout->p_sys->agl_ctx, AGL_BUFFER_RECT); /* update video internal bounds in drawable */ p_vout->p_sys->i_width = viewBounds.right-viewBounds.left; p_vout->p_sys->i_height = viewBounds.bottom-viewBounds.top; p_vout->p_sys->i_offx = -clipBounds.left - viewBounds.left; p_vout->p_sys->i_offy = clipBounds.bottom + viewBounds.top - p_vout->p_sys->i_height; aglUpdateContext(p_vout->p_sys->agl_ctx);}//default window event handlerstatic pascal OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData){ OSStatus result = noErr; UInt32 class = GetEventClass (event); UInt32 kind = GetEventKind (event); vout_thread_t *p_vout = (vout_thread_t *)userData; result = CallNextEventHandler(nextHandler, event); if(class == kEventClassCommand) { HICommand theHICommand; GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand ); switch ( theHICommand.commandID ) { default: result = eventNotHandledErr; } } else if(class == kEventClassWindow) { WindowRef window; Rect rectPort = {0,0,0,0}; GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); if(window) { GetPortBounds(GetWindowPort(window), &rectPort); } switch (kind) { case kEventWindowClosed: case kEventWindowZoomed: case kEventWindowBoundsChanged: break; default: result = eventNotHandledErr; } } else if(class == kEventClassMouse) { switch (kind) { case kEventMouseDown: { UInt16 button; GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); switch (button) { case kEventMouseButtonPrimary: { vlc_value_t val; var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 1; var_Set( p_vout, "mouse-button-down", val ); break; } case kEventMouseButtonSecondary: { vlc_value_t val; var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 2; var_Set( p_vout, "mouse-button-down", val ); break; } case kEventMouseButtonTertiary: { vlc_value_t val; var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 4; var_Set( p_vout, "mouse-button-down", val ); break; } default: result = eventNotHandledErr; } break; } case kEventMouseUp: { UInt16 button; GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); switch (button) { case kEventMouseButtonPrimary: { UInt32 clickCount = 0; GetEventParameter(event, kEventParamClickCount, typeUInt32, NULL, sizeof(clickCount), NULL, &clickCount); if( clickCount > 1 ) { vlc_value_t val; val.b_bool = false; var_Set((vout_thread_t *) p_vout->p_parent, "fullscreen", val); } else { vlc_value_t val; val.b_bool = true; var_Set( p_vout, "mouse-clicked", val ); var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~1; var_Set( p_vout, "mouse-button-down", val ); } break; } case kEventMouseButtonSecondary: { vlc_value_t val; var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~2; var_Set( p_vout, "mouse-button-down", val ); break; } case kEventMouseButtonTertiary: { vlc_value_t val; var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~2; var_Set( p_vout, "mouse-button-down", val ); break; } default: result = eventNotHandledErr; } break; } case kEventMouseMoved: { Point ml; vlc_value_t val; unsigned int i_x, i_y; unsigned int i_height = p_vout->p_sys->i_height; unsigned int i_width = p_vout->p_sys->i_width; vout_PlacePicture(p_vout, i_width, i_height, &i_x, &i_y, &i_width, &i_height); GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml); val.i_int = ( ((int)ml.h) - i_x ) * p_vout->render.i_width / i_width; var_Set( p_vout, "mouse-x", val ); val.i_int = ( ((int)ml.v) - i_y ) * p_vout->render.i_height / i_height; var_Set( p_vout, "mouse-y", val ); val.b_bool = true; var_Set( p_vout, "mouse-moved", val ); break; } default: result = eventNotHandledErr; } } else if(class == kEventClassTextInput) { switch (kind) { case kEventTextInputUnicodeForKeyEvent: { break; } default: result = eventNotHandledErr; } } else if(class == kEventClassVLCPlugin) { switch (kind) { case kEventVLCPluginShowFullscreen: ShowWindow (p_vout->p_sys->theWindow); SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); //CGDisplayHideCursor(kCGDirectMainDisplay); break; case kEventVLCPluginHideFullscreen: HideWindow (p_vout->p_sys->theWindow); SetSystemUIMode( kUIModeNormal, 0); CGDisplayShowCursor(kCGDirectMainDisplay); break; default: result = eventNotHandledErr; break; } } return result;}int aglLock( vout_thread_t * p_vout ){#ifdef __ppc__ /* * before 10.4, we set the AGL context as current and * then we retrieve and use the matching CGL context */ aglSetCurrentContext(p_vout->p_sys->agl_ctx); return kCGLNoError != CGLLockContext( CGLGetCurrentContext() );#else /* since 10.4, this is the safe way to get the underlying CGL context */ CGLContextObj cglContext; if( aglGetCGLContext(p_vout->p_sys->agl_ctx, (void**)&cglContext) ) { if( kCGLNoError == CGLLockContext( cglContext ) ) { aglSetCurrentContext(p_vout->p_sys->agl_ctx); return 0; } } return 1;#endif}void aglUnlock( vout_thread_t * p_vout ){#ifdef __ppc__ /* * before 10.4, we assume that the AGL context is current. * therefore, we use the current CGL context */ CGLUnlockContext( CGLGetCurrentContext() );#else /* since 10.4, this is the safe way to get the underlying CGL context */ CGLContextObj cglContext; if( aglGetCGLContext(p_vout->p_sys->agl_ctx, (void**)&cglContext) ) { CGLUnlockContext( cglContext ); }#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -