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;
    }
}
Пример #2
0
QQnxBuffer::QQnxBuffer(screen_buffer_t buffer)
    : m_buffer(buffer)
{
    qBufferDebug() << Q_FUNC_INFO << "normal";

    // Get size of buffer
    int size[2];
    Q_SCREEN_CRITICALERROR(screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_BUFFER_SIZE, size),
                        "Failed to query buffer size");

    // Get stride of buffer
    int stride;
    Q_SCREEN_CHECKERROR(screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride),
                        "Failed to query buffer stride");

    // Get access to buffer's data
    errno = 0;
    uchar *dataPtr = 0;
    Q_SCREEN_CRITICALERROR(
            screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr),
            "Failed to query buffer pointer");

    if (dataPtr == 0)
        qFatal("QQNX: buffer pointer is NULL, errno=%d", errno);

    // Get format of buffer
    int screenFormat;
    Q_SCREEN_CHECKERROR(
            screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_FORMAT, &screenFormat),
            "Failed to query buffer format");

    // Convert screen format to QImage format
    QImage::Format imageFormat = QImage::Format_Invalid;
    switch (screenFormat) {
    case SCREEN_FORMAT_RGBX4444:
        imageFormat = QImage::Format_RGB444;
        break;
    case SCREEN_FORMAT_RGBA4444:
        imageFormat = QImage::Format_ARGB4444_Premultiplied;
        break;
    case SCREEN_FORMAT_RGBX5551:
        imageFormat = QImage::Format_RGB555;
        break;
    case SCREEN_FORMAT_RGB565:
        imageFormat = QImage::Format_RGB16;
        break;
    case SCREEN_FORMAT_RGBX8888:
        imageFormat = QImage::Format_RGB32;
        break;
    case SCREEN_FORMAT_RGBA8888:
        imageFormat = QImage::Format_ARGB32_Premultiplied;
        break;
    default:
        qFatal("QQNX: unsupported buffer format, format=%d", screenFormat);
    }

    // wrap buffer in an image
    m_image = QImage(dataPtr, size[0], size[1], stride, imageFormat);
}
Пример #3
0
void display_frame(ffdec_context *ffd_context, AVFrame *frame)
{
    ffdec_reserved *ffd_reserved = (ffdec_reserved*) ffd_context->reserved;
    ffdec_view *view = ffd_reserved->view;
    if (!view) return;

    screen_window_t screen_window = view->screen_window;
    screen_buffer_t screen_pixel_buffer = view->screen_pixel_buffer;
    screen_context_t screen_context = view->screen_context;
    int stride = view->stride;

    unsigned char *ptr = NULL;
    screen_get_buffer_property_pv(screen_pixel_buffer, SCREEN_PROPERTY_POINTER, (void**) &ptr);

    int width = frame->width;
    int height = frame->height;

    uint8_t *srcy = frame->data[0];
    uint8_t *srcu = frame->data[1];
    uint8_t *srcv = frame->data[2];

    unsigned char *y = ptr;
    unsigned char *u = y + (height * stride);
    unsigned char *v = u + (height * stride) / 4;

    for (int i = 0; i < height; i++)
    {
        int doff = i * stride;
        int soff = i * frame->linesize[0];
        memcpy(&y[doff], &srcy[soff], frame->width);
    }

    for (int i = 0; i < height / 2; i++)
    {
        int doff = i * stride / 2;
        int soff = i * frame->linesize[1];
        memcpy(&u[doff], &srcu[soff], frame->width / 2);
    }

    for (int i = 0; i < height / 2; i++)
    {
        int doff = i * stride / 2;
        int soff = i * frame->linesize[2];
        memcpy(&v[doff], &srcv[soff], frame->width / 2);
    }

    screen_buffer_t screen_buffer;
    screen_get_window_property_pv(screen_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &screen_buffer);

    int attribs[] = { SCREEN_BLIT_SOURCE_WIDTH, width, SCREEN_BLIT_SOURCE_HEIGHT, height, SCREEN_BLIT_END };
    screen_blit(screen_context, screen_buffer, screen_pixel_buffer, attribs);

    int dirty_rects[] = { 0, 0, width, height };
    screen_post_window(screen_window, screen_buffer, 1, dirty_rects, 0);
}
screen_window_t create_hg_window(const char *group, const char *id, int dims[2])
{
	int i, j;

	screen_window_t screen_win;
	screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW);
	screen_join_window_group(screen_win, group);
	screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, strlen(id), id);

	int flag = 1;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_STATIC, &flag);

	int vis = 1;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &vis);

	int zorder = 2;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &zorder);

	int format = SCREEN_FORMAT_RGBA8888;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);

	int usage = SCREEN_USAGE_WRITE;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);

	int transparency = SCREEN_TRANSPARENCY_SOURCE_OVER;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_TRANSPARENCY, &transparency);

	int rect[4] = { 0, 0, 100, 100 };
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, &rect[2]);

	screen_buffer_t screen_buf;
	screen_create_window_buffers(screen_win, 1);
	screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);

	char *ptr = NULL;
	screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER, (void **)&ptr);

	int stride = 0;
	screen_get_buffer_property_iv(screen_buf, SCREEN_PROPERTY_STRIDE, &stride);

	for (i = 0; i < rect[3]; i++, ptr += stride) {
		for (j = 0; j < rect[2]; j++) {
			ptr[j*4] = 0xa0;
			ptr[j*4+1] = 0xa0;
			ptr[j*4+2] = 0xa0;
			ptr[j*4+3] = ((j >= i && j <= rect[3]-i) || (j <= i && j >= rect[3]-i)) ? 0xff : 0;
		}
	}

	screen_post_window(screen_win, screen_buf, 1, rect, 0);

	return screen_win;
}
Пример #5
0
void *qnxscreen_search_index(struct qnxscreen_api *q, uint32_t index)
{
    void *tmpbuf_dat;
    int ret;

    if (index > q->count || index > QNXSCREEN_MAX_INDEX)
        return NULL;

    ret = screen_get_buffer_property_pv(q->buf[index], SCREEN_PROPERTY_POINTER,
                        (void **)&tmpbuf_dat);
    if (ret)
        return NULL;

    return tmpbuf_dat;
}
Пример #6
0
static void bb10display_fillWindowBuffer(BB10Display *d, MSPicture *yuvbuf) {
    uint8_t *ptr = NULL;
    screen_get_buffer_property_pv(d->pixmap_buffer, SCREEN_PROPERTY_POINTER, (void **)&ptr);

    if (ptr) {
        uint8_t *dest_planes[3];
        int dest_strides[3];
        MSVideoSize roi = {0};

        uint8_t *y = ptr;
        uint8_t *u = y + (d->vsize.height * d->stride);
        uint8_t *v = u + (d->vsize.height * d->stride) / 4;

        dest_planes[0] = y;
        dest_planes[1] = u;
        dest_planes[2] = v;
        dest_strides[0] = d->stride;
        dest_strides[1] = d->stride / 2;
        dest_strides[2] = d->stride / 2;

        roi.width = yuvbuf->w;
        roi.height = yuvbuf->h;

        ms_yuv_buf_copy(yuvbuf->planes, yuvbuf->strides, dest_planes, dest_strides, roi);

        screen_buffer_t buffer;
        screen_get_window_property_pv(d->window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**) &buffer);

        MSRect rect;
        ms_layout_center_rectangle(d->wsize, d->vsize, &rect);
        int attributes[] = {
            SCREEN_BLIT_SOURCE_WIDTH, d->vsize.width, SCREEN_BLIT_SOURCE_HEIGHT, d->vsize.height,
            SCREEN_BLIT_DESTINATION_X, rect.x, SCREEN_BLIT_DESTINATION_Y, rect.y,
            SCREEN_BLIT_DESTINATION_WIDTH, rect.w, SCREEN_BLIT_DESTINATION_HEIGHT, rect.h,
            SCREEN_BLIT_END
        };
        screen_blit(d->context, buffer, d->pixmap_buffer, attributes);

        int dirty_rect[4] = { 0, 0, d->wsize.width, d->wsize.height };
        screen_post_window(d->window, buffer, 1, dirty_rect, 0);
    }
}
Пример #7
0
int PLAYBOOK_FlipHWSurface(SDL_VideoDevice *device, SDL_Surface *surface)
{
    // FIXME: device doesn't work properly yet. It flashes black, I think the new render buffers are wrong.
    static int fullRect[] = {0, 0, 1024, 600};
    //screen_flush_blits(device->hidden->screenContext, 0);
    int result = screen_post_window(device->hidden->screenWindow, surface->hwdata->front, 1, fullRect, 0);

    screen_buffer_t windowBuffer[2];
    int rc = screen_get_window_property_pv(device->hidden->screenWindow, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&windowBuffer);
    if (rc) {
        SDL_SetError("Cannot get window render buffers: %s", strerror(errno));
        return NULL;
    }

    rc = screen_get_buffer_property_pv(windowBuffer[0], SCREEN_PROPERTY_POINTER, &device->hidden->pixels);
    if (rc) {
        SDL_SetError("Cannot get buffer pointer: %s", strerror(errno));
        return NULL;
    }
    surface->hwdata->front = windowBuffer[0];
    surface->pixels = device->hidden->pixels;
    return 0;
}
Пример #8
0
uint32_t qnxscreen_search_buffer(struct qnxscreen_api *q, void *buffer)
{
    uint32_t index = QNXSCREEN_INVALID_INDEX;

    for (index = 0; index < q->count; index++) {
        void *tmpbuf_dat;
        int ret;

        ret = screen_get_buffer_property_pv(q->buf[index],
                            SCREEN_PROPERTY_POINTER,
                            (void **)&tmpbuf_dat);
        if (ret)
            return QNXSCREEN_INVALID_INDEX;

        if (tmpbuf_dat == buffer)
            return index;
    }

    if (index >= q->count)
        index = QNXSCREEN_INVALID_INDEX;

    return index;
}
Пример #9
0
gceSTATUS
gcoOS_GetPixmapInfo(
    IN HALNativeDisplayType Display,
    IN HALNativePixmapType Pixmap,
    OUT gctINT * Width,
    OUT gctINT * Height,
    OUT gctINT * BitsPerPixel,
    OUT gctINT * Stride,
    OUT gctPOINTER * Bits
    )
{
    gctINT rc, size[2], format;
    screen_buffer_t buf[2];
    gceSTATUS status = gcvSTATUS_OK;

    gcmHEADER_ARG("Display=0x%x Pixmap=0x%x", Display, Pixmap);

    if (Pixmap == gcvNULL)
    {
        /* Pixmap is not a valid pixmap data structure pointer. */
        goto OnError;
    }

    if ((Width != gcvNULL) || (Height != gcvNULL))
    {
        rc = screen_get_pixmap_property_iv(Pixmap, SCREEN_PROPERTY_BUFFER_SIZE, size);
        if (rc)
        {
            goto OnError;
        }

        if (Width != gcvNULL)
        {
            *Width = size[0];
        }

        if (Height != gcvNULL)
        {
            *Height = size[1];
        }
    }

    if (BitsPerPixel != gcvNULL)
    {
        rc = screen_get_pixmap_property_iv(Pixmap, SCREEN_PROPERTY_FORMAT, &format);
        if (rc)
        {
            goto OnError;
        }

        _ConvertWindowFormat(format, BitsPerPixel, gcvNULL);
    }

    rc = screen_get_pixmap_property_pv(Pixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void **) &buf);
    if (rc)
    {
        goto OnError;
    }

    if (Stride != NULL)
    {
        rc = screen_get_buffer_property_iv(buf[0], SCREEN_PROPERTY_STRIDE, (int *) Stride);
        if (rc)
        {
            goto OnError;
        }
    }


    if (Bits != NULL)
    {
        rc = screen_get_buffer_property_pv(buf[0], SCREEN_PROPERTY_POINTER, (void **) Bits);
        if (rc)
        {
            goto OnError;
        }
    }

    gcmFOOTER_NO();
    return status;

OnError:
    status = gcvSTATUS_INVALID_ARGUMENT;
    gcmFOOTER();
    return status;
}
Пример #10
0
gceSTATUS
gcoOS_GetDisplayInfoEx(
    IN HALNativeDisplayType Display,
    IN HALNativeWindowType Window,
    IN gctUINT DisplayInfoSize,
    OUT halDISPLAY_INFO * DisplayInfo
    )
{
    gceSTATUS status = gcvSTATUS_OK;
    screen_buffer_t buf[gcdDISPLAY_BACK_BUFFERS];
    gctPOINTER pointer;
    off64_t paddr;
    gctINT rc, stride;
    gctINT size[2];

    gcmHEADER_ARG("Display=0x%x Window=0x%x DisplayInfoSize=%u", Display, Window, DisplayInfoSize);

    /* Valid Window? and structure size? */
    if ((Window == gcvNULL) || (DisplayInfoSize != sizeof(halDISPLAY_INFO)))
    {
        goto OnError;
    }

    rc = screen_get_window_property_pv((screen_window_t)Window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)buf);
    if (rc)
    {
        goto OnError;
    }

    /* For QNX, the Width and Height are size of the framebuffer. */
    rc = screen_get_buffer_property_iv(buf[0], SCREEN_PROPERTY_BUFFER_SIZE, size);
    if (rc)
    {
        goto OnError;
    }

    DisplayInfo->width  = size[0];
    DisplayInfo->height = size[1];

    /* The stride of the window. */
    rc = screen_get_buffer_property_iv(buf[0], SCREEN_PROPERTY_STRIDE, &stride);
    if (rc)
    {
        goto OnError;
    }

    DisplayInfo->stride = stride;

    /* The logical address of the window. */
    rc = screen_get_buffer_property_pv(buf[0], SCREEN_PROPERTY_POINTER, &pointer);
    if (rc)
    {
        goto OnError;
    }

    DisplayInfo->logical = pointer;

    /* The physical address of the window. */
    rc = screen_get_buffer_property_llv(buf[0], SCREEN_PROPERTY_PHYSICAL_ADDRESS, &paddr);
    if (rc)
    {
        goto OnError;
    }

    DisplayInfo->physical = paddr;

    /* Flip. */
    DisplayInfo->flip = 1;

    /* Success. */
    gcmFOOTER_ARG("*DisplayInfo=0x%x", *DisplayInfo);
    return status;

OnError:
    status = gcvSTATUS_INVALID_ARGUMENT;
    gcmFOOTER();
    return status;
}
Пример #11
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;
}
Пример #12
0
bool_e qnxscreen_allocate(struct qnxscreen_api *q,
              uint32_t width, uint32_t height,
              uint32_t count, fourcc_t color)
{
    bool_e ret = false_e;
    int size[2] = {(int)width, (int)height};
    int bsize[2] = {(int)width, (int)height};
    int i;
    int pformat = 0;
    int err;
    int zOrder = 50;
    int dispCount = 0;
    int formatCount = 0;
    int sensitivity = SCREEN_SENSITIVITY_NEVER;
    int tranparency = SCREEN_TRANSPARENCY_NONE;
    int idleMode = SCREEN_IDLE_MODE_KEEP_AWAKE;
    screen_display_t *displays;
    screen_display_t display;
    int formats[SCREEN_FORMAT_NFORMATS];
    bool_e configured = false_e;
    const int usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE | SCREEN_USAGE_CAPTURE;

    mutex_lock(&q->m_lock);

    err = screen_create_window_type(&q->win, q->ctx, SCREEN_APPLICATION_WINDOW);
    if (err) {
            DVP_PRINT(DVP_ZONE_ERROR,
              "(%s) Failure on screen_create_window_type: (%d)\n",
              __func__, errno);
        goto leave;
    }

    err = screen_get_context_property_iv(q->ctx, SCREEN_PROPERTY_DISPLAY_COUNT, (void *)&dispCount);
    if (err) {
        DVP_PRINT(DVP_ZONE_ERROR, "Failed to query the number of displays! err=%d\n",err);
        goto leave2;
    }
    DVP_PRINT(DVP_ZONE_VIDEO, "There are %u displays\n", dispCount);

    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_ZORDER, &zOrder);
    if (err) {
            DVP_PRINT(DVP_ZONE_ERROR,
              "(%s) Failure on screen_create_window_type: (%d)\n",
              __func__, errno);
        goto leave2;
    }

    // this tells the window to not receive input events
    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_SENSITIVITY, &sensitivity);
    if (err) {
        DVP_PRINT(DVP_ZONE_ERROR, "Failed to set window sensitivity to zero (%d)\n", err);
        goto leave2;
    }

    // this is not the same as global alpha.
    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_TRANSPARENCY, &tranparency);
    if (err) {
        DVP_PRINT(DVP_ZONE_ERROR, "Failed to set window transparency to none (%d)\n", err);
        goto leave2;
    }

    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_USAGE, &usage);
    if (err) {
            DVP_PRINT(DVP_ZONE_ERROR,
              "(%s) Failure setting USAGE window property: (%d)\n",
              __func__, errno);
        goto leave2;
    }

    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_IDLE_MODE, &idleMode);
    if (err) {
        DVP_PRINT(DVP_ZONE_ERROR, "Failed to set window idle mode to keep awake (%d)\n", err);
        goto leave2;
    }

    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_SIZE, size);
    if (err)
        goto leave2;

    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_SOURCE_SIZE, bsize);
    if (err) {
            DVP_PRINT(DVP_ZONE_ERROR,
              "(%s) Failure setting SOURCE_SIZE window property: (%d)\n",
              __func__, errno);
        goto leave2;
    }

    if (width % OMX_CAMERA_ALIGNMENT)
        bsize[0] = ( (width / OMX_CAMERA_ALIGNMENT) + 1) * OMX_CAMERA_ALIGNMENT;

    err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_BUFFER_SIZE, bsize);
    if (err) {
            DVP_PRINT(DVP_ZONE_ERROR,
              "(%s) Failure setting BUFFER_SIZE window property: (%d)\n",
              __func__, errno);
        goto leave2;
    }

    for (i = 0; i < numCodes; i++) {
        if (color == codes[i].fourcc)
            pformat = codes[i].qnxscreen_fmt;
    }
    if (pformat == 0)
    {
        DVP_PRINT(DVP_ZONE_ERROR, "Unknown FOURCC 0x%x\n", color);
        goto leave2;
    }
    else
    {
        DVP_PRINT(DVP_ZONE_VIDEO, "Configuring display for fmt:%d\n", pformat);
    }

    screen_get_window_property_pv(q->win, SCREEN_PROPERTY_DISPLAY, (void *)&display);
    screen_get_display_property_iv(display, SCREEN_PROPERTY_FORMAT_COUNT, (void *)&formatCount);
    screen_get_display_property_iv(display, SCREEN_PROPERTY_FORMATS, (void *)formats);
    for (i = 0; i < formatCount; i++)
    {
        DVP_PRINT(DVP_ZONE_VIDEO, "Display %p supports format %d\n", display, formats[i]);
    }
    configured = false_e;
    for (i = 0; i < formatCount; i++)
    {
        if (formats[i] == pformat)
        {
            err = screen_set_window_property_iv(q->win, SCREEN_PROPERTY_FORMAT, &pformat);
            if (err)
            {
                DVP_PRINT(DVP_ZONE_ERROR, "screen_set_window_property_iv() returned %d when setting format %d\n", err, pformat);
                goto leave2;
            }
            else
                configured = true_e;
        }
    }
    if (configured == false_e)
    {
        DVP_PRINT(DVP_ZONE_ERROR, "Display %p does not support format %d\n", display, pformat);
        goto leave2;
    }

    err = screen_create_window_buffers(q->win, (int)count);
    if (err) {
        DVP_PRINT(DVP_ZONE_ERROR, "screen_create_window_buffers() returned %d when requesting %u buffers\n", err, count);
        goto leave2;
    }

    err = screen_get_window_property_pv(q->win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)q->buf);
    if (err) {
        perror("screen_get_window_property(SCREEN_PROPERTY_RENDER_BUFFERS)");
        goto leave2;
    }

    q->count = count;
    q->pfmt = pformat;
    q->metrics.left = 0;
    q->metrics.top = 0;
    q->metrics.width = size[0];
    q->metrics.height = size[1];
    bitfield_init(&q->used, q->count);

    DVP_PRINT(DVP_ZONE_VIDEO, "QNX Screen Configuring %u images for %ux%u fmt:%d\n",
            count, size[0], size[1], pformat);
    for (i = 0; i < q->count; i++)
    {
        void *ptr = NULL;
        screen_get_buffer_property_pv(q->buf[i], SCREEN_PROPERTY_POINTER, &ptr);
        DVP_PRINT(DVP_ZONE_VIDEO, "\t[%u] ptr=%p\n", i, ptr);
    }
    ret = true_e;
leave:
    mutex_unlock(&q->m_lock);
    return ret;

leave2:
    screen_destroy_window(q->win);
    mutex_unlock(&q->m_lock);
    return ret;
}
Пример #13
0
QBBBuffer::QBBBuffer(screen_buffer_t buffer)
    : mBuffer(buffer)
{
#if defined(QBBBUFFER_DEBUG)
    qDebug() << "QBBBuffer::QBBBuffer - normal";
#endif

    // get size of buffer
    errno = 0;
    int size[2];
    int result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_BUFFER_SIZE, size);
    if (result != 0) {
        qFatal("QBB: failed to query buffer size, errno=%d", errno);
    }

    // get stride of buffer
    errno = 0;
    int stride;
    result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride);
    if (result != 0) {
        qFatal("QBB: failed to query buffer stride, errno=%d", errno);
    }

    // get access to buffer's data
    errno = 0;
    uchar* dataPtr = NULL;
    result = screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr);
    if (result != 0) {
        qFatal("QBB: failed to query buffer pointer, errno=%d", errno);
    }
    if (dataPtr == NULL) {
        qFatal("QBB: buffer pointer is NULL, errno=%d", errno);
    }

    // get format of buffer
    errno = 0;
    int screenFormat;
    result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_FORMAT, &screenFormat);
    if (result != 0) {
        qFatal("QBB: failed to query buffer format, errno=%d", errno);
    }

    // convert screen format to QImage format
    QImage::Format imageFormat = QImage::Format_Invalid;
    switch (screenFormat) {
    case SCREEN_FORMAT_RGBX4444:
        imageFormat = QImage::Format_RGB444;
        break;
    case SCREEN_FORMAT_RGBA4444:
        imageFormat = QImage::Format_ARGB4444_Premultiplied;
        break;
    case SCREEN_FORMAT_RGBX5551:
        imageFormat = QImage::Format_RGB555;
        break;
    case SCREEN_FORMAT_RGB565:
        imageFormat = QImage::Format_RGB16;
        break;
    case SCREEN_FORMAT_RGBX8888:
        imageFormat = QImage::Format_RGB32;
        break;
    case SCREEN_FORMAT_RGBA8888:
        imageFormat = QImage::Format_ARGB32_Premultiplied;
        break;
    default:
        qFatal("QBB: unsupported buffer format, format=%d", screenFormat);
    }

    // wrap buffer in an image
    mImage = QImage(dataPtr, size[0], size[1], stride, imageFormat);
}