⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vout_beos.cpp

📁 vlc stand 0.1.99 ist sehr einfach
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * vout_beos.cpp: beos video output display method ***************************************************************************** * Copyright (C) 2000 VideoLAN * * Authors: * Jean-Marc Dressler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include "defs.h"#include <errno.h>                                                 /* ENOMEM */#include <stdlib.h>                                                /* free() */#include <stdio.h>#include <string.h>                                            /* strerror() */#include <kernel/OS.h>#include <View.h>#include <Application.h>#include <DirectWindow.h>#include <Locker.h>#include <malloc.h>#include <string.h>extern "C"{#include "config.h"#include "common.h"#include "threads.h"#include "mtime.h"#include "plugins.h"#include "video.h"#include "video_output.h"#include "intf_msg.h"#include "interface.h" /* XXX maybe to remove if beos_window.h is splitted */#include "main.h"}#include "beos_window.h"#define WIDTH 128#define HEIGHT 64#define BITS_PER_PLANE 16#define BYTES_PER_PIXEL 2/***************************************************************************** * vout_sys_t: dummy video output method descriptor ***************************************************************************** * This structure is part of the video output thread descriptor. * It describes the dummy specific properties of an output thread. *****************************************************************************/ typedef struct vout_sys_s{    VideoWindow *         p_window;        byte_t *              pp_buffer[2];    s32                   i_width;    s32                   i_height;} vout_sys_t;/***************************************************************************** * beos_GetAppWindow : retrieve a BWindow pointer from the window name *****************************************************************************/BWindow *beos_GetAppWindow(char *name){    int32       index;    BWindow     *window;        for (index = 0 ; ; index++)    {        window = be_app->WindowAt(index);        if (window == NULL)            break;        if (window->LockWithTimeout(200000) == B_OK)        {            if (strcmp(window->Name(), name) == 0)            {                window->Unlock();                break;            }            window->Unlock();        }    }    return window; }/***************************************************************************** * DrawingThread : thread that really does the drawing *****************************************************************************/int32 DrawingThread(void *data){    uint32 i, j, y;    uint64 *pp, *qq;    uint8 *p, *q;    uint32 byte_width;    uint32 height, bytes_per_line;    clipping_rect *clip;    VideoWindow *w;    w = (VideoWindow*) data;        while(!w->fConnectionDisabled)    {        w->locker->Lock();        if( w->fConnected )        {            if( w->fDirty && (!w->fReady || w->i_screen_depth != w->p_vout->i_screen_depth) )            {                bytes_per_line = w->fRowBytes;                for( i=0 ; i < w->fNumClipRects ; i++ )                {                    clip = &(w->fClipList[i]);                    height = clip->bottom - clip->top +1;                    byte_width = w->i_bytes_per_pixel * ((clip->right - clip->left)+1);                    p = w->fBits + clip->top*w->fRowBytes + clip->left * w->i_bytes_per_pixel;                    for( y=0 ; y < height ; )                    {                        pp = (uint64*) p;                        for( j=0 ; j < byte_width/64 ; j++ )                        {                            *pp++ = 0;                            *pp++ = 0;                             *pp++ = 0;                            *pp++ = 0;                             *pp++ = 0;                            *pp++ = 0;                             *pp++ = 0;                            *pp++ = 0;                         }                        memset( pp , 0, byte_width & 63 );                        y++;                        p += bytes_per_line;                    }                }            }            else if( w->fDirty )            {                bytes_per_line = w->fRowBytes;                for( i=0 ; i < w->fNumClipRects ; i++ )                {                    clip = &(w->fClipList[i]);                    height = clip->bottom - clip->top +1;                    byte_width = w->i_bytes_per_pixel * ((clip->right - clip->left)+1);                    p = w->fBits + clip->top * bytes_per_line + clip->left * w->i_bytes_per_pixel;                    q = w->p_vout->p_sys->pp_buffer[ !w->p_vout->i_buffer_index ] +                        clip->top * w->p_vout->i_bytes_per_line + clip->left *                        w->p_vout->i_bytes_per_pixel;                    for( y=0 ; y < height ; )                    {                        pp = (uint64*) p;                        qq = (uint64*) q;                        for( j=0 ; j < byte_width/64 ; j++ )                        {                            *pp++ = *qq++;                            *pp++ = *qq++;                             *pp++ = *qq++;                            *pp++ = *qq++;                             *pp++ = *qq++;                            *pp++ = *qq++;                             *pp++ = *qq++;                            *pp++ = *qq++;                         }                        memcpy( pp , qq, byte_width & 63 );                        y++;                        p += bytes_per_line;                        q += w->p_vout->p_sys->i_width * w->p_vout->i_bytes_per_pixel;                    }                }            }            w->fDirty = false;        }        w->locker->Unlock();        snooze( 20000 );    }    return B_OK;}/***************************************************************************** * VideoWindow constructor and destructor *****************************************************************************/VideoWindow::VideoWindow(BRect frame, const char *name, vout_thread_t *p_video_output )        : BDirectWindow(frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE){    BView * view;    fReady = false;    fConnected = false;    fConnectionDisabled = false;    locker = new BLocker();    fClipList = NULL;    fNumClipRects = 0;    p_vout = p_video_output;    view = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW);    view->SetViewColor(B_TRANSPARENT_32_BIT);    AddChild(view);/*    if(!SupportsWindowMode())    {        SetFullScreen(true);    }*/    fDirty = false;    fDrawThreadID = spawn_thread(DrawingThread, "drawing_thread",                    B_DISPLAY_PRIORITY, (void*) this);    resume_thread(fDrawThreadID);    Show();}VideoWindow::~VideoWindow(){    int32 result;    fConnectionDisabled = true;    Hide();    Sync();    wait_for_thread(fDrawThreadID, &result);    free(fClipList);    delete locker;}/***************************************************************************** * VideoWindow::DirectConnected *****************************************************************************/void VideoWindow::DirectConnected(direct_buffer_info *info){    unsigned int i;    if(!fConnected && fConnectionDisabled)    {        return;    }    locker->Lock();    switch(info->buffer_state & B_DIRECT_MODE_MASK)    {    case B_DIRECT_START:        fConnected = true;    case B_DIRECT_MODIFY:        fBits = (uint8*)((char*)info->bits +        (info->window_bounds.top) * info->bytes_per_row +        (info->window_bounds.left) * (info->bits_per_pixel>>3));;                i_bytes_per_pixel = info->bits_per_pixel >> 3;        i_screen_depth = info->bits_per_pixel;                fRowBytes = info->bytes_per_row;        fFormat = info->pixel_format;        fBounds = info->window_bounds;        fDirty = true;        if(fClipList)        {            free(fClipList);            fClipList = NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -