2014-06-05 15:12:49 +00:00
|
|
|
#ifndef CANVAS_H
|
|
|
|
#define CANVAS_H
|
|
|
|
|
|
|
|
#include "software_global.h"
|
|
|
|
|
2015-11-18 18:37:00 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2014-06-05 15:12:49 +00:00
|
|
|
namespace paysages {
|
|
|
|
namespace software {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Graphics area to draw and do compositing.
|
|
|
|
*
|
|
|
|
* Software rendering is done in portions of Canvas (in CanvasPortion class).
|
|
|
|
* This splitting in portions allows to keep memory consumption low.
|
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class SOFTWARESHARED_EXPORT Canvas {
|
|
|
|
public:
|
2014-06-05 15:12:49 +00:00
|
|
|
Canvas();
|
|
|
|
~Canvas();
|
|
|
|
|
|
|
|
void setSize(int width, int height);
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
inline int getHorizontalPortionCount() const {
|
|
|
|
return horizontal_portion_count;
|
|
|
|
}
|
|
|
|
inline int getVerticalPortionCount() const {
|
|
|
|
return vertical_portion_count;
|
|
|
|
}
|
2014-06-05 15:12:49 +00:00
|
|
|
|
|
|
|
CanvasPortion *at(int x, int y) const;
|
2014-08-21 10:36:28 +00:00
|
|
|
CanvasPortion *atPixel(int x, int y) const;
|
2014-06-05 15:12:49 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
inline int getWidth() const {
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
inline int getHeight() const {
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
inline CanvasPreview *getPreview() const {
|
|
|
|
return preview;
|
|
|
|
}
|
2014-06-05 15:12:49 +00:00
|
|
|
|
2014-08-21 10:36:28 +00:00
|
|
|
/**
|
|
|
|
* Save the canvas to a picture file on disk.
|
|
|
|
*
|
|
|
|
* Returns true if the save was successful.
|
|
|
|
*/
|
2015-12-10 23:36:50 +00:00
|
|
|
bool saveToDisk(const string &filepath, const ColorProfile &profile, int antialias) const;
|
2014-08-21 10:36:28 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
2015-12-10 23:36:50 +00:00
|
|
|
vector<CanvasPortion *> portions;
|
2014-06-05 15:12:49 +00:00
|
|
|
int horizontal_portion_count;
|
|
|
|
int vertical_portion_count;
|
|
|
|
int width;
|
|
|
|
int height;
|
2014-06-10 13:13:16 +00:00
|
|
|
|
|
|
|
CanvasPreview *preview;
|
2014-06-05 15:12:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CANVAS_H
|