예제 #1
0
void Window::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
	//lock();

	if (m_type == Type_QtNativePaintWindow)
	{
		g_critical("%s: window of type QtNativePaintWindow attempting base-class paint()!",__PRETTY_FUNCTION__);
		return;
	}

	const QPixmap* pix = acquireScreenPixmap();
	if (!pix) {
		g_critical("Failed to acquire screen pixmap");
		return;
	}
	
	painter->drawPixmap(m_visibleBounds.x(), m_visibleBounds.y(), *pix,
						0, 0, m_visibleBounds.width(), m_visibleBounds.height());

	//unlock();
}
예제 #2
0
void CardHostWindow::paintBase(QPainter* painter, bool maximized)
{
    if (maximized) {
        // faster, rectangular blit
        painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
        painter->rotate(m_adjustmentAngle);

        Window::paint(painter, 0, 0);
        painter->rotate(-m_adjustmentAngle);
        painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
    } else {
        // draw with rounded corners
        const QPixmap* pix = acquireScreenPixmap();
        if (pix) {
            QRectF brect = boundingRect();
            QPainterPath paintPath;

                            initializeRoundedCornerStage();

                            painter->setCompositionMode(QPainter::CompositionMode_SourceOver);

            if (m_adjustmentAngle == 90 || m_adjustmentAngle == -90) {
                QRectF rotRect = QRectF(brect.y(), brect.x(), brect.height(), brect.width());
                paintPath.addRoundedRect(rotRect, 25, 25);
            } else {
                paintPath.addRoundedRect(m_boundingRect, 25, 25);
            }

            int originX = brect.x();
            int originY = brect.y();

            if (m_adjustmentAngle == 90 || m_adjustmentAngle == -90) {
                originX = brect.y();
                originY = brect.x();
            }

            if (fullScreen()) {
                if (m_adjustmentAngle == 90 || m_adjustmentAngle == -90) {
                    painter->setBrushOrigin(originX - (pix->width()-brect.height())/2, originY);
                } else {
                    painter->setBrushOrigin(originX, originY - (pix->height() - brect.height()) / 2);
                }
            }
            else
                painter->setBrushOrigin(originX, originY);
                            painter->rotate(m_adjustmentAngle);
#if defined(USE_ROUNDEDCORNER_SHADER)
                            m_roundedCornerShaderStage->setOnPainter(painter);
                            if (m_adjustmentAngle == 90 || m_adjustmentAngle == -90) {
                                painter->drawPixmap(-brect.height()/2, -brect.width()/2, *pix);
                            }
                            else {
                                painter->drawPixmap(-brect.width()/2, -brect.height()/2, *pix);
                            }
                            m_roundedCornerShaderStage->removeFromPainter(painter);
#else
                            painter->fillPath(paintPath, *pix);
#endif
                            painter->rotate(-m_adjustmentAngle);
            painter->setBrushOrigin(0, 0);
        }
    }
}
예제 #3
0
void EmulatedCardWindow::paintBase(QPainter* painter, bool maximized)
{
	if (G_UNLIKELY(m_transition)) {
		painter->fillRect(boundingRect(), QColor(0x0f,0x0f,0x0f,0xff));

		bool clipping = painter->hasClipping();
		QPainterPath clipPath;
		if (clipping) {
			clipPath = painter->clipPath();
		}

		painter->rotate(rotationAdjustmentAngle());
		translateForPositiveSpaceChange(painter, false);
		drawDeviceFrame(painter);
		painter->setClipRect(transitionBoundingRect());
		m_transition->draw(painter, m_paintPath, m_maximized);
		drawRoundedCorners(painter);
		//Undo changes to the painter.
		translateForPositiveSpaceChange(painter, true);
		painter->rotate(-rotationAdjustmentAngle());

		if (m_transition->completed()) {

			m_data->onSceneTransitionFinish();

			delete m_transition;
			m_transition = NULL;

			m_transitionTimer.stop();
		}


		if (G_UNLIKELY(clipping)) {
			painter->setClipPath(clipPath);
		} else {
			painter->setClipping(false);
		}

	} else if (G_UNLIKELY(m_data->acquireTransitionPixmap())) {

		QRect targetRect = boundingRect().toRect();
		QRect sourceRect = QRect(0, 0, emulationBoundingRect().width(), emulationBoundingRect().height());

		painter->setBrushOrigin(targetRect.x(), targetRect.y());

		if (maximized) {
			painter->fillRect(boundingRect(), QColor(0x0f,0x0f,0x0f,0xff));
		} else {
			painter->fillPath(m_paintPath, QColor(0x0f,0x0f,0x0f,0xff));
		}

		painter->rotate(rotationAdjustmentAngle());
		translateForPositiveSpaceChange(painter, false);
		drawDeviceFrame(painter);

		if (G_LIKELY(maximized)) {
			painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
			painter->drawPixmap(emulationBoundingRect().toRect(), *m_data->acquireTransitionPixmap(), sourceRect);
			drawRoundedCorners(painter);
			//painter->drawPixmap(QRect(x,y,emuWidth,emuHeight), *m_data->acquireTransitionPixmap());
		} else {
			painter->drawPixmap(emulationBoundingRect().toRect(), *m_data->acquireTransitionPixmap(), sourceRect);
			drawRoundedCorners(painter);
			//painter->drawPixmap(QRect(x,y,emuWidth,emuHeight), *m_data->acquireTransitionPixmap());
		}

		if (G_LIKELY(maximized))
			painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
		painter->setBrushOrigin(0, 0);
		//Undo changes to the painter
		translateForPositiveSpaceChange(painter, true);
		painter->rotate(-rotationAdjustmentAngle());
	} else {
		if (maximized) {
			// faster, rectangular blit
			painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
			painter->fillRect(boundingRect(), QColor(0x0f,0x0f,0x0f,0xff));
			painter->rotate(rotationAdjustmentAngle());
			translateForPositiveSpaceChange(painter, false);
			drawDeviceFrame(painter);
			Window::paint(painter, 0, 0);
			drawRoundedCorners(painter);

			//Undo changes to the painter
			translateForPositiveSpaceChange(painter, true);

			painter->rotate(-rotationAdjustmentAngle());
			painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
		} else {
			// draw with rounded corners
                        const QPixmap* pix = acquireScreenPixmap();
                        if (pix) {
                                initializeSmoothEdgeStage();
                                initializeRoundedCornerStage();

                                painter->setCompositionMode(QPainter::CompositionMode_SourceOver);

                                //painter->fillRect(boundingRect(), QColor(0,0,0, 0xFF));
#if defined(USE_ROUNDEDCORNER_SHADER)
                                QRectF brect = boundingRect();
                                QRect sourceRectBG = QRect(0,0,boundingRect().toRect().width(), boundingRect().toRect().height());
                                m_roundedCornerShaderStage->setOnPainter(painter);
                                painter->drawPixmap(brect, *m_background, m_background->rect());
                                m_roundedCornerShaderStage->removeFromPainter(painter);
#else
                                painter->fillPath(m_paintPath, QColor(0x0f,0x0f,0x0f,0xff));
#endif
				painter->rotate(rotationAdjustmentAngle());
				drawDeviceFrame(painter);
				painter->save();
                                qreal zPosition = m_position.trans.z();
				//zPosition is a value between 0 and 1, with a minimized card being
				//approximately 0.5.  At 1, we want scaling to be 1 (i.e. no difference)
				//and at zPosition of 0.5, a scale of 1.5 looks pretty good.  So, we'll
				//subtract zPosition from 2.0 to get the scaling factor.
				painter->scale(2.0 - zPosition, 2.0 - zPosition);
                                QRect sourceRect = QRect(0,0,emulationBoundingRect().toRect().width(), emulationBoundingRect().toRect().height());
#if defined(USE_SMOOTHEDGE_SHADER)
                                m_smoothEdgeShaderStage->setOnPainter(painter);
                                painter->drawPixmap(emulationBoundingRect().toRect(), *pix, sourceRect);
                                m_smoothEdgeShaderStage->removeFromPainter(painter);
#else
                                painter->drawPixmap(emulationBoundingRect().toRect(), *pix, sourceRect);
#endif
                                drawRoundedCorners(painter);
				painter->rotate(-rotationAdjustmentAngle());
				painter->restore();
                                painter->setBrushOrigin(0, 0);
			}
		}
	}
}