コード例 #1
0
void SurfaceSdlGraphicsManager::clearOverlay() {
    if (!_overlayscreen)
        return;

    if (!_overlayVisible)
        return;

#ifdef USE_OPENGL
    if (_opengl) {
        SDL_Surface *tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, _overlayWidth, _overlayHeight,
                                                _overlayscreen->format->BytesPerPixel * 8,
                                                _overlayscreen->format->Rmask, _overlayscreen->format->Gmask,
                                                _overlayscreen->format->Bmask, _overlayscreen->format->Amask);

        SDL_LockSurface(tmp);
        SDL_LockSurface(_overlayscreen);

        glReadPixels(0, 0, _overlayWidth, _overlayHeight, GL_RGB, _overlayScreenGLFormat, tmp->pixels);

        // Flip pixels vertically
        byte *src = (byte *)tmp->pixels;
        byte *buf = (byte *)_overlayscreen->pixels + (_overlayHeight - 1) * _overlayscreen->pitch;
        int h = _overlayHeight;
        do {
            memcpy(buf, src, _overlayWidth * _overlayscreen->format->BytesPerPixel);
            src += tmp->pitch;
            buf -= _overlayscreen->pitch;
        } while (--h);

        SDL_UnlockSurface(_overlayscreen);
        SDL_UnlockSurface(tmp);

        SDL_FreeSurface(tmp);
    } else
#endif
    {
        SDL_LockSurface(_screen);
        SDL_LockSurface(_overlayscreen);
        Graphics::PixelBuffer srcBuf(_screenFormat, (byte *)_screen->pixels);
        Graphics::PixelBuffer dstBuf(_overlayFormat, (byte *)_overlayscreen->pixels);
        int h = _overlayHeight;

        do {
            dstBuf.copyBuffer(0, _overlayWidth, srcBuf);

            srcBuf.shiftBy(_overlayWidth);
            dstBuf.shiftBy(_overlayWidth);
        } while (--h);
        SDL_UnlockSurface(_screen);
        SDL_UnlockSurface(_overlayscreen);
    }
    _overlayDirty = true;
}
コード例 #2
0
ファイル: nsJSUtils.cpp プロジェクト: bebef1987/gecko-dev
nsresult
nsJSUtils::EvaluateString(JSContext* aCx,
                          const nsAString& aScript,
                          JS::Handle<JSObject*> aScopeObject,
                          JS::CompileOptions& aCompileOptions,
                          const EvaluateOptions& aEvaluateOptions,
                          JS::MutableHandle<JS::Value> aRetValue,
                          void **aOffThreadToken)
{
  const nsPromiseFlatString& flatScript = PromiseFlatString(aScript);
  JS::SourceBufferHolder srcBuf(flatScript.get(), aScript.Length(),
                                JS::SourceBufferHolder::NoOwnership);
  return EvaluateString(aCx, srcBuf, aScopeObject, aCompileOptions,
                        aEvaluateOptions, aRetValue, aOffThreadToken);
}
コード例 #3
0
void SurfaceSdlGraphicsManager::drawOverlay() {
    if (!_overlayscreen)
        return;

    SDL_LockSurface(_screen);
    SDL_LockSurface(_overlayscreen);
    Graphics::PixelBuffer srcBuf(_overlayFormat, (byte *)_overlayscreen->pixels);
    Graphics::PixelBuffer dstBuf(_screenFormat, (byte *)_screen->pixels);
    int h = _overlayHeight;

    do {
        dstBuf.copyBuffer(0, _overlayWidth, srcBuf);

        srcBuf.shiftBy(_overlayWidth);
        dstBuf.shiftBy(_overlayWidth);
    } while (--h);
    SDL_UnlockSurface(_screen);
    SDL_UnlockSurface(_overlayscreen);
}
コード例 #4
0
ファイル: Archiver7ZIP.cpp プロジェクト: Claybird/lhaforge
//指定されたディレクトリ内部を展開する;高速実装
bool CArchiver7ZIP::ExtractDirectoryEntry(LPCTSTR lpszArcFile,CConfigManager &ConfMan,const ARCHIVE_ENTRY_INFO_TREE* lpBase,const ARCHIVE_ENTRY_INFO_TREE* lpDir,LPCTSTR lpszOutputBaseDir,bool bCollapseDir,CString &strLog)
{
	//---一時フォルダ中にまとめて展開し、後からフォルダ構造を切り出す
	std::list<CString> files;

	CString strPath;

	bool bRestoreDir=false;
	if(lpDir->strFullPath.IsEmpty()){
		//ディレクトリが登録されていないのでパス名を算出する
		ArcEntryInfoTree_GetNodePathRelative(lpDir,lpBase,strPath);
		strPath.Replace(_T('/'),_T('\\'));

		CPath tmpPath(strPath);
		tmpPath.RemoveBackslash();	//ディレクトリだったら裸にする
		tmpPath.RemoveFileSpec();	//親ディレクトリまで切りつめる
		tmpPath.Append(_T("*"));	//特定ディレクトリ以下の全てのファイルを展開
		files.push_back(tmpPath);

		bRestoreDir=true;
	}else{
		//ディレクトリもアーカイブ中にエントリとして登録されているなら出力する
		CString tmpPath(lpDir->strFullPath);
		if(tmpPath[tmpPath.GetLength()-1]==_T('\\')||tmpPath[tmpPath.GetLength()-1]==_T('/')){
			//末尾の\もしくは/を削除
			tmpPath.Delete(tmpPath.GetLength()-1);
		}
		files.push_back(tmpPath);

		strPath=lpDir->strFullPath;
		strPath.Replace(_T('/'),_T('\\'));
	}

	//--------------------------------------
	// 修正された出力ディレクトリパスを算出
	//--------------------------------------
	//---本来の出力先
	CString strOutputDir=lpszOutputBaseDir+strPath;
	if(strOutputDir.GetLength()>_MAX_PATH){
		//フォルダ名が長くなりすぎた
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_MAX_PATH));
		return false;
	}

	//FileListには1件しか入っていないはず
	ASSERT(files.size()==1);

	//一時フォルダ
	CTemporaryDirectoryManager tdm(_T("lhaf"));
	CPath strTempOutput(tdm.GetDirPath());
	if(bRestoreDir){	//ディレクトリを手作業で復元
		strTempOutput+=strPath;
		strTempOutput.AddBackslash();
		TRACE(_T("手作業でのディレクトリ復元:%s\n"),(LPCTSTR)strTempOutput);
		if(!UtilMakeSureDirectoryPathExists(strTempOutput)){
			strLog.Format(IDS_ERROR_CANNOT_MAKE_DIR,strTempOutput);
			return false;
		}
	}
	//---一時フォルダ中にまとめて展開し、後からフォルダ構造を切り出す
	// ファイルを展開
	if(!ExtractSpecifiedOnly(lpszArcFile,ConfMan,strTempOutput,files,strLog,true)){
		return false;
	}

	//送り側ファイル名指定
	CPath tmp(strTempOutput);
	tmp+=(LPCTSTR)strPath;	//PathAppend相当
	tmp.RemoveBackslash();
	CString strSrcFiles(tmp);
	strSrcFiles+=_T("||");
	//受け側ファイル名指定
	tmp=lpszOutputBaseDir;
	{
		CString strTmp;
		ArcEntryInfoTree_GetNodePathRelative(lpDir,lpBase,strTmp);
		strTmp.Replace(_T('/'),_T('\\'));
		tmp+=(LPCTSTR)strTmp;
	}
	tmp.AddBackslash();
	CString strDestFiles(tmp);
	strDestFiles+=_T("||");

	//'|'を'\0'に変換する
	std::vector<TCHAR> srcBuf(strSrcFiles.GetLength()+1);
	UtilMakeFilterString(strSrcFiles,&srcBuf[0],srcBuf.size());
	std::vector<TCHAR> destBuf(strDestFiles.GetLength()+1);
	UtilMakeFilterString(strDestFiles,&destBuf[0],destBuf.size());

	//ファイル操作内容
	SHFILEOPSTRUCT fileOp={0};
	fileOp.wFunc=FO_MOVE;
	fileOp.fFlags=FOF_MULTIDESTFILES|/*FOF_NOCONFIRMATION|*/FOF_NOCONFIRMMKDIR|FOF_NOCOPYSECURITYATTRIBS|FOF_NO_CONNECTED_ELEMENTS;
	fileOp.pFrom=&srcBuf[0];
	fileOp.pTo=&destBuf[0];

	//移動実行
	if(::SHFileOperation(&fileOp)){
		//エラー
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_FILE_MOVE));
		return false;
	}else if(fileOp.fAnyOperationsAborted){
		//キャンセル
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_USERCANCEL));
		return false;
	}

	return true;

}
コード例 #5
0
ファイル: Archiver7ZIP.cpp プロジェクト: Claybird/lhaforge
bool CArchiver7ZIP::AddItemToArchive(LPCTSTR ArcFileName,const std::list<CString> &FileList,CConfigManager &ConfMan,LPCTSTR lpDestDir,CString &strLog)
{
	// レスポンスファイル用テンポラリファイル名取得
	TCHAR ResponceFileName[_MAX_PATH+1];
	FILL_ZERO(ResponceFileName);
	if(!UtilGetTemporaryFileName(ResponceFileName,_T("zip"))){
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_CREATE));
		return false;
	}
	ASSERT(0!=_tcslen(ResponceFileName));

	//===一時的にファイルをコピー
	//---\で終わる基点パスを取得
	CPath strBasePath;
	UtilGetBaseDirectory(strBasePath,FileList);
	TRACE(_T("%s\n"),strBasePath);

	//---テンポラリに対象ファイルをコピー
	//テンポラリ準備
	CTemporaryDirectoryManager tdm(_T("lhaf"));
	CPath strDestPath(tdm.GetDirPath());
	strDestPath+=lpDestDir;
	UtilMakeSureDirectoryPathExists(strDestPath);

	// 圧縮対象ファイル名を修正する
	const int BasePathLength=((CString)strBasePath).GetLength();
	CString strSrcFiles;	//コピー元ファイルの一覧
	CString strDestFiles;	//コピー先ファイルの一覧
	std::list<CString>::const_iterator ite;
	for(ite=FileList.begin();ite!=FileList.end();++ite){
		//ベースパスを元に相対パス取得 : 共通である基底パスの文字数分だけカットする
		LPCTSTR lpSrc((LPCTSTR)(*ite)+BasePathLength);

		//送り側ファイル名指定
		strSrcFiles+=(strBasePath+lpSrc);	//PathAppend相当
		strSrcFiles+=_T('|');
		//受け側ファイル名指定
		strDestFiles+=strDestPath+lpSrc;
		strDestFiles+=_T('|');
	}
	strSrcFiles+=_T('|');
	strDestFiles+=_T('|');

	//'|'を'\0'に変換する
	std::vector<TCHAR> srcBuf(strSrcFiles.GetLength()+1);
	UtilMakeFilterString(strSrcFiles,&srcBuf[0],srcBuf.size());
	std::vector<TCHAR> destBuf(strDestFiles.GetLength()+1);
	UtilMakeFilterString(strDestFiles,&destBuf[0],destBuf.size());

	//ファイル操作内容
	SHFILEOPSTRUCT fileOp={0};
	fileOp.wFunc=FO_COPY;
	fileOp.fFlags=FOF_MULTIDESTFILES|FOF_NOCONFIRMATION|FOF_NOCONFIRMMKDIR|FOF_NOCOPYSECURITYATTRIBS|FOF_NO_CONNECTED_ELEMENTS;
	fileOp.pFrom=&srcBuf[0];
	fileOp.pTo=&destBuf[0];

	//コピー実行
	if(::SHFileOperation(&fileOp)){
		//エラー
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_FILE_COPY));
		return false;
	}else if(fileOp.fAnyOperationsAborted){
		//キャンセル
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_USERCANCEL));
		return false;
	}

	//カレントディレクトリ設定
	::SetCurrentDirectory(tdm.GetDirPath());
	// 同時に、レスポンスファイル内にアーカイブ名および圧縮対象ファイル名を記入する
	{
		HANDLE hFile=CreateFile(ResponceFileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		if(INVALID_HANDLE_VALUE==hFile){
			strLog=CString(MAKEINTRESOURCE(IDS_ERROR_TEMPORARY_FILE_ACCESS));
			return false;
		}
		//レスポンスファイルへの書き込み
		//全て圧縮
		WriteResponceFile(hFile,_T("*"));
		CloseHandle(hFile);
	}


	//===========================
	// DLLに渡すオプションの設定
	//===========================
	TRACE(_T("DLLに渡すオプションの設定\n"));

	CString Param;//コマンドライン パラメータ バッファ

	CConfigZIP confZIP;
	CConfig7Z  conf7Z;
	ASSERT(ArchiverGetArchiveType);
	switch(ArchiverGetArchiveType(C2UTF8(ArcFileName))){
	case 1:	//ZIP形式で圧縮
		confZIP.load(ConfMan);
		if(!FormatCompressCommandZIP(confZIP,Param,false,0,NULL,NULL,strLog)){
			DeleteFile(ResponceFileName);
			return false;
		}
		break;
	case 2:	//7z形式で圧縮
		conf7Z.load(ConfMan);
		if(!FormatCompressCommand7Z(conf7Z,Param,0,NULL,strLog)){
			DeleteFile(ResponceFileName);
			return false;
		}
		break;
	default:
		ASSERT(!"This code cannot be run");
		//エラー処理が面倒なので放っておく。
		return false;
	}

	Param+=_T("-scsUTF-8 ");	//レスポンスファイルのコードページ指定

	//作業ディレクトリ
	Param+=_T("\"-w");
	Param+=UtilGetTempPath();
	Param+=_T("\" ");

	//圧縮先ファイル名指定
	Param+=_T("\"");
	Param+=ArcFileName;
	Param+=_T("\" ");

	//レスポンスファイル名指定
	Param+=_T("\"@");
	Param+=ResponceFileName;
	Param+=_T("\"");

	ASSERT(!Param.IsEmpty());
	TRACE(_T("ArchiveHandler Commandline Parameter:%s\n"),Param);

	TRACE(_T("ArchiveHandler呼び出し\n"));
	//char szLog[LOG_BUFFER_SIZE]={0};
	std::vector<BYTE> szLog(LOG_BUFFER_SIZE);
	szLog[0]='\0';
	int Ret=ArchiveHandler(NULL,C2UTF8(Param),(LPSTR)&szLog[0],LOG_BUFFER_SIZE-1);
	CString strTmp;
	UtilToUNICODE(strTmp,&szLog[0],szLog.size()-1,UTILCP_UTF8);
	//strLog=&szLog[0];
	strLog=strTmp;

	//使ったレスポンスファイルは消去
	DeleteFile(ResponceFileName);

	return 0==Ret;
}
コード例 #6
0
void SurfaceSdlGraphicsManager::updateScreen() {
#ifdef USE_OPENGL
	if (_opengl) {
		if (_overlayVisible) {
			if (_overlayDirty) {
				// remove if already exist
				if (_overlayNumTex > 0) {
					glDeleteTextures(_overlayNumTex, _overlayTexIds);
					delete[] _overlayTexIds;
					_overlayNumTex = 0;
				}

				_overlayNumTex = ((_overlayWidth + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE) *
								((_overlayHeight + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE);
				_overlayTexIds = new GLuint[_overlayNumTex];
				glGenTextures(_overlayNumTex, _overlayTexIds);
				for (int i = 0; i < _overlayNumTex; i++) {
					glBindTexture(GL_TEXTURE_2D, _overlayTexIds[i]);
					glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
					glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
					glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
					glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
					glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, BITMAP_TEXTURE_SIZE, BITMAP_TEXTURE_SIZE, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
				}

				glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
				glPixelStorei(GL_UNPACK_ROW_LENGTH, _overlayWidth);

				int curTexIdx = 0;
				for (int y = 0; y < _overlayHeight; y += BITMAP_TEXTURE_SIZE) {
					for (int x = 0; x < _overlayWidth; x += BITMAP_TEXTURE_SIZE) {
						int t_width = (x + BITMAP_TEXTURE_SIZE >= _overlayWidth) ? (_overlayWidth - x) : BITMAP_TEXTURE_SIZE;
						int t_height = (y + BITMAP_TEXTURE_SIZE >= _overlayHeight) ? (_overlayHeight - y) : BITMAP_TEXTURE_SIZE;
						glBindTexture(GL_TEXTURE_2D, _overlayTexIds[curTexIdx]);
						glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, t_width, t_height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, (byte *)_overlayscreen->pixels + (y * 2 * _overlayWidth) + (2 * x));
						curTexIdx++;
					}
				}
				glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
				glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
			}

			// Save current state
			glPushAttrib(GL_TRANSFORM_BIT | GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_SCISSOR_BIT);

			// prepare view
			glMatrixMode(GL_PROJECTION);
			glPushMatrix();
			glLoadIdentity();
			glOrtho(0, _overlayWidth, _overlayHeight, 0, 0, 1);

			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			glLoadIdentity();

			glMatrixMode(GL_TEXTURE);
			glPushMatrix();
			glLoadIdentity();

			glDisable(GL_LIGHTING);
			glEnable(GL_TEXTURE_2D);
			glDisable(GL_DEPTH_TEST);
			glDepthMask(GL_FALSE);
			glEnable(GL_SCISSOR_TEST);

			glScissor(0, 0, _overlayWidth, _overlayHeight);

			int curTexIdx = 0;
			for (int y = 0; y < _overlayHeight; y += BITMAP_TEXTURE_SIZE) {
				for (int x = 0; x < _overlayWidth; x += BITMAP_TEXTURE_SIZE) {
					glBindTexture(GL_TEXTURE_2D, _overlayTexIds[curTexIdx]);
					glBegin(GL_QUADS);
					glTexCoord2f(0, 0);
					glVertex2i(x, y);
					glTexCoord2f(1.0f, 0.0f);
					glVertex2i(x + BITMAP_TEXTURE_SIZE, y);
					glTexCoord2f(1.0f, 1.0f);
					glVertex2i(x + BITMAP_TEXTURE_SIZE, y + BITMAP_TEXTURE_SIZE);
					glTexCoord2f(0.0f, 1.0f);
					glVertex2i(x, y + BITMAP_TEXTURE_SIZE);
					glEnd();
					curTexIdx++;
				}
			}

			// Restore previous state
			glMatrixMode(GL_PROJECTION);
			glPopMatrix();

			glMatrixMode(GL_MODELVIEW);
			glPopMatrix();

			glMatrixMode(GL_TEXTURE);
			glPopMatrix();

			glPopAttrib();
		}
		SDL_GL_SwapBuffers();
	} else
#endif
	{
		if (_overlayVisible) {
			SDL_LockSurface(_screen);
			SDL_LockSurface(_overlayscreen);
			Graphics::PixelBuffer srcBuf(_overlayFormat, (byte *)_overlayscreen->pixels);
			Graphics::PixelBuffer dstBuf(_screenFormat, (byte *)_screen->pixels);
			int h = _overlayHeight;

			do {
				dstBuf.copyBuffer(0, _overlayWidth, srcBuf);

				srcBuf.shiftBy(_overlayWidth);
				dstBuf.shiftBy(_overlayWidth);
			} while (--h);
			SDL_UnlockSurface(_screen);
			SDL_UnlockSurface(_overlayscreen);
		}
		SDL_Flip(_screen);
	}
}