2014-09-09 15:56:52 +00:00
|
|
|
#ifndef RENDERPREVIEWPROVIDER_H
|
|
|
|
#define RENDERPREVIEWPROVIDER_H
|
|
|
|
|
|
|
|
#include "modeler_global.h"
|
|
|
|
|
|
|
|
#include <QQuickImageProvider>
|
|
|
|
#include "CanvasLiveClient.h"
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace modeler {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provider for a Qml Image content, filled from a canvas rendering.
|
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class RenderPreviewProvider : public QQuickImageProvider, public CanvasLiveClient {
|
|
|
|
public:
|
2014-09-09 15:56:52 +00:00
|
|
|
RenderPreviewProvider();
|
|
|
|
virtual ~RenderPreviewProvider();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the canvas to watch and display, null to stop watching.
|
|
|
|
*
|
|
|
|
* This function must be called from the graphics thread.
|
|
|
|
*/
|
|
|
|
void setCanvas(const Canvas *canvas);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Release the bound canvas.
|
|
|
|
*/
|
|
|
|
void releaseCanvas();
|
|
|
|
|
2015-09-13 23:35:25 +00:00
|
|
|
/**
|
|
|
|
* Call when the image is hidden, to clear it for next render.
|
|
|
|
*/
|
|
|
|
void hide();
|
|
|
|
|
2014-09-09 15:56:52 +00:00
|
|
|
/**
|
|
|
|
* Set the tone mapping to apply to pixel colors.
|
|
|
|
*/
|
|
|
|
void setToneMapping(const ColorProfile &profile);
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
protected:
|
2014-09-09 15:56:52 +00:00
|
|
|
virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
|
|
|
|
|
|
|
|
virtual void canvasResized(int width, int height) override;
|
|
|
|
virtual void canvasCleared(const Color &col) override;
|
|
|
|
virtual void canvasPainted(int x, int y, const Color &col) override;
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
|
|
|
QImage *pixbuf;
|
2014-09-09 15:56:52 +00:00
|
|
|
const Canvas *canvas;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // RENDERPREVIEWPROVIDER_H
|