<commit_before>//
// $Id$
//

#include "DFBDisplayEngine.h"
#include "Region.h"
#include "Player.h"
#include "Node.h"
#include "AVGNode.h"
#include "FramerateManager.h"
#include "DFBSurface.h"

#include "Event.h"
#include "MouseEvent.h"
#include "KeyEvent.h"

#include "../base/Exception.h"
#include "../base/Logger.h"

#include <directfb.h>
#include <signal.h>

#include <iostream>
#include <sstream>
#include <unistd.h>
#include <assert.h>

using namespace std;

namespace avg {

DFBDisplayEngine::DFBDisplayEngine()
    : m_pDirectFB(0),
      m_pBackBuffer(0)
{
}

DFBDisplayEngine::~DFBDisplayEngine()
{
    if (m_pDirectFB) {
        teardown();
    }
}

void DFBDisplayEngine::dumpSurface (IDirectFBSurface * pSurf, const string & name)
{
    int w, h;
    AVG_TRACE(Logger::BLTS, "Surface: " << name);

    pSurf->GetSize(pSurf, &w, &h);
    AVG_TRACE(Logger::BLTS, "  Size: " << w << "x" << h);

    DFBRectangle rect;
    pSurf->GetVisibleRectangle(pSurf, &rect);
    AVG_TRACE(Logger::BLTS, "  VisibleRect: x: " << rect.x << 
            ", y: " << rect.y << ", w: " << rect.w << ", h: " << rect.h);

    DFBSurfaceCapabilities caps;
    pSurf->GetCapabilities(pSurf, &caps);
    AVG_TRACE(Logger::BLTS, "  Caps: " << std::hex << caps);

    DFBSurfacePixelFormat fmt;
    pSurf->GetPixelFormat(pSurf, &fmt);
    string sFmt;
    switch (fmt) {
        case DSPF_ARGB1555:
            sFmt = "DSPF_ARGB155";
            break;
        case DSPF_RGB16:
            sFmt = "DSPF_RGB16";
            break;
        case DSPF_RGB24:
            sFmt = "DSPF_RGB24";
            break;
        case DSPF_RGB32:
            sFmt = "DSPF_RGB32";
            break;
        case DSPF_ARGB:
            sFmt = "DSPF_ARGB";
            break;
        case DSPF_A8:
            sFmt = "DSPF_A8";
            break;
        case DSPF_YUY2:
            sFmt = "DSPF_YUY2";
            break;
        case DSPF_RGB332:
            sFmt = "DSPF_RGB332";
            break;
        case DSPF_UYVY:
            sFmt = "DSPF_UYVY";
            break;
        case DSPF_I420:
            sFmt = "DSPF_I420";
            break;
        case DSPF_YV12:
            sFmt = "DSPF_YV12";
            break;
        case DSPF_LUT8:
            sFmt = "DSPF_LUT8";
            break;
        case DSPF_ALUT44:
            sFmt = "DSPF_ALUT44";
            break;
/*        case DSPF_AiRGB:
            sFmt = "DSPF_AiRGB";
            break;
        case DSPF_A1:
            sFmt = "DSPF_A1";
            break;*/
        default:
            sFmt = ""; 
    }
    if (sFmt != "") {
        AVG_TRACE(Logger::BLTS, "  PixelFormat: " << sFmt);
    } else {
        AVG_TRACE(Logger::BLTS, "  PixelFormat: " << fmt << std::dec);
    }
}


void DFBDisplayEngine::init(int width, int height, bool isFullscreen, int bpp,
        int WindowWidth, int WindowHeight)
{
    if (WindowWidth != 0 || WindowHeight != 0) {
        AVG_TRACE(Logger::ERROR, 
                "Can't set window width or height in DFB renderer. Aborting.");
        exit(-1);
    }
    DFBResult err;

    if (m_pDirectFB) {
        teardown();
    }

    initDFB(width, height, isFullscreen, bpp);
    initLayer(width, height);
    
    initBackbuffer();
    
    initInput();

    IDirectFBSurface * pLayerSurf;
    err = m_pDFBLayer->GetSurface(m_pDFBLayer, &pLayerSurf);
    DFBErrorCheck(AVG_ERR_VIDEO_INIT_FAILED, "DFBDisplayEngine::init", err);
    dumpSurface (pLayerSurf, "Layer surface");

    dumpSurface (m_pBackBuffer, "Backbuffer surface");

    pLayerSurf->Release(pLayerSurf);
    
    // SDL sets up a signal handler we really don't want.
    if (!m_IsFullscreen) {
        signal(SIGSEGV, SIG_DFL);
    }
}

void DFBDisplayEngine::initDFB(int width, int height, 
        bool isFullscreen, int bpp)
{
    // Init DFB system
    char ** argv = new (char *)[7];
    int argc = 3;
    argv[0] = strdup ("bogus_appname");<commit_msg>*** empty log message ***<commit_after>//
// $Id$
//

#include "DFBDisplayEngine.h"
#include "Region.h"
#include "Player.h"
#include "Node.h"
#include "AVGNode.h"
#include "FramerateManager.h"
#include "DFBSurface.h"

#include "Event.h"
#include "MouseEvent.h"
#include "KeyEvent.h"

#include "../base/Exception.h"
#include "../base/Logger.h"

#include <directfb.h>
#include <signal.h>

#include <iostream>
#include <sstream>
#include <unistd.h>
#include <assert.h>

using namespace std;

namespace avg {

DFBDisplayEngine::DFBDisplayEngine()
    : m_pDirectFB(0),
      m_pBackBuffer(0)
{
}

DFBDisplayEngine::~DFBDisplayEngine()
{
    if (m_pDirectFB) {
        teardown();
    }
}

void DFBDisplayEngine::dumpSurface (IDirectFBSurface * pSurf, const string & name)
{
    int w, h;
    AVG_TRACE(Logger::BLTS, "Surface: " << name);

    pSurf->GetSize(pSurf, &w, &h);
    AVG_TRACE(Logger::BLTS, "  Size: " << w << "x" << h);

    DFBRectangle rect;
    pSurf->GetVisibleRectangle(pSurf, &rect);
    AVG_TRACE(Logger::BLTS, "  VisibleRect: x: " << rect.x << 
            ", y: " << rect.y << ", w: " << rect.w << ", h: " << rect.h);

    DFBSurfaceCapabilities caps;
    pSurf->GetCapabilities(pSurf, &caps);
    AVG_TRACE(Logger::BLTS, "  Caps: " << std::hex << caps);

    DFBSurfacePixelFormat fmt;
    pSurf->GetPixelFormat(pSurf, &fmt);
    string sFmt;
    switch (fmt) {
        case DSPF_ARGB1555:
            sFmt = "DSPF_ARGB155";
            break;
        case DSPF_RGB16:
            sFmt = "DSPF_RGB16";
            break;
        case DSPF_RGB24:
            sFmt = "DSPF_RGB24";
            break;
        case DSPF_RGB32:
            sFmt = "DSPF_RGB32";
            break;
        case DSPF_ARGB:
            sFmt = "DSPF_ARGB";
            break;
        case DSPF_A8:
            sFmt = "DSPF_A8";
            break;
        case DSPF_YUY2:
            sFmt = "DSPF_YUY2";
            break;
        case DSPF_RGB332:
            sFmt = "DSPF_RGB332";
            break;
        case DSPF_UYVY:
            sFmt = "DSPF_UYVY";
            break;
        case DSPF_I420:
            sFmt = "DSPF_I420";
            break;
        case DSPF_YV12:
            sFmt = "DSPF_YV12";
            break;
        case DSPF_LUT8:
            sFmt = "DSPF_LUT8";
            break;
        case DSPF_ALUT44:
            sFmt = "DSPF_ALUT44";
            break;
/*        case DSPF_AiRGB:
            sFmt = "DSPF_AiRGB";
            break;
        case DSPF_A1:
            sFmt = "DSPF_A1";
            break;*/
        default:
            sFmt = ""; 
    }
    if (sFmt != "") {
        AVG_TRACE(Logger::BLTS, "  PixelFormat: " << sFmt);
    } else {
        AVG_TRACE(Logger::BLTS, "  PixelFormat: " << fmt << std::dec);
    }
}


void DFBDisplayEngine::init(int width, int height, bool isFullscreen, int bpp,
        int WindowWidth, int WindowHeight)
{
    if (WindowWidth != 0 || WindowHeight != 0) {
        AVG_TRACE(Logger::ERROR, 
                "Can't set window width or height in DFB renderer. Aborting.");
        exit(-1);
    }
    DFBResult err;

    if (m_pDirectFB) {
        teardown();
    }

    initDFB(width, height, isFullscreen, bpp);
    initLayer(width, height);
    
    initBackbuffer();
    
    initInput();

    IDirectFBSurface * pLayerSurf;
    err = m_pDFBLayer->GetSurface(m_pDFBLayer, &pLayerSurf);
    DFBErrorCheck(AVG_ERR_VIDEO_INIT_FAILED, "DFBDisplayEngine::init", err);
    dumpSurface (pLayerSurf, "Layer surface");

    dumpSurface (m_pBackBuffer, "Backbuffer surface");

    pLayerSurf->Release(pLayerSurf);
    
    // SDL sets up a signal handler we really don't want.
    if (!m_IsFullscreen) {
        signal(SIGSEGV, SIG_DFL);
    }
}

void DFBDisplayEngine::initDFB(int width, int height, 
        bool isFullscreen, int bpp)
{
    // Init DFB system
    char ** argv = new char *[7];
    int argc = 3;
    argv[0] = strdup ("bogus_appname");
{'fraction_non_alphanumeric': 0.13422131147540983, 'fraction_numerical': 0.01408811475409836, 'mean_word_length': 2.117365269461078, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5263571', 'n_tokens_mistral': 3018, 'n_tokens_neox': 2912, 'n_words': 573}