Пример #1
0
int
main (int argc, char **argv) {
#ifdef MOZ_WIDGET_GTK2
    gtk_init(&argc, &argv); 
#endif
#ifdef XP_MACOSX
    CocoaPoolInit();
#endif

    // Initialize XPCOM
    nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
    if (NS_FAILED(rv))
        return -1; 

    rv = gfxPlatform::Init();
    if (NS_FAILED(rv))
        return -1;

    // let's get all the xpcom goop out of the system
    fflush (stderr);
    fflush (stdout);

    nsRefPtr<gfxContext> context = MakeContext();

    // Start timing
    PRIntervalTime start = PR_IntervalNow();

    for (PRUint32 i = 0; i < iterations; ++i) {
        for (uint test = 0;
             test < NS_ARRAY_LENGTH(testList) - 1;
             test++)
        {
            RunTest(&testList[test], context);
        }
    }

    PRIntervalTime end = PR_IntervalNow();
    
    printf("Elapsed time (ms): %d\n", PR_IntervalToMilliseconds(end - start));

    fflush (stderr);
    fflush (stdout);
}
Пример #2
0
RelationGraph* MakeRelationGraph(string &inputFile){
          ifstream myfile(inputFile.c_str());
          if (myfile.is_open()){
              string line;
              getline (myfile,line);
              int numDomains = atoi(line.c_str()); //get the number of domains
              getline (myfile,line);
              int numContexts = atoi(line.c_str()); //get the number of contexts
              if(numContexts + 1 != numDomains) {
                  string errMsg = "Number of domains and number of contexts are not consistent";
                  Error(errMsg);
              }
              vector<string> domainNames;
              map<string,int> domainName_id_map;
              vector<NameMap*> nameMaps;
              map<int,int> domainId_size_map; //map domain number to number of elements
              //get set names and thier name files
              for(int i=0; i < numDomains; i++){
                 getline(myfile,line); //this is the domain name
                 
                 vector<string> tkns;
                 Tokenize(line, tkns, ";");
                 //first token is name of domain
                 domainNames.push_back(tkns[0]);
                 //second token is number of elements
                 domainId_size_map[i+1] = atoi(tkns[1].c_str());
                 domainName_id_map[tkns[0]]=i+1;
                 getline(myfile,line); //this is the path to the namefile
                 NameMap *nmp = new NameMap(line,atoi(tkns[1].c_str()));
                 nmp->SetId(i+1);
                 nameMaps.push_back(nmp);
               }
               //now get contexts and relation graph
              RelationGraph *grph = new RelationGraph();
              for(int i=0; i < numContexts; i++){
                  getline(myfile,line); //this line specifies the two domains
                  vector<string> currDomainNames;
                  string ctxName;
                  Tokenize(line,currDomainNames,"--");
                  int dId1 = domainName_id_map[currDomainNames[0]];
                  //check if a new element was inserted indicating an error
                  if(domainName_id_map.size() > numDomains) {
                      string errMsg = "Error specifying context..."+currDomainNames[0]+" does not match any previoulsy defined domain";
                      Error(errMsg);
                  }
                  int dId2 = domainName_id_map[currDomainNames[1]];
                  //check if a new element was inserted indicating an error
                  if(domainName_id_map.size() > numDomains) {
                      string errMsg = "Error specifying context..."+currDomainNames[1]+" does not match any previoulsy defined domain";
                      Error(errMsg);
                  }
                  ctxName = currDomainNames[0]+"__"+currDomainNames[1];
                  getline(myfile,line);  //this line specifies the fimi file
                  grph->AddContext(MakeContext(line,dId1,dId2,ctxName,i+1,nameMaps[dId1-1],nameMaps[dId2-1],domainId_size_map[dId1],domainId_size_map[dId2]));
              }
	      myfile.close();
              return grph;
          }
	  else{
              string errMsg="Could not open the input file: "+inputFile;
	  	Error(errMsg);
	  }

}
SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, void* storage) const {
    return MakeContext(*this, (TileMode)fTileModeX, (TileMode)fTileModeY,
                       SkBitmapProvider(fRawBitmap), rec, storage);
}
Пример #4
0
Context* RegexpCompile( const char* Pattern ) {
	Context* con = MakeContext();
	const char *p = Pattern;
	
	while ( *p != '\0' ) {
		printf( "deal with %c\n", *p );
		printf( "nfa size: %d\t%d\n", NumNfaList( con ), NumNfaStack( con ) );
		printf( "symbol stack size: %d\n", SymbolStackSize() );
		if ( isletter( *p ) ) {
			Nfa* nfa = AtomicMakeNfaBySingleC( con, *p );
			PushNfa( con, nfa );

			while ( SymbolGE( CONCAT, TopSymbol() )  ) {
				ChangeStack( con );
			}
			PushSymbol( CONCAT );
		}
		else if ( *p == '|' ) {
			if ( TopSymbol() == CONCAT ) {
				PopSymbol();
			}
			else {
				printf("error\n");
			}

			while ( SymbolGE( OR, TopSymbol() ) ) {
				ChangeStack( con );
			}

			PushSymbol( OR );
		}
		else if ( *p == '*' ) {
			if ( TopSymbol() == CONCAT ) {
				PopSymbol();
			}
			else {
				printf("error\n");
			}

			Nfa* nfa = PopNfa( con );
			nfa = AtomicClosureNfa( con, nfa );
			PushNfa( con, nfa );

			PushSymbol( CONCAT );
		}
		else if ( *p == '(' ) {
			PushSymbol( LBRACE );
		}
		else if ( *p == ')' ) {
			if ( TopSymbol() == CONCAT ) {
				PopSymbol();
			}
			else {
				printf("error\n");
			}

			while ( SymbolGE( RBRACE, TopSymbol() ) ) {
				if ( TopSymbol() == LBRACE ) {
					PopSymbol();
					break;
				}
				ChangeStack( con );
			}

			PushSymbol( CONCAT );
		}
		p ++;
	}

	while ( TopSymbol() != NONE ) {
		PopSymbol();
	}
	return con;
}
Пример #5
0
int
main (int argc, char **argv) {
#ifdef MOZ_WIDGET_GTK2
   gtk_init(&argc, &argv);
#endif
#ifdef XP_MACOSX
   CocoaPoolInit();
#endif

   // Initialize XPCOM
   nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
   if (NS_FAILED(rv))
       return -1;

   rv = gfxPlatform::Init();
   if (NS_FAILED(rv))
       return -1;

   // let's get all the xpcom goop out of the system
   fflush (stderr);
   fflush (stdout);

   gTextRuns = new FrameTextRunCache();

   nsRefPtr<gfxContext> ctx = MakeContext();
   {
       gfxFontStyle style (FONT_STYLE_NORMAL,
                           NS_FONT_STRETCH_NORMAL,
                           139,
                           10.0,
                           NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
                           0.0,
                           PR_FALSE, PR_FALSE, PR_FALSE,
                           NS_LITERAL_STRING(""),
                           NS_LITERAL_STRING(""));

       nsRefPtr<gfxFontGroup> fontGroup =
           gfxPlatform::GetPlatform()->CreateFontGroup(NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style, nsnull);

       gfxTextRunFactory::Parameters params = {
           ctx, nsnull, nsnull, nsnull, 0, 60
       };

       PRUint32 flags = gfxTextRunFactory::TEXT_IS_PERSISTENT;

       // First load an Arabic word into the cache
       const char cString[] = "\xd8\xaa\xd9\x85";
       nsDependentCString cStr(cString);
       NS_ConvertUTF8toUTF16 str(cStr);
       gfxTextRun *tr = MakeTextRun(str.get(), str.Length(), fontGroup, &params, flags);
       tr->GetAdvanceWidth(0, str.Length(), nsnull);

       // Now try to trigger an assertion with a word cache bug. The first
       // word is in the cache so it gets added to the new textrun directly.
       // The second word is not in the cache 
       const char cString2[] = "\xd8\xaa\xd9\x85\n\xd8\xaa\xd8\x85 ";
       nsDependentCString cStr2(cString2);
       NS_ConvertUTF8toUTF16 str2(cStr2);
       gfxTextRun *tr2 = MakeTextRun(str2.get(), str2.Length(), fontGroup, &params, flags);
       tr2->GetAdvanceWidth(0, str2.Length(), nsnull);
   }

   fflush (stderr);
   fflush (stdout);
}
Пример #6
0
//************************************
// Method:    CreateWindow
// FullName:  QuackWin::CreateWindow
// Access:    public 
// Returns:   bool
// Qualifier:
// Parameter: int width
// Parameter: int height
// Parameter: int colorBits
//************************************
bool QuackWin::B_CreateWindow(int width, int height, int colorBits) {
	if (!classRegistered) {
		WNDCLASS wc;

		memset(&wc, 0, sizeof(wc));

		wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
		wc.lpfnWndProc = (WNDPROC)wndproc;
		wc.cbClsExtra = 0;
		wc.cbWndExtra = sizeof(void*)+sizeof(int);
		wc.hInstance = GetModuleHandle(NULL);
		//wc.hIcon = LoadIcon(hinstOpenGL, MAKEINTRESOURCE(IDI_ICON1));
		wc.hCursor = LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground = NULL;
		wc.lpszMenuName = 0;
		wc.lpszClassName = WINDOW_CLASS_NAME;

		if (!RegisterClass(&wc)) {
			// TODO: Add safe error here
			// unable to register class
		}
		classRegistered = true;
	}

	// create HWND
	if (!hWnd) {
		hWnd = CreateWindowEx(
			WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
			WINDOW_CLASS_NAME,
			"Quack",
			WS_VISIBLE | WS_OVERLAPPEDWINDOW,
			0,
			0,
			width,
			height,
			NULL,
			NULL,
			hinstOpenGL,
			this
			);

		if (!hWnd) {
			// error creating the window
		}

		ShowWindow(hWnd, SW_SHOW);
		UpdateWindow(hWnd);
	}

	if (!(hDC = GetDC(hWnd))) {
		ShowWindow(hWnd, SW_HIDE);
		DestroyWindow(hWnd);
		hWnd = NULL;
		return false;
	}

	// Create OpenGL Context
	if (!MakeContext()) {
		ShowWindow(hWnd, SW_HIDE);
		DestroyWindow(hWnd);
		hWnd = NULL;

		return false;
	}

	SetForegroundWindow(hWnd);
	SetFocus(hWnd);

	return true;
}