コード例 #1
0
ファイル: MainCanvas.cpp プロジェクト: derric/libavg
void MainCanvas::renderTree()
{
    preRender();
    DisplayEngine* pDisplayEngine = getPlayer()->getDisplayEngine();
    unsigned numWindows = pDisplayEngine->getNumWindows();
    for (unsigned i=0; i<numWindows; ++i) {
        ScopeTimer Timer(RootRenderProfilingZone);
        WindowPtr pWindow = pDisplayEngine->getWindow(i);
        IntRect viewport = pWindow->getViewport();
        renderWindow(pWindow, MCFBOPtr(), viewport);
    }
    GLContextManager::get()->reset();
}
コード例 #2
0
ファイル: VideoWriter.cpp プロジェクト: bluscr33n/libavg
VideoWriter::VideoWriter(CanvasPtr pCanvas, const string& sOutFileName, int frameRate,
        int qMin, int qMax, bool bSyncToPlayback)
    : m_pCanvas(pCanvas),
      m_sOutFileName(sOutFileName),
      m_FrameRate(frameRate),
      m_QMin(qMin),
      m_QMax(qMax),
      m_bHasValidData(false),
      m_bSyncToPlayback(bSyncToPlayback),
      m_bPaused(false),
      m_PauseTime(0),
      m_bStopped(false),
      m_CurFrame(0),
      m_StartTime(-1),
      m_bFramePending(false)
{
    if (!pCanvas) {
        throw Exception(AVG_ERR_INVALID_ARGS, "VideoWriter needs a canvas to write to.");
    }
    if (GLContext::getCurrent()->isGLES()) {
        throw Exception(AVG_ERR_UNSUPPORTED, "VideoWriter not supported under GLES.");
    }
#ifdef WIN32
    int fd = _open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, _S_IREAD | _S_IWRITE);
#elif defined __linux__
    int fd = open64(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
#else
    int fd = open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
#endif
    if (fd == -1) {
        throw Exception(AVG_ERR_VIDEO_INIT_FAILED, 
                string("Could not open output file '") + m_sOutFileName + "'. Reason: " +
                strerror(errno));
    }
#ifdef WIN32
    _close(fd);
#else
    close(fd);
#endif
    remove(m_sOutFileName.c_str());
    CanvasPtr pMainCanvas = Player::get()->getMainCanvas();
    DisplayEngine* pDisplayEngine = Player::get()->getDisplayEngine();
    if (pMainCanvas == m_pCanvas) {
        m_FrameSize = pDisplayEngine->getWindowSize();
    } else {
        m_FrameSize = m_pCanvas->getSize();
        GLContext* pOldContext = GLContext::getCurrent();
        m_pMainGLContext = pDisplayEngine->getWindow(0)->getGLContext();
        m_pMainGLContext->activate();
        m_pFBO = dynamic_pointer_cast<OffscreenCanvas>(m_pCanvas)->
                getFBO(m_pMainGLContext);
        if (GLContext::getCurrent()->useGPUYUVConversion()) {
            m_pFilter = GPURGB2YUVFilterPtr(new GPURGB2YUVFilter(m_FrameSize));
        }
        pOldContext->activate();
    }
    VideoWriterThread writer(m_CmdQueue, m_sOutFileName, m_FrameSize, m_FrameRate, 
            qMin, qMax);
    m_pThread = new boost::thread(writer);
    m_pCanvas->registerPlaybackEndListener(this);
    m_pCanvas->registerFrameEndListener(this);
}