📄 videooutput.cpp
字号:
fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL); else fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL); } } break; case ASPECT_CORRECT: SetCorrectAspectRatio(!CorrectAspectRatio()); break; case SCREEN_SHOT: // save a screen shot if ( BBitmap* current = bitmap[i_buffer] ) {// the following line might be tempting, but does not work for some overlay bitmaps!!!// BBitmap* temp = new BBitmap( current );// so we clone the bitmap ourselves// however, we need to take care of potentially different padding!// memcpy() is slow when reading from grafix memory, but what the heck... BBitmap* temp = new BBitmap( current->Bounds(), current->ColorSpace() ); if ( temp && temp->IsValid() ) { int32_t height = (int32_t)current->Bounds().Height(); uint8_t* dst = (uint8_t*)temp->Bits(); uint8_t* src = (uint8_t*)current->Bits(); int32_t dstBpr = temp->BytesPerRow(); int32_t srcBpr = current->BytesPerRow(); int32_t validBytes = dstBpr > srcBpr ? srcBpr : dstBpr; for ( int32_t y = 0; y < height; y++ ) { memcpy( dst, src, validBytes ); dst += dstBpr; src += srcBpr; } char * path = config_GetPsz( p_vout, "beos-screenshotpath" ); if ( !path ) path = strdup( DEFAULT_SCREEN_SHOT_PATH ); /* FIXME - we should check which translators are actually available */ char * psz_format = config_GetPsz( p_vout, "beos-screenshotformat" ); int32_t format = DEFAULT_SCREEN_SHOT_FORMAT; if( !strcmp( psz_format, "TGA" ) ) format = 'TGA '; else if( !strcmp( psz_format, "PPM" ) ) format = 'PPM '; else if( !strcmp( psz_format, "JPEG" ) ) format = 'JPEG'; else if( !strcmp( psz_format, "BMP" ) ) format = 'BMP '; _SaveScreenShot( temp, path, format ); } else { delete temp; } } break; case SHORTCUT: { vlc_value_t val; p_message->FindInt32( "key", (int32*) &val.i_int ); var_Set( p_vout->p_vlc, "key-pressed", val ); break; } default: BWindow::MessageReceived( p_message ); break; }}/***************************************************************************** * VideoWindow::Zoom *****************************************************************************/voidVideoWindow::Zoom(BPoint origin, float width, float height ){ ToggleFullScreen();}/***************************************************************************** * VideoWindow::FrameMoved *****************************************************************************/voidVideoWindow::FrameMoved(BPoint origin){ if (IsFullScreen()) return ; winSize = Frame();}/***************************************************************************** * VideoWindow::FrameResized *****************************************************************************/voidVideoWindow::FrameResized( float width, float height ){ int32_t useWidth = CorrectAspectRatio() ? i_width : fTrueWidth; int32_t useHeight = CorrectAspectRatio() ? i_height : fTrueHeight; float out_width, out_height; float out_left, out_top; float width_scale = width / useWidth; float height_scale = height / useHeight; if (width_scale <= height_scale) { out_width = (useWidth * width_scale); out_height = (useHeight * width_scale); out_left = 0; out_top = (height - out_height) / 2; } else /* if the height is proportionally smaller */ { out_width = (useWidth * height_scale); out_height = (useHeight * height_scale); out_top = 0; out_left = (width - out_width) / 2; } view->MoveTo(out_left,out_top); view->ResizeTo(out_width, out_height); if (!IsFullScreen()) winSize = Frame();}/***************************************************************************** * VideoWindow::ScreenChanged *****************************************************************************/voidVideoWindow::ScreenChanged(BRect frame, color_space format){ BScreen screen(this); display_mode mode; screen.GetMode(&mode); float refresh = (mode.timing.pixel_clock * 1000) / ((mode.timing.h_total) * (mode.timing.v_total)); SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH);}/***************************************************************************** * VideoWindow::Activate *****************************************************************************/voidVideoWindow::WindowActivated(bool active){}/***************************************************************************** * VideoWindow::drawBuffer *****************************************************************************/voidVideoWindow::drawBuffer(int bufferIndex){ i_buffer = bufferIndex; // sync to the screen if required if (IsSyncedToRetrace()) { BScreen screen(this); screen.WaitForRetrace(22000); } if (fInitStatus >= B_OK && LockLooper()) { // switch the overlay bitmap if (mode == OVERLAY) { rgb_color key; view->SetViewOverlay(bitmap[i_buffer], bitmap[i_buffer]->Bounds() , view->Bounds(), &key, B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL| B_OVERLAY_TRANSFER_CHANNEL); view->SetViewColor(key); } else { // switch the bitmap view->DrawBitmap(bitmap[i_buffer], view->Bounds() ); } UnlockLooper(); }}/***************************************************************************** * VideoWindow::SetInterfaceShowing *****************************************************************************/voidVideoWindow::ToggleInterfaceShowing(){ SetInterfaceShowing(!fInterfaceShowing);}/***************************************************************************** * VideoWindow::SetInterfaceShowing *****************************************************************************/voidVideoWindow::SetInterfaceShowing(bool showIt){ BWindow* window = get_interface_window(); if (window) { if (showIt) { if (fCachedFeel != B_NORMAL_WINDOW_FEEL) SetFeel(B_NORMAL_WINDOW_FEEL); window->Activate(true); SendBehind(window); } else { SetFeel(fCachedFeel); Activate(true); window->SendBehind(this); } fInterfaceShowing = showIt; }}/***************************************************************************** * VideoWindow::SetCorrectAspectRatio *****************************************************************************/voidVideoWindow::SetCorrectAspectRatio(bool doIt){ if (CorrectAspectRatio() != doIt) { if (doIt) fSettings->AddFlags(VideoSettings::FLAG_CORRECT_RATIO); else fSettings->ClearFlags(VideoSettings::FLAG_CORRECT_RATIO); FrameResized(Bounds().Width(), Bounds().Height()); }}/***************************************************************************** * VideoWindow::CorrectAspectRatio *****************************************************************************/boolVideoWindow::CorrectAspectRatio() const{ return fSettings->HasFlags(VideoSettings::FLAG_CORRECT_RATIO);}/***************************************************************************** * VideoWindow::ToggleFullScreen *****************************************************************************/voidVideoWindow::ToggleFullScreen(){ SetFullScreen(!IsFullScreen());}/***************************************************************************** * VideoWindow::SetFullScreen *****************************************************************************/voidVideoWindow::SetFullScreen(bool doIt){ if (doIt) { SetLook( B_NO_BORDER_WINDOW_LOOK ); BScreen screen( this ); BRect rect = screen.Frame(); Activate(); MoveTo(0.0, 0.0); ResizeTo(rect.IntegerWidth(), rect.IntegerHeight()); be_app->ObscureCursor(); fInterfaceShowing = false; fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN); } else { SetLook( B_TITLED_WINDOW_LOOK ); MoveTo(winSize.left, winSize.top); ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight()); be_app->ShowCursor(); fInterfaceShowing = true; fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN); }}/***************************************************************************** * VideoWindow::IsFullScreen *****************************************************************************/boolVideoWindow::IsFullScreen() const{ return fSettings->HasFlags(VideoSettings::FLAG_FULL_SCREEN);}/***************************************************************************** * VideoWindow::SetSyncToRetrace *****************************************************************************/voidVideoWindow::SetSyncToRetrace(bool doIt){ if (doIt) fSettings->AddFlags(VideoSettings::FLAG_SYNC_RETRACE); else fSettings->ClearFlags(VideoSettings::FLAG_SYNC_RETRACE);}/***************************************************************************** * VideoWindow::IsSyncedToRetrace *****************************************************************************/boolVideoWindow::IsSyncedToRetrace() const{ return fSettings->HasFlags(VideoSettings::FLAG_SYNC_RETRACE);}/***************************************************************************** * VideoWindow::_AllocateBuffers *****************************************************************************/status_tVideoWindow::_AllocateBuffers(int width, int height, int* mode){ // clear any old buffers _FreeBuffers(); // set default mode *mode = BITMAP; BRect bitmapFrame( 0, 0, width, height ); // read from config, if we are supposed to use overlay at all int noOverlay = !config_GetInt( p_vout, "overlay" ); // test for overlay capability for (int i = 0; i < COLOR_COUNT; i++) { if (noOverlay) break; bitmap[0] = new BBitmap ( bitmapFrame, B_BITMAP_WILL_OVERLAY | B_BITMAP_RESERVE_OVERLAY_CHANNEL, colspace[i].colspace); if(bitmap[0] && bitmap[0]->InitCheck() == B_OK) { colspace_index = i; bitmap[1] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY, colspace[colspace_index].colspace); bitmap[2] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY, colspace[colspace_index].colspace); if ( (bitmap[2] && bitmap[2]->InitCheck() == B_OK) ) { *mode = OVERLAY; rgb_color key; view->SetViewOverlay(bitmap[0], bitmap[0]->Bounds() , view->Bounds(), &key, B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL|B_OVERLAY_FILTER_VERTICAL); view->SetViewColor(key); SetTitle("VLC " PACKAGE_VERSION " (Overlay)"); break; } else { _FreeBuffers(); *mode = BITMAP; // might want to try again with normal bitmaps } } else delete bitmap[0]; } if (*mode == BITMAP) { // fallback to RGB colspace_index = DEFAULT_COL; // B_RGB32 SetTitle( "VLC " PACKAGE_VERSION " (Bitmap)" ); bitmap[0] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[1] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[2] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); } // see if everything went well status_t status = B_ERROR; for (int32_t i = 0; i < 3; i++) { if (bitmap[i]) status = bitmap[i]->InitCheck(); if (status < B_OK) break; } if (status >= B_OK) { // clear bitmaps to black for (int32_t i = 0; i < 3; i++) _BlankBitmap(bitmap[i]); } return status;}/***************************************************************************** * VideoWindow::_FreeBuffers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -