void WindowGrabber::updateFrameSize()
{
    int size[2] = { m_screenBufferWidth, m_screenBufferHeight };

    screen_set_pixmap_property_iv(m_screenPixmaps[0], SCREEN_PROPERTY_BUFFER_SIZE, size);
    if (eglImageSupported())
        screen_set_pixmap_property_iv(m_screenPixmaps[1], SCREEN_PROPERTY_BUFFER_SIZE, size);

    int result = screen_create_pixmap_buffer(m_screenPixmaps[0]);
    if (eglImageSupported())
        result |= screen_create_pixmap_buffer(m_screenPixmaps[1]);

    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot create pixmap buffer:" << strerror(errno);
        return;
    } else {
        m_screenPixmapBuffersInitialized = true;
    }

    result = screen_get_pixmap_property_pv(m_screenPixmaps[0], SCREEN_PROPERTY_RENDER_BUFFERS,
            (void**)&m_screenPixmapBuffers[0]);
    if (eglImageSupported()) {
        result |= screen_get_pixmap_property_pv(m_screenPixmaps[1], SCREEN_PROPERTY_RENDER_BUFFERS,
                (void**)&m_screenPixmapBuffers[1]);
    }

    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get pixmap buffer:" << strerror(errno);
        return;
    }

    result = screen_get_buffer_property_pv(m_screenPixmapBuffers[0], SCREEN_PROPERTY_POINTER,
            (void**)&m_screenBuffers[0]);
    if (eglImageSupported()) {
        result |= screen_get_buffer_property_pv(m_screenPixmapBuffers[1], SCREEN_PROPERTY_POINTER,
                (void**)&m_screenBuffers[1]);
    }

    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get pixmap buffer pointer:" << strerror(errno);
        return;
    }

    result = screen_get_buffer_property_iv(m_screenPixmapBuffers[0], SCREEN_PROPERTY_STRIDE,
            &m_screenBufferStride);

    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get pixmap buffer stride:" << strerror(errno);
        return;
    }
}
Beispiel #2
0
void Control::fill()
{
	static unsigned controlNum = 0;
	static uint32_t controlColors[] = { 0xaaff0000, 0xaa00ff00, 0xaa0000ff, 0xaaffff00, 0xaaff00ff, 0xaa00ffff };

	int format = SCREEN_FORMAT_RGBA8888;
	int size[2] = {m_width, m_height};
	unsigned char *pixels;
	int stride;

	int rc = screen_create_pixmap(&m_pixmap, m_context); // FIXME: Check failure
	rc = screen_set_pixmap_property_iv(m_pixmap, SCREEN_PROPERTY_FORMAT, &format);
	rc = screen_set_pixmap_property_iv(m_pixmap, SCREEN_PROPERTY_BUFFER_SIZE, size);
	rc = screen_create_pixmap_buffer(m_pixmap);
	rc = screen_get_pixmap_property_pv(m_pixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&m_buffer);
//	rc = screen_get_buffer_property_pv(m_buffer, SCREEN_PROPERTY_POINTER, (void **)&pixels);
//	rc = screen_get_buffer_property_iv(m_buffer, SCREEN_PROPERTY_STRIDE, &stride);
	int attribs[] = {
		SCREEN_BLIT_COLOR, (int)controlColors[controlNum],
		SCREEN_BLIT_END
	};
	rc = screen_fill(m_context, m_buffer, attribs);
	controlNum++;
	if (controlNum > 5)
		controlNum = 0;
}
static void bb10display_createPixmap(BB10Display *d) {
    screen_pixmap_t pixmap;
    screen_buffer_t buffer;

    if (d->pixmap_created) {
        ms_warning("[bb10_display] pixmap is already created, skipping...");
        return;
    }

    screen_create_pixmap(&pixmap, d->context);

    int usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE;
    screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_USAGE, &usage);

    int format = SCREEN_FORMAT_YUV420;
    screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_FORMAT, &format);

    int dims[2] = { d->vsize.width, d->vsize.height };
    screen_set_pixmap_property_iv(pixmap, SCREEN_PROPERTY_BUFFER_SIZE, dims);

    screen_create_pixmap_buffer(pixmap);

    screen_get_pixmap_property_pv(pixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &buffer);
    int stride;
    screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);

    d->pixmap = pixmap;
    d->pixmap_buffer = buffer;
    d->stride = stride;
    ms_debug("[bb10_display] bb10display_initPixmap pixmap created with buffer size %i,%i and stride %i", dims[0], dims[1], stride);
    d->pixmap_created = TRUE;
}
Beispiel #4
0
int PLAYBOOK_AllocHWSurface(SDL_VideoDevice *device, SDL_Surface *surface)
{
    if (surface->hwdata != NULL) {
        fprintf(stderr, "Surface already has hwdata\n");
        return -1;
    }

    surface->hwdata = SDL_malloc(sizeof(struct private_hwdata));
    if (surface->hwdata == NULL) {
        SDL_OutOfMemory();
        return -1;
    }

    int rc = screen_create_pixmap(&surface->hwdata->pixmap, device->hidden->screenContext);
    if (rc) {
        fprintf(stderr, "Failed to create HW surface: screen_create_pixmap returned %s\n", strerror(errno));
        goto fail1;
    }

    int size[2] = {surface->w, surface->h};
    rc = screen_set_pixmap_property_iv(surface->hwdata->pixmap, SCREEN_PROPERTY_BUFFER_SIZE, size);
    if (rc) {
        fprintf(stderr, "Failed to set SCREEN_PROPERTY_BUFFER_SIZE: screen_set_pixmap_property_iv returned %s\n", strerror(errno));
        goto fail1;
    }

    int format = SCREEN_FORMAT_RGBA8888;
    rc = screen_set_pixmap_property_iv(surface->hwdata->pixmap, SCREEN_PROPERTY_FORMAT, &format);
    if (rc) {
        fprintf(stderr, "Failed to set SCREEN_PROPERTY_FORMAT: screen_set_pixmap_property_iv returned %s\n", strerror(errno));
        goto fail1;
    }

    rc = screen_create_pixmap_buffer(surface->hwdata->pixmap);
    if (rc) {
        fprintf(stderr, "Failed to allocate HW surface: screen_create_pixmap_buffer returned %s\n", strerror(errno));
        goto fail2;
    }

    surface->flags |= SDL_HWSURFACE;
    surface->flags |= SDL_PREALLOC;

    return 0;

fail2:
    screen_destroy_pixmap(surface->hwdata->pixmap);
fail1:
    SDL_free(surface->hwdata);
    surface->hwdata = 0;

    return -1;
}
gceSTATUS
gcoOS_CreatePixmap(
    IN HALNativeDisplayType Display,
    IN gctINT Width,
    IN gctINT Height,
    IN gctINT BitsPerPixel,
    OUT HALNativePixmapType * Pixmap
    )
{
    gctINT size[2];
    gctINT screen_format = SCREEN_FORMAT_RGBA8888;
    gctINT screen_usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENVG;
    gctINT rc;
    gceSTATUS status = gcvSTATUS_OK;
    gcmHEADER_ARG("Display=0x%x Width=%d Height=%d BitsPerPixel=%d", Display, Width, Height, BitsPerPixel);

    if ((Width <= 0) || (Height <= 0) || (BitsPerPixel <= 0))
    {
        status = gcvSTATUS_INVALID_ARGUMENT;
        gcmFOOTER();
        return status;
    }
    /* Create pixmap structure. */
    rc = screen_create_pixmap((struct _screen_pixmap **)Pixmap, screen_ctx);
    if (rc)
    {
        fprintf(stderr, "screen_create_pixmap failed with error %d (0x%08x)\n", errno, errno);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    switch (BitsPerPixel)
    {
    case 8:
        screen_format = SCREEN_FORMAT_BYTE;
        break;

    case 16:
        screen_format = SCREEN_FORMAT_RGB565;
        break;

    case 24:
        screen_format = SCREEN_FORMAT_RGB888;
        break;

    case 32:
        screen_format = SCREEN_FORMAT_RGBA8888;
        break;

    default:
        break;
    }

    /* Set pximap format. */
    rc = screen_set_pixmap_property_iv(*Pixmap, SCREEN_PROPERTY_FORMAT, &screen_format);
    if (rc)
    {
        fprintf(stderr, "screen_set_pixmap_property_iv(SCREEN_PROPERTY_FORMAT) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_pixmap(*Pixmap);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Set pixmap usage. */
    rc = screen_set_pixmap_property_iv(*Pixmap, SCREEN_PROPERTY_USAGE, &screen_usage);
    if (rc)
    {
        fprintf(stderr, "screen_set_pixmap_property_iv(SCREEN_PROPERTY_USAGE) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_pixmap(*Pixmap);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Resize the pixmap. */
    size[0] = Width;
    size[1] = Height;

    rc = screen_set_pixmap_property_iv(*Pixmap, SCREEN_PROPERTY_BUFFER_SIZE, size);
    if (rc)
    {
        fprintf(stderr, "screen_set_pixmap_property_iv(SCREEN_PROPERTY_BUFFER_SIZE) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_pixmap(*Pixmap);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Create pixmap buffer. */
    rc = screen_create_pixmap_buffer(*Pixmap);
    if (rc)
    {
        fprintf(stderr, "screen_create_pixmap_buffer failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_pixmap(*Pixmap);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    gcmFOOTER_ARG("*Pixmap=0x%x", *Pixmap);
    return status;
}
Beispiel #6
0
void WindowGrabber::start()
{
    int result = 0;

#ifdef Q_OS_BLACKBERRY_TABLET

    // HACK: On the Playbook, screen_read_window() will fail for invisible windows.
    //       To workaround this, make the window visible again, but set a global
    //       alpha of less than 255. The global alpha makes the window completely invisible
    //       (due to a bug?), but screen_read_window() will work again.

    errno = 0;
    int val = 200; // anything less than 255
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_GLOBAL_ALPHA, &val);
    if (result != 0) {
        qWarning() << "WindowGrabber: unable to set global alpha:" << strerror(errno);
        return;
    }

    errno = 0;
    val = 1;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &val);
    if (result != 0) {
        qWarning() << "WindowGrabber: unable to make window visible:" << strerror(errno);
        return;
    }
#endif

    result = screen_create_context(&m_screenContext, SCREEN_APPLICATION_CONTEXT);
    if (result != 0) {
        qWarning() << "WindowGrabber: cannot create screen context:" << strerror(errno);
        return;
    } else {
        m_screenContextInitialized = true;
    }

    result = screen_create_pixmap(&m_screenPixmap, m_screenContext);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot create pixmap:" << strerror(errno);
        return;
    } else {
        m_screenPixmapInitialized = true;
    }

    const int usage = SCREEN_USAGE_READ | SCREEN_USAGE_NATIVE;
    result = screen_set_pixmap_property_iv(m_screenPixmap, SCREEN_PROPERTY_USAGE, &usage);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot set pixmap usage:" << strerror(errno);
        return;
    }

    const int format = SCREEN_FORMAT_RGBA8888;
    result = screen_set_pixmap_property_iv(m_screenPixmap, SCREEN_PROPERTY_FORMAT, &format);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot set pixmap format:" << strerror(errno);
        return;
    }

    int size[2] = { 0, 0 };
    result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, size);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get window size:" << strerror(errno);
        return;
    }

    m_screenBufferWidth = size[0];
    m_screenBufferHeight = size[1];

    result = screen_set_pixmap_property_iv(m_screenPixmap, SCREEN_PROPERTY_BUFFER_SIZE, size);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot set pixmap size:" << strerror(errno);
        return;
    }

    result = screen_create_pixmap_buffer(m_screenPixmap);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot create pixmap buffer:" << strerror(errno);
        return;
    }

    result = screen_get_pixmap_property_pv(m_screenPixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&m_screenPixmapBuffer);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get pixmap buffer:" << strerror(errno);
        return;
    } else {
        m_screenPixmapBufferInitialized = true;
    }

    result = screen_get_buffer_property_pv(m_screenPixmapBuffer, SCREEN_PROPERTY_POINTER, (void**)&m_screenBuffer);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get pixmap buffer pointer:" << strerror(errno);
        return;
    }

    result = screen_get_buffer_property_iv(m_screenPixmapBuffer, SCREEN_PROPERTY_STRIDE, &m_screenBufferStride);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get pixmap buffer stride:" << strerror(errno);
        return;
    }

    m_timer.start();

    m_active = true;
}
Beispiel #7
0
ffdec_error ffdec_create_view(ffdec_context *ffd_context, QString group, QString id, screen_window_t *window)
{
    ffdec_reserved *ffd_reserved = (ffdec_reserved*) ffd_context->reserved;
    if (!ffd_reserved) return FFDEC_NOT_INITIALIZED;

    if (ffd_reserved->view)
    {
        *window = ffd_reserved->view->screen_window;
        return FFDEC_OK;
    }

    AVCodecContext *codec_context = ffd_context->codec_context;
    if (!codec_context) return FFDEC_NO_CODEC_SPECIFIED;
    if (!avcodec_is_open(codec_context)) return FFDEC_CODEC_NOT_OPEN;

    ffdec_view *view = (ffdec_view*) malloc(sizeof(ffdec_view));
    memset(view, 0, sizeof(ffdec_view));

    QByteArray groupArr = group.toAscii();
    QByteArray idArr = id.toAscii();

    screen_context_t screen_context;
    screen_create_context(&screen_context, SCREEN_APPLICATION_CONTEXT);

    screen_window_t screen_window;
    screen_create_window_type(&screen_window, screen_context, SCREEN_CHILD_WINDOW);
    screen_join_window_group(screen_window, groupArr.constData());
    screen_set_window_property_cv(screen_window, SCREEN_PROPERTY_ID_STRING, idArr.length(), idArr.constData());

    int usage = SCREEN_USAGE_NATIVE;
    screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_USAGE, &usage);

    int video_size[] = { codec_context->width, codec_context->height };
    screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_BUFFER_SIZE, video_size);
    screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_SOURCE_SIZE, video_size);

    int z = -1;
    screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_ZORDER, &z);

    int pos[] = { 0, 0 };
    screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_POSITION, pos);

    screen_create_window_buffers(screen_window, 1);

    screen_pixmap_t screen_pix;
    screen_create_pixmap(&screen_pix, screen_context);

    usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE;
    screen_set_pixmap_property_iv(screen_pix, SCREEN_PROPERTY_USAGE, &usage);

    int format = SCREEN_FORMAT_YUV420;
    screen_set_pixmap_property_iv(screen_pix, SCREEN_PROPERTY_FORMAT, &format);

    screen_set_pixmap_property_iv(screen_pix, SCREEN_PROPERTY_BUFFER_SIZE, video_size);

    screen_create_pixmap_buffer(screen_pix);

    screen_buffer_t screen_pixel_buffer;
    screen_get_pixmap_property_pv(screen_pix, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &screen_pixel_buffer);

    int stride;
    screen_get_buffer_property_iv(screen_pixel_buffer, SCREEN_PROPERTY_STRIDE, &stride);

    view->screen_context = screen_context;
    *window = view->screen_window = screen_window;
    view->screen_pixel_buffer = screen_pixel_buffer;
    view->stride = stride;
    ffd_reserved->view = view;

    return FFDEC_OK;
}