LCOV - code coverage report
Current view: top level - muse/framework/draw - svgrenderer.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 14 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : #include "svgrenderer.h"
      23              : 
      24              : #ifndef DRAW_NO_QSVGRENDER
      25              : #include <QPainter>
      26              : #include <QSvgRenderer>
      27              : 
      28              : #include "internal/qpainterprovider.h"
      29              : #endif
      30              : 
      31              : #include "log.h"
      32              : 
      33              : using namespace muse::draw;
      34              : 
      35              : //! NOTE Perhaps in the future we need to add something like ISvgRenderer
      36              : 
      37            0 : SvgRenderer::SvgRenderer(const ByteArray& data)
      38              : {
      39              : #ifndef DRAW_NO_QSVGRENDER
      40            0 :     m_qSvgRenderer = new QSvgRenderer(data.toQByteArray());
      41              : #else
      42              :     NOT_SUPPORTED;
      43              :     UNUSED(data);
      44              : #endif
      45            0 : }
      46              : 
      47            0 : SvgRenderer::~SvgRenderer()
      48              : {
      49              : #ifndef DRAW_NO_QSVGRENDER
      50            0 :     delete m_qSvgRenderer;
      51              : #endif
      52            0 : }
      53              : 
      54            0 : muse::SizeF SvgRenderer::defaultSize() const
      55              : {
      56              : #ifndef DRAW_NO_QSVGRENDER
      57            0 :     return SizeF::fromQSizeF(m_qSvgRenderer->defaultSize());
      58              : #else
      59              :     NOT_SUPPORTED;
      60              :     return SizeF();
      61              : #endif
      62              : }
      63              : 
      64            0 : void SvgRenderer::render(Painter* painter, const RectF& rect)
      65              : {
      66              : #ifndef DRAW_NO_QSVGRENDER
      67            0 :     IPaintProviderPtr paintProvider = painter->provider();
      68            0 :     std::shared_ptr<QPainterProvider> qPaintProvider = std::dynamic_pointer_cast<QPainterProvider>(paintProvider);
      69            0 :     if (qPaintProvider) {
      70            0 :         m_qSvgRenderer->render(qPaintProvider->qpainter(), rect.toQRectF());
      71              :     }
      72              : #else
      73              :     NOT_SUPPORTED;
      74              :     UNUSED(painter);
      75              :     UNUSED(rect);
      76              : #endif
      77            0 : }
        

Generated by: LCOV version 2.0-1