Krita Source Code Documentation
Loading...
Searching...
No Matches
KisGLImageF16.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include "KisGLImageF16.h"
8
9#include <QByteArray>
10#include <QSize>
11
12struct KisGLImageF16::Private : public QSharedData
13{
14 QSize size;
15 QByteArray data;
16};
17
18
19
21 : m_d(new Private)
22{
23}
24
25KisGLImageF16::KisGLImageF16(const QSize &size, bool clearPixels)
26 : m_d(new Private)
27{
29}
30
31KisGLImageF16::KisGLImageF16(int width, int height, bool clearPixels)
32 : KisGLImageF16(QSize(width, height), clearPixels)
33{
34}
35
37 : m_d(rhs.m_d)
38{
39}
40
42{
43 m_d = rhs.m_d;
44 return *this;
45}
46
47bool operator==(const KisGLImageF16 &lhs, const KisGLImageF16 &rhs)
48{
49 return lhs.m_d == rhs.m_d;
50}
51
55
57{
58 if (!m_d->data.isEmpty()) {
59 m_d->data.fill(0);
60 }
61}
62
63void KisGLImageF16::resize(const QSize &size, bool clearPixels)
64{
65 const int pixelSize = 2 * 4;
66
67 m_d->size = size;
68 m_d->data.resize(size.width() * size.height() * pixelSize);
69
70 if (clearPixels) {
71 m_d->data.fill(0);
72 }
73}
74
75const half *KisGLImageF16::constData() const
76{
77 Q_ASSERT(!m_d->data.isNull());
78 return reinterpret_cast<const half*>(m_d->data.data());
79}
80
82{
83 m_d->data.detach();
84 Q_ASSERT(!m_d->data.isNull());
85
86 return reinterpret_cast<half*>(m_d->data.data());
87}
88
90{
91 return m_d->size;
92}
93
95{
96 return m_d->size.width();
97}
98
100{
101 return m_d->size.height();
102}
103
105{
106 return m_d->data.isNull();
107}
bool operator==(const KisGLImageF16 &lhs, const KisGLImageF16 &rhs)
int height() const
void resize(const QSize &size, bool clearPixels=false)
QSize size() const
bool isNull() const
QSharedDataPointer< Private > m_d
KisGLImageF16 & operator=(const KisGLImageF16 &rhs)
const half * constData() const
int width() const