@@ -96,7 +96,7 @@ Graphics::~Graphics() {
9696 _screen = nullptr ;
9797}
9898
99- Font *Graphics::createFont (int style, int size) {
99+ Font *Graphics::createFont (int style, int size) const {
100100 Font *result;
101101 bool italic = (style & FONT_STYLE_ITALIC);
102102 if (style & FONT_STYLE_BOLD) {
@@ -107,7 +107,7 @@ Font *Graphics::createFont(int style, int size) {
107107 return result;
108108}
109109
110- void Graphics::deleteFont (Font *font) {
110+ void Graphics::deleteFont (const Font *font) {
111111 if (font == _font) {
112112 _font = nullptr ;
113113 }
@@ -208,7 +208,7 @@ void Graphics::drawAaEllipse(int xc, int yc, int rx, int ry, bool fill) {
208208 }
209209}
210210
211- void Graphics::drawLine (int startX, int startY, int endX, int endY) {
211+ void Graphics::drawLine (int startX, int startY, int endX, int endY) const {
212212 if (_drawTarget) {
213213 if (startY == endY) {
214214 // horizontal
@@ -271,13 +271,13 @@ void Graphics::drawLine(int startX, int startY, int endX, int endY) {
271271 }
272272}
273273
274- void Graphics::drawPixel (int posX, int posY) {
274+ void Graphics::drawPixel (int posX, int posY) const {
275275 pixel_t *line = _drawTarget->getLine (posY);
276276 line[posX] = _drawColor;
277277}
278278
279279void Graphics::drawRGB (const MAPoint2d *dstPoint, const void *src,
280- const MARect *srcRect, int opacity, int stride) {
280+ const MARect *srcRect, int opacity, int stride) const {
281281 auto *image = (uint8_t *)src;
282282 float op = opacity / 100 .0f ;
283283 int top = srcRect->top ;
@@ -316,7 +316,7 @@ void Graphics::drawRGB(const MAPoint2d *dstPoint, const void *src,
316316 }
317317}
318318
319- void Graphics::drawChar (FT_Bitmap *bitmap, FT_Int x, FT_Int y) {
319+ void Graphics::drawChar (FT_Bitmap *bitmap, FT_Int x, FT_Int y) const {
320320 FT_Int xMax = x + bitmap->width ;
321321 FT_Int yMax = y + bitmap->rows ;
322322
@@ -351,7 +351,7 @@ void Graphics::drawChar(FT_Bitmap *bitmap, FT_Int x, FT_Int y) {
351351 }
352352}
353353
354- void Graphics::drawText (int left, int top, const char *str, int len) {
354+ void Graphics::drawText (int left, int top, const char *str, int len) const {
355355 if (_drawTarget && _font) {
356356 FT_Vector pen;
357357 pen.x = left;
@@ -367,7 +367,7 @@ void Graphics::drawText(int left, int top, const char *str, int len) {
367367 }
368368}
369369
370- void Graphics::getImageData (Canvas *canvas, uint8_t *image, const MARect *srcRect, int stride) {
370+ void Graphics::getImageData (Canvas *canvas, uint8_t *image, const MARect *srcRect, int stride) const {
371371 size_t scale = 1 ;
372372 int x_end = srcRect->left + srcRect->width ;
373373 int y_end = srcRect->top + srcRect->height ;
@@ -389,7 +389,7 @@ void Graphics::getImageData(Canvas *canvas, uint8_t *image, const MARect *srcRec
389389 }
390390}
391391
392- int Graphics::getPixel (Canvas *canvas, int posX, int posY) {
392+ int Graphics::getPixel (Canvas *canvas, int posX, int posY) const {
393393 int result = 0 ;
394394 if (canvas == HANDLE_SCREEN) {
395395 canvas = _screen;
@@ -411,7 +411,7 @@ int Graphics::getPixel(Canvas *canvas, int posX, int posY) {
411411 return result;
412412}
413413
414- MAExtent Graphics::getTextSize (const char *str, int len) {
414+ MAExtent Graphics::getTextSize (const char *str, int len) const {
415415 int width = 0 ;
416416 int height = 0 ;
417417 if (_font) {
@@ -424,7 +424,7 @@ MAExtent Graphics::getTextSize(const char *str, int len) {
424424 return (MAExtent)((width << 16 ) + height);
425425}
426426
427- void Graphics::setClip (int x, int y, int w, int h) {
427+ void Graphics::setClip (int x, int y, int w, int h) const {
428428 if (_drawTarget) {
429429 _drawTarget->setClip (x, y, w, h);
430430 }
@@ -444,7 +444,7 @@ MAHandle Graphics::setDrawTarget(MAHandle maHandle) {
444444}
445445
446446// see: http://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
447- void Graphics::aaLine (int x0, int y0, int x1, int y1) {
447+ void Graphics::aaLine (int x0, int y0, int x1, int y1) const {
448448 int steep = abs (y1 - y0) > abs (x1 - x0);
449449
450450 if (steep) {
@@ -507,7 +507,7 @@ void Graphics::aaLine(int x0, int y0, int x1, int y1) {
507507 }
508508}
509509
510- void Graphics::aaPlot (int posX, int posY, double c) {
510+ void Graphics::aaPlot (int posX, int posY, double c) const {
511511 if (_drawTarget
512512 && posX >= _drawTarget->x ()
513513 && posY >= _drawTarget->y ()
@@ -527,7 +527,7 @@ void Graphics::aaPlot(int posX, int posY, double c) {
527527 }
528528}
529529
530- void Graphics::aaPlotX8 (int xc, int yc, int x, int y, double c, bool fill) {
530+ void Graphics::aaPlotX8 (int xc, int yc, int x, int y, double c, bool fill) const {
531531 if (fill) {
532532 int x1 = xc + x;
533533 int x2 = xc - x;
@@ -548,7 +548,7 @@ void Graphics::aaPlotX8(int xc, int yc, int x, int y, double c, bool fill) {
548548
549549}
550550
551- void Graphics::aaPlotY8 (int xc, int yc, int x, int y, double c, bool fill) {
551+ void Graphics::aaPlotY8 (int xc, int yc, int x, int y, double c, bool fill) const {
552552 if (fill) {
553553 int x1 = xc + x;
554554 int x2 = xc - x;
@@ -575,7 +575,7 @@ void Graphics::plot4(int xc, int yc, int x, int y) {
575575 drawPixel (xc - x, yc - y);
576576}
577577
578- void Graphics::line2 (int xc, int yc, int x, int y) {
578+ void Graphics::line2 (int xc, int yc, int x, int y) const {
579579 drawLine (xc - x, yc + y, xc + x, yc + y);
580580 drawLine (xc - x, yc - y, xc + x, yc - y);
581581}
0 commit comments