Пример #1
0
/*!
    \internal
    Creates an in-memory, linear accessible surface of dimensions \a w * \a h.
    This is the main surface that QWS blits to.
*/
static inline bool createMemSurface(QQnxScreenContext * const d, int w, int h)
{
#ifndef QT_NO_QWS_MULTIPROCESS
    if (QApplication::type() != QApplication::GuiServer) {
        unsigned sidlist[64];
        int n = gf_surface_sidlist(d->device, sidlist); // undocumented API
        for (int i = 0; i < n; ++i) {
            int ret = gf_surface_attach_by_sid(&d->memSurface, d->device, sidlist[i]);
            if (ret == GF_ERR_OK) {
                gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);
                if (d->memSurfaceInfo.sid != unsigned(GF_SID_INVALID)) {
                    // can we use the surface's vaddr?
                    unsigned flags = GF_SURFACE_CPU_LINEAR_READABLE | GF_SURFACE_CPU_LINEAR_WRITEABLE;
                    if ((d->memSurfaceInfo.flags & flags) == flags)
                        return true;
                }

                gf_surface_free(d->memSurface);
                d->memSurface = 0;
            }
        }
        qWarning("QQnxScreen: cannot attach to an usable surface; create a new one.");
    }
#endif
    int ret = gf_surface_create(&d->memSurface, d->device, w, h, d->displayInfo.format, 0,
                GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE
                | GF_SURFACE_CREATE_PHYS_CONTIG | GF_SURFACE_CREATE_SHAREABLE);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d",
                 w, h, ret);
        return false;
    }

    gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);

    if (d->memSurfaceInfo.sid == unsigned(GF_SID_INVALID)) {
        qWarning("QQnxScreen: gf_surface_get_info() failed.");
        return false;
    }

    return true;
}
Пример #2
0
/*! \internal
  Creates an in-memory, linear accessible surface of dimensions \a w * \a h.
  This is the main surface that QWS blits to.
 */
static bool createMemSurface(QQnxScreenContext * const d, int w, int h)
{
    // Note: gf_surface_attach() could also be used, so we'll create the buffer
    // and let the surface point to it. Here, we use surface_create instead.

    int ret = gf_surface_create(&d->memSurface, d->device, w, h,
                GF_FORMAT_ARGB8888, 0,
                GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE
                | GF_SURFACE_PHYS_CONTIG | GF_SURFACE_CREATE_SHAREABLE);
    if (ret != GF_ERR_OK) {
        qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d",
                w, h, ret);
        return false;
    }

    gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);

    if (d->memSurfaceInfo.sid == unsigned(GF_SID_INVALID)) {
        qWarning("QQnxScreen: gf_surface_get_info() failed.");
        return false;
    }

    return true;
}