コード例 #1
0
/** return data */
const void *GeoImage::data()
{
  if (data_)
    return (void *) data_;
  qDebug("GeoImage::data() - load data");
  QString fname = filename();
  qDebug("GeoImage::data() %s", fname.toLatin1().constData());

  FILE *fp;
  fp = fopen(fname.toLatin1().constData(), "r");
  if (!fp) {
    qDebug("#  (ERROR)GeoImage::load(%s) Can't open file for reading!",
           fname.toLatin1().constData());
    return 0;
  }
  int cols, rows;
  //float minval, maxval;
  switch (type_) {
  case PFM_FLOAT:
  case PFM_UINT:
  case PFM_SINT:
  case PFM_SINT16:
  case PFM_UINT16:
  case PFM_BYTE:
  case PFM_3BYTE:
    data_ = pfm_readpfm_type(fp, &cols, &rows, &minval_, &maxval_, type_, 0);
    testSize(cols, rows, type_);
    break;
  case PBM:
    data_ = (void *) pbm_readpbm(fp, &cols, &rows);
    minval_ = 0.0, maxval_ = 1.0;
    testSize(cols, rows, type_);
    break;
  case PGM:{
      gray maxval, **data_g;
      data_g = pgm_readpgm(fp, &cols, &rows, &maxval);
      data_ = (void *) data_g;
      minval_ = 0.0, maxval_ = (float) maxval;
      testSize(cols, rows, type_);
    }
    break;
  case PPM:
    pixval maxval;
    pixel **dat_p;
    dat_p = ppm_readppm(fp, &cols, &rows, &maxval);
    data_ = (void *) dat_p;
    minval_ = 0.0, maxval_ = (float) maxval;
    testSize(cols, rows, type_);
    break;
  default:
    qDebug("Unknown type %d",type_);
    fclose(fp);
    return 0;
  }
  fclose(fp);
  if (data_) dataSize_=rows_*cols_*sizeOfData(type_);
  cache_.useImage(this);
  return data_;
}
コード例 #2
0
ファイル: preproc.cpp プロジェクト: kuailexs/symbiandump-os1
void CMMFTestVideoPreProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize)
	{
	TSize testSize(KTestInputSize2X, KTestInputSize2Y);

	if (!(aFormat == KTestVidFormat2) || !(aPictureSize == testSize))
		User::Leave(KErrCorrupt);
	}
コード例 #3
0
void testLockFreeFIFO()
{
    testTwoThreads();
    testSize();
    testPushUntilFull();
    testPushUntilFullAndPopUntilEmpty();
    
}
コード例 #4
0
void CQueueLinkedListTests::run(void)
{
	testEnqueue();
	testDequeue();
	testIsEmpty();
	testSize();

	PRINT_TEST_RESULTS();
}
コード例 #5
0
boolean DccStandardTest::testAll() {
    UnitTest::suite("DccStandard");
  
    testSize();
    testAddress();
    testMFKind();
    testBasicSpeed();
    testFunctionF0_F4();
    testFunctionF5_F8();
    testFunctionF9_F12();
    testMF_CV_Short();
    testMF_CV_Long();
    testAccessoryKind();
    testAccessoryAddress();
    testAccessoryState();
    
    return UnitTest::report();
}
コード例 #6
0
ファイル: main_menu.cpp プロジェクト: jfreax/Ufs
CSingleplayerButton::CSingleplayerButton()
{
	/* Neuen Hintergrundsprite anlegen */
	sf::Image* buttonImg = GetGameClass()->GetImgResource()->Get( "themes/default/buttons/main_button1.png" );
// 	sf::Sprite buttonSprite ( *buttonImg );
	
	/* Verhältnis der Originalhintergrundgröße mit der jetzigen */
	double verh = settings::GetWidth() / 1024.f;
	
	/* Name des Buttons */
	this->SetName ( "singleplayer" );
	
	/* Größe anpassen */
	this->SetSize ( sf::Vector2f ( buttonImg->GetWidth() * verh, buttonImg->GetHeight() * verh ) );
	
	/* Sprite als Hintergrund zuweisen */
	this->SetBackground ( buttonImg );
	
	/* Position setzen */
	this->SetPosition( sf::Vector2f ( 482.f * verh, 139.f * verh ) );
	
	/* Text setzen */
	this->SetText ( "Singleplayer" );
	this->SetTextPosition ( sf::Vector2f ( 35.f * verh, 14.f * verh ) );
	this->SetTextSize ( 16 );
	this->SetFont ( "main_menu" );
	
	/* Textposition speichern */
	endTextPos_ = sf::Vector2f ( 35.f * verh, 14.f * verh );
	
	/* Mousehover Effekt deaktivieren */
	hoverEffect_ = unHoverEffect_ = false;
	
	sf::Vector2f testSize ( 100.f, 100.f );
	
	testShape.AddPoint( 0,0 );
	testShape.AddPoint( 100,0 );
	testShape.AddPoint( 100,100 );
	testShape.AddPoint( 0,100 );
	
}
コード例 #7
0
void runTests(struct Set *set)
{
    testEmpty();
    testSize();
    testFullAndGrow();
}
コード例 #8
0
TEST(StaticPNGTests, sizeTest) {
  testSize("/LayoutTests/images/resources/png-simple.png", IntSize(111, 29));
}
コード例 #9
0
ファイル: itemspawn.cpp プロジェクト: Aissurteivos/mdrngzer
void ItemSpawn::normalize(unsigned sizeLimit) {
    while (testSize() > sizeLimit) {

        //Decrease the size

        //Remove a category if the amount of categories are greater than a third of the amount of items
        if (categories.size() * MINIMUM_ITEM_TO_CATEGORY_RATIO > items.size()) {
            unsigned selection = rand() % categories.size();
            auto i = std::next(categories.begin(), selection);
            Category &category = i->second;
            //Remove items with this category
            for (auto j = items.begin(); j != items.end(); ) {
                Item &item = j->second;
                if (&category == &item.category) {
                    j = items.erase(j);
                } else
                    j++;
            }
            categories.erase(i);
        } else {
            unsigned selection = rand() % items.size();
            auto i = std::next(items.begin(), selection);
            for (auto j = categories.begin(); j != categories.end(); j++) {
                //Category of item matches category
                if (&j->second == &i->second.category) {
                    //Derease items in category
                    j->second.items--;
                    //Lower probability of category based on how many items are in it
                    j->second.probability *= double(j->second.items) / double(j->second.items + 1);
                    //Erase category when no items are left
                    if (j->second.items == 0)
                        categories.erase(j);
                    break;
                }
            }
            items.erase(i);
        }
    }
    
    double catagoryTotalProbability = 0.0;
    for (auto i = categories.begin(); i != categories.end(); i++)
        catagoryTotalProbability += i->second.probability;
    
    //Normalize probabilities in categories
    for (auto i = categories.begin(); i != categories.end(); i++) {
        i->second.probability /= catagoryTotalProbability;
        if (i != categories.begin())
            i->second.probability += std::prev(i)->second.probability;
    }
    
    //Normalize all category item probabilities
    for (auto i = categories.begin(); i != categories.end(); i++) {
        double itemTotalProbability = 0.0;
        
        for (auto j = items.begin(); j != items.end(); j++)
            if (&j->second.category == &i->second)
                itemTotalProbability += j->second.probability;
        
        //The first time we find an item we dont want to add the previous probability
        bool first = true;
        auto last = items.end();
        
        for (auto j = items.begin(); j != items.end(); j++)
            if (&j->second.category == &i->second) {
                j->second.probability /= itemTotalProbability;
                
                if (first)
                    first = false;
                else
                    j->second.probability += last->second.probability;
                last = j;
            }
    }
}
コード例 #10
0
ファイル: ocland_mem.c プロジェクト: sanguinariojoe/ocland
cl_int oclandEnqueueWriteBufferRect(int *                clientfd ,
                                    cl_command_queue     command_queue ,
                                    cl_mem               mem ,
                                    const size_t *       buffer_origin ,
                                    const size_t *       region ,
                                    size_t               buffer_row_pitch ,
                                    size_t               buffer_slice_pitch ,
                                    size_t               host_row_pitch ,
                                    size_t               host_slice_pitch ,
                                    void *               ptr ,
                                    cl_uint              num_events_in_wait_list ,
                                    ocland_event *       event_wait_list ,
                                    cl_bool              want_event ,
                                    ocland_event         event)
{
    // Test that the objects command queue matchs
    if(testCommandQueue(command_queue,mem,num_events_in_wait_list,event_wait_list) != CL_SUCCESS)
        return CL_INVALID_CONTEXT;
    // Test if the size is not out of bounds
    size_t cb =   buffer_origin[0]
                + buffer_origin[1]*buffer_row_pitch
                + buffer_origin[2]*buffer_slice_pitch
                + region[0]
                + region[1]*buffer_row_pitch
                + region[2]*buffer_slice_pitch;
    if(testSize(mem, cb) != CL_SUCCESS)
        return CL_INVALID_VALUE;
    // Test if the memory can be accessed
    if(testWriteable(mem) != CL_SUCCESS)
        return CL_INVALID_OPERATION;
    // Seems that data is correct, so we can proceed.
    // We need to create a new connection socket in a
    // new port in order to don't interfiere the next
    // packets exchanged with the client (for instance
    // to call new commands).
    unsigned int port;
    int serverfd = openPort(&port);
    if(serverfd < 0){
        shutdown(*clientfd, 2);
        *clientfd = -1;
        return CL_OUT_OF_HOST_MEMORY;
    }
    // We have a new connection socket ready, reports it to
    // the client and wait until he connects with us.
    Send(clientfd, &port, sizeof(unsigned int), 0);
    int fd = accept(serverfd, (struct sockaddr*)NULL, NULL);
    if(fd < 0){
        // we can't work, disconnect the client
        printf("ERROR: Can't listen on port %u binded.\n", port); fflush(stdout);
        shutdown(serverfd, 2);
        shutdown(*clientfd, 2);
        *clientfd = -1;
        return CL_OUT_OF_HOST_MEMORY;
    }
    // Now we have a new socket connected to client, so
    // hereinafter we rely the work to a new thread, that
    // will call to clEnqueueReadBuffer and will send the
    // data to the client.
    pthread_t thread;
    struct dataSend* _data = (struct dataSend*)malloc(sizeof(struct dataSend));
    _data->fd                      = fd;
    _data->command_queue           = command_queue;
    _data->mem                     = mem;
    _data->buffer_origin           = (size_t*)malloc(3*sizeof(size_t));
    _data->buffer_origin[0]        = buffer_origin[0];
    _data->buffer_origin[1]        = buffer_origin[1];
    _data->buffer_origin[2]        = buffer_origin[2];
    _data->region                  = (size_t*)malloc(3*sizeof(size_t));
    _data->region[0]               = region[0];
    _data->region[1]               = region[1];
    _data->region[2]               = region[2];
    _data->buffer_row_pitch        = buffer_row_pitch;
    _data->buffer_slice_pitch      = buffer_slice_pitch;
    _data->host_row_pitch          = host_row_pitch;
    _data->host_slice_pitch        = host_slice_pitch;
    _data->ptr                     = ptr;
    _data->num_events_in_wait_list = num_events_in_wait_list;
    _data->event_wait_list         = event_wait_list;
    _data->want_event              = want_event;
    _data->event                   = event;
    int rc = pthread_create(&thread, NULL, asyncDataRecvRect_thread, (void *)(_data));
    if(rc){
        // we can't work, disconnect the client
        printf("ERROR: Thread creation has failed with the return code %d\n", rc); fflush(stdout);
        shutdown(serverfd, 2);
        shutdown(*clientfd, 2);
        *clientfd = -1;
        return CL_OUT_OF_HOST_MEMORY;
    }
    return CL_SUCCESS;
}
コード例 #11
0
ファイル: ocland_mem.c プロジェクト: sanguinariojoe/ocland
cl_int oclandEnqueueWriteImage(int *                clientfd ,
                               cl_command_queue     command_queue ,
                               cl_mem               image ,
                               const size_t *       origin ,
                               const size_t *       region ,
                               size_t               row_pitch ,
                               size_t               slice_pitch ,
                               size_t               element_size ,
                               void *               ptr ,
                               cl_uint              num_events_in_wait_list ,
                               ocland_event *       event_wait_list ,
                               cl_bool              want_event ,
                               ocland_event         event)
{
    cl_int flag;
    size_t msgSize = 0;
    void *msg = NULL, *mptr = NULL;
    // Test that the objects command queue matchs
    if(testCommandQueue(command_queue,image,num_events_in_wait_list,event_wait_list) != CL_SUCCESS)
        return CL_INVALID_CONTEXT;
    // Test if the size is not out of bounds
    size_t offset = origin[2]*slice_pitch + origin[1]*row_pitch + origin[0]*element_size;
    size_t cb     = region[2]*slice_pitch + region[1]*row_pitch + region[0]*element_size;
    if(testSize(image, offset+cb) != CL_SUCCESS)
        return CL_INVALID_VALUE;
    // Test if the memory can be accessed
    if(testReadable(image) != CL_SUCCESS)
        return CL_INVALID_OPERATION;
    // Seems that data is correct, so we can proceed.
    // We need to create a new connection socket in a
    // new port in order to don't intercept the next
    // packets exchanged with the client (for instance
    // to call new commands).
    unsigned int port;
    int serverfd = openPort(&port);
    if(serverfd < 0)
        return CL_OUT_OF_HOST_MEMORY;
    // Here in after we assume that the works gone fine,
    // returning CL_SUCCESS. Therefore we will package
    // the flag, the event and the port to stablish the
    // connection for the asynchronous data transfer.
    flag = CL_SUCCESS;
    msgSize  = sizeof(cl_int);          // flag
    msgSize += sizeof(ocland_event);    // event
    msgSize += sizeof(unsigned int);    // port
    msg      = (void*)malloc(msgSize);
    mptr     = msg;
    ((cl_int*)mptr)[0]       = flag;  mptr = (cl_int*)mptr + 1;
    ((ocland_event*)mptr)[0] = event; mptr = (ocland_event*)mptr + 1;
    ((unsigned int*)mptr)[0] = port;
    Send(clientfd, &msgSize, sizeof(size_t), 0);
    Send(clientfd, msg, msgSize, 0);
    free(msg);msg=NULL;
    // We are ready to trasfer the control to a parallel thread
    pthread_t thread;
    struct dataSend* _data = (struct dataSend*)malloc(sizeof(struct dataSend));
    _data->fd                      = serverfd;
    _data->command_queue           = command_queue;
    _data->mem                     = image;
    _data->offset                  = offset;
    _data->cb                      = cb;
    _data->ptr                     = ptr;
    _data->num_events_in_wait_list = num_events_in_wait_list;
    _data->event_wait_list         = event_wait_list;
    _data->want_event              = want_event;
    _data->event                   = event;
    int rc = pthread_create(&thread, NULL, asyncDataRecvImage_thread, (void *)(_data));
    if(rc){
        // we can't work, disconnect the client
        printf("ERROR: Thread creation has failed with the return code %d\n", rc); fflush(stdout);
        shutdown(serverfd, 2);
    }
    return CL_SUCCESS;
}
コード例 #12
0
   virtual void OnStartup(dtGame::GameApplication& app)
   {
      std::string dataPath = dtCore::GetDeltaDataPathList();
      dtCore::SetDataFilePathList(dataPath + ";" + dtCore::GetDeltaRootPath() + "/examples/data"); 

      dtGame::GameManager& gameManager = *app.GetGameManager();
      gameManager.LoadActorRegistry("testGameActorComponents");

      try
      {
       
         // Get the screen size
         app.GetWindow()->SetWindowTitle("TestGameActorComponents");

         std::string context = dtCore::GetDeltaRootPath() + "/examples/data/demoMap";
         dtDAL::Project::GetInstance().SetContext(context, true);

         gameManager.ChangeMap("MyCoolMap");
         
      }
      catch (dtUtil::Exception& e)
      {
         LOG_ERROR("Can't find the project context or load the map. Exception follows.");
         e.LogException(dtUtil::Log::LOG_ERROR);
      }

      // add the input handler
      gameManager.AddComponent(*new TestInput(), dtGame::GameManager::ComponentPriority::NORMAL);

      // create help label
      dtABC::LabelActor* label = new dtABC::LabelActor();
      osg::Vec2 testSize(32.0f, 2.5f);
      label->SetBackSize(testSize);
      label->SetFontSize(0.8f);
      label->SetTextAlignment(dtABC::LabelActor::AlignmentEnum::LEFT_CENTER);
      label->SetText("Press space to let label blink");
      label->SetEnableDepthTesting(false);
      label->SetEnableLighting(false);
      app.GetCamera()->AddChild(label);
      dtCore::Transform labelOffset(-17.0f, 50.0f, 10.5f, 0.0f, 90.0f, 0.0f);
      label->SetTransform(labelOffset, dtCore::Transformable::REL_CS);
      app.AddDrawable(app.GetCamera());

      // make sure map is loaded
      dtCore::System::GetInstance().Step();
      dtCore::System::GetInstance().Step();
      dtCore::System::GetInstance().Step();

      // create a component game actor
      dtCore::RefPtr<ComponentGameActorProxy> proxy;
      app.GetGameManager()->CreateActor(*TestActorLibraryRegistry::COMPONENT_GAME_ACTOR_TYPE.get(), proxy);
      
      // set mesh property and translation of component game actor
      ComponentGameActor* actor;
      proxy->GetActor(actor);
      actor->SetMesh("models/physics_happy_sphere.ive");
      dtCore::Transform xform;
      xform.SetTranslation(TARGET_XYZ);
      actor->SetTransform(xform);

      // access text label component of actor
      TextLabelComponent* textcomp;
      actor->GetComponent(textcomp);
      textcomp->SetText("LOOK AT MEEEE!!!!!!!");
      textcomp->SetHeight(1);
      textcomp->SetFontSize(1);

      // WARNING: if you call AddACtor without the boolean arguments,
      // the OnEnteredWorld method of the game actor is not called!
      // This sucks!
      app.GetGameManager()->AddActor(*proxy.get(),false, false);

   }
コード例 #13
0
/**
   @SYMTestCaseID UIF-TCone5Step-DoTestsL
  
   @SYMPREQ
  
   @SYMTestCaseDesc Tests MCoeLayOutManager APIs.\n
  
   @SYMTestPriority High
  
   @SYMTestStatus Implemented
   
   @SYMTestActions : Gets the layout manager for the application initially using LayoutManager() API \n
   Sets the layout manager for the application using SetLayoutManager() API. \n
   The setting of layout manager is verified using the Get Function.\n
   The layouts performed by the layout manager are obtained using LayoutsPerformed() API. \n
   A relayout of the components of the application is requested using RequestReLayout() API.\n
   Change of component control sizes is tested.\n
  
   @SYMTestExpectedResults The application should be started without any error.\n
  
   @SYMTestType : CIT 
 */
void CCone5TestAppUi::DoTestsL()
    {
    INFO_PRINTF1(_L("Testing Setting the Layout Manager"));
    MCoeLayoutManager* layout = NULL;
    layout = iTestAppView->LayoutManager();
	TEST(layout == NULL);
	iTestAppView->SetLayoutManagerL(iLayoutMan);
	layout = iTestAppView->LayoutManager();
	TEST(layout == iLayoutMan);
	iTestAppView->SetLayoutManagerL(NULL);
	layout = iTestAppView->LayoutManager();
	TEST(layout == NULL);
	// set the layout manager in preparation for next test
	iTestAppView->SetLayoutManagerL(iLayoutMan);
	
	
	INFO_PRINTF1(_L("Testing CanAttach()"));
	layout = iTestAppView->LayoutManager();
	TEST(layout->CanAttach() != EFalse);
	
	INFO_PRINTF1(_L("Testing Request Relayout"));
	TUint layoutsPerformed = iLayoutMan->LayoutsPerformed();
	iTestAppView->RequestRelayout(iTestAppView);
	// this should have caused a layout to be performed
	++layoutsPerformed;
	TEST(iLayoutMan->LayoutsPerformed() == layoutsPerformed);	
	const RPointerArray<CTest5Control>& ctrlArray = iTestAppView->CtrlArray();
	TInt numCtrls = ctrlArray.Count();
	layoutsPerformed = iLayoutMan->LayoutsPerformed();
	TInt ctrlCount = 0;
	for (ctrlCount = 0; ctrlCount < numCtrls; ctrlCount++)
		{
		ctrlArray[ctrlCount]->RequestRelayout(iTestAppView);
		++layoutsPerformed;
		TEST(iLayoutMan->LayoutsPerformed() == layoutsPerformed);
		}
	
	
	INFO_PRINTF1(_L("Testing Changing Control Size"));	
	// every time a controls size is changed a layout will be performed
	layoutsPerformed = iLayoutMan->LayoutsPerformed();
	iTestAppView->SetRect(KViewRect);
	++layoutsPerformed;
	TEST(iLayoutMan->LayoutsPerformed() == layoutsPerformed);
	numCtrls = ctrlArray.Count();
	for (ctrlCount = 0; ctrlCount < numCtrls; ctrlCount++)
		{
		ctrlArray[ctrlCount]->SetRect(KMinSize);
		layoutsPerformed++;
		TEST(iLayoutMan->LayoutsPerformed() == layoutsPerformed);
		}
	
	INFO_PRINTF1(_L("Testing Calculating mimimum size"));
	TEST (iTestAppView->MinimumSize() == KMinSize);

	INFO_PRINTF1(_L("Testing baseline offset calculation"));
	TSize testSize(400, 400);

	// See implementation of CalcTextBaselineOffset - if the
	// width > 200, it returns height/4, else it returns 3*height/4
	// ctrlArray[0] only porvided as dummy because fct requires it
	TInt baseOffset = iLayoutMan->CalcTextBaselineOffset(*ctrlArray[0], testSize);
	INFO_PRINTF2(_L("Width 400, offset = %d"), baseOffset);
	TEST (baseOffset < 200);

	testSize.iWidth = 100;
	baseOffset = iLayoutMan->CalcTextBaselineOffset(*ctrlArray[0], testSize);
	INFO_PRINTF2(_L("Width 100, offset = %d"), baseOffset);
	TEST (baseOffset > 200);
	}
コード例 #14
0
ファイル: preproc.cpp プロジェクト: kuailexs/symbiandump-os1
void CMMFTestVideoPreProcHwDevice::SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation)
	{
	TSize testSize(KTestScaleY, KTestScaleX);
	if (!(aOutputSize == testSize) || !aFrameStabilisation)
		User::Leave(KErrCorrupt);
	}