dispatcher.h 1.89 KB
Newer Older
Ludmány Balázs committed
1 2 3
#ifndef RFBDISPATCH_H
#define RFBDISPATCH_H

4
#include <QOpenGLContext>
Ludmány Balázs committed
5
#include <QCoreApplication>
6
#include <QImage>
Ludmány Balázs committed
7 8 9 10 11
#include <QThreadPool>
#include <QObject>
#include <QPoint>
#include <QSize>
#include <QColor>
12 13
#include <QMouseEvent>
#include <QVector3D>
Ludmány Balázs committed
14 15 16 17 18 19 20 21 22 23
#include <rfb/rfbclient.h>

#include "uploader.h"
#include "jpegdecoder.h"

class Dispatcher : public QObject
{
    Q_OBJECT

public:
24 25
    Dispatcher(QObject *parent = 0);

Ludmány Balázs committed
26 27 28 29 30 31 32 33
    // libvnc hooks
    static rfbBool MallocFrameBuffer(rfbClient* client);
    static void GotCopyRect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y);
    static void GotFillRect(rfbClient* client, int x, int y, int w, int h, uint32_t colour);
    static void GotBitmap(rfbClient* client, const uint8_t* buffer, int x, int y, int w, int h);
    static rfbBool GotJpeg(rfbClient* client, const uint8_t* buffer, int length, int x, int y, int w, int h);
    static void FinishedFrameBufferUpdate(rfbClient* client);

34
    void setMouse(int x, int y, bool left, bool middle, bool right);
Ludmány Balázs committed
35 36 37 38 39

    unsigned int decoderCount() const;
    unsigned int incrementDecoderCount();
    unsigned int decrementDecoderCount();
    int bitsPerPixel();
40
    Uploader &uploader();
Ludmány Balázs committed
41
    void setFinished(bool finished);
42 43 44 45 46
    bool finished() const;

    unsigned int fill_count();
    unsigned int copy_count();
    unsigned int draw_count();
Ludmány Balázs committed
47

48
    QVector3D colorMax() const;
Ludmány Balázs committed
49 50 51 52
private:
    rfbClient *m_client;
    unsigned int m_decoderCount;
    bool m_finished;
53
    // TODO: move this to QVnc
Ludmány Balázs committed
54 55 56 57 58 59
    Uploader m_uploader;
signals:
    void resizeFramebuffer(const QSize &size);
    void updateFramebuffer();
    void error();
public slots:
60
    void create_context(QOpenGLContext *context);
Ludmány Balázs committed
61 62 63
    void open(QString host, int port);
    void refresh();
    void terminate();
64
    void decodingFinished(const QImage &bitmap, const int x, const int y, const int w, const int h);
Ludmány Balázs committed
65 66 67
};

#endif // RFBDISPATCH_H