Beispiel #1
0
StatusType NextValue_runtime(thread_queue_t * global_q, int port_id, void * dst)
{
  StatusType status = E_OK;
  struct port_queue_t *port_q = (struct port_queue_t*) global_q->port_queues[port_id];
  status = GetResource(*(global_q->rez));
  if (status != E_OK)
    return status;

  if(port_q->first_idx == port_q->last_idx)
  {
    if(port_q->blocking)
    {
      global_q->waiting=global_q->waiting+1;
      ReleaseResource(*(global_q->rez));
      status = WaitEvent(*(global_q->event));
      GetResource(*(global_q->rez));
      global_q->waiting=global_q->waiting-1;
    }
    else
    {
      ReleaseResource(*(global_q->rez));
      return E_OS_LIMIT;
    }
  }
  if(port_q->first_idx < port_q->last_idx)
    port_q->first_idx=(port_q->first_idx+1)%port_q->queue_size;

  memcpy(dst, &port_q->offset[(port_q->first_idx)*(port_q->msg_size/sizeof(char))], port_q->msg_size);

  global_q->msg_nb--;
  
  ReleaseResource(*(global_q->rez));
  return status;
}
Beispiel #2
0
//主进程
void main(void)
{
	//创建Opengl渲染环境及窗口
	char *device = "opengl";
	HCoreResizeFunc( ResizeWindow );
	HCoreCreateWindow(100, 100, 800, 600, device);

	if ( !HCoreInitGraphicsDevice(device) )
	{
		printf("初始化失败 \n", device);
		exit(0);
	}
	
	//注册输入函数
	HCoreInputInit();

	HCoreRegisterKeyDown(HCoreKEY_0, KeyDown_0);
	HCoreRegisterKeyDown(HCoreKEY_1, KeyDown_1);
	HCoreRegisterKeyDown(HCoreKEY_2, KeyDown_2);
	HCoreRegisterKeyDown(HCoreKEY_3, KeyDown_3);
	HCoreRegisterKeyDown(HCoreKEY_4, KeyDown_4);
	HCoreRegisterKeyDown(HCoreKEY_5, KeyDown_5);
	HCoreRegisterKeyDown(HCoreKEY_6, KeyDown_6);
	HCoreRegisterKeyDown(HCoreKEY_7, KeyDown_7);
	HCoreRegisterKeyDown(HCoreKEY_8, KeyDown_8);
	HCoreRegisterKeyDown(HCoreKEY_9, KeyDown_9);
	
	//设置相机
	g_Control.SetCamera(Vector4(0.0f, 0.0f, 1.0f), Vector4(0.0f, 1.0f, 1.0f), Vector4(0.0f, 0.0f, 1.0f) );

	//读取模型
	//地形
	g_Model.Load_ASCII("..\\models\\terrain.gma");
	//棋盘
	g_SSAOModel.Load_ASCII("..\\models\\chess.gma");

	// 载入shader
	if ( !InitResource() )
	{
		ReleaseResource();
		exit(0);
	}

	// 主循环
	while( HCoreProcessMessage() )
	{
		GetUserInput();
		RenderFrame();
	}

	// 释放shader
	ReleaseResource();

	// 关闭OpenGL绘图设备
	HCoreReleaseGraphicsDevice();
}
Beispiel #3
0
void ReleaseAnimatedCursors( void )
{
	short i;
	if ( gCursorList )
	{
		for ( i = 0; i< (*gCursorList)->numberOfFrames; i++ )
			ReleaseResource( (Handle) (*gCursorList)->frame[i] );
		ReleaseResource( (Handle) gCursorList );
	}
}
Beispiel #4
0
void
ShowLogo(Boolean bEraseRect)
{
	short 		reserr;
	Rect 		derefd, logoRect;
	PicHandle 	logoPicH;
	Handle		logoRectH; 

	/* draw the image well */
    ControlHandle imgWellH = GetNewControl(rLogoImgWell, gWPtr);
    if (!imgWellH)
    {
        ErrorHandler(eMem, nil);
        return;
	}

	/* initialize Netscape logo */
	logoPicH = GetPicture(rNSLogo);  
	reserr = ResError();
	
	if (reserr == noErr)
	{
		/* draw Netscape logo */
		if (logoPicH != nil)
		{		
			logoRectH = GetResource('RECT', rNSLogoBox);
			reserr = ResError();
			if (reserr == noErr && logoRectH)
			{
				HLock(logoRectH);
				derefd = (Rect) **((Rect**)logoRectH);
				SetRect(&logoRect, derefd.left, derefd.top, derefd.right, derefd.bottom);
				HUnlock(logoRectH);
				reserr = ResError();
				if (reserr == noErr)
				{
					if (bEraseRect)
					{
						EraseRect(&logoRect);
						InvalRect(&logoRect);
					}
					DrawPicture(logoPicH, &logoRect);
					ReleaseResource((Handle)logoPicH);
				}
				
				ReleaseResource((Handle)logoRectH);
			}
		}
	}
	
	if (reserr != noErr)
		ErrorHandler(reserr, nil);
}
Beispiel #5
0
BOOLEAN
NameCacheFree(PKLG_NAME_CACHE pNameCache, ULONG key)
{
	PNAMECACHE	Entry;
	PNAMECACHE	Prev;
	ULONG i;

	if (pNameCache == NULL)
		return FALSE;

	Prev = NULL;
	i = HASH_FUNC(key);
	AcquireResource(&pNameCache->m_CacheResource, TRUE);
	Entry=pNameCache->m_NameCache[i];
	while(Entry && Entry->Key!=key)
	{
		Prev=Entry;
		Entry=Entry->Next;
	}
	if(!Entry)
	{
		DbPrint(DC_NAMEC,DL_SPAM, ("CacheFree-%x %x not found. NCLen=%d\n",pNameCache,key,pNameCache->m_NCLen));
		ReleaseResource(&pNameCache->m_CacheResource);
	
		return FALSE;
	}
	Entry->RefCount--;
	if(Entry->RefCount)
	{
		DbPrint(DC_NAMEC,DL_INFO, ("CacheFree-%x. Owner=%x Ref decr for key %x ("_STRING_DEF") NCLen=%d\n",
			pNameCache, Entry->Owner, Entry->Key, Entry->Name, pNameCache->m_NCLen));
		ReleaseResource(&pNameCache->m_CacheResource);
		
		return TRUE;
	}
	if(Prev)
		Prev->Next = Entry->Next;
	else
		pNameCache->m_NameCache[i]=Entry->Next;

#ifdef __DBG__
	pNameCache->m_NCLen--;
	pNameCache->m_NameCacheLen[i]--;
	DbPrint(DC_NAMEC,DL_INFO, ("CacheFree-%x. Owner=%x Freed key %x ("_STRING_DEF") NCLen=%d\n", pNameCache, 
		Entry->Owner, Entry->Key, Entry->Name, pNameCache->m_NCLen));
#endif
	ReleaseResource(&pNameCache->m_CacheResource);
	ExFreePool(Entry);
	
	return TRUE;
}
Beispiel #6
0
wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
{
    m_refData = new wxCursorRefData;
    if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE )
    {
        Str255 theName ;
        wxMacStringToPascal( cursor_file , theName ) ;

        wxStAppResource resload ;
        Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ;
        if ( resHandle )
        {
            short theId = -1 ;
            OSType theType ;
            GetResInfo( resHandle , &theId , &theType , theName ) ;
            ReleaseResource( resHandle ) ;
            M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
            if ( M_CURSORDATA->m_hCursor )
                M_CURSORDATA->m_isColorCursor = true ;
        }
        else
        {
            Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ;
            if ( resHandle )
            {
                short theId = -1 ;
                OSType theType ;
                GetResInfo( resHandle , &theId , &theType , theName ) ;
                ReleaseResource( resHandle ) ;
                 M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
                if ( M_CURSORDATA->m_hCursor )
                    M_CURSORDATA->m_releaseHandle = true ;
            }
        }
    }
    else
    {
        wxImage image ;
        image.LoadFile( cursor_file , flags ) ;
        if( image.Ok() )
        {
            image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X,hotSpotX ) ;
            image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y,hotSpotY ) ;
            delete m_refData ;
            CreateFromImage(image) ;
        }
    }
}
Beispiel #7
0
// Pass resFile as -1 to use the current resource file
// true = exists
Boolean IndResourceExists(short resFile,ResType resType,short inIndex)
{
	short 	oldRes=::CurResFile();
	Handle	theRes=0L;
	
	if (resFile!=-1)
	{
		UseResFile(resFile);
		if (ResError())
			return false;
	}
	
	SetResLoad(false);
	theRes=Get1IndResource(resType,inIndex);
	SetResLoad(true);
	UseResFile(oldRes);
	
	if (theRes)
	{
		ReleaseResource(theRes);
		return true;
	}
	else
		return false;
}
Beispiel #8
0
VOID
NameCacheGetReplaceBinary(PKLG_NAME_CACHE pNameCache, ULONG key, PVOID Value, DWORD ValueLen)
{
	PVOID pRet = NULL;
	BOOLEAN bOverBuf = FALSE;
	if (pNameCache == NULL)
	{
		DbPrint(DC_NAMEC,DL_SPAM, ("NameCacheReplaceBinary: wrong internal status - NULL\n"));
		return;
	}
		
	AcquireResource(&pNameCache->m_CacheResource, FALSE);
	
	pRet = NameCacheGetBase(pNameCache, key, NULL, ValueLen, &bOverBuf, FALSE, NULL);
	if (bOverBuf == TRUE)
	{
		DbPrint(DC_NAMEC, DL_WARNING, ("NameCacheReplaceBunary: size mismatch\n"));
		DbgBreakPoint();
	}
	else
	{
		if (pRet != NULL)
			memcpy(pRet, Value, ValueLen);
	}
		
	ReleaseResource(&pNameCache->m_CacheResource);
}
Beispiel #9
0
VOID
NameCacheClean(PKLG_NAME_CACHE pNameCache)
{
	ULONG	i;
	PNAMECACHE	Tmp,Entry;
	if (pNameCache == NULL)
	{
		DbPrint(DC_NAMEC,DL_INFO, ("NameCacheClean: wrong internal status - NULL\n"));
		return;
	}

	AcquireResource(&pNameCache->m_CacheResource, TRUE);
	for(i =0; i < HASH_SIZE; i++)
	{
		Entry=pNameCache->m_NameCache[i];
		while(Entry)
		{
			Tmp=Entry->Next;
			ExFreePool(Entry);
			Entry = Tmp;
#ifdef __DBG__
			pNameCache->m_NCLen--;
			pNameCache->m_NameCacheLen[i]--;
#endif
		}
		pNameCache->m_NameCache[i] = NULL;
	}
	DbPrint(DC_NAMEC,DL_NOTIFY, ("CacheCleanup-%x. NCLen=%d\n",pNameCache,pNameCache->m_NCLen));
	ReleaseResource(&pNameCache->m_CacheResource);
}
Beispiel #10
0
OSErr GetConfig(Ptr config)
{
	OSErr			error = noErr;
	FSSpec		where;
	short			ref;
	Handle		theString;
	Ptr			temp = nil;
	long			len;
	config[0] = '\0';											// Start without a name
	error = FindPrefs(&where);
	ref = FSpOpenResFile(&where, fsRdWrPerm);
	if (ref != -1) {
		theString = Get1Resource('STR ',kConfigRes);	// Should look in most recent file first
		if (theString != nil) {
			len = SizeResource(theString);
			SetPtrSize(config, len);						// Set the size
			error = MemError();								// And make sure it worked
			if (error == noErr) {
				HLock(theString);
				temp = (Ptr)*theString;
				memcpy(config, temp, len);
				HUnlock(theString);
				ReleaseResource(theString);
			}
		} else {
			error = -4;
		}
		CloseResFile(ref);
	} else {
		error = ResError();
	}
	return error;
}
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance2(void)
{
	ApplicationType result_app_1;
	StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4;
	ScheduleTableStatusType ScheduleTableStatusType_inst_1;
	TickType TickType_inst_1;
	
	SCHEDULING_CHECK_INIT(10);
	result_app_1 = GetApplicationID(); 
	SCHEDULING_CHECK_AND_EQUAL_INT(10, app1, result_app_1);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_1 = GetAlarm(Alarm1, &TickType_inst_1); 
	SCHEDULING_CHECK_AND_EQUAL_INT(11, E_OS_NOFUNC, result_inst_1);
		
	SCHEDULING_CHECK_INIT(12);
	result_inst_2 = GetScheduleTableStatus(sched1, &ScheduleTableStatusType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(12 , SCHEDULETABLE_STOPPED , ScheduleTableStatusType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(12, E_OK, result_inst_2);
	
	SCHEDULING_CHECK_INIT(13);
	result_inst_3 = ReleaseResource(Resource1); 
	SCHEDULING_CHECK_AND_EQUAL_INT(13, E_OS_NOFUNC, result_inst_3);
	
	SCHEDULING_CHECK_INIT(14);
	result_inst_4 = TerminateApplication(app1, NO_RESTART); 
	SCHEDULING_CHECK_AND_EQUAL_INT(140, E_OK, result_inst_4);
			
}
HRESULT
D3DResourceManager::GetLockableRTSurface(UINT width, UINT height,
                                         D3DFORMAT format,
                                         D3DResource **ppSurfaceResource)
{
    HRESULT res = S_OK;

    J2dTraceLn(J2D_TRACE_INFO, "D3DRM::GetLockableRTSurface");
    RETURN_STATUS_IF_NULL(pCtx, E_FAIL);
    RETURN_STATUS_IF_NULL(ppSurfaceResource, E_FAIL);

    if (pLockableRTSurface != NULL) {
        D3DSURFACE_DESC *pDesc = pLockableRTSurface->GetDesc();
        if (width <= pDesc->Width && height <= pDesc->Height &&
            format == pDesc->Format)
        {
            *ppSurfaceResource = pLockableRTSurface;
            return res;
        }
        // current surface doesn't fit, release and allocate a new one
        ReleaseResource(pLockableRTSurface);
        pLockableRTSurface = NULL;
    }
    if (width  < D3DC_BLIT_TILE_SIZE) width  = D3DC_BLIT_TILE_SIZE;
    if (height < D3DC_BLIT_TILE_SIZE) height = D3DC_BLIT_TILE_SIZE;

    res = CreateRTSurface(width,height,
                          (format != D3DFMT_A8R8G8B8), TRUE /*lockable*/,
                          &format, &pLockableRTSurface);
    *ppSurfaceResource = pLockableRTSurface;

    return res;
}
Beispiel #13
0
void createOffscreen(int pictItem)
{
	PicHandle	pict;
	Rect		rect;
	CGrafPtr	currentPort;
	GDHandle	currentDevice;
	
	if (gGWorld != nil)
		DisposeGWorld( gGWorld );
	
	pict = (PicHandle)GetResource( 'PICT', pictItem + 127 );
	
	rect = (**pict).picFrame;
	
	GetGWorld( &currentPort, &currentDevice );
	NewGWorld( &gGWorld, 32, &rect, nil, nil, 0 );
		
	LockPixels( GetPortPixMap(gGWorld));
	SetGWorld( gGWorld, nil );

	DrawPicture( pict, &rect );
	
	SetGWorld( currentPort, currentDevice );
	
	ReleaseResource( (Handle)pict );
}
extern int8_t ciaaModbus_gatewayAddMaster(
      int32_t hModbusGW,
      int32_t hModbusMaster)
{
   uint32_t loopi;
   int8_t ret = -1;

   if ( (0 <= hModbusGW) && (0 <= hModbusMaster))
   {
      /* enter critical section */
      GetResource(MODBUSR);

      for (loopi = 0 ; (loopi < CIAA_MODBUS_GATEWAY_TOTAL_CLIENTS) && (ret != 0) ; loopi++)
      {
         if (ciaaModbus_gatewayObj[hModbusGW].client[loopi].inUse == false)
         {
            ciaaModbus_gatewayObj[hModbusGW].client[loopi].inUse = true;
            ciaaModbus_gatewayObj[hModbusGW].client[loopi].handler = hModbusMaster;
            ciaaModbus_gatewayObj[hModbusGW].client[loopi].recvMsg = ciaaModbus_masterRecvMsg;
            ciaaModbus_gatewayObj[hModbusGW].client[loopi].sendMsg = ciaaModbus_masterSendMsg;
            ciaaModbus_gatewayObj[hModbusGW].client[loopi].task = ciaaModbus_masterTask;
            ciaaModbus_gatewayObj[hModbusGW].client[loopi].getRespTimeout = ciaaModbus_masterGetRespTimeout;
            ret = 0;
         }
      }

      /* exit critical section */
      ReleaseResource(MODBUSR);
   }

   return ret;
}
Beispiel #15
0
void WriteThumbnailToResourceFork(FSRef *ref, int destWidth, int destHeight)
{
	OSStatus		err;
	PicHandle		pict;
	HFSUniStr255	fork;
	SInt16			resf;
	
	err = FSGetResourceForkName(&fork);
	if (err == noErr)
	{
		err = FSCreateResourceFork(ref, fork.length, fork.unicode, 0);
		if ((err == noErr) || (err == errFSForkExists))
		{
			err = FSOpenResourceFile(ref, fork.length, fork.unicode, fsWrPerm, &resf);
			if (err == noErr)
			{
				pict = GetScreenAsPicHandle(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight, destWidth, destHeight);
				if (pict)
				{
					AddResource((Handle) pict, 'PICT', 128, "\p");
					WriteResource((Handle) pict);
					ReleaseResource((Handle) pict);
				}
				
				CloseResFile(resf);
			}
extern int8_t ciaaModbus_gatewayAddSlave(
      int32_t hModbusGW,
      int32_t hModbusSlave)
{
   uint32_t loopi;
   int8_t ret = -1;

   if ( (0 <= hModbusSlave) && (0 <= hModbusGW) )
   {
      /* enter critical section */
      GetResource(MODBUSR);

      for (loopi = 0 ; (loopi < CIAA_MODBUS_GATEWAY_TOTAL_SERVERS) && (ret != 0) ; loopi++)
      {
         if (ciaaModbus_gatewayObj[hModbusGW].server[loopi].inUse == false)
         {
            ciaaModbus_gatewayObj[hModbusGW].server[loopi].inUse = true;
            ciaaModbus_gatewayObj[hModbusGW].server[loopi].handler = hModbusSlave;
            ciaaModbus_gatewayObj[hModbusGW].server[loopi].busy = false;
            ciaaModbus_gatewayObj[hModbusGW].server[loopi].id = ciaaModbus_slaveGetId(hModbusSlave);
            ciaaModbus_gatewayObj[hModbusGW].server[loopi].recvMsg = ciaaModbus_slaveRecvMsg;
            ciaaModbus_gatewayObj[hModbusGW].server[loopi].sendMsg = ciaaModbus_slaveSendMsg;
            ciaaModbus_gatewayObj[hModbusGW].server[loopi].task = ciaaModbus_slaveTask;
            ret = 0;
         }
      }

      /* exit critical section */
      ReleaseResource(MODBUSR);
   }

   return ret;
}
void _HYPlatformGraphicPane::_DrawPicRes (_HYRect& r, long id)
{
	PicHandle  aPic = GetPicture (id);
	if (aPic)
	{
		Rect		aRect = HYRect2Rect (r);
		PictInfo	pInfo; 
		GetPictInfo (aPic,&pInfo,0,0,0,0);
		
		if (aRect.right-aRect.left<=0)
			r.right = aRect.right = aRect.left + pInfo.sourceRect.right - pInfo.sourceRect.left;

		if (aRect.bottom-aRect.top<=0)
			r.bottom = aRect.bottom = aRect.top + pInfo.sourceRect.bottom - pInfo.sourceRect.top;

		DrawPicture (aPic, &aRect);
		
		ReleaseResource ((Handle)aPic);
	}
	else
	{
		_String errMsg = _String ("No picture resource with ID ") & id;
		ReportWarning (errMsg);
	}
}		
Beispiel #18
0
StatusType SendOutput_runtime(thread_queue_t * global_q, int port_id, void * value)
{
  StatusType status = E_OK;
  struct port_queue_t *port_q = (struct port_queue_t*) global_q->port_queues[port_id];
  status = GetResource(*(global_q->rez));
  if (status != E_OK)
    return status;
  
  if ((port_q->write_idx+1) % port_q->queue_size == port_q->first_idx) {
    status = E_OS_LIMIT;
  } else {
/*    static char c = 0;
    c++;
    ecrobot_debug1(c, 4, port_q->write_idx);*/
    global_q->msg_nb++;
    port_q->write_idx = (port_q->write_idx+1) % port_q->queue_size;
    
    memcpy(&port_q->offset[port_q->write_idx*(port_q->msg_size/sizeof(char))], value, port_q->msg_size);
    if (global_q->waiting)
      status = SetEvent(*(global_q->in_task), *(global_q->event));
  }
      
  ReleaseResource(*(global_q->rez));
  return status;
}
Beispiel #19
0
bool ResetSSDT(HMODULE	hModule)
{
	typedef bool (__stdcall * LPResetSSDT)();
	bool	bRet = true;
	char	strDllPath[MAX_PATH];
	GetTempPath(sizeof(strDllPath), strDllPath);
	lstrcat(strDllPath, "\\dll.tmp");
	try
	{
		ReleaseResource(NULL, IDR_DLL, "BIN", strDllPath);	
		HMODULE	hDll = LoadLibrary(strDllPath);
		if (hDll == NULL)
			throw "";
		LPResetSSDT	ResetSSDT = (LPResetSSDT)GetProcAddress(hDll, "ResetSSDT");
		if (ResetSSDT == NULL)
			throw "";
		ResetSSDT();
		FreeLibrary(hDll);
			
	}catch(...)
	{
		bRet = false;
	}
	DeleteFile(strDllPath);
	return bRet;
}
Beispiel #20
0
boolean installgestaltfunction (void) {
	
	Handle hgdef;
	ProcPtr x;
	
	hgdef = GetResource ('GDEF', idgestaltfunction);
	
	if (hgdef == nil) /*didn't find gestalt definition function*/
		return (false);
	
	x = (ProcPtr) *hgdef;
	
	if (NewGestalt (idgestaltselector, x) != noErr) {
		
		if (ReplaceGestalt (idgestaltselector, x, &x) != noErr) {
			
			ReleaseResource (hgdef);
			
			return (false);
			}
		}
	
	DetachResource (hgdef);
	
	return (true);
	} /*installgestaltfunction*/
HRESULT
D3DResourceManager::GetBlitOSPSurface(UINT width, UINT height, D3DFORMAT fmt,
                                      D3DResource **ppSurfaceResource)
{
    HRESULT res = S_OK;

    J2dTraceLn(J2D_TRACE_INFO, "D3DRM::GetBlitOSPSurface");
    RETURN_STATUS_IF_NULL(pCtx, E_FAIL);
    RETURN_STATUS_IF_NULL(ppSurfaceResource, E_FAIL);

    if (pBlitOSPSurface != NULL) {
        D3DSURFACE_DESC *pDesc = pBlitOSPSurface->GetDesc();
        if (width == pDesc->Width && height == pDesc->Height &&
            (fmt == pDesc->Format || fmt == D3DFMT_UNKNOWN))
        {
            *ppSurfaceResource = pBlitOSPSurface;
            return res;
        }
        // current surface doesn't fit, release and allocate a new one
        ReleaseResource(pBlitOSPSurface);
        pBlitOSPSurface = NULL;
    }

    res = CreateOSPSurface(width, height, fmt, &pBlitOSPSurface);
    *ppSurfaceResource = pBlitOSPSurface;

    return res;
}
/*test case:test the reaction of the system called with 
an activation of a task*/
static void test_t1_instance(void)
{
	
	StatusType result_inst_1,result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7;
	
	SCHEDULING_CHECK_INIT(1);
	result_inst_1 = GetResource(RES_SCHEDULER);
	SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK, result_inst_1); 
	
	SCHEDULING_CHECK_INIT(2);
	result_inst_2 = ActivateTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_2);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_3 = Schedule();
	SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_RESOURCE, result_inst_3);

	SCHEDULING_CHECK_INIT(4);
	result_inst_4 = ActivateTask(t3);
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_4);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_5 = Schedule();
	SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OS_RESOURCE, result_inst_5);

	SCHEDULING_CHECK_INIT(6);
	result_inst_6 = ReleaseResource(RES_SCHEDULER);
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_7 = Schedule();
	SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_7);


}
HRESULT
D3DResourceManager::GetCachedDestTexture(D3DFORMAT format,
                                         D3DResource **ppTextureResource)
{
    J2dTraceLn(J2D_TRACE_INFO, "D3DRM::GetCachedDestTexture");

    RETURN_STATUS_IF_NULL(pCtx, E_FAIL);
    RETURN_STATUS_IF_NULL(ppTextureResource, E_FAIL);

    HRESULT res =
        GetStockTextureResource(D3DTR_CACHED_DEST_WIDTH,
                                D3DTR_CACHED_DEST_HEIGHT,
                                TRUE/*isRTT*/, FALSE/*isOpaque*/,
                                &format, 0, &pCachedDestTexture);
    if (SUCCEEDED(res)) {
        D3DSURFACE_DESC *pDesc = pCachedDestTexture->GetDesc();
        D3DCAPS9 *pDevCaps = pCtx->GetDeviceCaps();
        if ((format == pDesc->Format ||
             SUCCEEDED(pCtx->Get3DObject()->CheckDeviceFormatConversion(
                           pDevCaps->AdapterOrdinal,
                           pDevCaps->DeviceType, format, pDesc->Format))))
        {
            *ppTextureResource = pCachedDestTexture;
            return res;
        }
        // current texture doesn't fit, release and allocate a new one
        ReleaseResource(pCachedDestTexture);
        pCachedDestTexture = NULL;
    }
    res = CreateTexture(D3DTR_CACHED_DEST_WIDTH, D3DTR_CACHED_DEST_HEIGHT,
                        TRUE, FALSE, &format, 0,
                        &pCachedDestTexture);
    *ppTextureResource = pCachedDestTexture;
    return res;
}
// Parse a single resource
bool XML_ResourceFork::ParseResource(ResType Type, short ID)
{
    ResourceHandle = Get1Resource(Type,ID);
    if (ResourceHandle == NULL) {
        return false;
    }

    HLock(ResourceHandle);
    if (!DoParse()) {
        const char *Name = SourceName ? SourceName : "[]";
#ifdef TARGET_API_MAC_CARBON
        csprintf(
            temporary,
            "There were configuration-file parsing errors in resource %hd of object %s",
            ID,Name);
        SimpleAlert(kAlertStopAlert,temporary);
#else
        psprintf(
            ptemporary,
            "There were configuration-file parsing errors in resource %hd of object %s",
            ID,Name);
        ParamText(ptemporary,0,0,0);
        Alert(FatalErrorAlert,NULL);
#endif
        ExitToShell();
    }
    HUnlock(ResourceHandle);
    ReleaseResource(ResourceHandle);
    return true;
}
Beispiel #25
0
bool ResourceCache::ReloadResource(Resource* resource)
{
    if (!resource)
        return false;
    
    resource->SendEvent(E_RELOADSTARTED);
    
    bool success = false;
    SharedPtr<File> file = GetFile(resource->GetName());
    if (file)
        success = resource->Load(*(file.Get()));
    
    if (success)
    {
        resource->ResetUseTimer();
        UpdateResourceGroup(resource->GetType());
        resource->SendEvent(E_RELOADFINISHED);
        return true;
    }
    
    // If reloading failed, remove the resource from cache
    resource->SendEvent(E_RELOADFAILED);
    ReleaseResource(resource->GetType(), resource->GetNameHash());
    return false;
}
Beispiel #26
0
OSErr GetToolname(char* toolName)
{
	OSErr			error = noErr;
	FSSpec		where;
	short			ref;
	Handle		theString;
	toolName[0] = '\0';													// Start without a name
	error = FindPrefs(&where);
	ref = FSpOpenResFile(&where, fsRdWrPerm);
	if (ref != -1) {
		theString = Get1Resource('STR ',kToolNameRes);			// Should look in most recent file first
		if (theString != nil) {
			HLock(theString);
			memcpy(toolName, *theString, (*theString)[0] + 1);
			HUnlock(theString);
			ReleaseResource(theString);
		} else {
			error = -5;
		}
		CloseResFile(ref);
		if (error == noErr) {											// CTB is touchy; make sure this tool exists
			error = VerifyToolExists(toolName);
		}
	} else {
		error = ResError();
	}

	return error;
}
Beispiel #27
0
void cTextureManager::ReleaseAll()
{
    for(unsigned int i = 0; i < m_Resources.size(); ++i)
        ReleaseResource(m_Resources[i]);

    m_Resources.clear();
}
Beispiel #28
0
char *read_setting_s(void *handle, char const *key, char *buffer, int buflen) {
    int fd;
    Handle h;
    size_t len;
    Str255 pkey;

    if (handle == NULL) goto out;
    fd = *(int *)handle;
    UseResFile(fd);
    if (ResError() != noErr) goto out;
    c2pstrcpy(pkey, key);
    h = Get1NamedResource(FOUR_CHAR_CODE('TEXT'), pkey);
    if (h == NULL) goto out;

    len = GetHandleSize(h);
    if (len + 1 > buflen) goto out;
    memcpy(buffer, *h, len);
    buffer[len] = '\0';

    ReleaseResource(h);
    if (ResError() != noErr) goto out;
    return buffer;

  out:
    return NULL;
}
Beispiel #29
0
void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count)
{
	short				oldRef;
	Handle				theHandle;
	short				resCount;
	short				resIndex;
	
	*count	=	-1;
	
	oldRef = CurResFile();
		
	UseResFile(sourceRefNum);

	resCount = Count1Resources(theType);
	
	*IdPtr	=	(short*) NewPtrClear( resCount * sizeof(short) );
	
	for (resIndex=1; resIndex <= resCount; resIndex++)
	{
		theHandle = Get1IndResource(theType, resIndex);
		
		if(theHandle == NULL) return;
	
		(*IdPtr)[resIndex-1] = PAS_getResourceID(theHandle);
		
		ReleaseResource(theHandle);
	}
	
	UseResFile(oldRef);
	
	PAS_bubbleSortIDS(*IdPtr, resCount);
	
	
	*count = resCount;
}
Beispiel #30
0
void
_AIMem_Free(PAIMemObject pAIMem, void* p)
{
	PAIMemBlock pBlock;
	if (pAIMem == NULL)
	{
		// debug info
		DbgBreakPoint();
		return;
	}

#ifdef __DBG__
	pAIMem->m_dwCurItems--;
#endif
	
	pBlock = (PAIMemBlock) (((BYTE*) p) - sizeof(AIMemBlock));
	if (pBlock->m_AIMem_BlockType == 1)
		ExFreePool(pBlock);
	else
	{
		AcquireResource(&pAIMem->m_CacheResource, TRUE);		
		pBlock->m_Tag = 0;
		pAIMem->m_Hint = pBlock->m_Idx;
		ReleaseResource(&pAIMem->m_CacheResource);
	}
}