Пример #1
0
/*****************************************************************************
 * VideoWindow::_AllocateBuffers
 *****************************************************************************/
status_t
VideoWindow::_AllocateBuffers(int width, int height, int* mode)
{
    // clear any old buffers
    _FreeBuffers();
    // set default mode
    *mode = BITMAP;
    bitmap_count = 3;

    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 every chroma in colspace,
       we try to do double-buffered overlay, single-buffered overlay
       or basic overlay. If nothing worked, we then have to work with
       a non-overlay BBitmap. */
    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;

            *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)" );

            bitmap[1] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY,
                                     colspace[colspace_index].colspace);
            if( bitmap[1] && bitmap[1]->InitCheck() == B_OK )
            {

                bitmap[2] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY,
                                         colspace[colspace_index].colspace);
                if( bitmap[2] && bitmap[2]->InitCheck() == B_OK )
                {
                    msg_Dbg( p_vout, "using double-buffered overlay" );
                }
                else
                {
                    msg_Dbg( p_vout, "using single-buffered overlay" );
                    bitmap_count = 2;
                    delete bitmap[2]; bitmap[2] = NULL;
                }
            }
            else
            {
                msg_Dbg( p_vout, "using simple overlay" );
                bitmap_count = 1;
                delete bitmap[1]; bitmap[1] = NULL;
            }
            break;
        }
        else
        {
            delete bitmap[0]; bitmap[0] = NULL;
        }
    }

    if (*mode == BITMAP)
    {
        msg_Warn( p_vout, "no possible overlay" );

        // fallback to RGB
        colspace_index = DEFAULT_COL;    // B_RGB32
        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 );
        SetTitle( "VLC " PACKAGE_VERSION " (Bitmap)" );
    }
    // see if everything went well
    status_t status = B_ERROR;
    for (int32_t i = 0; i < bitmap_count; 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 < bitmap_count; i++)
            _BlankBitmap(bitmap[i]);
    }
    return status;
}
Пример #2
0
BView* PrefsWindow::constructCommandBox(BRect frame)
{
	BBox* commandBox = new BBox(frame);
	commandBox->SetLabel("Commands");
	
	float 	offset = 30.0f,
			bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f,			
			globalTcOffset = 45.0f,		
			bitoffset = 45.0,
			secOffset = 170.0f
			;
				
	BRect textCtrlFrame(offset / 2.0f, offset, offset / 2.0f + 300.0f, offset + 20.0f);
	BStringView *textCtrlInfo = new BStringView(textCtrlFrame, "info", "The \'$\' represents the filename in filename.tex");
	commandBox->AddChild(textCtrlInfo);	
	
	BRect bitRect(offset / 2.0f, offset + globalTcOffset, offset / 2.0f + 31.0f, offset + 31.0f + globalTcOffset);
	BRect secCol(bitRect);	
	secCol.OffsetBy(secOffset, 0.0f);	
	secCol.OffsetBy(0.0f, bitoffset);	
	
	float	textCtrlWidth = 100.0f,
			textCtrlHeight = 20.0f,
			textCtrlCo = 6.0f
			;
			
	BRect bitctrlRect(offset / 2.0f + bitoffset, offset + textCtrlCo + globalTcOffset, offset / 2.0f + bitoffset + textCtrlWidth, textCtrlCo + offset + textCtrlHeight + globalTcOffset);		
	BRect secColCtrl(bitctrlRect);
	secColCtrl.OffsetBy(secOffset, 0.0f);
	secColCtrl.right += 50.0f;
	
	//tex to dvi
	BRect bitmapFrame(0.0f, 0.0f, 31.0f, 31.0f);	
	BBitmap	*texDviBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	texDviBitmap->SetBits(IconTexToDVI, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, texDviBitmap));
	
	BTextControl *texDviCtrl = new BTextControl(bitctrlRect, K_LATEX_CMD, NULL, "", GetPrefsMessage(K_LATEX_CMD));
	commandBox->AddChild(texDviCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//dvi to pdf
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* dviPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	dviPdfBitmap->SetBits(IconDVIToPDF, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, dviPdfBitmap));
	
	BTextControl *dviPdfCtrl = new BTextControl(bitctrlRect, K_DVIPDF_CMD, NULL, "",  GetPrefsMessage(K_DVIPDF_CMD));
	commandBox->AddChild(dviPdfCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//dvi to ps
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* dviPsBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	dviPsBitmap->SetBits(IconDVIToPS, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, dviPsBitmap));
	
	BTextControl *dviPsCtrl = new BTextControl(bitctrlRect, K_DVIPS_CMD, NULL, "",  GetPrefsMessage(K_DVIPS_CMD));
	commandBox->AddChild(dviPsCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//ps to pdf
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* psPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	psPdfBitmap->SetBits(IconPSToPDF, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, psPdfBitmap));
	
	BTextControl *psPdfCtrl = new BTextControl(bitctrlRect, K_PS2PDF_CMD, NULL, "",  GetPrefsMessage(K_PS2PDF_CMD));
	commandBox->AddChild(psPdfCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//tex to pdf
	bitRect.OffsetBy(0.0f, bitoffset);			
	BBitmap* texPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	texPdfBitmap->SetBits(IconTexToPDF,3072,0,B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, texPdfBitmap));
	
	BTextControl *texPdfCtrl = new BTextControl(bitctrlRect, K_PDFLATEX_CMD, NULL, "",  GetPrefsMessage(K_PDFLATEX_CMD));
	commandBox->AddChild(texPdfCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//tex to html
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* texHtmlBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	texHtmlBitmap->SetBits(IconTexToHTML, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(bitRect, texHtmlBitmap));
	
	BTextControl *texHtmlCtrl = new BTextControl(bitctrlRect, K_LATEX2HTML_CMD, NULL, "",  GetPrefsMessage(K_LATEX2HTML_CMD));
	commandBox->AddChild(texHtmlCtrl);
	bitctrlRect.OffsetBy(0.0f, bitoffset);
	
	//ps
	bitRect.OffsetBy(0.0f, bitoffset);	
	BBitmap* postScriptBitmap = new BBitmap(bitmapFrame, B_CMAP8);
	postScriptBitmap->SetBits(IconPrevPS, 3072, 0, B_CMAP8);
	commandBox->AddChild(new BitmapView(secCol, postScriptBitmap));
	
	BTextControl *postScriptCtrl = new BTextControl(secColCtrl, K_POSTSCRIPT_CMD, NULL, "", GetPrefsMessage(K_POSTSCRIPT_CMD));
	commandBox->AddChild(postScriptCtrl);
		
	BRect comboxRect = commandBox->Bounds();
	BRect comboxbtnRect(comboxRect.right - bspacing - bwidth, comboxRect.bottom - bspacing - bheight, comboxRect.right - bspacing, comboxRect.bottom - bspacing);
	BButton *resetCommandDefaults = new BButton(comboxbtnRect,"resetCommandDefaults","Defaults",new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_COMMAND_DEFAULTS));
	commandBox->AddChild(resetCommandDefaults);
	
	return commandBox;
}