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; } }
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; }
void Control::draw(screen_buffer_t buffer) const { screen_get_pixmap_property_pv(m_pixmap, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&m_buffer); int attribs[] = { SCREEN_BLIT_SOURCE_X, 0, SCREEN_BLIT_SOURCE_Y, 0, SCREEN_BLIT_SOURCE_WIDTH, m_srcWidth, SCREEN_BLIT_SOURCE_HEIGHT, m_srcHeight, SCREEN_BLIT_DESTINATION_X, m_x, SCREEN_BLIT_DESTINATION_Y, m_y, SCREEN_BLIT_DESTINATION_WIDTH, m_width, SCREEN_BLIT_DESTINATION_HEIGHT, m_height, SCREEN_BLIT_TRANSPARENCY, SCREEN_TRANSPARENCY_NONE, SCREEN_BLIT_GLOBAL_ALPHA, 0x30, SCREEN_BLIT_END }; screen_blit(m_context, buffer, m_buffer, attribs); }
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; }
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; }
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; }