summaryrefslogtreecommitdiffstats
path: root/src/imports/etcprovider/qetcprovider.h
blob: ec20db749462b23efe6fde06ef56e5e74fae6f85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef QETCPROVIDER_H
#define QETCPROVIDER_H

#include <QDeclarativeImageProvider>
#include <QSGTexture>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <QFileInfo>

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Declarative)

// #define ETC_DEBUG

class EtcTexture : public QSGTexture
{
    Q_OBJECT
public:
    EtcTexture();
    ~EtcTexture();

    void bind();
    QSize textureSize() const;

    int textureId() const { return m_texture_id; }

    void setImage(const QImage &image) { Q_UNUSED(image); }

    bool hasAlphaChannel() const { return false; }
    bool hasMipmaps() const { return false; }

    QByteArray m_data;
    QSize m_size;
    QSize m_paddedSize;
    GLuint m_texture_id;
};

class QEtcProvider : public QDeclarativeImageProvider
{
public:
    QEtcProvider()
        : QDeclarativeImageProvider(QDeclarativeImageProvider::Texture)
    {
#ifdef ETC_DEBUG
        qDebug () << "Creating QEtcProvider.";
#endif
    }
    QSGTexture *requestTexture(const QString &id, QSize *size, const QSize &requestedSize);
};

QT_END_NAMESPACE

QT_END_HEADER

#endif // QETCPROVIDER_H