static void dispmanx_surface_setup(void *data, int width, int height, int pitch, float aspect,
   struct dispmanx_surface *surface)
{
   struct dispmanx_video *_dispvars = data;
   int i, dst_width, dst_height, dst_xpos, dst_ypos;

   /* Allocate memory for all the pages in each surface
    * and initialize variables inside each page's struct. */
   surface->pages = calloc(surface->numpages, sizeof(struct dispmanx_page));
   for (i = 0; i < surface->numpages; i++) {
      surface->pages[i].used = false;   
      surface->pages[i].dispvars = _dispvars;   
      surface->pages[i].page_used_mutex = slock_new(); 
   }

   /* Internal frame dimensions. Pitch is total pitch including info 
    * between scanlines */
   surface->width = width;
   surface->height = height;
   surface->pitch = pitch;
   surface->aspect = aspect;  
 
   /* The "visible" width obtained from the core pitch. We blit based on 
    * the "visible" width, for cores with things between scanlines. */
   int visible_width = pitch / surface->bpp;
 
   dst_width  = _dispvars->dispmanx_height * aspect;	
   dst_height = _dispvars->dispmanx_height;
   
   /* If we obtain a scaled image width that is bigger than the physical screen width,
   * then we keep the physical screen width as our maximun width. */
   if (dst_width > _dispvars->dispmanx_width) 
      dst_width = _dispvars->dispmanx_width;
   
   dst_xpos = (_dispvars->dispmanx_width - dst_width) / 2;
   dst_ypos = (_dispvars->dispmanx_height - dst_height) / 2;

   /* We configure the rects now. */
   vc_dispmanx_rect_set(&surface->dst_rect, dst_xpos, dst_ypos, dst_width, dst_height);
   vc_dispmanx_rect_set(&surface->bmp_rect, 0, 0, width, height);	
   vc_dispmanx_rect_set(&surface->src_rect, 0, 0, width << 16, height << 16);	

   for (i = 0; i < surface->numpages; i++) {
      surface->pages[i].resource = 
         vc_dispmanx_resource_create(surface->pixformat, 
	 visible_width, height, &(_dispvars->vc_image_ptr));
   }
   /* Add element. */
   _dispvars->update = vc_dispmanx_update_start(0);

   surface->element = vc_dispmanx_element_add(
      _dispvars->update,_dispvars->display, surface->layer, 
      &surface->dst_rect, surface->pages[0].resource, 
      &surface->src_rect, DISPMANX_PROTECTION_NONE,
      &surface->alpha, 0, (DISPMANX_TRANSFORM_T)0);

   vc_dispmanx_update_submit_sync(_dispvars->update);		

   surface->setup = true;
}
static EGLNativeWindowType createDispmanxLayer(const QPoint &pos, const QSize &size, int z, DISPMANX_FLAGS_ALPHA_T flags)
{
    VC_RECT_T dst_rect;
    dst_rect.x = pos.x();
    dst_rect.y = pos.y();
    dst_rect.width = size.width();
    dst_rect.height = size.height();

    VC_RECT_T src_rect;
    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = size.width() << 16;
    src_rect.height = size.height() << 16;

    DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start(0);

    VC_DISPMANX_ALPHA_T alpha;
    alpha.flags = flags;
    alpha.opacity = 0xFF;
    alpha.mask = 0;

    DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add(
            dispman_update, dispman_display, z, &dst_rect, 0, &src_rect,
            DISPMANX_PROTECTION_NONE, &alpha, (DISPMANX_CLAMP_T *)NULL, (DISPMANX_TRANSFORM_T)0);

    vc_dispmanx_update_submit_sync(dispman_update);

    EGL_DISPMANX_WINDOW_T *eglWindow = new EGL_DISPMANX_WINDOW_T;
    eglWindow->element = dispman_element;
    eglWindow->width = size.width();
    eglWindow->height = size.height();

    return eglWindow;
}
static void DISPMANX_BlankBackground(void)
{
  //MAC: Funcion que simplemente pone un element nuevo cuyo resource es de un solo pixel de color negro,
  //se escala a pantalla completa y listo.
  
  // we create a 1x1 black pixel image that is added to display just behind video

  VC_IMAGE_TYPE_T type = VC_IMAGE_RGB565;
  uint32_t vc_image_ptr;
  uint16_t image = 0x0000; // black

  VC_RECT_T dst_rect, src_rect;

  dispvars->b_resource = vc_dispmanx_resource_create( type, 1 /*width*/, 1 /*height*/, &vc_image_ptr );

  vc_dispmanx_rect_set( &dst_rect, 0, 0, 1, 1);

  vc_dispmanx_resource_write_data( dispvars->b_resource, type, sizeof(image), &image, &dst_rect );

  vc_dispmanx_rect_set( &src_rect, 0, 0, 1<<16, 1<<16);
  vc_dispmanx_rect_set( &dst_rect, 0, 0, 0, 0);

  dispvars->b_update = vc_dispmanx_update_start(0);

  dispvars->b_element = vc_dispmanx_element_add(dispvars->b_update, dispvars->display, -1 /*layer*/, &dst_rect, 
	dispvars->b_resource, &src_rect, DISPMANX_PROTECTION_NONE, NULL, NULL, (DISPMANX_TRANSFORM_T)0 );
  
  vc_dispmanx_update_submit_sync( dispvars->b_update );
}
ViewBackend::Cursor::Cursor(WPE::LibinputServer::Client& targetClient, DISPMANX_DISPLAY_HANDLE_T displayHandle, uint32_t displayWidth, uint32_t displayHeight)
    : targetClient(targetClient)
    , position({ 0, 0 })
    , displaySize({ displayWidth, displayHeight })
{
    static VC_DISPMANX_ALPHA_T alpha = {
        static_cast<DISPMANX_FLAGS_ALPHA_T>(DISPMANX_FLAGS_ALPHA_FROM_SOURCE),
        255, 0
    };

    DISPMANX_UPDATE_HANDLE_T updateHandle = vc_dispmanx_update_start(0);

    uint32_t imagePtr;
    VC_RECT_T rect;
    vc_dispmanx_rect_set(&rect, 0, 0, CursorData::width, CursorData::height);
    DISPMANX_RESOURCE_HANDLE_T pointerResource = vc_dispmanx_resource_create(VC_IMAGE_RGBA32, CursorData::width, CursorData::height, &imagePtr);
    vc_dispmanx_resource_write_data(pointerResource, VC_IMAGE_RGBA32, CursorData::width * 4, CursorData::data, &rect);

    VC_RECT_T srcRect, destRect;
    vc_dispmanx_rect_set(&srcRect, 0, 0, CursorData::width << 16, CursorData::height << 16);
    vc_dispmanx_rect_set(&destRect, position.first, position.second, cursorWidth, cursorHeight);

    cursorHandle = vc_dispmanx_element_add(updateHandle, displayHandle, 10,
        &destRect, pointerResource, &srcRect, DISPMANX_PROTECTION_NONE, &alpha,
        nullptr, DISPMANX_NO_ROTATE);

    vc_dispmanx_resource_delete(pointerResource);

    vc_dispmanx_update_submit_sync(updateHandle);
}
Exemple #5
0
static void frontend_init(void)
{
  uint32_t display_width=0, display_height=0;

  VC_RECT_T dst_rect;
  VC_RECT_T src_rect;

  bcm_host_init();

  //initialise dispmanx display and resources
  fe_screen=(unsigned short *) calloc(1, 640*480*2);

  graphics_get_display_size(0 /* LCD */, &display_width, &display_height);

  fe_display = vc_dispmanx_display_open( 0 );

  //Create two surfaces for flipping between
  //Make sure bitmap type matches the source for better performance
  uint32_t crap;
  fe_resource = vc_dispmanx_resource_create(VC_IMAGE_RGB565, 640, 480, &crap);

  vc_dispmanx_rect_set( &dst_rect, 0, 0, display_width, display_height);
  vc_dispmanx_rect_set( &src_rect, 0, 0, 640 << 16, 480 << 16);

  //Make sure mame and background overlay the menu program
  fe_update = vc_dispmanx_update_start( 0 );

  // create the 'window' element - based on the first buffer resource (resource0)
  fe_element = vc_dispmanx_element_add(  fe_update,
      fe_display, 1, &dst_rect, fe_resource, &src_rect,
      DISPMANX_PROTECTION_NONE, 0, 0, (DISPMANX_TRANSFORM_T) 0 );

  vc_dispmanx_update_submit_sync( fe_update );
}
bool
addElementBackgroundLayer(
    BACKGROUND_LAYER_T *bg,
    DISPMANX_DISPLAY_HANDLE_T display,
    DISPMANX_UPDATE_HANDLE_T update)
{
    VC_DISPMANX_ALPHA_T alpha =
    {
        DISPMANX_FLAGS_ALPHA_FROM_SOURCE, 
        255,
        0
    };

    //---------------------------------------------------------------------

    VC_RECT_T src_rect;
    vc_dispmanx_rect_set(&src_rect, 0, 0, 1, 1);

    VC_RECT_T dst_rect;
    vc_dispmanx_rect_set(&dst_rect, 0, 0, 0, 0);

    bg->element =
        vc_dispmanx_element_add(update,
                                display,
                                bg->layer,
                                &dst_rect,
                                bg->resource,
                                &src_rect,
                                DISPMANX_PROTECTION_NONE,
                                &alpha,
                                NULL,
                                DISPMANX_NO_ROTATE);
    return bg->element;
}
Exemple #7
0
void
addElementWorms(
    WORMS_T *worms,
    DISPMANX_DISPLAY_HANDLE_T display,
    DISPMANX_UPDATE_HANDLE_T update)
{
    VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE, 0, 0 };

    VC_RECT_T src_rect;
    vc_dispmanx_rect_set(&src_rect,
                         0,
                         0,
                         worms->image.width << 16,
                         worms->image.height << 16);

    VC_RECT_T dst_rect;
    vc_dispmanx_rect_set(&dst_rect,
                         0,
                         0,
                         worms->image.width,
                         worms->image.height);

    worms->element =
        vc_dispmanx_element_add(update,
                                display,
                                2000,
                                &dst_rect,
                                worms->frontResource,
                                &src_rect,
                                DISPMANX_PROTECTION_NONE,
                                &alpha,
                                NULL,
                                DISPMANX_NO_ROTATE);
    assert(worms->element != 0);
}
uint32_t ViewBackendBCMRPi::createBCMElement(int32_t width, int32_t height)
{
    static VC_DISPMANX_ALPHA_T alpha = {
        static_cast<DISPMANX_FLAGS_ALPHA_T>(DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS),
        255, 0
    };

    if (m_elementHandle != DISPMANX_NO_HANDLE)
        return 0;

    m_width = std::max(width, 0);
    m_height = std::max(height, 0);

    DISPMANX_UPDATE_HANDLE_T updateHandle = vc_dispmanx_update_start(0);

    VC_RECT_T srcRect, destRect;
    vc_dispmanx_rect_set(&srcRect, 0, 0, m_width << 16, m_height << 16);
    vc_dispmanx_rect_set(&destRect, 0, 0, m_width, m_height);

    m_elementHandle = vc_dispmanx_element_add(updateHandle, m_displayHandle, 0,
        &destRect, DISPMANX_NO_HANDLE, &srcRect, DISPMANX_PROTECTION_NONE,
        &alpha, nullptr, DISPMANX_NO_ROTATE);

    vc_dispmanx_update_submit_sync(updateHandle);
    return m_elementHandle;
}
Exemple #9
0
void vo_display_frame (RECT_VARS_T* vars, int width, int height,
                      int chroma_width, int chroma_height,
                      uint8_t * const * buf, int num)
{
  int ret;
  static VC_RECT_T       src_rect;
  static VC_RECT_T       dst_rect;
  static VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, 
                                255, /*alpha 0->255*/
			        0 };
  int pitch = VO_ALIGN_UP(width,32);

  assert((height % 16) == 0);
  assert((chroma_height % 16) == 0);

  if (num == 0) {
    vars->resource = vc_dispmanx_resource_create( VC_IMAGE_YUV420,
                                                  width,
                                                  height,
                                                  &vars->vc_image_ptr );
    assert( vars->resource );

    vars->update = vc_dispmanx_update_start( 10 );
    assert( vars->update );

    vc_dispmanx_rect_set( &src_rect, 0, 0, width << 16, height << 16 );

    vc_dispmanx_rect_set( &dst_rect, 0, 0, vars->info.width, vars->info.height);

    vars->element = vc_dispmanx_element_add(    vars->update,
                                                vars->display,
                                                2000,               // layer
                                                &dst_rect,
                                                vars->resource,
                                                &src_rect,
                                                DISPMANX_PROTECTION_NONE,
                                                &alpha,
                                                NULL,             // clamp
                                                VC_IMAGE_ROT0 );
    ret = vc_dispmanx_update_submit( vars->update, NULL, NULL);

    vc_dispmanx_rect_set( &dst_rect, 0, 0, width, (3*height)/2);

  }

  ret = vc_dispmanx_resource_write_data(  vars->resource,
                                          VC_IMAGE_YUV420,
                                          pitch,
                                          buf[0],
                                          &dst_rect );
  assert( ret == 0 );

  vars->update = vc_dispmanx_update_start( 10 );
  assert( vars->update );

  //ret = vc_dispmanx_update_submit_sync( vars->update );
    ret = vc_dispmanx_update_submit( vars->update, NULL, NULL);
    assert( ret == 0 );
}
Exemple #10
0
qboolean RPI_Init (rendererstate_t *info, unsigned char *palette)
{
	static EGL_DISPMANX_WINDOW_T nativewindow;

	DISPMANX_ELEMENT_HANDLE_T dispman_element;
	DISPMANX_DISPLAY_HANDLE_T dispman_display;
	DISPMANX_UPDATE_HANDLE_T dispman_update;
	VC_RECT_T dst_rect;
	VC_RECT_T src_rect;
	int rw, rh;

	if (!EGL_LoadLibrary(info->subrenderer))
	{
		Con_Printf("couldn't load EGL library\n");
		return false;
	}
	bcm_host_init();

	graphics_get_display_size(0 /* LCD */, &rw, &rh);
	Con_Printf("Screen size is actually %i*%i\n", rw, rh);

	if (info->width < 64 || info->height < 64)
	{
		info->width = rw;
		info->height = rh;
	}
	dispman_display = vc_dispmanx_display_open(0 /* LCD */);
	dispman_update = vc_dispmanx_update_start(0);


	dst_rect.x = 0;
	dst_rect.y = 0;
	dst_rect.width = info->width;
	dst_rect.height = info->height;
	  
	src_rect.x = 0;
	src_rect.y = 0;
	src_rect.width = info->width << 16;
	src_rect.height = info->height << 16; 

	vid.pixelwidth = info->width;
	vid.pixelheight = info->height;
	 
	dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display, 0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
  
	nativewindow.element = dispman_element;
	nativewindow.width = info->width;
	nativewindow.height = info->height;
	vc_dispmanx_update_submit_sync(dispman_update);


	if (!EGL_Init(info, palette, &nativewindow, EGL_DEFAULT_DISPLAY))
	{
		Con_Printf("couldn't initialise EGL context\n");
		return false;
	}
	GL_Init(&EGL_Proc);
	return true;
}
EGLNativeWindowType
platform_create_native_window (gint width, gint height, gpointer * window_data)
{
  DISPMANX_ELEMENT_HANDLE_T dispman_element;
  DISPMANX_DISPLAY_HANDLE_T dispman_display;
  DISPMANX_UPDATE_HANDLE_T dispman_update;
  RPIWindowData *data;
  VC_RECT_T dst_rect;
  VC_RECT_T src_rect;
  GstVideoRectangle src, dst, res;

  uint32_t dp_height;
  uint32_t dp_width;

  int ret;

  ret = graphics_get_display_size (0, &dp_width, &dp_height);
  if (ret < 0) {
    GST_ERROR ("Can't open display");
    return (EGLNativeWindowType) 0;
  }
  GST_DEBUG ("Got display size: %dx%d\n", dp_width, dp_height);
  GST_DEBUG ("Source size: %dx%d\n", width, height);

  /* Center width*height frame inside dp_width*dp_height */
  src.w = width;
  src.h = height;
  src.x = src.y = 0;
  dst.w = dp_width;
  dst.h = dp_height;
  dst.x = dst.y = 0;
  gst_video_sink_center_rect (src, dst, &res, TRUE);

  dst_rect.x = res.x;
  dst_rect.y = res.y;
  dst_rect.width = res.w;
  dst_rect.height = res.h;

  src_rect.x = 0;
  src_rect.y = 0;
  src_rect.width = width << 16;
  src_rect.height = height << 16;

  dispman_display = vc_dispmanx_display_open (0);
  dispman_update = vc_dispmanx_update_start (0);
  dispman_element = vc_dispmanx_element_add (dispman_update,
      dispman_display, 0, &dst_rect, 0, &src_rect,
      DISPMANX_PROTECTION_NONE, 0, 0, 0);

  *window_data = data = g_slice_new0 (RPIWindowData);
  data->d = dispman_display;
  data->w.element = dispman_element;
  data->w.width = width;
  data->w.height = height;
  vc_dispmanx_update_submit_sync (dispman_update);

  return (EGLNativeWindowType) data;
}
Exemple #12
0
///
//  WinCreate() - RaspberryPi, direct surface (No X, Xlib)
//
//      This function initialized the display and window for EGL
//
EGLBoolean WinCreate(ESContext *esContext, const char *title) 
{
   int32_t success = 0;

   static EGL_DISPMANX_WINDOW_T nativewindow;

   DISPMANX_ELEMENT_HANDLE_T dispman_element;
   DISPMANX_DISPLAY_HANDLE_T dispman_display;
   DISPMANX_UPDATE_HANDLE_T dispman_update;
   VC_RECT_T dst_rect;
   VC_RECT_T src_rect;
   

   int display_width;
   int display_height;

   // create an EGL window surface, passing context width/height
   success = graphics_get_display_size(0 /* LCD */, &display_width, &display_height);
   if ( success < 0 )
   {
      return EGL_FALSE;
   }
   
   // You can hardcode the resolution here:
   // <JJW> : But I don't want to hardcode resolution!
   // display_width = 640;
   // display_height = 480;

   dst_rect.x = 0;
   dst_rect.y = 0;
   dst_rect.width = display_width;
   dst_rect.height = display_height;
      
   src_rect.x = 0;
   src_rect.y = 0;
   src_rect.width = display_width << 16;
   src_rect.height = display_height << 16;   

   dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
   dispman_update = vc_dispmanx_update_start( 0 );
         
   dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
      0/*layer*/, &dst_rect, 0/*src*/,
      &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
      
   nativewindow.element = dispman_element;
   nativewindow.width = display_width;
   nativewindow.height = display_height;
   vc_dispmanx_update_submit_sync( dispman_update );

   //JJW : save window resolution of LCD moniter in esContext
   esContext->width = display_width;
   esContext->height = display_height;
   
   esContext->hWnd = &nativewindow;

	return EGL_TRUE;
}
Exemple #13
0
/** Creates a native window for the GL surface using dispmanx
 * @param raspitex_state A pointer to the GL preview state.
 * @return Zero if successful, otherwise, -1 is returned.
 */
int raspitexutil_create_native_window(RASPITEX_STATE *raspitex_state)
{
   VC_DISPMANX_ALPHA_T alpha = {DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, 255, 0};
   VC_RECT_T src_rect = {0};
   VC_RECT_T dest_rect = {0};
   uint32_t disp_num = 0; // Primary
   uint32_t layer_num = 0;
   DISPMANX_ELEMENT_HANDLE_T elem;
   DISPMANX_UPDATE_HANDLE_T update;

   alpha.opacity = raspitex_state->opacity;
   dest_rect.x = raspitex_state->x;
   dest_rect.y = raspitex_state->y;
   dest_rect.width = raspitex_state->width;
   dest_rect.height = raspitex_state->height;

   vcos_log_trace("%s: %d,%d,%d,%d %d,%d,0x%x,0x%x", VCOS_FUNCTION,
         src_rect.x, src_rect.y, src_rect.width, src_rect.height,
         dest_rect.x, dest_rect.y, dest_rect.width, dest_rect.height);

   src_rect.width = dest_rect.width << 16;
   src_rect.height = dest_rect.height << 16;

   raspitex_state->disp = vc_dispmanx_display_open(disp_num);
   if (raspitex_state->disp == DISPMANX_NO_HANDLE)
   {
      vcos_log_error("Failed to open display handle");
      goto error;
   }

   update = vc_dispmanx_update_start(0);
   if (update == DISPMANX_NO_HANDLE)
   {
      vcos_log_error("Failed to open update handle");
      goto error;
   }

   elem = vc_dispmanx_element_add(update, raspitex_state->disp, layer_num,
         &dest_rect, 0, &src_rect, DISPMANX_PROTECTION_NONE, &alpha, NULL,
         DISPMANX_NO_ROTATE);
   if (elem == DISPMANX_NO_HANDLE)
   {
      vcos_log_error("Failed to create element handle");
      goto error;
   }

   raspitex_state->win.element = elem;
   raspitex_state->win.width = raspitex_state->width;
   raspitex_state->win.height = raspitex_state->height;
   vc_dispmanx_update_submit_sync(update);

   raspitex_state->native_window = (EGLNativeWindowType*) &raspitex_state->win;

   return 0;
error:
   return -1;
}
bool
NativeStateDispmanx::create_window(WindowProperties const& properties)
{
    int dispmanx_output = 0; /* LCD */

    if (!properties.fullscreen) {
        Log::error("Error: Dispmanx only supports full screen rendering.\n");
	return false;
    }

    unsigned screen_width, screen_height;
    if (graphics_get_display_size(dispmanx_output,
				  &screen_width, &screen_height) < 0) {
        Log::error("Error: Couldn't get screen width/height.\n");
	return false;
    }

    properties_.fullscreen = properties.fullscreen;
    properties_.visual_id = properties.visual_id;
    properties_.width = screen_width;
    properties_.height = screen_height;

    dispmanx_display = vc_dispmanx_display_open(dispmanx_output);

    VC_RECT_T dst_rect;
    VC_RECT_T src_rect;
    dst_rect.x = 0;
    dst_rect.y = 0;
    dst_rect.width = screen_width;
    dst_rect.height = screen_height;

    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = screen_width << 16;
    src_rect.height = screen_height << 16;

    dispmanx_update = vc_dispmanx_update_start(0);

    dispmanx_element = vc_dispmanx_element_add(dispmanx_update,
					       dispmanx_display,
					       0 /*layer*/,
					       &dst_rect,
					       0 /*src*/,
					       &src_rect,
					       DISPMANX_PROTECTION_NONE,
					       0 /*alpha*/,
					       0 /*clamp*/,
					       DISPMANX_NO_ROTATE);

    egl_dispmanx_window.element = dispmanx_element;
    egl_dispmanx_window.width = dst_rect.width;
    egl_dispmanx_window.height = dst_rect.height;
    vc_dispmanx_update_submit_sync(dispmanx_update);

    return true;
}
Exemple #15
0
BBEGLContext *createDisplayContext(){
	EGLContext context;
	EGLSurface surface;

	static const EGLint contextAttribs[]={
		EGL_CONTEXT_CLIENT_VERSION,2,
		EGL_NONE};

	context=eglCreateContext(display,config,EGL_NO_CONTEXT,contextAttribs);
	assert(eglGetError()==EGL_SUCCESS);

	unsigned int width,height;

	graphics_get_display_size(0,&width,&height);
	printf("display size is %dx%d\n",width,height);

	VC_RECT_T dst={0};
	dst.width=width;
	dst.height=height;
	VC_RECT_T src={0};
	src.width=width<<16;
	src.height=height<<16;

	static EGL_DISPMANX_WINDOW_T nativewindow;

	DISPMANX_ELEMENT_HANDLE_T dispman_element;
	DISPMANX_DISPLAY_HANDLE_T dispman_display;
	DISPMANX_UPDATE_HANDLE_T dispman_update;

	dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
	dispman_update = vc_dispmanx_update_start( 0 );

	dispman_element = vc_dispmanx_element_add ( dispman_update,
                                             dispman_display, 0/*layer*/, &dst, 0/*src*/,
                                             &src, DISPMANX_PROTECTION_NONE, 0 /*alpha*/,
                                             0/*clamp*/, DISPMANX_NO_ROTATE/*transform*/);

	nativewindow.element = dispman_element;
 	nativewindow.width = width;
	nativewindow.height = height;

	vc_dispmanx_update_submit_sync( dispman_update );

	surface=eglCreateWindowSurface(display,config,&nativewindow,NULL);

	eglMakeCurrent(display,surface,surface,context);

	DeviceContext.width=width;
	DeviceContext.height=height;
	DeviceContext.depth=32;
	DeviceContext.hertz=60;
	DeviceContext.context=context;
	DeviceContext.surface=surface;

	return &DeviceContext;
}
Exemple #16
0
void gp2x_frontend_init(void)
{
	int ret;
        
	uint32_t display_width, display_height;
    
	VC_RECT_T dst_rect;
	VC_RECT_T src_rect;
    
	surface_width = 640;
	surface_height = 480;
    
	gp2x_screen8=0;
	gp2x_screen15=(unsigned short *) calloc(1, 640*480*2);
	
	graphics_get_display_size(0 /* LCD */, &display_width, &display_height);
    
	dispman_display = vc_dispmanx_display_open( 0 );
	assert( dispman_display != 0 );
        
	// Add border around bitmap for TV
	display_width -= options.display_border * 2;
	display_height -= options.display_border * 2;
    
	//Create two surfaces for flipping between
	//Make sure bitmap type matches the source for better performance
	uint32_t crap;
	resource0 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, 640, 480, &crap);
	resource1 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, 640, 480, &crap);
    
	vc_dispmanx_rect_set( &dst_rect, options.display_border, options.display_border,
                         display_width, display_height);
	vc_dispmanx_rect_set( &src_rect, 0, 0, 640 << 16, 480 << 16);
    
	//Make sure mame and background overlay the menu program
	dispman_update = vc_dispmanx_update_start( 0 );
    
	// create the 'window' element - based on the first buffer resource (resource0)
	dispman_element = vc_dispmanx_element_add(  dispman_update,
                                              dispman_display,
                                              1,
                                              &dst_rect,
                                              resource0,
                                              &src_rect,
                                              DISPMANX_PROTECTION_NONE,
                                              0,
                                              0,
                                              (DISPMANX_TRANSFORM_T) 0 );
    
	ret = vc_dispmanx_update_submit_sync( dispman_update );
    
	// setup swapping of double buffers
	cur_res = resource1;
	prev_res = resource0;
    
}
Exemple #17
0
static void show_cursor(ALLEGRO_DISPLAY_RASPBERRYPI *d)
{
    if (d->cursor_data == NULL || cursor_added) {
        return;
    }

    int width = d->cursor_width;
    int height = d->cursor_height;

    uint32_t unused;
    cursor_resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888, width, height, &unused);

    VC_RECT_T r;
    r.x = 0;
    r.y = 0;
    r.width = width;
    r.height = height;

    int dpitch = pot(sizeof(uint32_t) * width);

    dispman_update = vc_dispmanx_update_start(0);
    vc_dispmanx_resource_write_data(cursor_resource, VC_IMAGE_ARGB8888, dpitch, d->cursor_data, &r);
    vc_dispmanx_update_submit_sync(dispman_update);

    ALLEGRO_MOUSE_STATE state;
    al_get_mouse_state(&state);

    dst_rect.x = state.x+d->cursor_offset_x;
    dst_rect.y = state.y+d->cursor_offset_y;
    dst_rect.width = width;
    dst_rect.height = height;
    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = width << 16;
    src_rect.height = height << 16;

    dispman_update = vc_dispmanx_update_start(0);

    cursor_element = vc_dispmanx_element_add(
                         dispman_update,
                         dispman_display,
                         0/*layer*/,
                         &dst_rect,
                         cursor_resource,
                         &src_rect,
                         DISPMANX_PROTECTION_NONE,
                         0 /*alpha*/,
                         0/*clamp*/,
                         0/*transform*/
                     );

    vc_dispmanx_update_submit_sync(dispman_update);

    cursor_added = true;
}
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateWindowSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong win, jlong attrib_list) {
    EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
    EGLConfig config = (EGLConfig)(intptr_t)config_ptr;
    const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list;

	//@@spsn
	int32_t success = 0;
	EGLBoolean result;
	EGLint num_config;
	EGLint screen_width;
	EGLint screen_height;

	static EGL_DISPMANX_WINDOW_T nativewindow;

	DISPMANX_ELEMENT_HANDLE_T dispman_element;
	DISPMANX_DISPLAY_HANDLE_T dispman_display;
	DISPMANX_UPDATE_HANDLE_T dispman_update;
	VC_RECT_T dst_rect;
	VC_RECT_T src_rect;

	bcm_host_init();

	// create an EGL window surface
	success = graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height);

	dst_rect.x = 0;
	dst_rect.y = 0;
	dst_rect.width = screen_width;
	dst_rect.height = screen_height;
      
	src_rect.x = 0;
	src_rect.y = 0;
	src_rect.width = screen_width << 16;
	src_rect.height = screen_height << 16;        

	VC_DISPMANX_ALPHA_T alpha;
	alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
	alpha.opacity = 255;
	alpha.mask = 0;

	dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
	dispman_update = vc_dispmanx_update_start( 0 );
         
	dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
      0/*layer*/, &dst_rect, 0/*src*/,
      &src_rect, DISPMANX_PROTECTION_NONE, &alpha/*alpha*/, 0/*clamp*/, 0/*transform*/);
      
	nativewindow.element = dispman_element;
	nativewindow.width = screen_width;
	nativewindow.height = screen_height;
	vc_dispmanx_update_submit_sync( dispman_update );
      
//    return (intptr_t)eglCreateWindowSurface(dpy, config, (EGLNativeWindowType)(intptr_t)win, attrib_list_address);
    return (intptr_t)eglCreateWindowSurface(dpy, config, (EGLNativeWindowType)(intptr_t)&nativewindow, attrib_list_address);
}
static void
window_resize (GstGLWindowDispmanxEGL * window_egl, guint width, guint height)
{
  GST_DEBUG ("resizing window from %ux%u to %ux%u",
      window_egl->native.width, window_egl->native.height, width, height);

  if (window_egl->display) {
    VC_RECT_T dst_rect;
    VC_RECT_T src_rect;
    GstVideoRectangle src, dst, res;
    DISPMANX_UPDATE_HANDLE_T dispman_update;
    VC_DISPMANX_ALPHA_T alpha =
        { DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, 255, 0 };

    /* Center width*height frame inside dp_width*dp_height */
    src.w = width;
    src.h = height;
    src.x = src.y = 0;
    dst.w = window_egl->dp_width;
    dst.h = window_egl->dp_height;
    dst.x = dst.y = 0;
    gst_video_sink_center_rect (src, dst, &res, FALSE);

    dst_rect.x = res.x;
    dst_rect.y = res.y;
    dst_rect.width = res.w;
    dst_rect.height = res.h;

    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = width << 16;
    src_rect.height = height << 16;

    dispman_update = vc_dispmanx_update_start (0);

    if (window_egl->native.element) {
      vc_dispmanx_element_change_attributes (dispman_update,
          window_egl->native.element, 0x00000110, 0, 0, &dst_rect, &src_rect, 0,
          0);
    } else {
      window_egl->native.element = vc_dispmanx_element_add (dispman_update,
          window_egl->display, 0, &dst_rect, 0, &src_rect,
          DISPMANX_PROTECTION_NONE, &alpha, 0, 0);
    }

    vc_dispmanx_update_submit_sync (dispman_update);

    if (GST_GL_WINDOW (window_egl)->resize)
      GST_GL_WINDOW (window_egl)->
          resize (GST_GL_WINDOW (window_egl)->resize_data, width, height);
  }

  window_egl->native.width = width;
  window_egl->native.height = height;
}
Exemple #20
0
void EGLInitializeSubsystemWindow(int requested_width, int requested_height,
int& width, int& height, void *&window) {
    bcm_host_init();

    int success = graphics_get_display_size(0 /* LCD */,
        (uint32_t *)&width, (uint32_t *)&height);
    assert(success >= 0);

    static EGL_DISPMANX_WINDOW_T native_window;
    DISPMANX_ELEMENT_HANDLE_T dispman_element;
    DISPMANX_DISPLAY_HANDLE_T dispman_display;
    DISPMANX_UPDATE_HANDLE_T dispman_update;
    VC_RECT_T dst_rect;
    VC_RECT_T src_rect;

    dst_rect.x = 0;
    dst_rect.y = 0;
    dst_rect.width = width;
    dst_rect.height = height;

    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = width << 16;
    src_rect.height = height << 16;

    dispman_display = vc_dispmanx_display_open(0 /* LCD */);
    dispman_update = vc_dispmanx_update_start(0);

    VC_DISPMANX_ALPHA_T alpha;
    alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
    alpha.opacity = 0xFF;
    alpha.mask = DISPMANX_NO_HANDLE;
    dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display,
        0/*layer*/, &dst_rect, 0/*src*/,
        &src_rect, DISPMANX_PROTECTION_NONE, &alpha /*alpha*/, 0/*clamp*/,
        (DISPMANX_TRANSFORM_T)0/*transform*/);

//    nativewindow.element = dispman_element;
//    nativewindow.width = width;
//    nativewindow.height = height;

    vc_dispmanx_update_submit_sync(dispman_update);
    check();

    LinuxFBInitializeUI(width, height);

    native_window.element = dispman_element;
    native_window.width = width;
    native_window.height = height;
    window = &native_window;
}
int 
pf_re_native_init (EGLNativeDisplayType *display_out, 
		   EGLNativeWindowType *window_out,
		   int w, int h)
{
bcm_host_init();

   DISPMANX_ELEMENT_HANDLE_T dispman_element;
   DISPMANX_DISPLAY_HANDLE_T dispman_display;
   DISPMANX_UPDATE_HANDLE_T dispman_update;
   VC_RECT_T dst_rect;
   VC_RECT_T src_rect;
int success;
int screen_width = 800, screen_height = 600;

#if 1
   // create an EGL window surface
   success = graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height);
   if ( success < 0 ) 	
	{
	fprintf (stderr, "Cannot get display size\n");
	exit (1);
}
#endif
   dst_rect.x = 0;
   dst_rect.y = 0;
   dst_rect.width = screen_width;
   dst_rect.height = screen_height;

   src_rect.x = 0;
   src_rect.y = 0;
   src_rect.width = screen_width << 16;
   src_rect.height = screen_height << 16;

   dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
   dispman_update = vc_dispmanx_update_start( 0 );

   dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
      0/*layer*/, &dst_rect, 0/*src*/,
      &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);

   nativewindow.element = dispman_element;
   nativewindow.width = screen_width;
   nativewindow.height = screen_height;
   vc_dispmanx_update_submit_sync( dispman_update );


  *display_out = EGL_DEFAULT_DISPLAY;
  *window_out = &nativewindow;
}
Exemple #22
0
int main(void)
{
   uint32_t width, height;
   bcm_host_init();
   int s;

   static EGL_DISPMANX_WINDOW_T nativewindow;

   DISPMANX_ELEMENT_HANDLE_T dispman_element;
   DISPMANX_DISPLAY_HANDLE_T dispman_display;
   DISPMANX_UPDATE_HANDLE_T dispman_update;
   VC_RECT_T dst_rect;
   VC_RECT_T src_rect;

   s = graphics_get_display_size(0 /* LCD */, &width, &height);
   assert( s >= 0 );

   dst_rect.x = 0;
   dst_rect.y = 0;
   dst_rect.width = width;
   dst_rect.height = height;
      
   src_rect.x = 0;
   src_rect.y = 0;
   src_rect.width = width << 16;
   src_rect.height = height << 16;        

   dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
   dispman_update = vc_dispmanx_update_start( 0 );
         
   dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
      1/*layer*/, &dst_rect, 0/*src*/,
      &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
      
   nativewindow.element = dispman_element;
   nativewindow.width = width;
   nativewindow.height = height;
   vc_dispmanx_update_submit_sync( dispman_update );

   init(&nativewindow);

   while (1) {
      render(width, height);
      rotateN += 1.0f;
   }
   deinit();

   return 0;
}
Exemple #23
0
static void LoadOpenGLESWindow(uint32_t width, uint32_t height)
{
    bcm_host_init();
    
    display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    eglInitialize(display, NULL, NULL);
    
    static const EGLint attribute_list[] =
	{
	    EGL_RED_SIZE, 8,
	    EGL_GREEN_SIZE, 8,
	    EGL_BLUE_SIZE, 8,
	    EGL_ALPHA_SIZE, 8,
	    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
	    EGL_NONE
	};
    EGLint num_config;
    eglChooseConfig(display, attribute_list, &config, 1, &num_config);
    
    eglBindAPI(EGL_OPENGL_ES_API);

    static const EGLint context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
    context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attributes);

    dst_rect.x = 0;
    dst_rect.y = 0;
    dst_rect.width = width;
    dst_rect.height = height;
    
    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = width << 16;
    src_rect.height = height << 16;

    dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
    dispman_update = vc_dispmanx_update_start( 0 );
    dispman_element = vc_dispmanx_element_add(
    	dispman_update, dispman_display,
		0/*layer*/, &dst_rect, 0/*src*/,
		&src_rect, DISPMANX_PROTECTION_NONE, 
		0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
    nativewindow.element = dispman_element;
    nativewindow.width = width;
    nativewindow.height = height;
    vc_dispmanx_update_submit_sync(dispman_update);

    surface = eglCreateWindowSurface(display, config, &nativewindow, NULL);
    eglMakeCurrent(display, surface, surface, context);
}
Exemple #24
0
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow
  (JNIEnv *env, jobject obj, jint width, jint height, jboolean opaque, jint alphaBits)
{
   int32_t success = 0;
   VC_RECT_T dst_rect;
   VC_RECT_T src_rect;

   dst_rect.x = 0;
   dst_rect.y = 0;
   dst_rect.width = width;
   dst_rect.height = height;
      
   src_rect.x = 0;
   src_rect.y = 0;
   src_rect.width = width << 16;
   src_rect.height = height << 16;   

   VC_DISPMANX_ALPHA_T dispman_alpha;
   memset(&dispman_alpha, 0x0, sizeof(VC_DISPMANX_ALPHA_T));

   if( JNI_TRUE == opaque ) {
       dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS ;
       dispman_alpha.opacity = 0xFF;
       dispman_alpha.mask = 0;
   } else {
       dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE ;
       dispman_alpha.opacity = 0xFF;
       dispman_alpha.mask = 0xFF;
   }

   DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
   DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
   DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
                                                                         0/*layer*/, &dst_rect, 0/*src*/,
                                                                         &src_rect, DISPMANX_PROTECTION_NONE, 
                                                                         &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/);

   EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T));  
   nativeWindowPtr->element = dispman_element;
   nativeWindowPtr->width = width;
   nativeWindowPtr->height = height;

   vc_dispmanx_update_submit_sync( dispman_update );

   (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, JNI_TRUE); // FIXME: or defer=true ?

   return (jlong) (intptr_t) nativeWindowPtr;
}
Exemple #25
0
void dispmanxtest() {
	DISPMANX_DISPLAY_HANDLE_T display;
	int ret;
	DISPMANX_MODEINFO_T displayinfo;
	DISPMANX_RESOURCE_HANDLE_T res;
	int width = 1024;
	int height = 576;
	uint32_t vc_image_ptr;
	DISPMANX_UPDATE_HANDLE_T update;
	VC_RECT_T dst_rect,src_rect;
	DISPMANX_ELEMENT_HANDLE_T element;

	
	bcm_host_init();
	display = vc_dispmanx_display_open(0);
	ret = vc_dispmanx_display_get_info( display, &displayinfo);
	assert(ret==0);
	printf("display is %dx%d\n",displayinfo.width,displayinfo.height);
	res = vc_dispmanx_resource_create(VC_IMAGE_YUV420,width,height,&vc_image_ptr);
	vc_image_ptr = vc_dispmanx_resource_get_image_handle(res);
	printf("vc_image_ptr %x\n",vc_image_ptr);
	assert(res);
	update = vc_dispmanx_update_start(10);
	assert(update);
	vc_dispmanx_rect_set(&src_rect,0,0,width<<16,height<<16);
	vc_dispmanx_rect_set(&dst_rect,0,(displayinfo.height - height)/2,width-32,height);
	element = vc_dispmanx_element_add(update,display,2000,&dst_rect,res,&src_rect,DISPMANX_PROTECTION_NONE,NULL,NULL,DISPMANX_NO_ROTATE);
	ret = vc_dispmanx_update_submit_sync(update);
	assert(ret==0);
	uint8_t *rawfb = (uint8_t*)mapmem(vc_image_ptr,0x1000);
	for (int i=0; i<0x100; i++) {
		printf("%02x ",rawfb[i]);
	}
	printf("\n");
	unmapmem(rawfb,0x1000);
	puts("sleeping");
	sleep(10);
	update = vc_dispmanx_update_start(10);
	assert(update);
	ret = vc_dispmanx_element_remove(update,element);
	assert(ret==0);
	ret = vc_dispmanx_update_submit_sync(update);
	assert(ret==0);
	ret = vc_dispmanx_resource_delete(res);
	assert(ret==0);
	ret = vc_dispmanx_display_close(display);
	assert(ret==0);
}
Exemple #26
0
void
addElementLife(
    LIFE_T *life,
    DISPMANX_MODEINFO_T *info,
    DISPMANX_DISPLAY_HANDLE_T display,
    DISPMANX_UPDATE_HANDLE_T update)
{
    VC_DISPMANX_ALPHA_T alpha =
    {
        DISPMANX_FLAGS_ALPHA_FROM_SOURCE, 
        255, /*alpha 0->255*/
        0
    };

    int32_t dst_size = life->height;

    if (dst_size < info->height)
    {
        dst_size = info->height - (info->height % life->height);
    }

    //---------------------------------------------------------------------

    vc_dispmanx_rect_set(&(life->srcRect),
                         0,
                         0,
                         life->width << 16,
                         life->height << 16);

    vc_dispmanx_rect_set(&(life->dstRect),
                         (info->width - dst_size) / 2,
                         (info->height - dst_size) / 2,
                         dst_size,
                         dst_size);

    life->element =
        vc_dispmanx_element_add(update,
                                display,
                                1,
                                &(life->dstRect),
                                life->frontResource,
                                &(life->srcRect),
                                DISPMANX_PROTECTION_NONE,
                                &alpha,
                                NULL,
                                DISPMANX_NO_ROTATE);
    assert(life->element != 0);
}
/*!***********************************************************************
 @Function		OsGetNativeWindowType
 @Return		The 'NativeWindowType' for EGL
 @description	Called from InitAPI() to get the NativeWindowType
*************************************************************************/
void *PVRShellInit::OsGetNativeWindowType()
{
	unsigned int iWidth, iHeight;
	if(graphics_get_display_size(0 /* LCD */, &iWidth, &iHeight) < 0)
	{
		m_pShell->PVRShellOutputDebug("ERROR: graphics_get_display_size() failed.\n");
		return 0;
	}

	m_pShell->PVRShellOutputDebug("Creating Pi display with size: %dx%d\n", iWidth, iHeight);

	VC_RECT_T dst_rect;
	VC_RECT_T src_rect;
	DISPMANX_ELEMENT_HANDLE_T dispman_element;
	DISPMANX_DISPLAY_HANDLE_T dispman_display;
	DISPMANX_UPDATE_HANDLE_T dispman_update;
	static EGL_DISPMANX_WINDOW_T nativeWindow;

	dst_rect.x = 0;
	dst_rect.y = 0;
	dst_rect.width 	= iWidth;
	dst_rect.height = iHeight;
	src_rect.x = 0;
	src_rect.y = 0;
	src_rect.width 	= iWidth  << 16;
	src_rect.height = iHeight << 16;

	dispman_display = vc_dispmanx_display_open(0);
	dispman_update  = vc_dispmanx_update_start(0);
	dispman_element = vc_dispmanx_element_add(	dispman_update, 
							dispman_display,
							0, // layer
							&dst_rect,
							0, // src
							&src_rect,
							DISPMANX_PROTECTION_NONE,
							0, // alpha
							0, // clamp
							DISPMANX_NO_ROTATE);
	nativeWindow.element = dispman_element;
	nativeWindow.width   = iWidth;
	nativeWindow.height  = iHeight;
	vc_dispmanx_update_submit_sync(dispman_update);

	return (void*)&nativeWindow;
}
Exemple #28
0
void InitializeSurface(DisplaySurface *surface, unsigned int xOrigin, unsigned int yOrigin, unsigned int width, unsigned int height) {

	//VC
	VC_RECT_T destinationRect;
	VC_RECT_T sourceRect;

	if (xOrigin > displayWidth) xOrigin = 0;
	if (yOrigin > displayHeight) yOrigin = 0;
	if (width == 0 || xOrigin + width > displayWidth) width = displayWidth - xOrigin;
	if (height == 0 || yOrigin + height > displayHeight) height = displayHeight - yOrigin;

	surface->xOrigin = xOrigin;
	surface->yOrigin = yOrigin;
	surface->width = width;
	surface->height = height;

	// create an EGL window surface
	destinationRect.x = xOrigin;
	destinationRect.y = displayHeight - yOrigin - height;
	destinationRect.width = width;
	destinationRect.height = height;

	sourceRect.x = 0;
	sourceRect.y = 0;
	sourceRect.width = width << 16;
	sourceRect.height = height << 16;

	dispmanDisplay = vc_dispmanx_display_open( 0 /* LCD */);
	dispmanUpdate = vc_dispmanx_update_start( 0 );

	surface->dispmanWindow.element = vc_dispmanx_element_add (dispmanUpdate, dispmanDisplay, 0/*layer*/, &destinationRect, 0/*src*/, &sourceRect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
	surface->dispmanWindow.width = width;
	surface->dispmanWindow.height = height;
	vc_dispmanx_update_submit_sync(dispmanUpdate);

	// create the surfrace
	surface->eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, &surface->dispmanWindow, NULL );

	// connect the context to the surface
	eglMakeCurrent(eglDisplay, surface->eglSurface, surface->eglSurface, eglContext);

	// JDO: preserve buffer https://www.khronos.org/registry/egl/sdk/docs/man/html/eglSwapBuffers.xhtml
	// Slower eglSwapBuffers but allows for partial screen update
	eglSurfaceAttrib(eglDisplay, surface->eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
}
Exemple #29
0
void
addElementLife(
    LIFE_T *life,
    int32_t xOffset,
    int32_t yOffset,
    int32_t dstSize,
    DISPMANX_DISPLAY_HANDLE_T display,
    DISPMANX_UPDATE_HANDLE_T update)
{
    VC_DISPMANX_ALPHA_T alpha =
    {
        DISPMANX_FLAGS_ALPHA_FROM_SOURCE, 
        255, /*alpha 0->255*/
        0
    };

    //---------------------------------------------------------------------

    vc_dispmanx_rect_set(&(life->srcRect),
                         0,
                         0,
                         life->width << 16,
                         life->height << 16);

    vc_dispmanx_rect_set(&(life->dstRect),
                         xOffset,
                         yOffset,
                         dstSize,
                         dstSize);

    life->element =
        vc_dispmanx_element_add(update,
                                display,
                                1,
                                &(life->dstRect),
                                life->frontResource,
                                &(life->srcRect),
                                DISPMANX_PROTECTION_NONE,
                                &alpha,
                                NULL,
                                DISPMANX_NO_ROTATE);
    assert(life->element != 0);
}
void SubtitleRenderer::initialize_window(int display, int layer,
                                         unsigned int x,
                                         unsigned int y,
                                         unsigned int width,
                                         unsigned int height) {
  VC_RECT_T dst_rect;
  dst_rect.x = x;
  dst_rect.y = y;
  dst_rect.width = width;
  dst_rect.height = height;

  VC_RECT_T src_rect;
  src_rect.x = 0;
  src_rect.y = 0;
  src_rect.width = dst_rect.width << 16;
  src_rect.height = dst_rect.height << 16;        

  dispman_display_ = vc_dispmanx_display_open(display);
  ENFORCE(dispman_display_);

  {
    auto dispman_update = vc_dispmanx_update_start(0);
    ENFORCE(dispman_update);
    SCOPE_EXIT {
      ENFORCE(!vc_dispmanx_update_submit_sync(dispman_update));
    };

    dispman_element_ =
        vc_dispmanx_element_add(dispman_update,
                                dispman_display_,
                                layer,
                                &dst_rect,
                                0 /*src*/,
                                &src_rect,
                                DISPMANX_PROTECTION_NONE,
                                0 /*alpha*/,
                                0 /*clamp*/,
                                (DISPMANX_TRANSFORM_T) 0 /*transform*/);
    ENFORCE(dispman_element_);
  }
}