void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<PlatformCALayer> rootChild)
{
    if (m_rootChild == rootChild)
        return;

    if (m_rootChild)
        m_rootChild->removeFromSuperlayer();

    m_rootChild = rootChild;

    if (!m_rootChild)
        return;

    m_layerTreeHost->setRootChildLayer(m_rootChild.get());
    PlatformCALayer* rootLayer = m_rootChild->rootLayer();
    CGRect rootBounds = m_rootChild->rootLayer()->bounds();
    m_rootChild->setFrame(rootBounds);
    m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
#ifndef NDEBUG
    RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1));
    rootLayer->setBackgroundColor(redColor.get());
#else
    rootLayer->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
#endif
}
Exemple #2
0
void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<WKCACFLayer> rootChild)
{
    if (m_rootChild == rootChild)
        return;

    if (m_rootChild)
        m_rootChild->removeFromSuperlayer();

    m_rootChild = rootChild;

    if (!m_rootChild)
        return;

    m_layerRenderer->setRootChildLayer(m_rootChild.get());
    WKCACFLayer* rootLayer = m_rootChild->rootLayer();
    CGRect rootBounds = m_rootChild->rootLayer()->bounds();
    m_rootChild->setFrame(rootBounds);
    m_layerRenderer->setScrollFrame(IntPoint(rootBounds.origin), IntSize(rootBounds.size));
    m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
#ifndef NDEBUG
    RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1));
    rootLayer->setBackgroundColor(redColor.get());
#else
    rootLayer->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
#endif
}
void RenderableDebugableEntityItem::render(EntityItem* entity, RenderArgs* args) {
    if (args->_debugFlags & RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP) {
        Q_ASSERT(args->_batch);
        gpu::Batch& batch = *args->_batch;

        batch.setModelTransform(entity->getTransformToCenter()); // we want to include the scale as well
        
        auto nodeList = DependencyManager::get<NodeList>();
        const QUuid& myNodeID = nodeList->getSessionUUID();
        bool highlightSimulationOwnership = (entity->getSimulatorID() == myNodeID);
        if (highlightSimulationOwnership) {
            glm::vec4 greenColor(0.0f, 1.0f, 0.2f, 1.0f);
            renderBoundingBox(entity, args, 0.08f, greenColor);
        }

        quint64 now = usecTimestampNow();
        if (now - entity->getLastEditedFromRemote() < 0.1f * USECS_PER_SECOND) {
            glm::vec4 redColor(1.0f, 0.0f, 0.0f, 1.0f);
            renderBoundingBox(entity, args, 0.16f, redColor);
        }

        if (now - entity->getLastBroadcast() < 0.2f * USECS_PER_SECOND) {
            glm::vec4 yellowColor(1.0f, 1.0f, 0.2f, 1.0f);
            renderBoundingBox(entity, args, 0.24f, yellowColor);
        }

        ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
        if (motionState && motionState->isActive()) {
            glm::vec4 blueColor(0.0f, 0.0f, 1.0f, 1.0f);
            renderBoundingBox(entity, args, 0.32f, blueColor);
        }
    }
}
void TupColorPalette::setBaseColorsPanel()
{
#ifndef Q_OS_ANDROID
    QSize cellSize(50, 30);
#else
    QSize cellSize(70, 50);
#endif

    k->currentBaseColor = 0;
    QColor redColor(255, 0, 0);
    QBrush redBrush(redColor, k->brush.style());
    TupColorWidget *red = new TupColorWidget(0, redBrush, cellSize, false);
    red->selected();
    connect(red, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << red;

    QColor greenColor(0, 255, 0);
    QBrush greenBrush(greenColor, k->brush.style());
    TupColorWidget *green = new TupColorWidget(1, greenBrush, cellSize, false);
    connect(green, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << green;

    QColor blueColor(0, 0, 255);
    QBrush blueBrush(blueColor, k->brush.style());
    TupColorWidget *blue = new TupColorWidget(2, blueBrush, cellSize, false);
    connect(blue, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << blue;

    QColor whiteColor(255, 255, 255);
    QBrush whiteBrush(whiteColor, k->brush.style());
    TupColorWidget *white = new TupColorWidget(3, whiteBrush, cellSize, false);
    connect(white, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << white;

    QBoxLayout *bottomLayout = new QHBoxLayout;
    bottomLayout->setAlignment(Qt::AlignHCenter);
    bottomLayout->setContentsMargins(3, 3, 3, 3);

#ifndef Q_OS_ANDROID
    bottomLayout->setSpacing(10);
#else
    bottomLayout->setSpacing(25);
#endif

    bottomLayout->addWidget(red);
    bottomLayout->addWidget(green);
    bottomLayout->addWidget(blue);
    bottomLayout->addWidget(white);

    k->paletteGlobalLayout->addWidget(new TupSeparator(Qt::Horizontal));
    k->paletteGlobalLayout->addLayout(bottomLayout);
}
Exemple #5
0
void Widget::drawWidget(QPainter &qp) {

    QString num[] = { "75", "150", "225", "300", "375", "450",
                      "525", "600", "675" };

    int asize = sizeof(num)/sizeof(num[1]);

    QColor redColor(255, 175, 175);
    QColor yellowColor(255, 255, 184);

    int width = size().width();

    Burning *burn = (Burning *) m_parent;
    int cur_width = burn->getCurrentWidth();

    int step = (int) qRound((double)width / DIVISIONS);
    int till = (int) ((width / MAX_CAPACITY) * cur_width);
    int full = (int) ((width / MAX_CAPACITY) * FULL_CAPACITY);

    if (cur_width >= FULL_CAPACITY) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, full, 30);
        qp.setPen(redColor);
        qp.setBrush(redColor);
        qp.drawRect(full, 0, till-full, PANEL_HEIGHT);

    } else if (till > 0) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, till, PANEL_HEIGHT);
    }

    QColor grayColor(90, 80, 60);
    qp.setPen(grayColor);

    for (int i=1; i <=asize; i++) {

        qp.drawLine(i*step, 0, i*step, LINE_WIDTH);
        QFont newFont = font();
        newFont.setPointSize(7);
        setFont(newFont);

        QFontMetrics metrics(font());

        int w = metrics.width(num[i-1]);
        qp.drawText(i*step-w/2, DISTANCE, num[i-1]);
    }
}
Exemple #6
0
void KeyboardDemo::Render( )
{
    if( d3dContext_ == 0 )
        return;

    float clearColor[4] = { 0.0f, 0.0f, 0.25f, 1.0f };
    d3dContext_->ClearRenderTargetView( backBufferTarget_, clearColor );

    unsigned int stride = sizeof( VertexPos );
    unsigned int offset = 0;

    d3dContext_->IASetInputLayout( inputLayout_ );
    d3dContext_->IASetVertexBuffers( 0, 1, &vertexBuffer_, &stride, &offset );
    d3dContext_->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

	XMFLOAT4 redColor( 1.0f, 0.0f, 0.0f, 1.0f );
	XMFLOAT4 greenColor( 0.0f, 1.0f, 0.0f, 1.0f );
	XMFLOAT4 blueColor( 0.0f, 0.0f, 1.0f, 1.0f );

	if( selectedColor_ == 0 )
	{
		d3dContext_->UpdateSubresource( colorCB_, 0, 0, &redColor, 0, 0 );
	}
	else if( selectedColor_ == 1 )
	{
		d3dContext_->UpdateSubresource( colorCB_, 0, 0, &greenColor, 0, 0 );
	}
	else
	{
		d3dContext_->UpdateSubresource( colorCB_, 0, 0, &blueColor, 0, 0 );
	}

    d3dContext_->VSSetShader( customColorVS_, 0, 0 );
    d3dContext_->PSSetShader( customColorPS_, 0, 0 );
	d3dContext_->PSSetConstantBuffers( 0, 1, &colorCB_ );
    d3dContext_->Draw( 3, 0 );

    swapChain_->Present( 0, 0 );
}
Exemple #7
0
void MasterClass::playGameOver()
{
	
	View view = window->getView();
	Vector2u window_size = window->getSize();
	Color darkColor(0,0,0,0);
	Color redColor(6,0,0,6);
	RectangleShape darkenedScreen(Vector2f(window_size.x, window_size.y));
	darkenedScreen.setPosition(view.getCenter().x - (float)window_size.x/2, 0);
	darkenedScreen.setFillColor(darkColor);
	
	RectangleShape redScreen(Vector2f(window_size.x, window_size.y));
	redScreen.setPosition(view.getCenter().x - (float)window_size.x/2, 0);
	redScreen.setFillColor(redColor);

    Clock clock;
    Time time;
    int t = 0, cpt = 0, dt = 0;
    
    Texture gameOverTex;
	gameOverTex.loadFromFile("res/tex/decor/game_over.png");
	Sprite gameOverSprite(gameOverTex);
	Vector2u texture_size = gameOverTex.getSize();
	gameOverSprite.scale((float)window_size.x/texture_size.x, (float)window_size.y/texture_size.y);
	gameOverSprite.setPosition(view.getCenter().x - (float)window_size.x/2, 0);
    
    game->updateVolume();
    game->resume();
	while (window->isOpen() && state == GAMEOVER)
    {
    	Event event;
    	while(window->pollEvent(event))
    	{
    		if(event.type == Event::KeyPressed && event.key.code == Keyboard::Escape)
    		{
    			previousState = state;
				state = MAINMENU;
			}
    	}
    	time = clock.restart();
    	dt = time.asMilliseconds();
    	t += dt;
    	cpt += dt;
        game->update(time);
        game->checkCollisions();
        
        if(t < 2550 && cpt >= 50)
        {
        	cpt = 0;
        	if(redColor.r < 250)
        	{
        		redColor.r += 6;
        		redColor.a += 6;
        	}
        	else
        	{
        		redColor.r = 255;
        		redColor.a = 255;
        	}
        	
        	if(darkColor.a < 250)
        		darkColor.a += 6;
        	else
        		darkColor.a = 255;
        }
		
		if(t > 2550)
			redColor.a = 0;
		
		if(t > 2550 && cpt >= 50)
        {
        	cpt = 0;
        	if(darkColor.a > 5)
        		darkColor.a -= 6;
        	else
        		darkColor.a = 0;
        }
        
        darkenedScreen.setFillColor(darkColor);
        redScreen.setFillColor(redColor);
        window->clear();
        game->display(window);
        if(t > 2550)
        	window->draw(gameOverSprite);
        window->draw(redScreen);
        window->draw(darkenedScreen);

        window->display();
    }
}
void CameraProjections::Publish(Mat &guiRawImg, bool showHorizonBox)
{

	if (!lastProjectionIsValid || guiRawImg.empty())
		return;

	ros::Time now = ros::Time::now();
	if (params.debug.showTopView->get())
	{

		Mat UnDistRawImg;
		//Mat tmpp;
		//_distorionModel.CreateUndistortFull(guiRawImg, tmpp);
		_distorionModel.CreateUndistort(guiRawImg, UnDistRawImg);
		unDistortedImg_pub.publish(UnDistRawImg, MatPublisher::bgr);

		int sizeOfTopViewW = params.topView.width->get()
				/ params.topView.scale->get();
		int sizeOfTopViewH = params.topView.width->get()
				/ params.topView.scale->get();

		if (topImg_pub.thereAreListeners())
		{
			Mat topHomoFor, topHomoBack;
			double picYawDegree;

			if (ipm.GetHomographyNoYaw(diagnalAngleView, cameraLocation,
					cameraOrintation, topHomoFor, topHomoBack, picYawDegree))
			{

				warpPerspective(UnDistRawImg, topViewBGR, topHomoFor,
						Size(sizeOfTopViewW, sizeOfTopViewH),
						CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS);
				topImg_pub.publish(topViewBGR, MatPublisher::bgr);
			}
		}

		if (mmap_pub.getNumSubscribers() > 0)
		{
			warpPerspective(UnDistRawImg, calibViewBGR, realHomoFor,
					Size(sizeOfTopViewW, sizeOfTopViewH),
					CV_INTER_LINEAR | CV_WARP_FILL_OUTLIERS);
			calibImg_pub.publish(calibViewBGR, MatPublisher::bgr);
			Mat mapMonoImg(calibViewBGR.size(), CV_8UC1);
			cvtColor(calibViewBGR, mapMonoImg, CV_BGR2GRAY);
			std_msgs::Header head;
			nav_msgs::MapMetaData mapMeta;
			head.frame_id = "/ego_floor";
			head.stamp = now;
			mapMeta.height = mapMonoImg.size().height;
			mapMeta.width = mapMonoImg.size().width;
			mapMeta.map_load_time = now;
			mapMeta.resolution = 0.01 * params.topView.scale->get();
			mapMeta.origin.orientation.w = 1;
			mapMeta.origin.position.x =
					-(int) (params.topView.width->get() / 2.) / 100.;
			mapMeta.origin.position.y =
					-(int) (params.topView.width->get() / 2.) / 100.;
			mapMeta.origin.position.z = 0.1;
			for (uint16_t y = 0; y < mapMonoImg.size().height; y++)
			{
				for (uint16_t x = 0; x < mapMonoImg.size().width; x++)
				{
					mmap.data.push_back(
							(mapMonoImg.at<uchar>(y, x) / 255.) * 100.);
				}
			}
			mmap.header = head;
			mmap.info = mapMeta;

			mmap_pub.publish(mmap);
			mmap.data.clear();
		}

	}

	if (params.debug.showCameraPoints->get())
	{
		for (int i = 0; i <= 4; i++)
		{
			int k = i;
			if (i == 4)
			{
				k = 0;
			}
			geometry_msgs::Point p;
			p.x = transformedPointsRes[k].x / 100.;
			p.y = transformedPointsRes[k].y / 100.;
			p.z = transformedPointsRes[k].z / 100.;
			topViewCPoints.marker.points.push_back(p);
		}
		geometry_msgs::Point p;

		p.x = cameraLocation.x;
		p.y = cameraLocation.y;
		p.z = cameraLocation.z;
		topViewCPoints.marker.points.push_back(p);
		for (int i = 0; i <= 4; i++)
		{
			int k = i;
			if (i == 4)
			{
				k = 0;
			}
			geometry_msgs::Point p;
			p.x = gPointRes[k].x / 100.;
			p.y = gPointRes[k].y / 100.;
			p.z = -0.0;
			topViewGPoints.marker.points.push_back(p);

		}
		topViewCPoints.update();
		topViewGPoints.update();
		topViewMarker.publish();
		topViewCPoints.marker.points.clear();
		topViewGPoints.marker.points.clear();
	}
	if (showHorizonBox && params.debug.showHorizonBox->get())
	{
		for (int i = 0; i <= 3; i++)
		{
			int p1 = i;
			int p2 = i + 1;
			if (i == 3)
			{
				p2 = 0;
			}

			char msg[255];
			sprintf(msg, "(%d)", i);
			putText(guiRawImg, msg, outerCornetrsRawImg[i], 1, 1, greenColor());
			line(guiRawImg, outerCornetrsRawImg[p1], outerCornetrsRawImg[p2],
					redColor(), 3);
		}
		circle(guiRawImg, Point2d(320, 240), 5, redColor(), 5);
	}
}