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;
}
Example #2
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);
}
static void bb10display_set_window_id_and_group(BB10Display *d) {
    if (!d->window_created) {
        ms_warning("[bb10_display] window wasn't created yet, skipping...");
        return;
    }

    screen_set_window_property_cv(d->window, SCREEN_PROPERTY_ID_STRING, strlen(d->window_id), d->window_id);
    screen_join_window_group(d->window, d->window_group);
}
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::joinWindowGroup(const QString &group)
{
	int returnCode = 0;

	if (m_screen_win != NULL) {
		returnCode = screen_join_window_group(m_screen_win, group.toAscii());
	} else {
		returnCode = EXIT_SUCCESS;
	}

	return returnCode;
}
Example #6
0
int NativeWindow::joinWindowGroup(const QString &group)
{
	int returnCode = EXIT_SUCCESS;

	if (_screenWindow != NULL) {
		if (_createGroup) {
			returnCode = screen_create_window_group(_screenWindow, group.toAscii().data());
			qDebug()  << "NativeWindow::joinWindowGroup: create group: " << group << ":" << returnCode;
		}

		if (!returnCode) {
			returnCode = screen_join_window_group(_screenWindow, group.toAscii().data());
			qDebug()  << "NativeWindow::joinWindowGroup: join group: " << group << ":" << returnCode;
		}
	}

	return returnCode;
}
Example #7
0
void QQnxWindow::setScreen(QQnxScreen *platformScreen)
{
    qWindowDebug() << Q_FUNC_INFO << "window =" << window() << "platformScreen =" << platformScreen;

    if (platformScreen == 0) { // The screen has been destroyed
        m_screen = 0;
        return;
    }

    if (m_screen == platformScreen)
        return;

    if (m_screen)
        m_screen->removeWindow(this);
    platformScreen->addWindow(this);
    m_screen = platformScreen;

    // Move window to proper screen/display
    errno = 0;
    screen_display_t display = platformScreen->nativeDisplay();
    int result = screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display);
    if (result != 0)
        qFatal("QQnxWindow: failed to set window display, errno=%d", errno);

    // Add window to display's window group
    errno = 0;
    result = screen_join_window_group(m_window, platformScreen->windowGroupName());
    if (result != 0)
        qFatal("QQnxWindow: failed to join window group, errno=%d", errno);

    Q_FOREACH (QQnxWindow *childWindow, m_childWindows) {
        // Only subwindows and tooltips need necessarily be moved to another display with the window.
        if ((window()->type() & Qt::WindowType_Mask) == Qt::SubWindow ||
                (window()->type() & Qt::WindowType_Mask) == Qt::ToolTip)
            childWindow->setScreen(platformScreen);
    }

    m_screen->updateHierarchy();
}
void MinutesPerGameRenderer::initialize() {
    m_startPos = 1;

    QByteArray groupArr = m_group.toAscii();
    QByteArray idArr = m_id.toAscii();

    // Initialize the BBS components.
    initGL();

    // We want to handle openGL Events in the foreign window. So bring the
    // in front of the cascades window (z > 0).
    m_screen_win = bbutil_get_window();
    int z = 1;
    screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_ZORDER, &z);
    screen_join_window_group(m_screen_win, groupArr.constData());
    screen_set_window_property_cv(m_screen_win, SCREEN_PROPERTY_ID_STRING, idArr.length(), idArr.constData());
    int vis = 1;
    screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_VISIBLE, &vis);

    int pos[2] = { 280, 0 };
    screen_set_window_property_iv(getWindow(), SCREEN_PROPERTY_POSITION, pos);
    screen_flush_context(GLThread::instance()->getContext(), SCREEN_WAIT_IDLE);
}
Example #9
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;
}
Example #11
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);
}
Example #12
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;
}