예제 #1
0
파일: testr.cpp 프로젝트: BrandRegard/gnash
int
main(int argc, char *argv[])
{
    // FIXME: for now, always run verbose till this supports command line args
    dbglogfile.setVerbosity();

    const char *pixelformat = "RGB24";
    int fd = 0;

#ifdef BUILD_RAWFB_DEVICE_XXX
    rawfb::RawFBDevice rawfb(argc, argv);
    fd = rawfb.getHandle();
#endif  // BUILD_RAWFB_DEVICE

#if defined(BUILD_EGL_DEVICE) && !defined(BUILD_X11_DEVICE)
    // Setup EGL, OpenVG needs it
    EGLDevice egl(argc, argv);
    egl.bindClient(GnashDevice::OPENVG);
    fd = open("/dev/fb0", O_RDWR);
    egl.attachWindow(fd);
#endif  // BUILD_EGL_DEVICE
    
#ifdef BUILD_X11_DEVICE
    // Setup EGL, OpenVG needs it
    EGLDevice egl;
    //egl.setAttrib(1);
    egl.initDevice(argc, argv);
    int vid = egl.getNativeVisual();
    egl.bindClient(GnashDevice::OPENVG);

    // Create an X11 device for the display. This is for libMesa
    // where we can also run OpenVG on the desktop.
    x11::X11Device x11(vid);
    //x11.initDevice(argc, argv);
    x11.createWindow("TestR", 0, 0, 640, 480);
    
    // This is the window that gets rendered in
    Window win = x11.getHandle();
    if (win) {
        egl.attachWindow(win);
    } else {
        log_error(_("Couldn't get Drawable window from X11"));
        exit(1);
    }    
    // Set initial projection/viewing transformation.
    // We can't be sure we'll get a ConfigureNotify event when the window
    // first appears.
#if 0
    if (reshape) {
        reshape(640, 480);
    }
#endif
    x11.eventLoop(10);
    std::cerr << "Hello World!" << std::endl;
    x11.eventLoop(10);
#endif

#ifdef RENDERER_AGG
    Timer tagg("AGG");
    Renderer *renderer1 = create_Renderer_agg(pixelformat);
    // The methods were moved to the glue API
    // if (renderer1) {
    //     test_device(renderer1, "EGL");
    //     test_device(renderer1, "DIRECTFB");
    //     test_device(renderer1, "X11");
    // }
    if (renderer1) {
        test_renderer(renderer1, "AGG");
        test_geometry(renderer1, "AGG");
        test_iterators(renderer1, "AGG");
        tagg.stop();
    }
    cerr << "AGG tests took " << tagg.elapsed() << endl << endl;
#endif

#ifdef RENDERER_OPENVG
    Timer tovg("OpenVG");
    Renderer *renderer2 = renderer::openvg::create_handler(pixelformat);
//     EGLDevice *ovg = dynamic_cast<EGLDevice *>(renderer2);
//     if (ovg) {
//         ovg->initDevice(0, 0);
// //        ovg->attachWindow(*(reinterpret_cast<EGLNativeWindowType *>(canvas)));
//         ovg->attachWindow(0);
    if (renderer2) {
        test_renderer(renderer2, "OpenVG");
        test_geometry(renderer2, "OpenVG");
        test_iterators(renderer2, "OpenVG");
    } else {
        cerr << "ERROR: No OpenVG renderer to test!" << endl;
    }
    tovg.stop();
    cerr << "OpenVG tests took " << tovg.elapsed() << endl;
#endif
    
#if 0
#ifdef RENDERER_GLES1
    Timer tgles1("OpenGLES1");
    Renderer *renderer3 = renderer::gles1::create_handler(pixelformat);
    if (renderer3) {
        test_renderer(renderer3, "OpenGLES1");
        test_geometry(renderer3, "OpenGLES1");
        test_iterators(renderer3, "OpenGLES1");
    } else {
        cerr << "ERROR: No OpenGLES1 renderer to test!" << endl;
    }
    tgles1.stop();
    cerr << "OpenGLES1 tests took " << tgles1.elapsed() << endl;
#endif

#ifdef RENDERER_GLES2
    Timer tgles2("OpenGLES2");
    Renderer *renderer4 = renderer::gles2::create_handler(pixelformat);
    if (renderer4) {
        test_renderer(renderer4, "OpenGLES2");
        test_geometry(renderer4, "OpenGLES2");
        test_iterators(renderer4, "OpenGLES2");
    } else {
        cerr << "ERROR: No OpenGLES2 renderer to test!" << endl;
    }
    tgles2.stop();
    cerr << "OpenGLES2 tests took " << tgles2.elapsed() << endl;
#endif

#ifdef RENDERER_CAIRO 
    Timer tcairo("Cairo");
    Renderer *renderer5 = renderer::cairo::create_handler();
    if (renderer5) {
        test_renderer(renderer5, "Cairo");
        test_geometry(renderer5, "Cairo");
        test_iterators(renderer5, "Cairo");
    } else {
        cerr << "ERROR: No Cairo renderer to test!" << endl;
    }
    tcairo.stop();
    cerr << "Cairo tests took " << tcairo.elapsed() << endl;
#endif
    
#ifdef RENDERER_OPENGL
    Timer tgl("OpenGL");
    Renderer *renderer6 = renderer::opengl::create_handler(true);
    if (renderer6) {
        test_renderer(renderer6, "OpenGL");
        test_geometry(renderer6, "OpenGL");
        test_iterators(renderer6, "OpenGL");
    } else {
        cerr << "ERROR: No OpenGL renderer to test!" << endl;
    }
    tgl.stop();
    cerr << "OpenGL tests took " << tgl.elapsed() << endl;
#endif
#endif    
}
예제 #2
0
파일: test_egl.cpp 프로젝트: jlopez/gnash
void
test_egl(EGLDevice &egl, GnashDevice::rtype_t rtype, int argc, char *argv[])
{
    bool hwinit = false;

    if (EGLDevice::getRenderableTypes()) {
        runtest.pass("EGLDevice::getRenderableTypes()");
    } else {
        runtest.fail("EGLDevice::getRenderableTypes()");
    }
    
    // This is a utility method for converting integer error codes to
    // something human readable for debugging.
    string result = "EGL_BAD_CONFIG";
    if (egl.getErrorString(EGL_BAD_CONFIG) == result) {
        runtest.pass("EGLDevice::getErrorString()");
    } else {
        runtest.fail("EGLDevice::getErrorString()");
    }

    if (egl.initDevice(argc, argv)) {
        runtest.pass("EGLDevice::initDevice()");
        hwinit = true;
    } else {
        runtest.fail("EGLDevice::initDevice()");
    }

    if (hwinit) {
        if (egl.bindClient(rtype)) {
            runtest.pass("EGLDevice::bindClient()");
        } else {
            runtest.fail("EGLDevice::bindClient()");
        }
    } else {
        runtest.untested("EGLDevice::bindClient()");
    }

//    egl.printEGLConfig();
    
    // If there are more than zero configurations, something beyond
    // initializing is working
    if (hwinit) {
        if (egl.queryEGLConfig()) {
            runtest.pass("EGLDevice::queryEGLConfig()");
        } else {
            runtest.fail("EGLDevice::queryEGLConfig()");
        }
    } else {
        runtest.untested("EGLDevice::queryEGLConfig()");
    }

    // Init'ing to zero uses the root screen as the display. Otherwise
    // the argument should be an EGLNativeWindowType.
    int win = 0;
#ifdef ENABLE_FAKE_FRAMEBUFFER
    win = open("/tmp/fbe_buffer", O_RDWR);
#else
# ifdef BUILD_RAWFB_DEVICE
    win = open("/dev/fb0", O_RDWR);
# endif
# ifdef BUILD_X11_DEVICE
    x11::X11Device x11(egl.getNativeVisual());
    win = x11.getHandle();
# endif
#endif
    if (egl.attachWindow(win)) {
        runtest.pass("EGLDevice::attachWindow()");
    } else {
        runtest.fail("EGLDevice::attachWindow()");
        hwinit = false;
    }
    
    if (hwinit) {
        if (egl.supportsRenderer(rtype)) {
            runtest.pass("EGLDevice::supportsRenderer()");
        } else {
            runtest.fail("EGLDevice::supportsRenderer()");
        }
    } else {
        runtest.untested("EGLDevice::supportsRenderer()");
    }

    // pixel formats are either 8,8,8 or 5,6,5
    if (hwinit) {    
        if ((egl.getRedSize() == 8) || (egl.getRedSize() == 5)) {
            runtest.pass("EGLDevice::getRedSize()");
        } else {
            runtest.fail("EGLDevice::getRedSize()");
        }    
    } else {
        runtest.untested("EGLDevice::getRedSize()");
    }
    
    if (hwinit) {
        if ((egl.getGreenSize() == 8) || (egl.getGreenSize() == 6)) {
            runtest.pass("EGLDevice::getGreenSize()");
        } else {
            runtest.fail("EGLDevice::getGreenSize()");
        }    
    } else {
        runtest.untested("EGLDevice::getGreenSize()");
    }
    
    if (hwinit) {
        if ((egl.getBlueSize() == 8) || (egl.getBlueSize() == 5)) {
            runtest.pass("EGLDevice::getBlueSize()");
        } else {
            runtest.fail("EGLDevice::getBlueSize()");
        }
    } else {
        runtest.untested("EGLDevice::getBlueSize()");
    }

    // Surface config info tests
    if (hwinit) {
        if ((egl.getSurfaceID() > 0) && (egl.getSurfaceID() <= 10)) {
            runtest.pass("EGLDevice::getSurfaceID()");
        } else {
            runtest.fail("EGLDevice::getSurfaceID()");
        }
    } else {
        runtest.untested("EGLDevice::getSurfaceID()");
    }
    
    if (hwinit) {
        if (egl.getWidth() < 16000) {
            runtest.pass("EGLDevice::getWidth()");
        } else {
            runtest.fail("EGLDevice::getWidth()");
        }
    } else {
        runtest.untested("EGLDevice::getWidth()");
    }
    
    if (hwinit) {
        if (egl.getHeight() < 16000) {
            runtest.pass("EGLDevice::getHeigth()");
        } else {
            runtest.fail("EGLDevice::getHeigth()");
        }
    } else {
        runtest.untested("EGLDevice::getHeigth()");
    }

    if (hwinit) {
        if (egl.isSingleBuffered() != egl.isBackBuffered()) {
            runtest.pass("EGLDevice::is*Buffered()");
        } else {
            runtest.fail("EGLDevice::is*Buffered()");
        }
    } else {
        runtest.untested("EGLDevice::is*Buffered()");
    }

    // these are often the same as width and height, but not on all
    // displays. When EGL is back buffered, the size of the display
    // horizontally is doubled.
    if (hwinit) {
        if (egl.getVerticalRes() == 480) {
            runtest.pass("EGLDevice::getVerticalRes()");
        } else {
            runtest.fail("EGLDevice::getVerticalRes()");
        }
    } else {
        runtest.untested("EGLDevice::getVerticalRes()");
    }

    
    if (hwinit) {
        int newval = 800;
        if (egl.isBackBuffered()) {
            newval += newval;
        }
        if (egl.getHorzRes() == 1600) {
            runtest.pass("EGLDevice::getHorzRes()");
        } else {
            runtest.fail("EGLDevice::getHorzRes()");
        }
    } else {
        runtest.untested("EGLDevice::getHorzRes()");
    }
    
    // When running in a framebuffer, EGL_SWAP_BEHAVIOR is EGL_BUFFER_PRESERVED
    if (hwinit) {
        if (egl.isBufferDestroyed()) {
            runtest.fail("EGLDevice::isBufferDestroyed()");
        } else {
            runtest.pass("EGLDevice::isBufferDestroyed()");
        }
    } else {
        runtest.untested("EGLDevice::isBufferDestroyed()");
    }
    
    if (hwinit) {
        if (!egl.isMultiSample()) {
            runtest.pass("EGLDevice::isMultiSample()");
        } else {
            runtest.fail("EGLDevice::isMultiSample()");
        }
    } else {
        runtest.untested("EGLDevice::isMultiSample()");
    }

    // Context accessor tests
    if (hwinit) {
        if (egl.getContextID() < 10) {
            runtest.pass("EGLDevice::getContextID()");
        } else {
            runtest.fail("EGLDevice::getContextID()");
        }
    } else {
        runtest.untested("EGLDevice::getContextID()");
    }

#if 0
    if (egl.supportsClient(rtype)) {
        runtest.pass("EGLDevice::supportsClient()");
    } else {
        runtest.fail("EGLDevice::supportsClient()");
    }
#endif
    
    if (hwinit) {
        if (egl.isContextSingleBuffered() != egl.isContextBackBuffered()) {
            runtest.pass("EGLDevice::isContext*Buffered()");
        } else {
            runtest.fail("EGLDevice::isContext*Buffered()");
        }
    } else {
        runtest.untested("EGLDevice::isContext*Buffered()");
    }

    // When running in a framebuffer, EGL_NATIVE_RENDERABLE is false
    if (hwinit) {
        if (egl.isNativeRender()) {
            runtest.fail("EGLDevice::isNativeRender()");
        } else {
            runtest.pass("EGLDevice::isNativeRender()");
        }
    } else {
        runtest.untested("EGLDevice::isNativeRender()");
    }

    if (hwinit) {
        if (egl.getSamples() == 0) {
            runtest.pass("EGLDevice::getSamples()");
        } else {
            runtest.fail("EGLDevice::getSamples()");
        }
    } else {
        runtest.untested("EGLDevice::getSamples()");
    }
    
    if (hwinit) {
        if (egl.getSampleBuffers() == 0) {
            runtest.pass("EGLDevice::getSampleBuffers()");
        } else {
            runtest.fail("EGLDevice::getSampleBuffers()");
        }
    } else {
        runtest.untested("EGLDevice::getSampleBuffers()");
    }
    
    if (hwinit) {
        if ((egl.getDepth() == 32) || (egl.getDepth() == 16)) {
            runtest.pass("EGLDevice::getDepth()");
        } else {
            runtest.fail("EGLDevice::getDepth()");
        }
    } else {
        runtest.untested("EGLDevice::getDepth()");
    }
    
    if (hwinit) {
        if (egl.getMaxSwapInterval() == 1) {
            runtest.pass("EGLDevice::getMaxSwapInterval()");
        } else {
            runtest.fail("EGLDevice::getMaxSwapInterval()");
        }
    } else {
        runtest.untested("EGLDevice::getMaxSwapInterval()");
    }
    
    if (hwinit) {
        if (egl.getMinSwapInterval() == 1) {
            runtest.pass("EGLDevice::getMinSwapInterval()");
        } else {
            runtest.fail("EGLDevice::getMinSwapInterval()");
        }
    } else {
        runtest.untested("EGLDevice::getMinSwapInterval()");
    }

    // Test Pbuffers
    if (hwinit) {
        EGLSurface surf = egl.createPbuffer(200, 200);
        if ((egl.getWidth(surf) == 200) && (egl.getHeight(surf) == 200)) {
            runtest.pass("EGLDevice::createPbuffer(int, int)");
        } else {
            runtest.fail("EGLDevice::createPbuffer(int, int)");
        }
    } else {
        runtest.untested("EGLDevice::createPbuffer(int, int)");
    }
    
    // EGLSurface surf1 = egl[0];
    // if ((surf1 != EGL_NO_SURFACE) && (egl.getWidth(surf1) == 200)
    //     && (egl.getHeight(surf1) == 200)) {
    //     runtest.pass("EGLDevice::operator[]()");
    // } else {
    //     runtest.fail("EGLDevice::operator[]()");
    // }

    if (hwinit) {
        if (egl.totalPbuffers() == 3) {
            runtest.pass("EGLDevice::totalPbuffers(2)");
        } else {
            runtest.fail("EGLDevice::totalPbuffers(2)");
        }
    }

    // Since we're EGL_SINGLE_BUFFER'd, this is a nop
    if (hwinit) {
        if (egl.swapBuffers()) {
            runtest.pass("EGLDevice::swapBuffers()");
        } else {
            runtest.fail("EGLDevice::swapBuffers()");
        }
    } else {
        runtest.untested("EGLDevice::swapBuffers()");
    }

    egl.makePbufferCurrent(1);
    // The current surface is fullscreen
    EGLSurface surf4 = eglGetCurrentSurface(EGL_DRAW);
    if (hwinit) {
        if ((egl.getWidth(surf4) == 800) && ((egl.getHeight(surf4) == 480))) {
            runtest.pass("EGLDevice::makePbufferCurrent(int)");
        } else {
            runtest.fail("EGLDevice::makePbufferCurrent(int)");
        }
    } else {
        runtest.untested("EGLDevice::makePbufferCurrent(int)");
    }

    // This should trigger an error as the number is more than we
    // have created
    if (hwinit) {
        if (!egl.makePbufferCurrent(10)) {
            runtest.pass("EGLDevice::makePbufferCurrent(maxed)");
        } else {
            runtest.fail("EGLDevice::makePbufferCurrent(maxed)");
        }
    } else {
        runtest.untested("EGLDevice::makePbufferCurrent(maxed)");
    }
    
#if 0
    if (!egl.copyPbuffers(1)) {
        runtest.pass("EGLDevice::copyPbuffers()");
    } else {
        runtest.fail("EGLDevice::copyPbuffers()");
    }
#endif
    
    // EGLSurface surf5 = eglGetCurrentSurface(EGL_DRAW);
    // egl.printEGLSurface(surf5);
#ifndef BUILD_X11_DEVICE
    close(win);
#endif
}