当前位置: 首页>>代码示例>>C++>>正文


C++ Rect类代码示例

本文整理汇总了C++中Rect的典型用法代码示例。如果您正苦于以下问题:C++ Rect类的具体用法?C++ Rect怎么用?C++ Rect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Rect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv)
{
    Mat img;
    FILE* f = 0;
    char _filename[1024];

    if( argc == 1 )
    {
        printf("Usage: peopledetect (<image_filename> | <image_list>.txt)\n");
        return 0;
    }
    img = imread(argv[1]);

    if( img.data )
    {
	    strcpy(_filename, argv[1]);
    }
    else
    {
        f = fopen(argv[1], "rt");
        if(!f)
        {
		    fprintf( stderr, "ERROR: the specified file could not be loaded\n");
		    return -1;
	    }
    }

    HOGDescriptor hog;
    hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
    namedWindow("people detector", 1);

    for(;;)
    {
	    char* filename = _filename;
	    if(f)
	    {
		    if(!fgets(filename, (int)sizeof(_filename)-2, f))
			    break;
		    //while(*filename && isspace(*filename))
		    //	++filename;
		    if(filename[0] == '#')
			    continue;
		    int l = strlen(filename);
		    while(l > 0 && isspace(filename[l-1]))
			    --l;
		    filename[l] = '\0';
		    img = imread(filename);
	    }
	    printf("%s:\n", filename);
	    if(!img.data)
		    continue;
		
	    fflush(stdout);
	    vector<Rect> found, found_filtered;
	    double t = (double)getTickCount();
	    // run the detector with default parameters. to get a higher hit-rate
	    // (and more false alarms, respectively), decrease the hitThreshold and
	    // groupThreshold (set groupThreshold to 0 to turn off the grouping completely).
	    hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2);
	    t = (double)getTickCount() - t;
	    printf("tdetection time = %gms\n", t*1000./cv::getTickFrequency());
	    size_t i, j;
	    for( i = 0; i < found.size(); i++ )
	    {
		    Rect r = found[i];
		    for( j = 0; j < found.size(); j++ )
			    if( j != i && (r & found[j]) == r)
				    break;
		    if( j == found.size() )
			    found_filtered.push_back(r);
	    }
	    for( i = 0; i < found_filtered.size(); i++ )
	    {
		    Rect r = found_filtered[i];
		    // the HOG detector returns slightly larger rectangles than the real objects.
		    // so we slightly shrink the rectangles to get a nicer output.
		    r.x += cvRound(r.width*0.1);
		    r.width = cvRound(r.width*0.8);
		    r.y += cvRound(r.height*0.07);
		    r.height = cvRound(r.height*0.8);
		    rectangle(img, r.tl(), r.br(), cv::Scalar(0,255,0), 3);
	    }
	    imshow("people detector", img);
	    int c = waitKey(0) & 255;
	    if( c == 'q' || c == 'Q' || !f)
            break;
    }
    if(f)
        fclose(f);
    return 0;
}
开发者ID:ljw3351639,项目名称:college-work,代码行数:91,代码来源:peopledetect.cpp

示例2: scalingWindow

Rect MotionDetection::SupplementRect(Rect rect, int videoWidth, int videoHeight)
{

    int topLeftX = rect.x;
    int topLeftY = rect.y;
    int bottomRightX = rect.br().x;
    int bottomRightY = rect.br().y;
    int widthValue = rect.width;
    int heightValue = rect.height;
    Size scalingWindow(rect.width,rect.height);
    //Boundry detection (Might be changed later due to the different requirement)
    //there are at least 9 possibilites where the rectangle is  
    // |1 2 3|
    // |4 5 6|
    // |7 8 9|
    if(topLeftX < 0 
      && topLeftY < 0 
      && IsBetweenTwoInt(bottomRightX,1,videoWidth)
      && IsBetweenTwoInt(bottomRightY,1,videoHeight)
      ) //in 1
    {
      cout << "get in 1" << endl; 
      return Rect(Point(0,0),scalingWindow);
    }
    else if(IsBetweenTwoInt(topLeftX,0,videoWidth-1) 
      && topLeftY < 0 
      && IsBetweenTwoInt(bottomRightX,1,videoWidth)
      && IsBetweenTwoInt(bottomRightY,1,videoHeight)) // in 2
    {
      cout << "get in 2" << endl;  
      return Rect(Point(topLeftX,0),scalingWindow);
    }
    else if(IsBetweenTwoInt(topLeftX,1,videoWidth-1)
      && topLeftY < 0
      && bottomRightX > videoWidth
      && IsBetweenTwoInt(bottomRightY,1,videoHeight)) // in 3
    {
      cout << "get in 3" << endl;  
      return Rect(Point(videoWidth - widthValue,0), scalingWindow);
    }
    else if(topLeftX < 0 
      && IsBetweenTwoInt(topLeftY,0,videoHeight-1)
      && IsBetweenTwoInt(bottomRightX,1,videoWidth)
      && IsBetweenTwoInt(bottomRightY,1,videoHeight)) // in 4
    {
      cout << "get in 4" << endl; 
      return Rect(Point(0,topLeftY),scalingWindow); 
    }
    else if(IsBetweenTwoInt(topLeftX,0,videoWidth-1)
      && IsBetweenTwoInt(topLeftY,0,videoHeight-1)
      && IsBetweenTwoInt(bottomRightX,1,videoWidth)
      && IsBetweenTwoInt(bottomRightY,1,videoHeight)) // in 5
    {
      cout << "get in 5" << endl; 
      return Rect(Point(topLeftX,topLeftY),scalingWindow);
    }
    else if(IsBetweenTwoInt(topLeftX,0,videoWidth-1)
      && IsBetweenTwoInt(topLeftY,0,videoHeight-1)
      && bottomRightX > videoWidth
      && IsBetweenTwoInt(bottomRightY,1,videoHeight)) // in 6
    {
      cout << "get in 6" << endl; 
      return Rect(Point(videoWidth - widthValue,topLeftY),scalingWindow);
    }
    else if(topLeftX < 0 
      && IsBetweenTwoInt(topLeftY,1,videoHeight-1)
      && IsBetweenTwoInt(bottomRightX,1,videoWidth)-1
      && bottomRightY > videoHeight) // in 7
    {
      cout << "get in 7" << endl; 
      return Rect(Point(0,videoHeight-heightValue),scalingWindow);
    }
    else if(IsBetweenTwoInt(topLeftX,0,videoWidth)
      && IsBetweenTwoInt(topLeftY,1,videoHeight-1)
      && IsBetweenTwoInt(bottomRightX,1,videoWidth)
      && bottomRightY > 0) // in 8
    {
      cout << "get in 8" << endl; 
      return Rect(Point(topLeftX,videoHeight-heightValue),scalingWindow);
    }
    else if(IsBetweenTwoInt(topLeftX,0,videoHeight-1)
      && IsBetweenTwoInt(topLeftY,1,videoHeight-1)
      && bottomRightX > videoWidth
      && bottomRightY > videoHeight) // in 9
    {
      cout << "get in 9" << endl; 
      return Rect(Point(videoWidth - widthValue,videoHeight - heightValue),scalingWindow);
    }
}
开发者ID:kuanghaochina,项目名称:Smart-Assistant-Surveillance-System,代码行数:89,代码来源:MotionDetection.cpp

示例3: main

//-----------------------------------【main( )函数】--------------------------------------------
//		描述:控制台应用程序的入口函数,我们的程序从这里开始
//-------------------------------------------------------------------------------------------------
int main( int argc, const char** argv )
{
	ShowHelpText();

	VideoCapture cap;
	Rect trackWindow;
	int hsize = 16;
	float hranges[] = {0,180};
	const float* phranges = hranges;

	cap.open(0);

	if( !cap.isOpened() )
	{
		cout << "不能初始化摄像头\n";
	}

	namedWindow( "Histogram", 0 );
	namedWindow( "CamShift Demo", 0 );
	setMouseCallback( "CamShift Demo", onMouse, 0 );
	createTrackbar( "Vmin", "CamShift Demo", &vmin, 256, 0 );
	createTrackbar( "Vmax", "CamShift Demo", &vmax, 256, 0 );
	createTrackbar( "Smin", "CamShift Demo", &smin, 256, 0 );

	Mat frame, hsv, hue, mask, hist, histimg = Mat::zeros(200, 320, CV_8UC3), backproj;
	bool paused = false;

	for(;;)
	{
		if( !paused )
		{
			cap >> frame;
			if( frame.empty() )
				break;
		}

		frame.copyTo(image);

		if( !paused )
		{
			cvtColor(image, hsv, COLOR_BGR2HSV);

			if( trackObject )
			{
				int _vmin = vmin, _vmax = vmax;

				inRange(hsv, Scalar(0, smin, MIN(_vmin,_vmax)),
					Scalar(180, 256, MAX(_vmin, _vmax)), mask);
				int ch[] = {0, 0};
				hue.create(hsv.size(), hsv.depth());
				mixChannels(&hsv, 1, &hue, 1, ch, 1);

				if( trackObject < 0 )
				{
					Mat roi(hue, selection), maskroi(mask, selection);
					calcHist(&roi, 1, 0, maskroi, hist, 1, &hsize, &phranges);
					normalize(hist, hist, 0, 255, CV_MINMAX);

					trackWindow = selection;
					trackObject = 1;

					histimg = Scalar::all(0);
					int binW = histimg.cols / hsize;
					Mat buf(1, hsize, CV_8UC3);
					for( int i = 0; i < hsize; i++ )
						buf.at<Vec3b>(i) = Vec3b(saturate_cast<uchar>(i*180./hsize), 255, 255);
					cvtColor(buf, buf, CV_HSV2BGR);

					for( int i = 0; i < hsize; i++ )
					{
						int val = saturate_cast<int>(hist.at<float>(i)*histimg.rows/255);
						rectangle( histimg, Point(i*binW,histimg.rows),
							Point((i+1)*binW,histimg.rows - val),
							Scalar(buf.at<Vec3b>(i)), -1, 8 );
					}
				}

				calcBackProject(&hue, 1, 0, hist, backproj, &phranges);
				backproj &= mask;
				RotatedRect trackBox = CamShift(backproj, trackWindow,
					TermCriteria( CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1 ));
				if( trackWindow.area() <= 1 )
				{
					int cols = backproj.cols, rows = backproj.rows, r = (MIN(cols, rows) + 5)/6;
					trackWindow = Rect(trackWindow.x - r, trackWindow.y - r,
						trackWindow.x + r, trackWindow.y + r) &
						Rect(0, 0, cols, rows);
				}

				if( backprojMode )
					cvtColor( backproj, image, COLOR_GRAY2BGR );
				ellipse( image, trackBox, Scalar(0,0,255), 3, CV_AA );
			}
		}
		else if( trackObject < 0 )
			paused = false;

//.........这里部分代码省略.........
开发者ID:BigCreatation,项目名称:OpenCV3-Intro-Book-Src,代码行数:101,代码来源:8_CamShiftDemo.cpp

示例4: RENDER_TRANSFORMED_IF_NEED

bool
Layer_SphereDistort::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{
	RENDER_TRANSFORMED_IF_NEED(__FILE__, __LINE__)

	/*	Things to consider:
		1) Block expansion for distortion (ouch... quality level??)
		2) Bounding box clipping
		3) Super sampling for better visual quality (based on the quality level?)
		4) Interpolation type for sampling (based on quality level?)

		//things to defer until after
		super sampling, non-linear interpolation
	*/

	//bounding box reject
	Vector center=param_center.get(Vector());
	double radius=param_radius.get(double());
	double percent=param_amount.get(double());
	int type=param_type.get(int());
	bool clip=param_clip.get(bool());
	{
		Rect	sphr;

		sphr.set_point(center[0]-radius,center[1]-radius);
		sphr.expand(center[0]+radius,center[1]+radius);

		//get the bounding box of the transform
		Rect	windr;

		//and the bounding box of the rendering
		windr.set_point(renddesc.get_tl()[0],renddesc.get_tl()[1]);
		windr.expand(renddesc.get_br()[0],renddesc.get_br()[1]);

		//test bounding boxes for collision
		if( (type == TYPE_NORMAL && !intersect(sphr,windr)) ||
			(type == TYPE_DISTH && (sphr.minx >= windr.maxx || windr.minx >= sphr.maxx)) ||
			(type == TYPE_DISTV && (sphr.miny >= windr.maxy || windr.miny >= sphr.maxy)) )
		{
			//synfig::warning("Spherize: Bounding box reject");
			if (clip)
			{
				surface->set_wh(renddesc.get_w(), renddesc.get_h());
				surface->clear();
				return true;
			}
			else
				return context.accelerated_render(surface,quality,renddesc,cb);
		}

		//synfig::warning("Spherize: Bounding box accept");
	}

	//Ok, so we overlap some... now expand the window for rendering
	RendDesc r = renddesc;
	Surface background;
	Real pw = renddesc.get_pw(),ph = renddesc.get_ph();

	int nl=0,nt=0,nr=0,nb=0, nw=0,nh=0;
	Point tl = renddesc.get_tl(), br = renddesc.get_br();

	{
		//must enlarge window by pixel coordinates so go!

		//need to figure out closest and farthest point and distort THOSE

		Point origin[4] = {tl,tl,br,br};
		Vector v[4] = {Vector(0,br[1]-tl[1]),
					   Vector(br[0]-tl[0],0),
					   Vector(0,tl[1]-br[1]),
					   Vector(tl[0]-br[0],0)};

		Point close(0,0);
		Real t = 0;
		Rect	expandr(tl,br);

		//expandr.set_point(tl[0],tl[1]);
		//expandr.expand(br[0],br[1]);

		//synfig::warning("Spherize: Loop through lines and stuff");
		for(int i=0; i<4; ++i)
		{
			//synfig::warning("Spherize: 	%d", i);
			Vector p_o = center-origin[i];

			//project onto left line
			t = (p_o*v[i])/v[i].mag_squared();

			//clamp
			if(t < 0) t = 0; if(t > 1) t = 1;

			close = origin[i] + v[i]*t;

			//now get transforms and expand the rectangle to accommodate
			Point p = sphtrans(close,center,radius,percent,type);
			expandr.expand(p[0],p[1]);
			p = sphtrans(origin[i],center,radius,percent,type);
			expandr.expand(p[0],p[1]);
			p = sphtrans(origin[i]+v[i],center,radius,percent,type);
			expandr.expand(p[0],p[1]);
//.........这里部分代码省略.........
开发者ID:ChillyCider,项目名称:synfig-reloaded,代码行数:101,代码来源:sphere_distort.cpp

示例5: hw

void LayerBase::drawWithOpenGL(const Region& clip,
        GLint textureName, const GGLSurface& t) const
{
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
    const uint32_t fbHeight = hw.getHeight();
    const State& s(drawingState());

    // bind our texture
    validateTexture(textureName);
    glEnable(GL_TEXTURE_2D);

    // Dithering...
    if (s.flags & ISurfaceComposer::eLayerDither) {
        glEnable(GL_DITHER);
    } else {
        glDisable(GL_DITHER);
    }

    if (UNLIKELY(s.alpha < 0xFF)) {
        // We have an alpha-modulation. We need to modulate all
        // texture components by alpha because we're always using 
        // premultiplied alpha.
        
        // If the texture doesn't have an alpha channel we can
        // use REPLACE and switch to non premultiplied alpha
        // blending (SRCA/ONE_MINUS_SRCA).
        
        GLenum env, src;
        if (needsBlending()) {
            env = GL_MODULATE;
            src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
        } else {
            env = GL_REPLACE;
            src = GL_SRC_ALPHA;
        }
        const GGLfixed alpha = (s.alpha << 16)/255;
        glColor4x(alpha, alpha, alpha, alpha);
        glEnable(GL_BLEND);
        glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA);
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env);
    } else {
        glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
        if (needsBlending()) {
            GLenum src = mPremultipliedAlpha ? GL_ONE : GL_SRC_ALPHA;
            glEnable(GL_BLEND);
            glBlendFunc(src, GL_ONE_MINUS_SRC_ALPHA);
        } else {
            glDisable(GL_BLEND);
        }
    }

    if (UNLIKELY(transformed()
            || !(mFlags & DisplayHardware::DRAW_TEXTURE_EXTENSION) )) 
    {
        //StopWatch watch("GL transformed");
        Region::iterator iterator(clip);
        if (iterator) {
            // always use high-quality filtering with fast configurations
            bool fast = !(mFlags & DisplayHardware::SLOW_CONFIG);
            if (!fast && s.flags & ISurfaceComposer::eLayerFilter) {
                glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            }            
            const GLfixed texCoords[4][2] = {
                    { 0,        0 },
                    { 0,        0x10000 },
                    { 0x10000,  0x10000 },
                    { 0x10000,  0 }
            };

            glMatrixMode(GL_TEXTURE);
            glLoadIdentity();
            if (!(mFlags & DisplayHardware::NPOT_EXTENSION)) {
                // find the smallest power-of-two that will accommodate our surface
                GLuint tw = 1 << (31 - clz(t.width));
                GLuint th = 1 << (31 - clz(t.height));
                if (tw < t.width)  tw <<= 1;
                if (th < t.height) th <<= 1;
                // this divide should be relatively fast because it's
                // a power-of-two (optimized path in libgcc)
                GLfloat ws = GLfloat(t.width) /tw;
                GLfloat hs = GLfloat(t.height)/th;
                glScalef(ws, hs, 1.0f);
            }

            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glVertexPointer(2, GL_FIXED, 0, mVertices);
            glTexCoordPointer(2, GL_FIXED, 0, texCoords);

            Rect r;
            while (iterator.iterate(&r)) {
                const GLint sy = fbHeight - (r.top + r.height());
                glScissor(r.left, sy, r.width(), r.height());
                glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 
            }

            if (!fast && s.flags & ISurfaceComposer::eLayerFilter) {
                glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例6: Rect

void DrumSprite::RegistListener(cocos2d::experimental::AudioProfile& _audioProfile)
{
	// Make sprite1 touchable
	auto listener1 = EventListenerTouchOneByOne::create();
	listener1->setSwallowTouches(true);

	listener1->onTouchBegan = [&](Touch* touch, Event* event) {
		auto target = static_cast<Sprite*>(event->getCurrentTarget());

		Vec2 locationInNode = target->convertToNodeSpace(touch->getLocation());
		Size s = target->getContentSize();
		Rect rect = Rect(0, 0, s.width, s.height);

		//log("touched!");

		if (rect.containsPoint(locationInNode))
		{
			
			//this->setSpriteFrame(SpriteFrame::create("main/drum4_sel.png", Rect(0, 0, 457, 282)));
			//auto temp =  static_cast<AudioTestScene*>(target->getParent());

			//log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y);
			//target->setOpacity(180);


			//log("%s",this->_musicFile);
			//log(musicFile->_string) ;
			_id = AudioEngine::play2d(this->_musicFile->c_str(), false, 1.0f, &_audioProfile);
			int id = _id;
			//log("_idBack: %d", _id);
			// 			if (id != AudioEngine::INVALID_AUDIO_ID) {
			// 				log("--");
			// 			}
			//}
			this->setTexture(_selSprite->c_str());
			this->getParent()->setZOrder(60);

			Size visibleSize = Director::getInstance()->getVisibleSize();
			//score 
			auto scene = (MainGameScene*)(this->getParent()->getParent());
			auto note = (NoteNode*)scene->getChildByTag(scene->_curTag);
			if (note != nullptr) {

				float dist = note->getPositionX() - visibleSize.width * 0.1;
				if (this->getParent()->getTag() == note->_type)
				{
					ScoreUtil::SetScore(dist, scene);
				}
				

			}
			

			return true;
		}

		return false;
	};

	listener1->onTouchEnded = [&](Touch* touch, Event* event) {
		auto target = static_cast<Sprite*>(event->getCurrentTarget());

		this->setTexture(_sprite->c_str());
		this->getParent()->setZOrder(this->_order);
		//this->setSpriteFrame(SpriteFrame::create("main/drum4.png", Rect(0, 0, 417, 242)));


		// 		log("sprite onTouchesEnded.. ");
		//target->setOpacity(255);

		//auto temp = static_cast<AudioTestScene*>(target->getParent());

		//AudioEngine::stop(_id);
		// 		if (target == sprite2)
		// 		{
		// 			containerForSprite1->setLocalZOrder(100);
		// 		}
		// 		else if (target == sprite1)
		// 		{
		// 			containerForSprite1->setLocalZOrder(0);
		// 		}

		//log("moved!");
	};

	listener1->retain();

	(this->getParent()->getParent())->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener1, this);


}
开发者ID:luck49,项目名称:DrumGame,代码行数:91,代码来源:DrumSprite.cpp

示例7: Rect

void HierarchyPanel::listGameObjects(int* indent, int* y, int* total, GameObject*
  gameObject)
{
  Rect rect;
  Rect expandRect;
  bool display = false;

  //*total = *y;
  *total = *total + 1;
  rect.x = position.x + (10 * *indent);
  rect.height = ITEM_HEIGHT;
  rect.y = position.y + rect.height + (*y * rect.height) + ITEM_HEIGHT;
  rect.width = position.width;

  if(totalDisplay >= maxDisplay)
  {
    rect.width -= 20;
  }

  expandRect = Rect(rect.x, rect.y, expandTexture->getWidth(),
    expandTexture->getHeight());

  if(*y <= maxDisplay && *y >= 0)
  {
    display = true;
  }

  if(display == true)
  {
    Rect labelRect(rect.x + expandTexture->getWidth(), rect.y, rect.width
      - ((position.x + rect.x) - position.x + expandTexture->getWidth()),
      rect.height);

    Rect clickRect(position.x, rect.y, rect.width, rect.height);

    if(selectedGo != NULL && gameObject->getName() == selectedGo->getName())
    {
      Gui::drawTexture(Rect(position.x, rect.y, rect.width, rect.height), selectedTexture.get());
    }

    Gui::label(labelRect, gameObject->getName());

    if(Input::getMouseButtonDown(0) == true)
    {
      if(clickRect.contains(Input::getMousePosition()) == true &&
         expandRect.contains(Input::getMousePosition()) == false)
      {
        selectedGo = gameObject;
      }
    }
  }

  *y = *y + 1;

  if(display == true)
  {
    if(gameObject->getTransform()->getChildCount() > 0)
    {
      if(gameObject->getTag() != "expanded")
      {
        Gui::drawTexture(expandRect, expandTexture);
      }
      else
      {
        GuiUtility::rotateAroundPivot(90, Vector2(rect.x +
          (expandTexture->getWidth() / 2), rect.y + (expandTexture->getHeight() / 2)));

        Gui::drawTexture(expandRect, expandTexture);

        GuiUtility::rotateAroundPivot(-90, Vector2(rect.x +
          (expandTexture->getWidth() / 2), rect.y + (expandTexture->getHeight() / 2)));
      }
    }

    if(Input::getMouseButtonDown(0) == true)
    {
      if(expandRect.contains(Input::getMousePosition()) == true)
      {
        if(gameObject->getTag() != "expanded") gameObject->setTag("expanded");
        else if(gameObject->getTag() == "expanded") gameObject->setTag("");
      }
    }
  }

  if(gameObject->getTag() != "expanded")
  {
    return;
  }

  *indent = *indent + 1;
  for(int i = 0; i < gameObject->getTransform()->getChildCount(); i++)
  {
    listGameObjects(indent, y, total,
      gameObject->getTransform()->getChild(i)->getGameObject());
  }
  *indent = *indent - 1;
}
开发者ID:ConnorRB96,项目名称:mutiny,代码行数:97,代码来源:HierarchyPanel.cpp

示例8: Point

void Inventory::addItem(InventoryObject *draggedObject)
{
    items.pushBack(draggedObject);
    
    listView->pushBackCustomItem(draggedObject->getPicture());
    
    EventListenerTouchOneByOne *backgroundListener = EventListenerTouchOneByOne::create();
    backgroundListener->setSwallowTouches(true);
    backgroundListener->onTouchBegan = [draggedObject, this](Touch *touch, Event *event)
    {
        auto target = static_cast<ImageView *>(event->getCurrentTarget());

        Size s = target->getContentSize();
        Point locationInNode = target->convertToNodeSpace(touch->getLocation());
        locationInNode = Point(locationInNode.x + s.width * 0.5f, locationInNode.y + s.height * 0.5f);

        Rect rect = Rect(0, 0, s.width, s.height);
        
        if (rect.containsPoint(locationInNode))
        {
            draggedObject->startDrag();
            simpleLayout->addChild(draggedObject->getPictureDrag());
            draggedObject->getPictureDrag()->setPosition(touch->getLocation());
            return true;
        }
      
        return false;
    };
    
    backgroundListener->onTouchMoved = [draggedObject,this](Touch *touch, Event *event)
    {
        if(draggedObject->getPictureDrag() != nullptr)
            draggedObject->getPictureDrag()->setPosition(touch->getLocation());
    };
    
    backgroundListener->onTouchEnded = [draggedObject,this](Touch *touch, Event *event)
    {
        log("onTouchEnded draggedObject=%d", draggedObject ? draggedObject->getId() : 0);
        
        if(draggedObject->getPictureDrag() != nullptr)
            draggedObject->getPictureDrag()->setVisible(false);
        
        
        Vector<CollectObject *> gameObjects = FirstScene::getInstance()->getGameObjectsLayer()->getGameObjects();
        for(int i = 0; i < gameObjects.size(); ++i)
        {
            log("collect obj=%d",gameObjects.at(i)->getId());
            
            Size size = gameObjects.at(i)->getSpriteMain()->getContentSize();
            
            Rect rect = Rect(0, 0, size.width, size.height);
            
            Point locationInNode = gameObjects.at(i)->getSpriteMain()->convertToNodeSpace(touch->getLocation());
            
            //locationInNode = Point(locationInNode.x , locationInNode.y - size.height * 0.5f);
            
            log("!!!locationInNode=%f %f",locationInNode.x, locationInNode.y);
            if (rect.containsPoint(locationInNode))
            {
                log("AHTUNG");
            }
        }
        
        for(int i = 0; i < items.size(); ++i)
        {
            InventoryObject *droppedObject = items.at(i);
            
            Size s = droppedObject->getPicture()->getContentSize();
            Rect rect = Rect(0, 0, s.width, s.height);
            
            Point locationInNode = droppedObject->getPicture()->convertToNodeSpace(touch->getLocation());
            locationInNode = Point(locationInNode.x + s.width * 0.5f, locationInNode.y + s.height * 0.5f);
            
            log("2onTouchEnded draggedObject=%d obj=%d locationInNode=%f %f", draggedObject ? draggedObject->getId() : 0, droppedObject ? droppedObject->getId() : 0, locationInNode.x,locationInNode.y);
            
            if (droppedObject != draggedObject && rect.containsPoint(locationInNode))
            {
                ValueMap *draggedObjectData = DataManager::getInstance()->getItemByID(draggedObject->getId());
                ValueMap *draggedObjectCraft = &draggedObjectData->at("craft").asValueMap();
                
                ValueMap *droppedObjectData = DataManager::getInstance()->getItemByID(droppedObject->getId());
                ValueMap *droppedObjectCraft = &droppedObjectData->at("craft").asValueMap();
                
                ValueVector draggedObjectCraftItems = draggedObjectCraft->at("items").asValueVector();
                
                bool shouldCraft = false;
                
                for(int i = 0; i < draggedObjectCraftItems.size(); ++i)
                {
                    if(draggedObjectCraftItems.at(i).asInt() == droppedObject->getId())
                    {
                        shouldCraft = true;
                        break;
                    }
                }
                
                if(shouldCraft)
                {
                    int draggedCapacity = draggedObjectCraft->at("capacity").asInt();
                    --draggedCapacity;
//.........这里部分代码省略.........
开发者ID:kovalgek,项目名称:quest2,代码行数:101,代码来源:Inventory.cpp

示例9: Contains

bool Rect::Contains(const Rect& rect) const {
  return (rect.x() >= x() && rect.right() <= right() &&
          rect.y() >= y() && rect.bottom() <= bottom());
}
开发者ID:BenitoJedai,项目名称:mutantspider,代码行数:4,代码来源:mutantspider.cpp

示例10: ComputeRectsForInsetBoxShadow

static void
ComputeRectsForInsetBoxShadow(IntSize aBlurRadius,
                              IntSize aSpreadRadius,
                              IntRect& aOutOuterRect,
                              IntRect& aOutInnerRect,
                              IntMargin& aOutPathMargins,
                              const Rect& aDestRect,
                              const Rect& aShadowClipRect,
                              bool aHasBorderRadius,
                              const RectCornerRadii& aInnerClipRectRadii)
{
  IntSize rectBufferSize = aBlurRadius + aSpreadRadius;
  float cornerWidth = 0;
  float cornerHeight = 0;
  if (aHasBorderRadius) {
    for (size_t i = 0; i < 4; i++) {
      cornerWidth = std::max(cornerWidth, aInnerClipRectRadii[i].width);
      cornerHeight = std::max(cornerHeight, aInnerClipRectRadii[i].height);
    }
  }

  // Create the inner rect to be the smallest possible size based on
  // blur / spread / corner radii
  IntMargin innerMargin = IntMargin(ceil(cornerHeight) + rectBufferSize.height,
                                    ceil(cornerWidth) + rectBufferSize.width,
                                    ceil(cornerHeight) + rectBufferSize.height,
                                    ceil(cornerWidth) + rectBufferSize.width);
  aOutPathMargins = innerMargin;

  // If we have a negative spread radius, we would not have enough
  // size to actually do the blur. So the min size must be the abs() of the blur
  // and spread radius.
  IntSize minBlurSize(std::abs(aSpreadRadius.width) + std::abs(aBlurRadius.width),
                      std::abs(aSpreadRadius.height) + std::abs(aBlurRadius.height));

  IntMargin minInnerMargins = IntMargin(ceil(cornerHeight) + minBlurSize.height,
                                        ceil(cornerWidth) + minBlurSize.width,
                                        ceil(cornerHeight) + minBlurSize.height,
                                        ceil(cornerWidth) + minBlurSize.width);

  IntSize minInnerSize(minInnerMargins.LeftRight() + 1,
                       minInnerMargins.TopBottom() + 1);

  if (aShadowClipRect.height < minInnerSize.height) {
    minInnerSize.height = aShadowClipRect.height;
  }

  if (aShadowClipRect.width < minInnerSize.width) {
    minInnerSize.width = aShadowClipRect.width;
  }

  // Then expand the outer rect based on the size between the inner/outer rects
  IntSize minOuterSize(minInnerSize);
  IntMargin outerRectMargin(rectBufferSize.height, rectBufferSize.width,
                            rectBufferSize.height, rectBufferSize.width);
  minOuterSize.width += outerRectMargin.LeftRight();
  minOuterSize.height += outerRectMargin.TopBottom();

  aOutOuterRect = IntRect(IntPoint(), minOuterSize);
  aOutInnerRect = IntRect(IntPoint(rectBufferSize.width, rectBufferSize.height), minInnerSize);

  if (aShadowClipRect.IsEmpty()) {
    aOutInnerRect.width = 0;
    aOutInnerRect.height = 0;
  }
}
开发者ID:benfrancis,项目名称:gecko-tablet,代码行数:66,代码来源:gfxBlur.cpp

示例11: BlurCache

already_AddRefed<mozilla::gfx::SourceSurface>
gfxAlphaBoxBlur::GetInsetBlur(IntMargin& aExtendDestBy,
                              IntMargin& aSlice,
                              const Rect aDestinationRect,
                              const Rect aShadowClipRect,
                              const IntSize& aBlurRadius,
                              const IntSize& aSpreadRadius,
                              const RectCornerRadii& aInnerClipRadii,
                              const Color& aShadowColor,
                              const bool& aHasBorderRadius,
                              const Point aShadowOffset,
                              bool& aMovedOffset,
                              DrawTarget* aDestDrawTarget)
{
  if (!gBlurCache) {
    gBlurCache = new BlurCache();
  }

  IntRect outerRect;
  IntRect innerRect;
  ComputeRectsForInsetBoxShadow(aBlurRadius, aSpreadRadius,
                                outerRect, innerRect,
                                aSlice, aDestinationRect,
                                aShadowClipRect, aHasBorderRadius,
                                aInnerClipRadii);

  // If we have a shadow offset larger than the min rect,
  // there's no clean way we can properly create a min rect with the offset
  // in the correct place and still render correctly.  In those cases,
  // fallback to just rendering the dest rect as is.
  bool useDestRect = (std::abs(aShadowOffset.x) > aSlice.left) ||
                     (std::abs(aShadowOffset.y) > aSlice.top);
  aMovedOffset = false;
  if (useDestRect) {
    aDestinationRect.ToIntRect(&outerRect);
    aShadowClipRect.ToIntRect(&innerRect);
    aMovedOffset = true;
  }

  BlurCacheData* cached =
      gBlurCache->LookupInsetBoxShadow(outerRect.Size(), innerRect.Size(),
                                       aBlurRadius, aSpreadRadius,
                                       &aInnerClipRadii, aShadowColor,
                                       aHasBorderRadius,
                                       aDestDrawTarget->GetBackendType());
  if (cached && !useDestRect) {
    aExtendDestBy = cached->mExtendDest;
    // Need to extend it twice: once for the outer rect and once for the inner rect.
    aSlice += aExtendDestBy;
    aSlice += aExtendDestBy;

    // So we don't forget the actual cached blur
    RefPtr<SourceSurface> cachedBlur = cached->mBlur;
    return cachedBlur.forget();
  }

  // Dirty rect and skip rect are null for the min inset shadow.
  // When rendering inset box shadows, we respect the spread radius by changing
  //  the shape of the unblurred shadow, and can pass a spread radius of zero here.
  IntSize zeroSpread(0, 0);
  gfxContext* minGfxContext = Init(ThebesRect(outerRect),
                                   zeroSpread, aBlurRadius, nullptr, nullptr);
  if (!minGfxContext) {
    return nullptr;
  }

  DrawTarget* minDrawTarget = minGfxContext->GetDrawTarget();
  RefPtr<Path> maskPath =
    GetBoxShadowInsetPath(minDrawTarget, IntRectToRect(outerRect),
                          IntRectToRect(innerRect), aHasBorderRadius,
                          aInnerClipRadii);

  Color black(0.f, 0.f, 0.f, 1.f);
  minGfxContext->SetColor(black);
  minGfxContext->SetPath(maskPath);
  minGfxContext->Fill();

  IntPoint topLeft;
  RefPtr<SourceSurface> minMask = DoBlur(minDrawTarget, &topLeft);
  if (!minMask) {
    return nullptr;
  }

  RefPtr<SourceSurface> minInsetBlur = CreateBoxShadow(minMask, aShadowColor);
  if (!minInsetBlur) {
    return nullptr;
  }

  IntRect blurRect(topLeft, minInsetBlur->GetSize());
  aExtendDestBy = blurRect - outerRect;

  if (useDestRect) {
    // Since we're just going to paint the actual rect to the destination
    aSlice.SizeTo(0, 0, 0, 0);
  } else {
    aSlice += aExtendDestBy;
    aSlice += aExtendDestBy;

    CacheInsetBlur(outerRect.Size(), innerRect.Size(),
                 aBlurRadius, aSpreadRadius,
//.........这里部分代码省略.........
开发者ID:benfrancis,项目名称:gecko-tablet,代码行数:101,代码来源:gfxBlur.cpp

示例12: CalculateBlurRadius

/* static */ void
gfxAlphaBoxBlur::BlurRectangle(gfxContext* aDestinationCtx,
                               const gfxRect& aRect,
                               RectCornerRadii* aCornerRadii,
                               const gfxPoint& aBlurStdDev,
                               const Color& aShadowColor,
                               const gfxRect& aDirtyRect,
                               const gfxRect& aSkipRect)
{
  IntSize blurRadius = CalculateBlurRadius(aBlurStdDev);

  IntRect rect = RoundedToInt(ToRect(aRect));
  IntMargin extendDestBy;
  IntMargin slice;

  RefPtr<SourceSurface> boxShadow = GetBlur(aDestinationCtx,
                                            rect.Size(), blurRadius,
                                            aCornerRadii, aShadowColor,
                                            extendDestBy, slice);
  if (!boxShadow) {
    return;
  }

  DrawTarget& destDrawTarget = *aDestinationCtx->GetDrawTarget();
  destDrawTarget.PushClipRect(ToRect(aDirtyRect));

  // Copy the right parts from boxShadow into destDrawTarget. The middle parts
  // will be stretched, border-image style.

  Rect srcOuter(Point(), Size(boxShadow->GetSize()));
  Rect srcInner = srcOuter;
  srcInner.Deflate(Margin(slice));

  rect.Inflate(extendDestBy);
  Rect dstOuter(rect);
  Rect dstInner(rect);
  dstInner.Deflate(Margin(slice));

  Rect skipRect = ToRect(aSkipRect);

  if (srcInner.IsEqualInterior(srcOuter)) {
    MOZ_ASSERT(dstInner.IsEqualInterior(dstOuter));
    // The target rect is smaller than the minimal size so just draw the surface
    destDrawTarget.DrawSurface(boxShadow, dstInner, srcInner);
  } else {
    DrawBoxShadows(destDrawTarget, boxShadow, dstOuter, dstInner,
                   srcOuter, srcInner, skipRect);

    // Middle part
    RepeatOrStretchSurface(destDrawTarget, boxShadow,
                           RectWithEdgesTRBL(dstInner.Y(), dstInner.XMost(),
                                             dstInner.YMost(), dstInner.X()),
                           RectWithEdgesTRBL(srcInner.Y(), srcInner.XMost(),
                                             srcInner.YMost(), srcInner.X()),
                           skipRect);
  }

  // A note about anti-aliasing and seems between adjacent parts:
  // We don't explicitly disable anti-aliasing in the DrawSurface calls above,
  // so if there's a transform on destDrawTarget that is not pixel-aligned,
  // there will be seams between adjacent parts of the box-shadow. It's hard to
  // avoid those without the use of an intermediate surface.
  // You might think that we could avoid those by just turning of AA, but there
  // is a problem with that: Box-shadow rendering needs to clip out the
  // element's border box, and we'd like that clip to have anti-aliasing -
  // especially if the element has rounded corners! So we can't do that unless
  // we have a way to say "Please anti-alias the clip, but don't antialias the
  // destination rect of the DrawSurface call".
  // On OS X there is an additional problem with turning off AA: CoreGraphics
  // will not just fill the pixels that have their pixel center inside the
  // filled shape. Instead, it will fill all the pixels which are partially
  // covered by the shape. So for pixels on the edge between two adjacent parts,
  // all those pixels will be painted to by both parts, which looks very bad.

  destDrawTarget.PopClip();
}
开发者ID:benfrancis,项目名称:gecko-tablet,代码行数:76,代码来源:gfxBlur.cpp

示例13: DrawBoxShadows

static void
DrawBoxShadows(DrawTarget& aDestDrawTarget, SourceSurface* aSourceBlur,
               Rect aDstOuter, Rect aDstInner, Rect aSrcOuter, Rect aSrcInner,
               Rect aSkipRect)
{
  // Corners: top left, top right, bottom left, bottom right
  DrawCorner(aDestDrawTarget, aSourceBlur,
             RectWithEdgesTRBL(aDstOuter.Y(), aDstInner.X(),
                               aDstInner.Y(), aDstOuter.X()),
             RectWithEdgesTRBL(aSrcOuter.Y(), aSrcInner.X(),
                               aSrcInner.Y(), aSrcOuter.X()),
             aSkipRect);

  DrawCorner(aDestDrawTarget, aSourceBlur,
             RectWithEdgesTRBL(aDstOuter.Y(), aDstOuter.XMost(),
                               aDstInner.Y(), aDstInner.XMost()),
             RectWithEdgesTRBL(aSrcOuter.Y(), aSrcOuter.XMost(),
                               aSrcInner.Y(), aSrcInner.XMost()),
             aSkipRect);

  DrawCorner(aDestDrawTarget, aSourceBlur,
             RectWithEdgesTRBL(aDstInner.YMost(), aDstInner.X(),
                               aDstOuter.YMost(), aDstOuter.X()),
             RectWithEdgesTRBL(aSrcInner.YMost(), aSrcInner.X(),
                               aSrcOuter.YMost(), aSrcOuter.X()),
             aSkipRect);

  DrawCorner(aDestDrawTarget, aSourceBlur,
             RectWithEdgesTRBL(aDstInner.YMost(), aDstOuter.XMost(),
                               aDstOuter.YMost(), aDstInner.XMost()),
             RectWithEdgesTRBL(aSrcInner.YMost(), aSrcOuter.XMost(),
                               aSrcOuter.YMost(), aSrcInner.XMost()),
             aSkipRect);

  // Edges: top, left, right, bottom
  RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
                         RectWithEdgesTRBL(aDstOuter.Y(), aDstInner.XMost(),
                                           aDstInner.Y(), aDstInner.X()),
                         RectWithEdgesTRBL(aSrcOuter.Y(), aSrcInner.XMost(),
                                           aSrcInner.Y(), aSrcInner.X()),
                         aSkipRect);
  RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
                         RectWithEdgesTRBL(aDstInner.Y(), aDstInner.X(),
                                           aDstInner.YMost(), aDstOuter.X()),
                         RectWithEdgesTRBL(aSrcInner.Y(), aSrcInner.X(),
                                           aSrcInner.YMost(), aSrcOuter.X()),
                         aSkipRect);
  RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
                         RectWithEdgesTRBL(aDstInner.Y(), aDstOuter.XMost(),
                                           aDstInner.YMost(), aDstInner.XMost()),
                         RectWithEdgesTRBL(aSrcInner.Y(), aSrcOuter.XMost(),
                                           aSrcInner.YMost(), aSrcInner.XMost()),
                         aSkipRect);
  RepeatOrStretchSurface(aDestDrawTarget, aSourceBlur,
                         RectWithEdgesTRBL(aDstInner.YMost(), aDstInner.XMost(),
                                           aDstOuter.YMost(), aDstInner.X()),
                         RectWithEdgesTRBL(aSrcInner.YMost(), aSrcInner.XMost(),
                                           aSrcOuter.YMost(), aSrcInner.X()),
                         aSkipRect);
}
开发者ID:benfrancis,项目名称:gecko-tablet,代码行数:60,代码来源:gfxBlur.cpp

示例14: ARX_UNICODE_FormattingInRect

void ARX_UNICODE_FormattingInRect(Font * font, const std::string & text,
                                  const Rect & rect, Color col, long * textHeight = 0,
                                  long * numChars = 0, bool computeOnly = false) {
	
	std::string::const_iterator itLastLineBreak = text.begin();
	std::string::const_iterator itLastWordBreak = text.begin();
	std::string::const_iterator it = text.begin();
	
	int maxLineWidth;
	if(rect.right == Rect::Limits::max()) {
		maxLineWidth = std::numeric_limits<int>::max();
	} else {
		maxLineWidth = rect.width();
	}
	arx_assert(maxLineWidth > 0);
	int penY = rect.top;
	
	if(textHeight) {
		*textHeight = 0;
	}
	
	if(numChars) {
		*numChars = 0;
	}
	
	// Ensure we can at least draw one line...
	if(penY + font->GetLineHeight() > rect.bottom) {
		return;
	}
	
	for(it = text.begin(); it != text.end(); ++it) {
		
		// Line break ?
		bool isLineBreak = false;
		if(*it == '\n' || *it == '*') {
			isLineBreak = true;
		} else {
			
			// Word break ?
			if(*it == ' ' || *it == '\t') {
				itLastWordBreak = it;
			}
			
			// Check length of string up to this point
			Vec2i size = font->GetTextSize(itLastLineBreak, it + 1);
			if(size.x > maxLineWidth) { // Too long ?
				isLineBreak = true;
				if(itLastWordBreak > itLastLineBreak) {
					// Draw a line from the last line break up to the last word break
					it = itLastWordBreak;
				} else if(it == itLastLineBreak) {
					// Not enough space to render even one character!
					break;
				} else {
					// The current word is too long to fit on a line, force a line break
				}
			}
		}
		
		// If we have to draw a line
		//  OR
		// This is the last character of the string
		if(isLineBreak || it + 1 == text.end()) {
			
			std::string::const_iterator itTextStart = itLastLineBreak;
			std::string::const_iterator itTextEnd;
			
			itTextEnd = (isLineBreak) ? it : it + 1;
			
			// Draw the line
			if(!computeOnly) {
				font->Draw(rect.left, penY, itTextStart, itTextEnd, col);
			}
			
			if(it != text.end()) {
				itLastLineBreak = it + 1;
			}
			
			penY += font->GetLineHeight();
			
			// Validate that the new line will fit inside the rect...
			if(penY + font->GetLineHeight() > rect.bottom) {
				break;
			}
		}
	}
	
	// Return text height
	if(textHeight) {
		*textHeight = penY - rect.top;
	}
	
	// Return num characters displayed
	if(numChars) {
		*numChars = it - text.begin();
	}
}
开发者ID:temojin,项目名称:ArxLibertatis,代码行数:97,代码来源:Text.cpp

示例15: initTexture

bool BootAnimation::android()
{
    initTexture(&mAndroid[0], mAssets, "images/android-logo-mask.png");
    initTexture(&mAndroid[1], mAssets, "images/android-logo-shine.png");

    // clear screen
    glShadeModel(GL_FLAT);
    glDisable(GL_DITHER);
    glDisable(GL_SCISSOR_TEST);
    glClearColor(0,0,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    eglSwapBuffers(mDisplay, mSurface);

    glEnable(GL_TEXTURE_2D);
    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

    const GLint xc = (mWidth  - mAndroid[0].w) / 2;
    const GLint yc = (mHeight - mAndroid[0].h) / 2;
    const Rect updateRect(xc, yc, xc + mAndroid[0].w, yc + mAndroid[0].h);

    glScissor(updateRect.left, mHeight - updateRect.bottom, updateRect.width(),
            updateRect.height());

    // Blend state
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

    const nsecs_t startTime = systemTime();
    do {
        nsecs_t now = systemTime();
        double time = now - startTime;
        float t = 4.0f * float(time / us2ns(16667)) / mAndroid[1].w;
        GLint offset = (1 - (t - floorf(t))) * mAndroid[1].w;
        GLint x = xc - offset;

        glDisable(GL_SCISSOR_TEST);
        glClear(GL_COLOR_BUFFER_BIT);

        glEnable(GL_SCISSOR_TEST);
        glDisable(GL_BLEND);
        glBindTexture(GL_TEXTURE_2D, mAndroid[1].name);
        glDrawTexiOES(x,                 yc, 0, mAndroid[1].w, mAndroid[1].h);
        glDrawTexiOES(x + mAndroid[1].w, yc, 0, mAndroid[1].w, mAndroid[1].h);

        glEnable(GL_BLEND);
        glBindTexture(GL_TEXTURE_2D, mAndroid[0].name);
        glDrawTexiOES(xc, yc, 0, mAndroid[0].w, mAndroid[0].h);

        EGLBoolean res = eglSwapBuffers(mDisplay, mSurface);
        if (res == EGL_FALSE)
            break;

        // 12fps: don't animate too fast to preserve CPU
        const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now);
        if (sleepTime > 0)
            usleep(sleepTime);

        checkExit();
    } while (!exitPending());

    glDeleteTextures(1, &mAndroid[0].name);
    glDeleteTextures(1, &mAndroid[1].name);
    return false;
}
开发者ID:GiggleKatDevs,项目名称:giggle_base,代码行数:64,代码来源:BootAnimation.cpp


注:本文中的Rect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。