Пример #1
0
static void bb10display_createWindow(BB10Display *d) {
    screen_window_t window;

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

    screen_create_window_type(&window, d->context, SCREEN_CHILD_WINDOW);

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

    int wdims[2] = { d->wsize.width, d->wsize.height };
    screen_set_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, wdims);
    screen_set_window_property_iv(window, SCREEN_PROPERTY_SOURCE_SIZE, wdims);

    int zorder = -5;
    screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &zorder);

    screen_create_window_buffers(window, 1);
    ms_debug("[bb10_display] bb10display_createWindow window created with size %i,%i", wdims[0], wdims[1]);

    if (!d->pixmap_created) {
        bb10display_createPixmap(d);
    }

    d->window = window;
    d->window_created = TRUE;

    if (d->window_id != NULL && d->window_group != NULL) {
        bb10display_set_window_id_and_group(d);
    }
}
screen_window_t create_bar_window(const char *group, const char *id, int dims[2])
{
	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 vis = 1;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &vis);

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

	int color = 0xff0000ff;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_COLOR, &color);

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

	int pos[2] = { -rect[2], -rect[3] };
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_POSITION, pos);
	pos[0] = pos[1] = 0;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_POSITION, pos);
	int size[2] = {barwidth,dims[1]};
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);


	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);
	screen_post_window(screen_win, screen_buf, 1, rect, 0);

	return screen_win;
}
Пример #3
0
ButtonMap::ButtonMap(screen_context_t screen_ctx, QString groupId, int coid)
{
   this->screen_cxt = screen_ctx;
   this->groupId = groupId;
   this->coid = coid;

   const int usage = SCREEN_USAGE_NATIVE | SCREEN_USAGE_WRITE | SCREEN_USAGE_READ;
   int rc;

   if(screen_create_window_type(&screen_win, screen_cxt, SCREEN_CHILD_WINDOW))
   {
      RARCH_ERR("ButtonMap: screen_create_window_type failed.\n");
   }

   screen_join_window_group(screen_win, (const char *)groupId.toAscii().constData());
   int format = SCREEN_FORMAT_RGBA8888;
   screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);

   screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);

   screen_display_t screen_disp;
   if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp))
   {
      RARCH_ERR("screen_get_window_property_pv [SCREEN_PROPERTY_DISPLAY] failed.\n");
   }

   if (screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution))
   {
      RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_SIZE] failed.\n");
   }

   rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, screen_resolution);
   if (rc) {
      perror("screen_set_window_property_iv");
   }

   int z = -10;
   if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &z) != 0) {
      return;
   }

   rc = screen_create_window_buffers(screen_win, 1);
   if (rc) {
      perror("screen_create_window_buffers");
   }

   screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);

   int bg[] = { SCREEN_BLIT_COLOR, 0x00000000,
                SCREEN_BLIT_GLOBAL_ALPHA, 0x80,
                SCREEN_BLIT_END };
   screen_fill(screen_cxt, screen_buf, bg);

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

   buttonDataModel = new ArrayDataModel();

   refreshButtonMap(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;
}
int OpenGLView::initGL()
{
    int numberDisplays;
    int numberModes;
    int returnCode;
    EGLBoolean status;
    int type;
    EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
    EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                            EGL_GREEN_SIZE,      8,
                            EGL_BLUE_SIZE,       8,
                            EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
                            EGL_NONE};

    // try this first as it will fail if an HDMI display is not attached
    if (m_api == GL_ES_2) {
        m_egl_ctx = eglCreateContext(m_egl_disp, m_egl_conf, EGL_NO_CONTEXT, attributes);
    } else {
        m_egl_ctx = eglCreateContext(m_egl_disp, m_egl_conf, EGL_NO_CONTEXT, NULL);
    }
    if (m_egl_ctx == EGL_NO_CONTEXT) {
        perror("eglCreateContext");
        return EXIT_FAILURE;
    }

	screen_get_context_property_iv(m_screen_ctx, SCREEN_PROPERTY_DISPLAY_COUNT, &numberDisplays);

	m_screen_dpy = (screen_display_t *)calloc(numberDisplays, sizeof(screen_display_t));
	screen_get_context_property_pv(m_screen_ctx, SCREEN_PROPERTY_DISPLAYS, (void **)m_screen_dpy);


	for (int index = 0; index < numberDisplays; index++) {
		int displayID;

        returnCode = screen_get_display_property_iv(m_screen_dpy[index], SCREEN_PROPERTY_ID,  (int *)&displayID);
    	if (returnCode) {
    		perror("display ID");
    		return EXIT_FAILURE;
    	} else {
			if (displayID == m_display) {
			    screen_get_display_property_iv(m_screen_dpy[index], SCREEN_PROPERTY_TYPE,  &type);
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
			    	returnCode = screen_create_window(&m_screen_win, m_screen_ctx);
			    	if (returnCode) {
			            perror("screen_create_window");
			            return EXIT_FAILURE;
			        }
			    } else {
			    	returnCode = screen_create_window_type(&m_screen_win, m_screen_ctx, SCREEN_CHILD_WINDOW);
			    	if (returnCode) {
			            perror("screen_create_window (child window)");
			            return EXIT_FAILURE;
			        }
			    }
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
					returnCode = screen_set_window_property_pv(m_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&(m_screen_dpy[index]));
					if (returnCode) {
						perror("window display");
						return EXIT_FAILURE;
					}
		        }
			}
        }
	}

	qDebug()  << "OpenGLView::initialize: "<< m_screen_ctx << ":" << m_egl_disp << ":" << m_egl_conf << ":" << m_egl_ctx << ":" << m_screen_win;


	int format = SCREEN_FORMAT_RGBA8888;
	returnCode = screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_FORMAT, &format);
	if (returnCode) {
		perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
		return EXIT_FAILURE;
	}

	if (m_transparency > 0) {
		returnCode = setWindowTransparency(m_transparency);
		if (returnCode) {
			perror("transparency");
			return EXIT_FAILURE;
		}
	}

	returnCode = screen_get_window_property_pv(m_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&m_screen_disp);
	if (returnCode) {
		perror("screen_get_window_property_pv");
		return EXIT_FAILURE;
	}

	int angle = atoi(getenv("ORIENTATION"));

	screen_get_display_property_iv(m_screen_disp, SCREEN_PROPERTY_MODE_COUNT, &numberModes);

	m_screen_modes = (screen_display_mode_t *)calloc(numberModes, sizeof(screen_display_mode_t));
	returnCode = screen_get_display_property_pv(m_screen_disp, SCREEN_PROPERTY_MODE, (void**)m_screen_modes);
	if (returnCode) {
		perror("screen modes");
		return EXIT_FAILURE;
	}

    int dpi = calculateDPI();
    if (dpi == EXIT_FAILURE) {
        fprintf(stderr, "Unable to calculate dpi\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowPosition(m_x, m_y);
	if (returnCode) {
		perror("window position");
		return EXIT_FAILURE;
	}

	returnCode = setWindowSize(m_width, m_height);
	if (returnCode) {
		perror("window size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowZ(m_z);
	if (returnCode) {
		perror("z order");
		return EXIT_FAILURE;
	}

	returnCode = setWindowBufferSize(m_width, m_height);
	if (returnCode) {
		perror("buffer size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowAngle(m_angle);
	if (returnCode) {
		perror("angle");
		return EXIT_FAILURE;
	}

	returnCode = screen_create_window_buffers(m_screen_win, m_nbuffers);
	if (returnCode) {
		perror("screen_create_window_buffers");
		return EXIT_FAILURE;
	}


    if (m_api == GL_ES_1) {
        m_usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
    } else if (m_api == GL_ES_2) {
    	attrib_list[9] = EGL_OPENGL_ES2_BIT;
    	m_usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
    } else if (m_api == VG) {
    	attrib_list[9] = EGL_OPENVG_BIT;
    	m_usage = SCREEN_USAGE_OPENVG | SCREEN_USAGE_ROTATION;
    } else {
        fprintf(stderr, "invalid api setting\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowUsage(m_usage);
	if (returnCode) {
		perror("screen_set_window_property_iv(window usage)");
		return EXIT_FAILURE;
	}

	qDebug()  << "OpenGLView::initGL:eglCreateContext "<< m_egl_ctx;
	m_egl_surf = eglCreateWindowSurface(m_egl_disp, m_egl_conf, m_screen_win, NULL);
	if (m_egl_surf == EGL_NO_SURFACE) {
		OpenGLThread::eglPrintError("eglCreateWindowSurface");
		return EXIT_FAILURE;
	}

	getGLContext();

    EGLint interval = 1;
    status = eglSwapInterval(m_egl_disp, interval);
	if (status != EGL_TRUE) {
		OpenGLThread::eglPrintError("eglSwapInterval");
		return EXIT_FAILURE;
	}

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_WIDTH, &m_surface_width);
	if (status != EGL_TRUE) {
		perror("query surface width");
		return EXIT_FAILURE;
	}

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_HEIGHT, &m_surface_height);
	if (status != EGL_TRUE) {
		perror("query surface height");
		return EXIT_FAILURE;
	}

	returnCode = joinWindowGroup(m_group);
	if (returnCode) {
		perror("window group");
		return EXIT_FAILURE;
	}

	returnCode = setScreenWindowID(m_id);
	if (returnCode) {
		perror("window ID");
		return EXIT_FAILURE;
	}

	qDebug()  << "OpenGLView::initGL: "<< angle << ":" << numberModes << ":" << m_screen_modes[0].width << ":" << m_screen_modes[0].height << ":" << m_egl_disp << ":" << dpi;

	setInitialized(true);

	return EXIT_SUCCESS;
}
Пример #6
0
QT_BEGIN_NAMESPACE

QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context)
    : QPlatformWindow(window),
      m_screenContext(context),
      m_window(0),
      m_currentBufferIndex(-1),
      m_previousBufferIndex(-1),
#if !defined(QT_NO_OPENGL)
      m_platformOpenGLContext(0),
#endif
      m_screen(0),
      m_parentWindow(0),
      m_visible(true),
      m_windowState(Qt::WindowNoState),
      m_requestedBufferSize(window->geometry().size())
{
    qWindowDebug() << Q_FUNC_INFO << "window =" << window << ", size =" << window->size();
    int result;

    // Create child QNX window
    errno = 0;
    result = screen_create_window_type(&m_window, m_screenContext, SCREEN_CHILD_WINDOW);
    if (result != 0)
        qFatal("QQnxWindow: failed to create window, errno=%d", errno);

    // Set window buffer usage based on rendering API
    int val;
    QSurface::SurfaceType surfaceType = window->surfaceType();
    switch (surfaceType) {
    case QSurface::RasterSurface:
        val = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE;
        break;
    case QSurface::OpenGLSurface:
        val = SCREEN_USAGE_OPENGL_ES2;
        break;
    default:
        qFatal("QQnxWindow: unsupported window API");
        break;
    }

    errno = 0;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, &val);
    if (result != 0)
        qFatal("QQnxWindow: failed to set window buffer usage, errno=%d", errno);

    // Alpha channel is always pre-multiplied if present
    errno = 0;
    val = SCREEN_PRE_MULTIPLIED_ALPHA;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ALPHA_MODE, &val);
    if (result != 0)
        qFatal("QQnxWindow: failed to set window alpha mode, errno=%d", errno);

    // Make the window opaque
    errno = 0;
    val = SCREEN_TRANSPARENCY_NONE;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, &val);
    if (result != 0)
        qFatal("QQnxWindow: failed to set window transparency, errno=%d", errno);

    // Set the window swap interval
    errno = 0;
    val = 1;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, &val);
    if (result != 0)
        qFatal("QQnxWindow: failed to set window swap interval, errno=%d", errno);

    if (window->flags() && Qt::WindowDoesNotAcceptFocus) {
        errno = 0;
        val = SCREEN_SENSITIVITY_NO_FOCUS;
        result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val);
        if (result != 0)
            qFatal("QQnxWindow: failed to set window sensitivity, errno=%d", errno);
    }

    setScreen(static_cast<QQnxScreen *>(window->screen()->handle()));

    // Add window to plugin's window mapper
    QQnxIntegration::addWindow(m_window, window);

    // Qt never calls these setters after creating the window, so we need to do that ourselves here
    setWindowState(window->windowState());
    if (window->parent() && window->parent()->handle())
        setParent(window->parent()->handle());
    setGeometryHelper(window->geometry());
    setVisible(window->isVisible());
}
Пример #7
0
void ScreenWindow::setVideoMode(int width, int height)
{
	if (m_window) {
		screen_destroy_window(m_window);
		m_window = 0;
	}
	if (!m_window) {
		screen_create_window_type(&m_window, m_context, SCREEN_CHILD_WINDOW);
		char groupName[256];
		snprintf(groupName, 256, "screen-%d", getpid());
		screen_join_window_group(m_window, groupName);
	} else {
		screen_destroy_window_buffers(m_window);
	}

	m_width = width;
	m_height = height;

//#define NOSTRETCH
#define STRETCH_PRESERVE_ASPECT
#ifdef NOSTRETCH
	int position[2] = {ceil((1024-width)/2), ceil((600-height)/2)};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position);

	int sizeOfWindow[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, sizeOfWindow);

	int sizeOfBuffer[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, sizeOfBuffer);
#elif defined(STRETCH_PRESERVE_ASPECT)
	width = ceil(width * 600 / height);
	height = 600;

	int position[2] = {ceil((1024-width)/2), ceil((600-height)/2)};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position);

	int sizeOfWindow[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, sizeOfWindow);

	int sizeOfBuffer[2] = {m_width, m_height}; // OLD DIMS
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, sizeOfBuffer);
#else
	int sizeOfWindow[2] = {1024, 600};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, sizeOfWindow);

	int sizeOfBuffer[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, sizeOfBuffer);
#endif

	int zOrder = 1;
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ZORDER, &zOrder);

	int format = SCREEN_FORMAT_RGBX8888;
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, &format);

	int usage = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE;
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, &usage);

	int angle = 0;
	char *orientation = getenv("ORIENTATION");
	if (orientation) {
		 angle = atoi(orientation);
	}
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &angle);

	int visible = 1;
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &visible);

	screen_create_window_buffers(m_window, 1);
}
int create_gles_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 = 3;
	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_OPENGL_ES2;
	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);

	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, dims);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, dims);

	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);

	int rect[4] = { 0, 0, dims[0], dims[1] }; // OpenGL window covers all display
	screen_post_window(screen_win, screen_buf, 1, rect, 0);

	// EGL initialization stuff starts here
	EGLint surface_width, surface_height;
	GLuint rendering_program;
	EGLConfig egl_conf;

    EGLint interval = 1;
    int rc, num_configs;

    EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                            EGL_GREEN_SIZE,      8,
                            EGL_BLUE_SIZE,       8,
                            EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
                            EGL_NONE};
    EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };

    //EGL initialization
    egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (egl_disp == EGL_NO_DISPLAY) {
        egl_perror("bbutil_init_egl: eglGetDisplay");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    rc = eglInitialize(egl_disp, NULL, NULL);
    if (rc != EGL_TRUE) {
        egl_perror("bbutil_init_egl: eglInitialize");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    rc = eglBindAPI(EGL_OPENGL_ES_API);
    if (rc != EGL_TRUE) {
        egl_perror("bbutil_init_egl: eglBindApi");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    if(!eglChooseConfig(egl_disp, attrib_list, &egl_conf, 1, &num_configs)) {
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, attributes);
    if (egl_ctx == EGL_NO_CONTEXT) {
        egl_perror("bbutil_init_egl: eglCreateContext");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    // Bound EGL serface to our Native Window
    egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL);
    if (egl_surf == EGL_NO_SURFACE) {
        egl_perror("eglCreateWindowSurface");
        gl_terminate(&screen_win);
        return 1;
    }

    rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx);
    if (rc != EGL_TRUE) {
        egl_perror("eglMakeCurrent");
        gl_terminate(&screen_win);
        return 1;
    }

    rc = eglSwapInterval(egl_disp, interval);
    if (rc != EGL_TRUE) {
        egl_perror("eglSwapInterval");
        gl_terminate(&screen_win);
        return 1;
    }

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Last byte is 'transparency', it's important to have it 0.0f
    glEnable(GL_CULL_FACE);

    // Enable 2d
    eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width);
    eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height);

    EGLint err = eglGetError();
    if (err != 0x3000) {
        fprintf(stderr, "Unable to query EGL surface dimensions\n");
        return EXIT_FAILURE;
    }
    glViewport(0, 0, surface_width, surface_height);

    // Create shaders
    const char *v_source =
    		"attribute vec4 vPosition;\n"
    		"void main()\n"
    		"{\n"
			"gl_Position = vPosition;\n"
			"}";
    const char *f_source =
    		"precision mediump float; \n"
    		"void main()\n"
    		"{\n"
    		"gl_FragColor = vec4(1.0, 0.0, 0.0, 0.7); \n" // 0.7 means we make it 'a bit' transparent
    		"}	\n";

    // Compile the vertex shader
    GLint status;
    GLuint vs = glCreateShader(GL_VERTEX_SHADER);
    if (!vs) {
        fprintf(stderr, "Failed to create vertex shader: %d\n", glGetError());
        return EXIT_FAILURE;
    } else {
        glShaderSource(vs, 1, &v_source, 0);
        glCompileShader(vs);
        glGetShaderiv(vs, GL_COMPILE_STATUS, &status);
        if (GL_FALSE == status) {
            GLchar log[256];
            glGetShaderInfoLog(vs, 256, NULL, log);

            fprintf(stderr, "Failed to compile vertex shader: %s\n", log);

            glDeleteShader(vs);
            return EXIT_FAILURE;
        }
    }

    // Compile the fragment shader
    GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
    if (!fs) {
        fprintf(stderr, "Failed to create fragment shader: %d\n", glGetError());
        return EXIT_FAILURE;
    } else {
        glShaderSource(fs, 1, &f_source, 0);
        glCompileShader(fs);
        glGetShaderiv(fs, GL_COMPILE_STATUS, &status);
        if (GL_FALSE == status) {
            GLchar log[256];
            glGetShaderInfoLog(fs, 256, NULL, log);

            fprintf(stderr, "Failed to compile fragment shader: %s\n", log);

            glDeleteShader(vs);
            glDeleteShader(fs);

            return EXIT_FAILURE;
        }
    }

    // Create and link the program
    rendering_program = glCreateProgram();
    if (rendering_program)
    {
        glAttachShader(rendering_program, vs);
        glAttachShader(rendering_program, fs);
        glLinkProgram(rendering_program);

        glGetProgramiv(rendering_program, GL_LINK_STATUS, &status);
        if (status == GL_FALSE){
            GLchar log[256];
            glGetProgramInfoLog(fs, 256, NULL, log);

            fprintf(stderr, "Failed to link text rendering shader program: %s\n", log);

            glDeleteProgram(rendering_program);
            rendering_program = 0;

            return EXIT_FAILURE;
        }
    } else {
        fprintf(stderr, "Failed to create a shader program\n");

        glDeleteShader(vs);
        glDeleteShader(fs);
        return EXIT_FAILURE;
    }
    // We don't need the shaders anymore - the program is enough
    glDeleteShader(fs);
    glDeleteShader(vs);

    glUseProgram(rendering_program); // In this example we use only one rendering program, so we can call this function once

    screen_gles_win = screen_win;

    return EXIT_SUCCESS;
}
Пример #9
0
int InitQNX(const char *Title,int Width,int Height)
{
  /* Initialize variables */
  AppTitle    = Title;
  XSize       = Width;
  YSize       = Height;
  TimerON     = 0;
  TimerReady  = 0;
  JoyState    = 0;
  LastKey     = 0;
  KeyModes    = 0;
  FrameCount  = 0;
  FrameRate   = 0;

  /* Get initial timestamp */
  gettimeofday(&TimeStamp,0);

	screen_create_context(&ctxt, SCREEN_APPLICATION_CONTEXT);

	int dispCount;
	screen_get_context_property_iv(ctxt, SCREEN_PROPERTY_DISPLAY_COUNT, &dispCount);
	screen_display_t* displays = new screen_display_t[dispCount];
	screen_get_context_property_pv(ctxt, SCREEN_PROPERTY_DISPLAYS, (void**)displays);
	int resolution[2] = { 0, 0 };
	screen_get_display_property_iv(displays[0], SCREEN_PROPERTY_SIZE, resolution);
	delete[] displays;
	actualSize_x = resolution[0];
	actualSize_y = resolution[1];
	double scaleY;
	if (isPhysicalKeyboardDevice)
		scaleY = ((double)resolution[1]) / 600.0;
	else
		scaleY = ((double)resolution[1]) / 1024.0;
	double scaleX = ((double)resolution[0]) / 600.0;
	scaleTouchMap(scaleX, scaleY);

	if (BPS_SUCCESS != screen_request_events(ctxt))
	{
		screen_destroy_context(ctxt);
		return 0;
	}

#ifdef __BBTEN__
	screen_create_window_type(&window, ctxt, SCREEN_CHILD_WINDOW);
	screen_join_window_group(window, windowGroup);
	screen_set_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, windowIdLength, "AlmostTIAppID");
	int vis = 1;
	screen_set_window_property_iv(window, SCREEN_PROPERTY_VISIBLE, &vis);
	int z = -5;
	screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &z);
	if (isPhysicalKeyboardDevice)
		virtualkeyboard_request_events(0);
#else
	screen_create_window(&window, ctxt);

	int usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE;
	screen_set_window_property_iv(window, SCREEN_PROPERTY_USAGE, &usage);
#endif
	screen_create_window_buffers(window, 1);
	screen_get_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);

  /* Done */
  return(1);
}
Пример #10
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;
}
Пример #11
0
int NativeWindow::initialize(bool _createFullWindow)
{
    int returnCode;
    int numberModes;
	screen_display_mode_t* screenModes;
    int type;

    if (_createFullWindow) {
    	returnCode = screen_create_window(&_screenWindow, _screenContext);
    	qDebug()  << "NativeWindow::initialize: _screenWindow (full window): " << ":" << _screenWindow << ":" << _screenContext << ":" << returnCode;

    	if (returnCode) {
            perror("screen_create_window");
            return EXIT_FAILURE;
        }

    } else {
    	returnCode = screen_create_window_type(&_screenWindow, _screenContext, SCREEN_CHILD_WINDOW);
    	qDebug()  << "NativeWindow::initialize: _screenWindow (child window): " << _screenWindow << ":" << returnCode;

    	if (returnCode) {
            perror("screen_create_window (child window)");
            return EXIT_FAILURE;
        }

    }

    _displaysMutex.lock();

    if (_screenDisplays) {
    	free (_screenDisplays);
    }

	// try this first as it will fail if an HDMI display is not attached
	screen_get_context_property_iv(_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT, &_numberDisplays);

	_screenDisplays = (screen_display_t *)calloc(_numberDisplays, sizeof(screen_display_t));
	screen_get_context_property_pv(_screenContext, SCREEN_PROPERTY_DISPLAYS, (void **)_screenDisplays);

	for (int index = 0; index < _numberDisplays; index++) {
		int displayID;

        returnCode = screen_get_display_property_iv(_screenDisplays[index], SCREEN_PROPERTY_ID,  (int *)&displayID);
    	qDebug()  << "NativeWindow::initialize: display: " << ":" << index << ":" << displayID << ":" << _display << ":" << _screenDisplays[index];

    	if (returnCode) {
    		perror("display ID");
    		return EXIT_FAILURE;
    	} else {
			if (displayID == _display) {
			    screen_get_display_property_iv(_screenDisplays[index], SCREEN_PROPERTY_TYPE,  &type);
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
					returnCode = screen_set_window_property_pv(_screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&(_screenDisplays[index]));

					if (returnCode) {
						perror("window display");
						return EXIT_FAILURE;
					}
		        }
			}
        }
	}

    _displaysMutex.unlock();


	qDebug()  << "NativeWindow::initialize: "<< _screenContext << ":" << _screenWindow;


    returnCode = setWindowFormat(_format);
	if (returnCode) {
		perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
		return EXIT_FAILURE;
	}

	returnCode = setWindowTransparency(_transparency);
	if (returnCode) {
		perror("transparency");
		return EXIT_FAILURE;
	}

	returnCode = screen_get_window_property_pv(_screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&_screenDisplay);
	if (returnCode) {
		perror("screenDisplay");
		return EXIT_FAILURE;
	}

	int angle = atoi(getenv("ORIENTATION"));

	screen_get_display_property_iv(_screenDisplay, SCREEN_PROPERTY_MODE_COUNT, &numberModes);

	screenModes = (screen_display_mode_t *)calloc(numberModes, sizeof(screen_display_mode_t));
	returnCode = screen_get_display_property_pv(_screenDisplay, SCREEN_PROPERTY_MODE, (void**)screenModes);
	if (returnCode) {
		perror("screen modes");
		return EXIT_FAILURE;
	}

    int dpi = calculateDPI();
    if (dpi == EXIT_FAILURE) {
        fprintf(stderr, "Unable to calculate dpi\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowPosition(_x, _y);
	if (returnCode) {
		perror("window position");
		return EXIT_FAILURE;
	}

	returnCode = setWindowSize(_width, _height);
	if (returnCode) {
		perror("window size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowZ(_z);
	if (returnCode) {
		perror("z order");
		return EXIT_FAILURE;
	}

	if (_sourceWidth > 0) {
        returnCode = setWindowSourcePosition(_sourceX, _sourceY);
        if (returnCode) {
            perror("source size");
            return EXIT_FAILURE;
        }

        returnCode = setWindowSourceSize(_sourceWidth, _sourceHeight);
        if (returnCode) {
            perror("source size");
            return EXIT_FAILURE;
        }
	}

    if (_bufferWidth > 0) {
        returnCode = setWindowBufferSize(_bufferWidth, _bufferHeight);
        if (returnCode) {
            perror("buffer size");
            return EXIT_FAILURE;
        }
    }

	returnCode = setWindowAngle(_angle);
	if (returnCode) {
		perror("angle");
		return EXIT_FAILURE;
	}

	returnCode = screen_create_window_buffers(_screenWindow, _nbuffers);
	if (returnCode) {
		perror("screen_create_window_buffers");
		return EXIT_FAILURE;
	}

	_usage = Graphics::getNativeWindowUsage();
    // enable this in case we need any native API access to this window
    _usage |= SCREEN_USAGE_NATIVE;

	returnCode = setWindowUsage(_usage);
	if (returnCode) {
		perror("screen_set_window_property_iv(window usage)");
		return EXIT_FAILURE;
	}

	returnCode = joinWindowGroup(_group);
	if (returnCode) {
		perror("window group");
		return EXIT_FAILURE;
	}

	returnCode = setScreenWindowID(_id);
	if (returnCode) {
		perror("window ID");
		return EXIT_FAILURE;
	}

	qDebug()  << "NativeWindow::initialize: "<< angle << ":" << numberModes << ":" << screenModes[0].width << ":" << screenModes[0].height << ":" << dpi;

	if (screenModes != NULL) {
		free(screenModes);
	}

	return EXIT_SUCCESS;
}
Пример #12
0
QT_BEGIN_NAMESPACE

/*!
    \class QQnxWindow
    \brief The QQnxWindow is the base class of the various classes used as instances of
    QPlatformWindow in the QNX QPA plugin.

    The standard properties and methods available in Qt are not a perfect match for the
    features provided by the QNX screen service. While for the majority of applications
    the default behavior suffices, some circumstances require greater control over the
    interaction with screen.

    \section1 Window Types

    The QNX QPA plugin can operate in two modes, with or without a root window. The
    selection of mode is made via the \e rootwindow and \e no-rootwindow options to the
    plugin. The default mode is rootwindow for BlackBerry builds and no-rootwindow for
    non-BlackBerry builds.

    Windows with parents are always created as child windows, the difference in the modes
    is in the treatment of parentless windows. In no-rootwindow mode, these windows are
    created as application windows while in rootwindow mode, the first window on a screen
    is created as an application window while subsequent windows are created as child
    windows. The only exception to this is any window of type Qt::Desktop or Qt::CoverWindow;
    these are created as application windows, but will never become the root window,
    even if they are the first window created.

    It is also possible to create a parentless child window. These may be useful to
    create windows that are parented by windows from other processes. To do this, you
    attach a dynamic property \e qnxInitialWindowGroup to the QWindow though this must be done
    prior to the platform window class (this class) being created which typically happens
    when the window is made visible. When the window is created in QML, it is acceptable
    to have the \e visible property hardcoded to true so long as the qnxInitialWindowGroup
    is also set.

    \section1 Joining Window Groups

    Window groups may be joined in a number of ways, some are automatic based on
    predefined rules though an application is also able to provide explicit control.

    A QWindow that has a parent will join its parent's window group. When rootwindow mode
    is in effect, all but the first parentless window on a screen will be child windows
    and join the window group of the first parentless window, the root window.

    If a QWindow has a valid dynamic property called \e qnxInitialWindowGroup at the time the
    QQnxWindow is created, the window will be created as a child window and, if the
    qnxInitialWindowGroup property is a non-empty string, an attempt will be made to join that
    window group. This has an effect only when the QQnxWindow is created, subsequent
    changes to this property are ignored. Setting the property to an empty string
    provides a means to create 'top level' child windows without automatically joining
    any group. Typically when this property is used \e qnxWindowId should be used as well
    so that the process that owns the window group being joined has some means to
    identify the window.

    At any point following the creation of the QQnxWindow object, an application can
    change the window group it has joined. This is done by using the \e
    setWindowProperty function of the native interface to set the \e qnxWindowGroup property
    to the desired value, for example:

    \code
    QQuickView *view = new QQuickView(parent);
    view->create();
    QGuiApplication::platformNativeInterface()->setWindowProperty(view->handle(), "qnxWindowGroup",
                                                                  group);
    \endcode

    To leave the current window group, one passes a null value for the property value,
    for example:

    \code
    QQuickView *view = new QQuickView(parent);
    view->create();
    QGuiApplication::platformNativeInterface()->setWindowProperty(view->handle(), "qnxWindowGroup",
                                                                  QVariant());
    \endcode

    \section1 Window Id

    The screen window id string property can be set on a window by assigning the desired
    value to a dynamic property \e qnxWindowId on the QWindow prior to the QQnxWindow having
    been created. This is often wanted when one joins a window group belonging to a
    different process.

*/
QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context, bool needRootWindow)
    : QPlatformWindow(window),
      m_screenContext(context),
      m_window(0),
      m_screen(0),
      m_parentWindow(0),
      m_visible(false),
      m_exposed(true),
      m_windowState(Qt::WindowNoState),
      m_mmRendererWindow(0)
{
    qWindowDebug() << Q_FUNC_INFO << "window =" << window << ", size =" << window->size();

    QQnxScreen *platformScreen = static_cast<QQnxScreen *>(window->screen()->handle());

    // If a qnxInitialWindowGroup property is set on the window we'll take this as an
    // indication that we want to create a child window and join that window group.
    const QVariant windowGroup = window->property("qnxInitialWindowGroup");

    if (window->type() == Qt::CoverWindow) {
        // Cover windows have to be top level to be accessible to window delegate (i.e. navigator)
        // Desktop windows also need to be toplevel because they are not
        // supposed to be part of the window hierarchy tree
        m_isTopLevel = true;
    } else if (parent() || windowGroup.isValid()) {
        // If we have a parent we are a child window.  Sometimes we have to be a child even if we
        // don't have a parent e.g. our parent might be in a different process.
        m_isTopLevel = false;
    } else {
        // We're parentless.  If we're not using a root window, we'll always be a top-level window
        // otherwise only the first window is.
        m_isTopLevel = !needRootWindow || !platformScreen->rootWindow();
    }

    if (window->type() == Qt::Desktop)  // A desktop widget does not need a libscreen window
        return;

    if (m_isTopLevel) {
        Q_SCREEN_CRITICALERROR(screen_create_window(&m_window, m_screenContext),
                            "Could not create top level window"); // Creates an application window
        if (window->type() != Qt::CoverWindow) {
            if (needRootWindow)
                platformScreen->setRootWindow(this);
        }
    } else {
        Q_SCREEN_CHECKERROR(
                screen_create_window_type(&m_window, m_screenContext, SCREEN_CHILD_WINDOW),
                "Could not create child window");
    }

    createWindowGroup();

    // If the window has a qnxWindowId property, set this as the string id property. This generally
    // needs to be done prior to joining any group as it might be used by the owner of the
    // group to identify the window.
    const QVariant windowId = window->property("qnxWindowId");
    if (windowId.isValid() && windowId.canConvert<QByteArray>()) {
        QByteArray id = windowId.toByteArray();
        Q_SCREEN_CHECKERROR(screen_set_window_property_cv(m_window, SCREEN_PROPERTY_ID_STRING,
                            id.size(), id), "Failed to set id");
    }

    // If a window group has been provided join it now. If it's an empty string that's OK too,
    // it'll cause us not to join a group (the app will presumably join at some future time).
    if (windowGroup.isValid() && windowGroup.canConvert<QByteArray>())
        joinWindowGroup(windowGroup.toByteArray());
}
Пример #13
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;
}