Exemplo n.º 1
0
OOP_Object *CM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
{
    struct Library *UtilityBase = CSD(cl)->cs_UtilityBase;
    struct Library *OOPBase = CSD(cl)->cs_OOPBase;
    struct colormap_data    *data;
    ULONG   	    	    numentries;
    struct TagItem  	    *tag, *tstate;
    BOOL    	    	    ok = FALSE;
    
    EnterFunc(bug("ColorMap::New()\n"));
    numentries = 256;
    
    for (tstate = msg->attrList; (tag = NextTagItem(&tstate)); )
    {
    	ULONG idx;
	
    	if (IS_COLORMAP_ATTR(tag->ti_Tag, idx))
	{
	    switch (idx)
	    {
	    	case aoHidd_ColorMap_NumEntries:
		    numentries = tag->ti_Data;
		    if (numentries > 256 || numentries < 0)
		    {
		     	D(bug("!!! ILLEGAL value for NumEntries in ColorMap::New()\n"));
		    }
		    break;
		   
	    } /* switch */
	
	}
    }
    
    /* Create the object */
    
    o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
    if (NULL == o)
    	return NULL;
	
    data = OOP_INST_DATA(cl, o);
    
    data->clut.entries = numentries;
    
    data->clut.colors = AllocMem(sizeof (HIDDT_Color) * data->clut.entries, MEMF_CLEAR);
    if (NULL != data->clut.colors)
    {
	ok = TRUE;
    }
    
    if (!ok)
    {
    	ULONG dispose_mid;
	
	dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
	OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
	o = NULL;
    }
    
    ReturnPtr("ColorMap::New", OOP_Object *, o);
}
Exemplo n.º 2
0
/*********** BitMap::New() *************************************/
OOP_Object *MNAME_ROOT(New)(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
{

    EnterFunc(bug("VesaGfx.BitMap::New()\n"));
    o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
    if (o)
    {
	struct BitmapData   *data;
	IPTR 	    	     width, height, depth, multi;
	OOP_Object  	    *friend, *pf;
	
	data = OOP_INST_DATA(cl, o);
	
	/* clear all data  */
	memset(data, 0, sizeof(struct BitmapData));
	
	/* Get attr values */
	OOP_GetAttr(o, aHidd_BitMap_Width, &width);
	OOP_GetAttr(o, aHidd_BitMap_Height, &height);
	OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (IPTR *)&data->gfxhidd);
	OOP_GetAttr(o, aHidd_BitMap_PixFmt, (IPTR *)&pf);
	data->pixfmtobj = pf;
	OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
	OOP_GetAttr(pf, aHidd_PixFmt_BytesPerPixel, &multi);
	
	/* Get the friend bitmap. This should be a displayable bitmap */
	OOP_GetAttr(o, aHidd_BitMap_Friend, (IPTR *)&friend);
	
	/* If you got a friend bitmap, copy its colormap */
	if (friend)
	{
	    struct BitmapData *src = OOP_INST_DATA(cl, friend);
	    CopyMem(&src->cmap, &data->cmap, 4*16);
	}
	
	ASSERT (width != 0 && height != 0 && depth != 0);
	
	width=(width+15) & ~15;
	data->width = width;
	data->height = height;
	data->bpp = depth;
	data->disp = 0;

	data->bytesperpix = multi;
	data->bytesperline = width * multi;
	
	data->VideoData = AllocVec(width*height*multi, MEMF_PUBLIC | MEMF_CLEAR);
	if (data->VideoData)
	{
	    data->data = &XSD(cl)->data;
	    
	    if (XSD(cl)->activecallback)
		XSD(cl)->activecallback(XSD(cl)->callbackdata, o, TRUE);
		
	    ReturnPtr("VesaGfx.BitMap::New()", OOP_Object *, o);
	} /* if got data->VideoData */
	
	{
	    OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
	    OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
	}
	
	o = NULL;
	
    } /* if created object */
Exemplo n.º 3
0
OOP_Object *PCVGAOnBM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
{
    EnterFunc(bug("VGAGfx.BitMap::New()\n"));

    o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
    if (o)
    {
    	struct bitmap_data *data;
	
		OOP_Object *pf;

        IPTR width, height, depth;
	
        data = OOP_INST_DATA(cl, o);

		/* clear all data  */
        memset(data, 0, sizeof(struct bitmap_data));
	
		/* Get attr values */
		OOP_GetAttr(o, aHidd_BitMap_Width,		&width);
		OOP_GetAttr(o, aHidd_BitMap_Height, 	&height);
		OOP_GetAttr(o,  aHidd_BitMap_PixFmt,	&pf);
		OOP_GetAttr(pf, aHidd_PixFmt_Depth,		&depth);
	
		ASSERT (width != 0 && height != 0 && depth != 0);
	
		/* 
		   We must only create depths that are supported by the friend drawable
	  	 Currently we only support the default depth
		*/

		data->width = width;
		data->height = height;
		data->bpp = depth;
		data->Regs = AllocVec(sizeof(struct vgaHWRec),MEMF_PUBLIC|MEMF_CLEAR);
		data->disp = -1;
		width=(width+15) & ~15;

		/*
			Here there is brand new method of getting pixelclock data.
			It was introduced here to make the code more portable. Besides
			it may now be used as a base for creating other low level
			video drivers
		*/

		if (data->Regs)
		{
		    data->VideoData = AllocVec(width*height,MEMF_PUBLIC|MEMF_CLEAR);
		    if (data->VideoData)
		    {
				struct vgaModeDesc mode;
				HIDDT_ModeID modeid;
				OOP_Object *sync;
				OOP_Object *pf;
				ULONG pixelc;
				
				/* We should be able to get modeID from the bitmap */
				OOP_GetAttr(o, aHidd_BitMap_ModeID, &modeid);
				
				if (modeid != vHidd_ModeID_Invalid)
				{
					struct Box box = {0, 0, width-1, height-1};
	
					/* Get Sync and PixelFormat properties */
					HIDD_Gfx_GetMode(XSD(cl)->vgahidd, modeid, &sync, &pf);

					mode.Width 	= width;
					mode.Height = height;
					mode.Depth 	= depth;
					OOP_GetAttr(sync, aHidd_Sync_PixelClock, &pixelc);

					mode.clock	= (pixelc > 26000000) ? 1 : 0;
					mode.Flags	= 0;
					mode.HSkew	= 0;
					OOP_GetAttr(sync, aHidd_Sync_HDisp, 		&mode.HDisplay);
					OOP_GetAttr(sync, aHidd_Sync_VDisp, 		&mode.VDisplay);
					OOP_GetAttr(sync, aHidd_Sync_HSyncStart, 	&mode.HSyncStart);
					OOP_GetAttr(sync, aHidd_Sync_VSyncStart, 	&mode.VSyncStart);
					OOP_GetAttr(sync, aHidd_Sync_HSyncEnd,		&mode.HSyncEnd);
					OOP_GetAttr(sync, aHidd_Sync_VSyncEnd,		&mode.VSyncEnd);
					OOP_GetAttr(sync, aHidd_Sync_HTotal,		&mode.HTotal);
					OOP_GetAttr(sync, aHidd_Sync_VTotal,		&mode.VTotal);
				    
				    ObtainSemaphore(&XSD(cl)->HW_acc);

				    /* Now, when the best display mode is chosen, we can build it */
				    vgaInitMode(&mode, data->Regs);
				    vgaLoadPalette(data->Regs,(unsigned char *)NULL);

				    /*
				       Because of not defined BitMap_Show method show 
				       bitmap immediately
				    */
		
				    vgaRestore(data->Regs, FALSE);
				    vgaRefreshArea(data, 1, &box);

				    ReleaseSemaphore(&XSD(cl)->HW_acc);

				    XSD(cl)->visible = data;	/* Set created object as visible */

				    ReturnPtr("VGAGfx.BitMap::New()", OOP_Object *, o);
				}
		
		    } /* if got data->VideoData */
		    FreeVec(data->Regs);
		} /* if got data->Regs */

		{
		    OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
	    	    OOP_CoerceMethod(cl, o, (OOP_Msg) &disp_mid);
		}
	
		o = NULL;
    } /* if created object */