NS_IMETHODIMP
EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
			   const PRUnichar *aTipText)
{
  nsAutoString tipText ( aTipText );
  const char* tipString = ToNewCString(tipText), *font = "TextFont08";
  PtArg_t args[10];
  PhRect_t extent;
  PhDim_t dim;
  PhPoint_t pos = {0, 0};
  int n = 0, w, h;

  if (sTipWindow)
    PtDestroyWidget(sTipWindow);
  
  // get the root origin for this content window
  nsCOMPtr<nsIWidget> mainWidget;
  mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget));
  PtWidget_t *window;
  window = static_cast<PtWidget_t *>(mainWidget->GetNativeData(NS_NATIVE_WINDOW));

  PgExtentText(&extent, &pos, font, tipString, 0);
  w = extent.lr.x - extent.ul.x + 1;
  h = extent.lr.y - extent.ul.y + 1;

  n = 0;
  pos.x = aXCoords;
  pos.y = aYCoords + 10; /* we add 10 so that we don't position it right under the mouse */
	dim.w = w + 6; dim.h = h + 6;
  PtSetArg(&args[n++], Pt_ARG_POS, &pos, 0);
  PtSetArg(&args[n++], Pt_ARG_DIM, &dim, 0);
	PtSetArg( &args[n++], Pt_ARG_REGION_OPAQUE,   Ph_EV_EXPOSE, Ph_EV_EXPOSE);
  sTipWindow = PtCreateWidget(PtRegion, Pt_NO_PARENT, n, args);

  n = 0;
  pos.x = pos.y = 0;
	dim.w = w; dim.h = h;
  PtSetArg(&args[n++], Pt_ARG_POS, &pos, 0);
  PtSetArg(&args[n++], Pt_ARG_DIM, &dim, 0);
  PtSetArg(&args[n++], Pt_ARG_FLAGS, Pt_HIGHLIGHTED, -1 );
  PtSetArg(&args[n++], Pt_ARG_FILL_COLOR, 0xfeffb1, 0);
  PtSetArg(&args[n++], Pt_ARG_TEXT_FONT, font, 0);
  PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, tipString, 0);
  PtSetArg(&args[n++], Pt_ARG_BASIC_FLAGS, Pt_STATIC_GRADIENT | Pt_TOP_OUTLINE | Pt_LEFT_OUTLINE |
      Pt_RIGHT_OUTLINE | Pt_BOTTOM_OUTLINE, -1 );
  PtCreateWidget(PtLabel, sTipWindow, n, args);

  // realize the widget
  PtRealizeWidget(sTipWindow);

  nsMemory::Free( (void*)tipString );

  return NS_OK;
}
static PtWidget_t *ph_CreateWindow(_THIS)
{
    PtWidget_t *widget;
    
    widget = PtCreateWidget(PtWindow, NULL, 0, 0);

    return widget;
}
示例#3
0
nsresult
nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth)
{
  PtWidget_t *mMenuBar= nsnull;
  void        *voidData;

  voidData = mWindow->GetNativeData(NS_NATIVE_WINDOW);
  mMenuBar = PtCreateWidget( PtMenuBar, (PtWidget_t *) voidData , 0, NULL);

  if (mMenuBar)
  {
      mWindow->ShowMenuBar( PR_TRUE );
      ::CreateViewerMenus(mMenuBar,this);
  }
  return NS_OK;
}
示例#4
0
PtWidget_t *tblInit(PtWidget_t *parent, PhPoint_t pos, PhDim_t dim)
{
  int c = 0;
  PtArg_t argsScrCon[6];
  tblWidget_t *tbl;
  PtCallback_t callbacks[1];

  assert(parent);

  if ((tbl = (tblWidget_t *)malloc(sizeof(tblWidget_t))) == NULL)
    PtExit(EXIT_FAILURE);

  memset(tbl, 0, sizeof(tblWidget_t));
  tbl->geom = pos;
  tbl->dim = dim;

  /* automatically scroll container resize both X and Y */
  PtSetArg(&argsScrCon[c++], Pt_ARG_SCROLLCONT_RESIZE_FLAGS,
      Pt_RESIZE_XY_ALWAYS, 0);
  PtSetArg(&argsScrCon[c++], Pt_ARG_BASIC_FLAGS,
      Pt_FLAT_FILL      |
      Pt_TOP_OUTLINE    |
      Pt_BOTTOM_OUTLINE |
      Pt_LEFT_OUTLINE   |
      Pt_RIGHT_OUTLINE, 0);
  PtSetArg(&argsScrCon[c++], Pt_ARG_POS, &pos, 0);
  PtSetArg(&argsScrCon[c++], Pt_ARG_DIM, &dim, 0);
  /* save the table into "data" in this container */
  PtSetArg(&argsScrCon[c++], Pt_ARG_POINTER, tbl, 0);

  callbacks[0].event_f = tblDestructionCB;
  callbacks[0].data = NULL;
  PtSetArg(&argsScrCon[c++], Pt_CB_DESTROYED, callbacks,
      sizeof(callbacks)/sizeof(callbacks[0]));

  /* another widget as a child of a parent */
  return PtCreateWidget(PtScrollContainer, parent, c, argsScrCon);
}
示例#5
0
int initStateDebugWindow( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
	PtWidget_t *scroll;
	PtWidget_t *allGroup;
	PtWidget_t *buttonGroup;
	PhPoint_t sPos;
	ApDBase_t *stateDebugdbase;
	PtArg_t args[6];
	int nArgs;
	int chainIndx;
	int chainStateIndx;
	int i, j;
	char buttonLabel[128];
	char timeStamp[32];

	/* eliminate 'unreferenced' warnings */
	link_instance = link_instance, apinfo = apinfo, cbinfo = cbinfo;

	/* get a pointer to the scroll container */
	scroll = ApGetWidgetPtr(link_instance, ABN_debugScrollContainer);

	/* create a master group widget */
	nArgs = 0;
	PtSetArg(&args[nArgs], Pt_ARG_GROUP_ORIENTATION, Pt_GROUP_HORIZONTAL, 0); ++nArgs;
	PtSetArg(&args[nArgs], Pt_ARG_GROUP_SPACING, 30, 0); ++nArgs;
	allGroup = PtCreateWidget(PtGroup, scroll, nArgs, args);
	
	/* open the state debug variables data base */
	stateDebugdbase = ApOpenDBase(ABM_stateDebugPictures);

	i = 0;
	chainIndx = -1;

	// if this paradigm was built with rebel
	if((snames[0]->rebelFlag1 == REBEL_FLAG1) && (snames[0]->rebelFlag2 == REBEL_FLAG2)) {
		while(snames[i]) {
			j = 0;
			while(nowstate[j].initial_state) {
				if(!strcmp(snames[i]->statename, nowstate[j].initial_state->statename)) {
					chainIndx++;		/* increment chain index */
					chainStateIndx = 0;	/* initial this chain's state index */

					/* create a group widget to hold the state buttons */
					nArgs = 0;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_ORIENTATION, Pt_GROUP_ASIS, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
							 Pt_LEFT_ANCHORED_LEFT|Pt_TOP_ANCHORED_TOP|Pt_BOTTOM_ANCHORED_BOTTOM); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_FLAGS, Pt_TRUE, Pt_GROUP_EQUAL_SIZE); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateButtonColors[2], 0); ++nArgs;
					buttonGroup = PtCreateWidget(PtGroup, allGroup, nArgs, args);
				}
				j++;
			}

			/* create a set of buttons in the group */
			if(snames[i]->preset) strcpy(buttonLabel, "T");
			else strcpy(buttonLabel, "-");

			if(snames[i]->random) strcat(buttonLabel, "R");
			else strcat(buttonLabel, "-");

			strncat(buttonLabel, snames[i]->statename, 10);
			sprintf(timeStamp, "  %ld", stateDebug[i].time);
			strcat(buttonLabel, timeStamp);
			sPos.x = snames[i]->stateXpos;
			sPos.y = snames[i]->stateYpos;

			nArgs = 0;
			PtSetArg(&args[nArgs], Pt_ARG_TEXT_STRING, buttonLabel, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateDebug[i].color, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_USER_DATA, &i, sizeof(int)); ++nArgs;
			chainStates[chainIndx][chainStateIndx].stateButton = ApCreateWidget(stateDebugdbase, "stateButton", sPos.x, sPos.y, nArgs, args);
			chainStates[chainIndx][chainStateIndx].stateIndex = i;
			chainStateIndx++;
		
			i++;
		}
	}
	// if this paradigm was built with spot
	else {
		while(snames[i]) {
			j = 0;
			while(nowstate[j].initial_state) {
				if(!strcmp(snames[i]->statename, nowstate[j].initial_state->statename)) {
					chainIndx++;		/* increment chain index */
					chainStateIndx = 0;	/* initial this chain's state index */

					/* create a group widget to hold the state buttons */
					nArgs = 0;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_ORIENTATION, Pt_GROUP_VERTICAL, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_ROWS_COLS, 24, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
							 Pt_LEFT_ANCHORED_LEFT|Pt_TOP_ANCHORED_TOP|Pt_BOTTOM_ANCHORED_BOTTOM); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_SPACING, 4, 0); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_GROUP_FLAGS, Pt_TRUE, Pt_GROUP_EQUAL_SIZE); ++nArgs;
					PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateButtonColors[2], 0); ++nArgs;
					buttonGroup = PtCreateWidget(PtGroup, allGroup, nArgs, args);
				}
				j++;
			}

			/* create a set of buttons in the group */
			if(snames[i]->preset) strcpy(buttonLabel, "T");
			else strcpy(buttonLabel, "-");

			if(snames[i]->random) strcat(buttonLabel, "R");
			else strcat(buttonLabel, "-");

			strncat(buttonLabel, snames[i]->statename, 10);
			sprintf(timeStamp, "  %ld", stateDebug[i].time);
			strcat(buttonLabel, timeStamp);

			nArgs = 0;
			PtSetArg(&args[nArgs], Pt_ARG_TEXT_STRING, buttonLabel, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_FILL_COLOR, stateDebug[i].color, 0); ++nArgs;
			PtSetArg(&args[nArgs], Pt_ARG_USER_DATA, &i, sizeof(int)); ++nArgs;
			chainStates[chainIndx][chainStateIndx].stateButton = ApCreateWidget(stateDebugdbase, "stateButton", 0, 0, nArgs, args);
			chainStates[chainIndx][chainStateIndx].stateIndex = i;
			chainStateIndx++;
		
			i++;
		}
	}

	PtSetArg(&args[0], Pt_ARG_USER_DATA, 0, 0);
	PtGetResources(chainStates[0][0].stateButton, 1, &args[0]);
	ApCloseDBase(stateDebugdbase);

	return( Pt_CONTINUE );
}
示例#6
0
文件: vout.c 项目: FLYKingdom/vlc
/*****************************************************************************
 * QNXCreateWnd: create and realize the main window
 *****************************************************************************/
static int QNXCreateWnd( vout_thread_t * p_vout )
{
    PtArg_t args[8];
    PhPoint_t pos = { 0, 0 };
    PgColor_t color = Pg_BLACK;

    if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY )
    {
        if( p_vout->p_sys->i_vc_flags & Pg_SCALER_CAP_DST_CHROMA_KEY )
        {
            color = PgGetOverlayChromaColor();
        }
    }

    /* fullscreen, set dimension */
    if( p_vout->b_fullscreen )
    {
        p_vout->p_sys->old_dim.w = p_vout->p_sys->dim.w;
        p_vout->p_sys->old_dim.h = p_vout->p_sys->dim.h;
        p_vout->output.i_width = p_vout->p_sys->dim.w = p_vout->p_sys->screen_dim.w;
        p_vout->output.i_height = p_vout->p_sys->dim.h = p_vout->p_sys->screen_dim.h;
    }

    /* set window parameters */
    PtSetArg( &args[0], Pt_ARG_POS, &pos, 0 );
    PtSetArg( &args[1], Pt_ARG_DIM, &p_vout->p_sys->dim, 0 );
    PtSetArg( &args[2], Pt_ARG_FILL_COLOR, color, 0 );
    PtSetArg( &args[3], Pt_ARG_WINDOW_TITLE, "VLC media player", 0 );
    PtSetArg( &args[4], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE );
    PtSetArg( &args[5], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
              Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_CLOSE );
    PtSetArg( &args[6], Pt_ARG_WINDOW_RENDER_FLAGS,
              p_vout->b_fullscreen ? Pt_FALSE : Pt_TRUE,
              Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE );

    /* create window */
    p_vout->p_sys->p_window = PtCreateWidget( PtWindow, Pt_NO_PARENT, 7, args);
    if( p_vout->p_sys->p_window == NULL )
    {
        msg_Err( p_vout, "unable to create window" );
        return( 1 );
    }

    /* realize the window widget */
    if( PtRealizeWidget( p_vout->p_sys->p_window ) != 0 )
    {
        msg_Err( p_vout, "unable to realize window widget" );
        PtDestroyWidget( p_vout->p_sys->p_window );
        return( 1 );
    }

    /* get window frame size */
    if( PtWindowFrameSize( NULL, p_vout->p_sys->p_window,
                           &p_vout->p_sys->frame ) != 0 )
    {
        msg_Err( p_vout, "unable to get window frame size" );
        PtDestroyWidget( p_vout->p_sys->p_window );
        return( 1 );
    }

    return( 0 );
}
int main( int argc, char *argv[] )
{
  PtWidget_t *window, *container, *grid, *divider, *column00, *column01;
  PtArg_t args[20];
  int i = 0;

  /* Create a window */
  i = 0;
  PtSetArg( &args[i++], Pt_ARG_WINDOW_TITLE, "demo window", 0 );
  if ( NULL == ( window = PtAppInit( NULL, &argc, argv, i, args ) ) ) {
    perror( "PtAppInit()" );
    return 1;
  }

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_ANCHOR_FLAGS,
      Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP |
      Pt_LEFT_ANCHORED_LEFT     | Pt_RIGHT_ANCHORED_RIGHT,
      Pt_IS_ANCHORED);
  container = PtCreateWidget( PtContainer, window, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_ANCHOR_FLAGS,
      Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP |
      Pt_LEFT_ANCHORED_LEFT     | Pt_RIGHT_ANCHORED_RIGHT,
      Pt_IS_ANCHORED);
  grid = PtCreateWidget( PtScrollContainer, container, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtSetArg( &args[i++], Pt_ARG_DIVIDER_FLAGS, Pt_FALSE, Pt_DIVIDER_RESIZE_BOTH );
  //PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
  //    Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS | Pt_AUTO_EXTENT, 0 );
  divider = PtCreateWidget( PtDivider, grid, i, args );

  /* Set layout type and layout info */
  PtRowLayoutInfo_t info;
  info.type = Pt_LAYOUT_VERTICAL;
  info.flags = 0;  // all widgets will have the same size
  info.margin.ul.x = 0;  // upper left
  info.margin.ul.y = 0;
  info.margin.lr.x = 0;  // lower right
  info.margin.lr.y = 0;
  info.h_spacing = 0;
  info.v_spacing = 0;

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
      Pt_AUTO_EXTENT | Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS, 0 );
  PtSetArg( &args[i++], Pt_ARG_LAYOUT, PtRowLayout, &info );
  column00 = PtCreateWidget( PtContainer, divider, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_CONTAINER_FLAGS,
      Pt_AUTO_EXTENT | Pt_ENABLE_CUA | Pt_ENABLE_CUA_ARROWS, 0 );
  PtSetArg( &args[i++], Pt_ARG_LAYOUT, PtRowLayout, &info );
  column01 = PtCreateWidget( PtContainer, divider, i, args );

  /* column00 buttons */

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "T1", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtText, column00, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Button 2 (two)", 0);
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column00, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Butt 3", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column00, i, args );

  /* column01 buttons */

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "B4", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column01, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Butt 5", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column01, i, args );

  i = 0;
  PtSetArg( &args[i++], Pt_ARG_TEXT_STRING, "Buttonchen 6", 0 );
  //PtSetArg( &args[i++], Pt_ARG_RESIZE_FLAGS, Pt_RESIZE_XY_ALWAYS, 0 );
  PtCreateWidget( PtButton, column01, i, args );

  PtRealizeWidget( window );
  PtMainLoop();

  return 0;
}
示例#8
0
int ph_window_create_display (int bitmap_depth)
{
	PtArg_t arg[9];
	PhRect_t rect;
    PhRegion_t region_info;
    
    // Only image_height??!!
    int image_height;
    int window_width, window_height;

	// Create the Photon Window

	view_size.w = widthscale * visual_width;
	view_size.h = heightscale * visual_height;
	
    image_width      = widthscale  * visual_width;
    image_height     = heightscale * visual_height;
    
    // TODO: Finish always ontop (Make phearbear happy)
	PtSetArg( &arg[0], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 );
	PtSetArg( &arg[1], Pt_ARG_WINDOW_MANAGED_FLAGS, 0, Ph_WM_MAX | Ph_WM_RESIZE | Ph_WM_MENU | Ph_WM_CLOSE | Ph_WM_HIDE );
	PtSetArg( &arg[2], Pt_ARG_DIM, &view_size, 0 );
	PtSetArg( &arg[3], Pt_ARG_WINDOW_NOTIFY_FLAGS, Ph_WM_FOCUS, Ph_WM_FOCUS | Ph_WM_RESIZE | Ph_WM_CLOSE );
	PtSetArg( &arg[4], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_MENU | Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_MIN | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RESIZE );
	PtSetArg( &arg[5], Pt_ARG_WINDOW_TITLE, title, 0);
	//PtSetArg( &arg[6], Pt_ARG_WINDOW_STATE, 0, Ph_WM_STATE_ISFRONT );
	
	PtSetParentWidget(NULL);
	if((P_mainWindow = PtCreateWidget(PtWindow, NULL, 6, arg)) == NULL)
		fprintf(stderr,"error: could not create main photon window.\n");

	/* add raw callback handler */
	PtAddEventHandler( P_mainWindow,
		Ph_EV_BUT_PRESS |
		Ph_EV_BUT_RELEASE |
		Ph_EV_BOUNDARY |
		Ph_EV_EXPOSE |
		Ph_EV_PTR_MOTION |
		Ph_EV_KEY |
		Ph_EV_INFO,
		I_GetEvent,
		NULL );

	/* set draw buffer size */
	PgSetDrawBufferSize( 0xFF00 );

	PtRealizeWidget( P_mainWindow );

	if (show_cursor == FALSE)
	{
    	region_info.cursor_type = Ph_CURSOR_NONE;
    	region_info.rid = PtWidgetRid(P_mainWindow);
    	PhRegionChange (Ph_REGION_CURSOR, 0, &region_info, NULL, NULL); // turn off cursor
	}


	/* create and setup the image */
	switch (ph_window_update_method)
	{
		case PH_NORMAL:

//		image = PdCreateOffscreenContext(0, ((view_size.w+7) & ~7), view_size.h, Pg_OSC_MEM_PAGE_ALIGN);
		image = PdCreateOffscreenContext(0, view_size.w, view_size.h, Pg_OSC_MEM_PAGE_ALIGN);
	 	if (image == NULL)
	 	{
			fprintf(stderr_file, "error: failed to create offscreen context\n");
			return OSD_NOT_OK;
		}

		scaled_buffer_ptr = PdGetOffscreenContextPtr (image);
		if (!scaled_buffer_ptr)
		{
			fprintf (stderr_file, "error: failed get a pointer to offscreen context.\n");
			PhDCRelease (image);
			return OSD_NOT_OK;
		}

		depth = 0;

		switch (image->format)
		{
			case Pg_IMAGE_PALETTE_BYTE   :
			// TODO :
			break;
			case Pg_IMAGE_DIRECT_565  :
				depth = 16;
				pixels_per_line = image->pitch >> 1;
			break;
			case Pg_IMAGE_DIRECT_555  :
			// TODO:
			break;
			case Pg_IMAGE_DIRECT_888  :
				depth = 24;
				pixels_per_line = image->pitch / 3;
			break;	
			case Pg_IMAGE_DIRECT_8888 :
				depth = 32;
				pixels_per_line = image->pitch >> 2;
			break;
		}
		break;
	
		default:
			fprintf (stderr_file, "error: unknown photon update method, this shouldn't happen\n");
		return OSD_NOT_OK;
	}

	/* setup the palette_info struct now we have the depth */
	if (ph_init_palette_info() != OSD_OK)
	return OSD_NOT_OK;

	fprintf(stderr_file, "Actual bits per pixel = %d...\n", depth);
    if (bitmap_depth == 32)
   {
      if (depth == 32)
         ph_window_update_display_func = ph_window_update_32_to_32bpp_direct;
   }
	else if (bitmap_depth == 16)
	{
		switch(depth)
		{
			case 16:
				ph_window_update_display_func = ph_window_update_16_to_16bpp;
			break;
			case 24:
				ph_window_update_display_func = ph_window_update_16_to_24bpp;
			break;
			case 32:
				ph_window_update_display_func = ph_window_update_16_to_32bpp;
			break;
		}
	}

	if (ph_window_update_display_func == NULL)
	{
		fprintf(stderr_file, "error: unsupported\n");
		return OSD_NOT_OK;
	}

	fprintf(stderr_file, "Ok\n");

	return OSD_OK;
}
示例#9
0
main(int argc,char *argv[])
{
	CoolImage *image;
	int x,y;
	int i,j;
	PtWidget_t *win;
	PtArg_t args[3];
	PhDim_t dim={m_W,m_H};
	PhPoint_t pos={50,250};
	int fd; //Bt878 driver file descriptor
	int fd_temp;
	int size_read;
	struct timeval tv;
    fd_set rfd;
    int n;
	int error;
	int counter = 0;
	int counter_mean = 0;
	int file = 0;


	//Timing calculation
    uint64_t cps, cycle1, cycle2, ncycles;
    float sec;
    float msec;

	// if a paramater was passed, grab it as the blit type 
	if (argc>1) blittype=atoi(argv[1]);

	// initialize our connection to Photon, and create/realize a window 
	//PtInit("/net/irene2/dev/photon");
	PtInit("/dev/photon");
	PtSetArg(&args[0],Pt_ARG_POS,&pos,0);
	PtSetArg(&args[1],Pt_ARG_DIM,&dim,0);
	win=PtCreateWidget(PtWindow,Pt_NO_PARENT,2,args);
	PtRealizeWidget(win);

	// Allocate and fill a series of NUMIMAGES images with a little 
	// fading type animation.  Put your own animation in here if you like.


	/*
     *    Set a 5 second timeout.
     */
    tv.tv_sec = 5;
    tv.tv_usec = 0;

	image = AllocBuffer(m_W,m_H,fd);	
	assert(image!=0);
	
	if (file != 2)
	{
	init_bttvx(2,0, m_W,m_H,0,0);
	open_bttvx();
	
	BttvxSetImageBuffer(0, image->buffer);
	}
	fd_temp = fd;
	FD_ZERO( &rfd );
	FD_SET( fd, &rfd );
	
	
	while(1)
	{
		//fd = open("/net/europa/dev/bttvx0",O_RDWR);
		//if ( fd > 0 )
		//{
			
			///switch ( n = select( 1 + max( fd,0 ),
			///   &rfd, 0, 0, &tv ) ) 
			///{
			///  case -1:
			///	perror( "select" );
			///	return EXIT_FAILURE;
			///  case  0:
			///	puts( "select timed out" );
			///	break;
			///  default:
				//printf( "descriptor ready ...\n");
				//if( FD_ISSET( console, &rfd ) )
				//  puts( " -- console descriptor has data pending" );
				//if( FD_ISSET( serial, &rfd ) )
				//  puts( " -- serial descriptor has data pending" );
				/* Read the text */

				cycle1=ClockCycles( );

				//lseek(fd,0L,SEEK_SET);
			///	size_read = read( fd, image->buffer, W*H*deep );
		   if (file != 2)
		   {
		   BttvxWaitEvent();
		   BttvxAcquireBuffer(image->buffer);	
		    }
		   
		   switch(file)
		   {
		   	case 0:
		   		BlitBuffer(win,image);
		   		break;
		   	case 1:
		   		SaveImage(counter,image);
		   		break;
		   	case 2:
		   		
		   		LoadImage(counter,image);
		   		BlitBuffer(win,image);
		   		getchar();
		   		break;
		   };
		   
		   if (file!=2)
		   	BttvxReleaseBuffer();
		   cycle2=ClockCycles( );
		   counter++;
		   counter_mean++;

		   
		   ncycles=cycle2-cycle1;
		   //printf("%lld cycles elapsed \n", ncycles);

		   /* find out how many cycles per second */
		
		   cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
		   //printf( "This system has %lld cycles/sec.\n",cps );
		   sec=(float)ncycles/cps;
		   msec +=sec;
		   if (counter_mean == 250 )
		   {
		   	msec = msec/counter_mean;
		   	printf("The cycles in seconds is %f \n",msec);
		   	counter_mean = 0;
		   	msec = 0;
		   }
		//}else
			//sleep(2);
		}

	//printf("Blitted %d frames using method %d\n",REPS*NUMIMAGES,blittype);

	// now free the images
	FreeBuffer(image);
	close( fd );
	/// hide the window and destroy it.
	PtUnrealizeWidget(win);
	PtDestroyWidget(win);
}