void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect) { QRectF target = targetRect; if (target.isNull()) { QPaintDevice *dev = p->device(); QRectF deviceRect(0, 0, dev->width(), dev->height()); if (deviceRect.isNull()) { if (sourceRect.isNull()) target = QRectF(QPointF(0, 0), size()); else target = QRectF(QPointF(0, 0), sourceRect.size()); } else { target = deviceRect; } } QRectF source = sourceRect; if (source.isNull()) source = viewBox(); if (source != target && !source.isNull()) { QTransform transform; transform.scale(target.width() / source.width(), target.height() / source.height()); QRectF c2 = transform.mapRect(source); p->translate(target.x() - c2.x(), target.y() - c2.y()); p->scale(target.width() / source.width(), target.height() / source.height()); } }
void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &color) { Q_Q(QBlitterPaintEngine); pmData->unmarkRasterOverlay(rect); QRectF targetRect = rect; if (hasXForm) targetRect = q->state()->matrix.mapRect(rect); const QClipData *clipData = clip(); if (clipData) { if (clipData->hasRectClip) { unlock(); pmData->blittable()->fillRect(targetRect & clipData->clipRect, color); } else if (clipData->hasRegionClip) { QVector<QRect> rects = clipData->clipRegion.rects(); for (int i = 0; i < rects.size(); ++i) { QRect intersectRect = rects.at(i).intersected(targetRect.toRect()); if (!intersectRect.isEmpty()) { unlock(); pmData->blittable()->fillRect(intersectRect, color); } } } } else { if (targetRect.x() >= 0 && targetRect.y() >= 0 && targetRect.width() <= q->paintDevice()->width() && targetRect.height() <= q->paintDevice()->height()) { unlock(); pmData->blittable()->fillRect(targetRect, color); } else { QRectF deviceRect(0, 0, q->paintDevice()->width(), q->paintDevice()->height()); unlock(); pmData->blittable()->fillRect(deviceRect & targetRect, color); } } }
void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { Q_D(QBlitterPaintEngine); bool canDrawOpacity; canDrawOpacity = d->caps.canBlitterDrawPixmapOpacity(pm); if (canDrawOpacity || (d->caps.canBlitterDrawPixmap(r, pm, sr))) { d->unlock(); QRectF targetRect = r; if (d->hasXForm) targetRect = state()->matrix.mapRect(r); const QClipData *clipData = d->clip(); if (clipData) { if (clipData->hasRectClip) { d->clipAndDrawPixmap(clipData->clipRect, targetRect, pm, sr, canDrawOpacity); } else if (clipData->hasRegionClip) { QVector<QRect>rects = clipData->clipRegion.rects(); for (int i = 0; i<rects.size(); ++i) d->clipAndDrawPixmap(rects.at(i), targetRect, pm, sr, canDrawOpacity); } } else { QRectF deviceRect(0, 0, paintDevice()->width(), paintDevice()->height()); d->clipAndDrawPixmap(deviceRect, targetRect, pm, sr, canDrawOpacity); } }else { d->lock(); d->pmData->markRasterOverlay(r); QRasterPaintEngine::drawPixmap(r, pm, sr); } }
void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { Q_D(QBlitterPaintEngine); if (d->capabillities->canBlitterDrawPixmap(r,pm,sr)) { d->unlock(); QRectF targetRect = r; if (d->hasXForm) { targetRect = state()->matrix.mapRect(r); } const QClipData *clipData = clip(); if (clipData) { if (clipData->hasRectClip) { d->clipAndDrawPixmap(clipData->clipRect,targetRect,pm,sr); }else if (clipData->hasRegionClip) { QVector<QRect>rects = clipData->clipRegion.rects(); for (int i = 0; i<rects.size(); i++) { d->clipAndDrawPixmap(rects.at(i),targetRect,pm,sr); } } } else { QRectF deviceRect(0,0,d->raster->paintDevice()->width(), d->raster->paintDevice()->height()); d->clipAndDrawPixmap(deviceRect,targetRect,pm,sr); } }else { d->lock(); d->pmData->markRasterOverlay(r); d->raster->drawPixmap(r, pm, sr); } }
void QSGDefaultRenderer::render() { #if defined (QML_RUNTIME_TESTING) static bool dumpTree = qApp->arguments().contains(QLatin1String("--dump-tree")); if (dumpTree) { printf("\n\n"); QSGNodeDumper::dump(rootNode()); } #endif #ifdef RENDERER_DEBUG debugTimer.invalidate(); debugTimer.start(); geometryNodesDrawn = 0; materialChanges = 0; #endif glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glFrontFace(isMirrored() ? GL_CW : GL_CCW); glDisable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glDepthMask(true); glDepthFunc(GL_GREATER); #if defined(QT_OPENGL_ES) glClearDepthf(0); #else glClearDepth(0); #endif glDisable(GL_SCISSOR_TEST); glClearColor(m_clear_color.redF(), m_clear_color.greenF(), m_clear_color.blueF(), m_clear_color.alphaF()); #ifdef RENDERER_DEBUG int debugtimeSetup = debugTimer.elapsed(); #endif bindable()->clear(clearMode()); #ifdef RENDERER_DEBUG int debugtimeClear = debugTimer.elapsed(); #endif QRect r = viewportRect(); glViewport(r.x(), deviceRect().bottom() - r.bottom(), r.width(), r.height()); m_current_projection_matrix = projectionMatrix(); m_current_model_view_matrix.setToIdentity(); m_currentClip = 0; glDisable(GL_STENCIL_TEST); m_currentMaterial = 0; m_currentProgram = 0; m_currentMatrix = 0; if (m_rebuild_lists) { m_opaqueNodes.reset(); m_transparentNodes.reset(); m_currentRenderOrder = 1; buildLists(rootNode()); m_rebuild_lists = false; } #ifdef RENDERER_DEBUG int debugtimeLists = debugTimer.elapsed(); #endif if (m_needs_sorting) { if (!m_opaqueNodes.isEmpty()) { qSort(&m_opaqueNodes.first(), &m_opaqueNodes.first() + m_opaqueNodes.size(), m_sort_front_to_back ? nodeLessThanWithRenderOrder : nodeLessThan); } m_needs_sorting = false; } #ifdef RENDERER_DEBUG int debugtimeSorting = debugTimer.elapsed(); #endif m_renderOrderMatrix.setToIdentity(); m_renderOrderMatrix.scale(1, 1, qreal(1) / m_currentRenderOrder); glDisable(GL_BLEND); glDepthMask(true); #ifdef QML_RUNTIME_TESTING if (m_render_opaque_nodes) #endif { #if defined (QML_RUNTIME_TESTING) if (dumpTree) qDebug() << "Opaque Nodes:"; #endif renderNodes(m_opaqueNodes); } #ifdef RENDERER_DEBUG int debugtimeOpaque = debugTimer.elapsed(); int opaqueNodes = geometryNodesDrawn; int opaqueMaterialChanges = materialChanges; #endif glEnable(GL_BLEND); glDepthMask(false); #ifdef QML_RUNTIME_TESTING if (m_render_alpha_nodes) #endif { #if defined (QML_RUNTIME_TESTING) if (dumpTree) qDebug() << "Alpha Nodes:"; #endif renderNodes(m_transparentNodes); } #ifdef RENDERER_DEBUG int debugtimeAlpha = debugTimer.elapsed(); #endif if (m_currentProgram) m_currentProgram->deactivate(); #ifdef RENDERER_DEBUG if (debugTimer.elapsed() > DEBUG_THRESHOLD) { printf(" --- Renderer breakdown:\n" " - setup=%d, clear=%d, building=%d, sorting=%d, opaque=%d, alpha=%d\n" " - material changes: opaque=%d, alpha=%d, total=%d\n" " - geometry ndoes: opaque=%d, alpha=%d, total=%d\n", debugtimeSetup, debugtimeClear - debugtimeSetup, debugtimeLists - debugtimeClear, debugtimeSorting - debugtimeLists, debugtimeOpaque - debugtimeSorting, debugtimeAlpha - debugtimeOpaque, opaqueMaterialChanges, materialChanges - opaqueMaterialChanges, materialChanges, opaqueNodes, geometryNodesDrawn - opaqueNodes, geometryNodesDrawn); } #endif }