| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/context2d/qquickcontext2dtile.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | #include "qquickcontext2dtile_p.h" | - | ||||||||||||
| 41 | #if QT_CONFIG(opengl) | - | ||||||||||||
| 42 | # include <QOpenGLFramebufferObject> | - | ||||||||||||
| 43 | # include <QOpenGLFramebufferObjectFormat> | - | ||||||||||||
| 44 | # include <QOpenGLPaintDevice> | - | ||||||||||||
| 45 | #endif | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | QQuickContext2DTile::QQuickContext2DTile() | - | ||||||||||||
| 50 | : m_dirty(true) | - | ||||||||||||
| 51 | , m_rect(QRect(0, 0, 1, 1)) | - | ||||||||||||
| 52 | , m_device(nullptr) | - | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||
| 55 | - | |||||||||||||
| 56 | QQuickContext2DTile::~QQuickContext2DTile() | - | ||||||||||||
| 57 | { | - | ||||||||||||
| 58 | if (m_painter.isActive())
| 0 | ||||||||||||
| 59 | m_painter.end(); never executed: m_painter.end(); | 0 | ||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||
| 61 | - | |||||||||||||
| 62 | QPainter* QQuickContext2DTile::createPainter(bool smooth, bool antialiasing) | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | if (m_painter.isActive())
| 0 | ||||||||||||
| 65 | m_painter.end(); never executed: m_painter.end(); | 0 | ||||||||||||
| 66 | - | |||||||||||||
| 67 | aboutToDraw(); | - | ||||||||||||
| 68 | if (m_device) {
| 0 | ||||||||||||
| 69 | m_painter.begin(m_device); | - | ||||||||||||
| 70 | m_painter.resetTransform(); | - | ||||||||||||
| 71 | m_painter.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | #ifdef QQUICKCONTEXT2D_DEBUG | - | ||||||||||||
| 74 | int v = 100; | - | ||||||||||||
| 75 | int gray = (m_rect.x() / m_rect.width() + m_rect.y() / m_rect.height()) % 2; | - | ||||||||||||
| 76 | if (gray) | - | ||||||||||||
| 77 | v = 150; | - | ||||||||||||
| 78 | m_painter.fillRect(QRect(0, 0, m_rect.width(), m_rect.height()), QColor(v, v, v, 255)); | - | ||||||||||||
| 79 | #endif | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | if (antialiasing)
| 0 | ||||||||||||
| 82 | m_painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true); never executed: m_painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true); | 0 | ||||||||||||
| 83 | else | - | ||||||||||||
| 84 | m_painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, false); never executed: m_painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, false); | 0 | ||||||||||||
| 85 | - | |||||||||||||
| 86 | if (smooth)
| 0 | ||||||||||||
| 87 | m_painter.setRenderHint(QPainter::SmoothPixmapTransform, true); never executed: m_painter.setRenderHint(QPainter::SmoothPixmapTransform, true); | 0 | ||||||||||||
| 88 | else | - | ||||||||||||
| 89 | m_painter.setRenderHint(QPainter::SmoothPixmapTransform, false); never executed: m_painter.setRenderHint(QPainter::SmoothPixmapTransform, false); | 0 | ||||||||||||
| 90 | - | |||||||||||||
| 91 | m_painter.setCompositionMode(QPainter::CompositionMode_SourceOver); | - | ||||||||||||
| 92 | m_painter.translate(-m_rect.left(), -m_rect.top()); | - | ||||||||||||
| 93 | m_painter.setClipRect(m_rect); | - | ||||||||||||
| 94 | m_painter.setClipping(false); | - | ||||||||||||
| 95 | return &m_painter; never executed: return &m_painter; | 0 | ||||||||||||
| 96 | } | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||
| 99 | } | - | ||||||||||||
| 100 | #if QT_CONFIG(opengl) | - | ||||||||||||
| 101 | QQuickContext2DFBOTile::QQuickContext2DFBOTile() | - | ||||||||||||
| 102 | : QQuickContext2DTile() | - | ||||||||||||
| 103 | , m_fbo(nullptr) | - | ||||||||||||
| 104 | { | - | ||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | - | |||||||||||||
| 108 | QQuickContext2DFBOTile::~QQuickContext2DFBOTile() | - | ||||||||||||
| 109 | { | - | ||||||||||||
| 110 | if (m_fbo)
| 0 | ||||||||||||
| 111 | m_fbo->release(); never executed: m_fbo->release(); | 0 | ||||||||||||
| 112 | delete m_fbo; | - | ||||||||||||
| 113 | } never executed: end of block | 0 | ||||||||||||
| 114 | - | |||||||||||||
| 115 | void QQuickContext2DFBOTile::aboutToDraw() | - | ||||||||||||
| 116 | { | - | ||||||||||||
| 117 | m_fbo->bind(); | - | ||||||||||||
| 118 | if (!m_device) {
| 0 | ||||||||||||
| 119 | QOpenGLPaintDevice *gl_device = new QOpenGLPaintDevice(rect().size()); | - | ||||||||||||
| 120 | m_device = gl_device; | - | ||||||||||||
| 121 | QPainter p(m_device); | - | ||||||||||||
| 122 | p.fillRect(QRectF(0, 0, m_fbo->width(), m_fbo->height()), QColor(qRgba(0, 0, 0, 0))); | - | ||||||||||||
| 123 | p.end(); | - | ||||||||||||
| 124 | } never executed: end of block | 0 | ||||||||||||
| 125 | } never executed: end of block | 0 | ||||||||||||
| 126 | - | |||||||||||||
| 127 | void QQuickContext2DFBOTile::drawFinished() | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | } | - | ||||||||||||
| 130 | - | |||||||||||||
| 131 | void QQuickContext2DFBOTile::setRect(const QRect& r) | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | if (m_rect == r)
| 0 | ||||||||||||
| 134 | return; never executed: return; | 0 | ||||||||||||
| 135 | m_rect = r; | - | ||||||||||||
| 136 | m_dirty = true; | - | ||||||||||||
| 137 | if (!m_fbo || m_fbo->size() != r.size()) {
| 0 | ||||||||||||
| 138 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||
| 139 | format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); | - | ||||||||||||
| 140 | format.setInternalTextureFormat(GL_RGBA); | - | ||||||||||||
| 141 | format.setMipmap(false); | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | if (m_painter.isActive())
| 0 | ||||||||||||
| 144 | m_painter.end(); never executed: m_painter.end(); | 0 | ||||||||||||
| 145 | - | |||||||||||||
| 146 | delete m_fbo; | - | ||||||||||||
| 147 | m_fbo = new QOpenGLFramebufferObject(r.size(), format); | - | ||||||||||||
| 148 | } never executed: end of block | 0 | ||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||
| 150 | #endif | - | ||||||||||||
| 151 | - | |||||||||||||
| 152 | QQuickContext2DImageTile::QQuickContext2DImageTile() | - | ||||||||||||
| 153 | : QQuickContext2DTile() | - | ||||||||||||
| 154 | { | - | ||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||
| 156 | - | |||||||||||||
| 157 | QQuickContext2DImageTile::~QQuickContext2DImageTile() | - | ||||||||||||
| 158 | { | - | ||||||||||||
| 159 | } | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | void QQuickContext2DImageTile::setRect(const QRect& r) | - | ||||||||||||
| 162 | { | - | ||||||||||||
| 163 | if (m_rect == r)
| 0 | ||||||||||||
| 164 | return; never executed: return; | 0 | ||||||||||||
| 165 | m_rect = r; | - | ||||||||||||
| 166 | m_dirty = true; | - | ||||||||||||
| 167 | if (m_image.size() != r.size()) {
| 0 | ||||||||||||
| 168 | m_image = QImage(r.size(), QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||
| 169 | } never executed: end of block | 0 | ||||||||||||
| 170 | m_device = &m_image; | - | ||||||||||||
| 171 | } never executed: end of block | 0 | ||||||||||||
| 172 | - | |||||||||||||
| 173 | QT_END_NAMESPACE | - | ||||||||||||
| 174 | - | |||||||||||||
| Source code | Switch to Preprocessed file |