Renderer.h
Go to the documentation of this file.
1 /****
2  * Renderer.h
3  *
4  * Copyright 2021 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming-Graphics Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  * @author: May 2021 - mikee47 <mike@sillyhouse.net>
19  *
20  ****/
21 
22 #pragma once
23 
24 #include "Scene.h"
25 #include "Buffer.h"
26 #include <Delegate.h>
27 
28 namespace Graphics
29 {
30 class Surface;
31 
38 template <typename T> class ItemList
39 {
40 public:
41  ItemList(uint8_t capacity) : capacity(capacity)
42  {
43  items.reset(new T[capacity]);
44  }
45 
46  void add(T value)
47  {
48  assert(count < capacity);
49  items[count++] = value;
50  }
51 
52  T* get()
53  {
54  return (index < count) ? &items[index] : nullptr;
55  }
56 
57  T* next()
58  {
59  ++index;
60  return get();
61  }
62 
63  void reset()
64  {
65  index = count = 0;
66  }
67 
68  explicit operator bool() const
69  {
70  return count != 0;
71  }
72 
73 private:
74  std::unique_ptr<T[]> items;
75  uint8_t capacity;
76  uint8_t count{0};
77  uint8_t index{0};
78 };
79 
86 class PointList : public ItemList<Point>
87 {
88 public:
89  using ItemList::ItemList;
90 
91  PointList(const Rect& bounds, const Brush& brush, uint8_t capacity)
92  : ItemList(capacity), bounds(bounds), object(brush, {})
93  {
94  }
95 
96  void add(int16_t x, int16_t y)
97  {
98  Point pt{x, y};
99  if(Rect(bounds.size()).contains(pt)) {
100  ItemList::add(pt);
101  }
102  }
103 
109  bool render(Surface& surface);
110 
111 private:
112  Rect bounds;
113  PointObject object;
114  std::unique_ptr<Renderer> renderer;
115 };
116 
120 class RectList : public ItemList<Rect>
121 {
122 public:
123  RectList(const Rect& bounds, const Brush& brush, uint8_t capacity)
124  : ItemList(capacity), bounds(bounds), object(brush, {})
125  {
126  }
127 
128  void add(const Rect& rect)
129  {
130  auto r = intersect(rect, bounds.size());
131  if(r) {
132  ItemList::add(r);
133  }
134  }
135 
136  bool render(Surface& surface);
137 
138 private:
139  Rect bounds;
140  FilledRectObject object;
141  std::unique_ptr<Renderer> renderer;
142 };
143 
147 class MultiRenderer : public Renderer
148 {
149 public:
150  using Renderer::Renderer;
151 
152  bool execute(Surface& surface) override;
153 
154 protected:
155  virtual void renderDone(const Object* object) = 0;
156  virtual const Object* getNextObject() = 0;
157 
158 private:
159  std::unique_ptr<Renderer> renderer;
160  const Object* object{nullptr};
161 };
162 
170 {
171 public:
172  SceneRenderer(const Location& location, const SceneObject& scene)
173  : MultiRenderer(location), nextObject(scene.objects.head())
174  {
175  }
176 
177 protected:
178  void renderDone(const Object* object) override
179  {
180  nextObject = nextObject->getNext();
181  }
182 
183  const Object* getNextObject() override
184  {
185  return nextObject;
186  }
187 
188 private:
189  const Object* nextObject;
190 };
191 
197 class GfxLineRenderer : public Renderer
198 {
199 public:
200  GfxLineRenderer(const Location& location, const LineObject& object)
201  : GfxLineRenderer(location, object.pen, object.pt1, object.pt2)
202  {
203  }
204 
205  GfxLineRenderer(const Location& location, Pen pen, Point pt1, Point pt2)
206  : Renderer(location), pen(pen), x0(pt1.x), y0(pt1.y), x1(pt2.x), y1(pt2.y)
207  {
208  init();
209  }
210 
211  bool execute(Surface& surface) override;
212 
213 private:
214  void init();
215 
216  Point pos{};
217  Pen pen;
218  uint16_t x0;
219  uint16_t y0;
220  uint16_t x1;
221  uint16_t y1;
222  uint16_t xaddr;
223  int16_t dx;
224  int16_t dy;
225  int16_t err;
226  int8_t ystep;
227  bool steep;
228 };
229 
235 class LineRenderer : public Renderer
236 {
237 public:
238  LineRenderer(const Location& location, const LineObject& object)
239  : LineRenderer(location, object.pen, object.pt1, object.pt2)
240  {
241  }
242 
243  LineRenderer(const Location& location, Pen pen, Point pt1, Point pt2)
244  : Renderer(location), rectangles(location.dest, pen, 1), w(pen.width), x1(pt1.x), y1(pt1.y), x2(pt2.x),
245  y2(pt2.y)
246  {
247  init();
248  }
249 
250  bool execute(Surface& surface) override;
251 
252 private:
253  enum class Mode {
254  simple,
255  diagonal,
256  horizontal,
257  vertical,
258  done,
259  };
260 
261  void init();
262  void drawDiagonal();
263  void initHorizontal();
264  void drawHorizontal();
265  void initVertical();
266  void drawVertical();
267 
268  RectList rectangles;
269  const uint16_t w;
270  uint16_t x1;
271  uint16_t y1;
272  uint16_t x2;
273  uint16_t y2;
274  Rect r;
275  uint16_t dx;
276  uint16_t dy;
277  uint16_t adj_up;
278  uint16_t adj_down;
279  uint16_t whole_step;
280  uint16_t initial_run;
281  uint16_t final_run;
282  uint16_t run_length;
283  uint16_t run_pos{0};
284  int16_t error_term;
285  int8_t xadvance;
286  Mode mode{};
287 };
288 
293 {
294 public:
295  PolylineRenderer(const Location& location, const PolylineObject& object) : Renderer(location), object(object)
296  {
297  }
298 
299  bool execute(Surface& surface) override;
300 
301 protected:
304  std::unique_ptr<Renderer> renderer;
305  uint16_t index{0};
306 };
307 
311 class RectRenderer : public Renderer
312 {
313 public:
314  RectRenderer(const Location& location, const Pen& pen, const Rect& rect)
315  : Renderer(location), rectangles(location.dest, pen, 4)
316  {
317  auto w = pen.width;
318  auto& r = rect;
319 
320  auto w2 = w + w;
321  if(w2 >= r.w || w2 >= r.h)
322  rectangles.add(r);
323  else {
324  rectangles.add(Rect(r.x, r.y, r.w - w, w));
325  rectangles.add(Rect(r.x, r.y + w, w, r.h - w));
326  rectangles.add(Rect(r.x + r.w - w, r.y, w, r.h - w));
327  rectangles.add(Rect(r.x + w, r.y + r.h - w, r.w - w, w));
328  }
329  }
330 
331  RectRenderer(const Location& location, const RectObject& object) : RectRenderer(location, object.pen, object.rect)
332  {
333  }
334 
335  bool execute(Surface& surface) override
336  {
337  return rectangles.render(surface);
338  }
339 
340 private:
341  RectList rectangles;
342 };
343 
350 {
351 public:
352  FilledRectRenderer(const Location& location, const Brush& brush, const Rect& rect, std::unique_ptr<Blend> blender)
353  : Renderer(location), brush(brush), rect{rect}, blender(std::move(blender))
354  {
355  }
356 
357  FilledRectRenderer(const Location& location, const FilledRectObject& object)
358  : Renderer(location), brush(object.brush), rect(object.rect)
359  {
360  }
361 
362  FilledRectRenderer(const Location& location, const PointObject& object)
363  : Renderer(location), brush(object.brush), rect{object.point, 1, 1}
364  {
365  }
366 
367  bool execute(Surface& surface) override;
368 
369 private:
370  struct Buffer : public ReadStatusBuffer {
371  enum class State {
372  empty,
373  reading,
374  writing,
375  };
376  static constexpr size_t bufSize{256};
377  static constexpr size_t bufPixels{bufSize / 3};
378 
379  Rect r;
380 
381  Buffer() : ReadStatusBuffer{PixelFormat::None, bufSize}
382  {
383  }
384  };
385 
386  int queueRead(Surface& surface);
387 
388  Brush brush;
389  Rect rect;
390  Point pos{};
391  Size blockSize;
392  std::unique_ptr<Blend> blender;
393  Buffer buffers[2];
394  uint8_t index{0};
395  uint8_t busyCount{0};
396  bool done{false};
397 };
398 
405 {
406 public:
407  RoundedRectRenderer(const Location& location, const RectObject& object)
408  : Renderer(location), polyline(object), pen(object.pen), rect(object.rect),
409  radius(object.radius), corners{Point(rect.left() + radius, rect.top() + radius),
410  Point(rect.right() - radius, rect.top() + radius),
411  Point(rect.right() - radius, rect.bottom() - radius),
412  Point(rect.left() + radius, rect.bottom() - radius)}
413  {
414  renderer.reset(new PolylineRenderer(location, polyline));
415  }
416 
417  bool execute(Surface& surface) override;
418 
419 private:
420  std::unique_ptr<Renderer> renderer;
421  PolylineObject polyline;
422  Pen pen;
423  Rect rect;
424  uint8_t radius;
425  uint8_t state{0};
426  Point corners[4];
427 };
428 
435 {
436 public:
437  FilledRoundedRectRenderer(const Location& location, const FilledRectObject& object)
438  : Renderer(location), object(object)
439  {
440  auto& rect = this->object.rect;
441  auto r = object.radius;
442  corners[0] = Point(rect.x + r, rect.y + r);
443  corners[1] = Point(rect.x + r, rect.bottom() - r);
444  }
445 
446  bool execute(Surface& surface) override;
447 
448 private:
449  std::unique_ptr<Renderer> renderer;
450  FilledRectObject object;
451  uint8_t state{0};
452  Point corners[2];
453 };
454 
460 class CircleRenderer : public Renderer
461 {
462 public:
463  CircleRenderer(const Location& location, const CircleObject& object)
464  : CircleRenderer(location, object.pen, object.centre, object.radius, 0, 0x0f)
465  {
466  pixels.add(x0, y0 + y);
467  pixels.add(x0, y0 - y);
468  pixels.add(x0 + y, y0);
469  pixels.add(x0 - y, y0);
470  }
471 
475  CircleRenderer(const Location& location, const Pen& pen, Point centre, uint16_t radius, uint16_t delta,
476  uint8_t corners)
477  : Renderer(location), pixels(location.dest, pen, 8), x0(centre.x), y0(centre.y), f(1 - radius), ddF_x(1),
478  ddF_y(-2 * radius), x(0), y(radius), delta(delta), corners(corners)
479  {
480  }
481 
482  bool execute(Surface& surface) override;
483 
484 private:
485  PointList pixels;
486  int16_t x0;
487  int16_t y0;
488  int16_t f;
489  int16_t ddF_x;
490  int16_t ddF_y;
491  int16_t x;
492  int16_t y;
493  uint16_t delta;
494  uint8_t corners;
495 };
496 
503 {
504 public:
505  FilledCircleRenderer(const Location& location, const FilledCircleObject& object)
506  : FilledCircleRenderer(location, object.brush, object.centre, object.radius, 0, 0x03)
507  {
508  addLine(x0 - x, x0 + x, y0);
509  }
510 
515  FilledCircleRenderer(const Location& location, const Brush& brush, Point centre, uint16_t radius, uint16_t delta,
516  uint8_t quadrants)
517  : Renderer(location), rectangles(location.dest, brush, 4), x0(centre.x), y0(centre.y), f(1 - radius),
518  ddF_x(-2 * radius), ddF_y(1), x(radius), y(0), px(x), py(y), delta(delta), quadrants(quadrants)
519  {
520  }
521 
522  bool execute(Surface& surface) override;
523 
524 private:
525  void addLine(uint16_t x0, uint16_t x1, uint16_t y)
526  {
527  rectangles.add(Rect(x0, y, 1 + x1 - x0, 1));
528  }
529 
530  RectList rectangles;
531  int16_t x0;
532  int16_t y0;
533  int16_t f;
534  int16_t ddF_x;
535  int16_t ddF_y;
536  int16_t x;
537  int16_t y;
538  int16_t px;
539  int16_t py;
540  uint16_t delta;
541  uint8_t quadrants;
542  Location loc;
543  uint16_t pixelsToWrite{0};
544 };
545 
549 struct Ellipse {
551  {
552  }
553 
554  /* ellipse: e(x,y) = b*b*x*x + a*a*y*y - a*a*b*b */
555  Ellipse(Size size)
556  : a(size.w / 2), b(size.h / 2), x(0), y(b), a2(a * a), b2(b * b), xcrit((3 * a2 / 4) + 1),
557  ycrit((3 * b2 / 4) + 1), t(b2 + a2 - 2 * a2 * b), dxt(b2 * (3 + x + x)), dyt(a2 * (3 - y - y)), d2xt(b2 + b2),
558  d2yt(a2 + a2)
559  {
560  }
561 
562  enum class Move {
563  down,
564  out,
565  };
567 
568  Step step();
569 
570  uint16_t a; // semi-major axis length
571  uint16_t b; // semi-minor axis length
574  int32_t a2;
575  int32_t b2;
576  int32_t xcrit;
577  int32_t ycrit;
578  int32_t t;
579  int32_t dxt;
580  int32_t dyt;
581  int32_t d2xt;
582  int32_t d2yt;
583 };
584 
585 class ArcRectList : public RectList
586 {
587 public:
588  using RectList::RectList;
589 
590  void fill(const Rect& r, Point p0, Point p1, Point p2, int start_angle, int end_angle);
591 };
592 
600 class EllipseRenderer : public Renderer
601 {
602 public:
603  EllipseRenderer(const Location& location, const Pen& pen, const Rect& rect)
604  : Renderer(location), r(rect), rectangles(location.dest, pen, 8), w(pen.width)
605  {
606  }
607 
608  EllipseRenderer(const Location& location, const EllipseObject& object)
609  : EllipseRenderer(location, object.pen, object.rect)
610  {
611  }
612 
613  EllipseRenderer(const Location& location, const CircleObject& object)
614  : EllipseRenderer(location, object.pen, object.getRect())
615  {
616  }
617 
618  bool execute(Surface& surface) override;
619 
620 protected:
621  enum class State {
622  init,
623  running,
624  final1,
625  final2,
626  done,
627  };
628 
629  virtual void addRectangles1();
630  virtual void addRectangles2();
631  virtual void final();
632 
633  const Rect r;
637  const uint16_t w;
639  State state{};
640 
641 private:
642  Ellipse outer;
643  Ellipse inner;
644  Point prev;
645  uint16_t innerX{0};
646 };
647 
654 {
655 public:
656  FilledEllipseRenderer(const Location& location, const Brush& brush, const Rect& rect)
657  : Renderer(location), r(rect), rectangles(location.dest, brush, 4)
658  {
659  }
660 
661  FilledEllipseRenderer(const Location& location, const FilledEllipseObject& object)
662  : FilledEllipseRenderer(location, object.brush, object.rect)
663  {
664  }
665 
666  FilledEllipseRenderer(const Location& location, const FilledCircleObject& object)
667  : FilledEllipseRenderer(location, object.brush, object.getRect())
668  {
669  }
670 
671  bool execute(Surface& surface) override;
672 
673 protected:
674  virtual void doStep(Ellipse::Step step);
675  virtual void final();
676 
677  enum class State {
678  init,
679  running,
680  final,
681  done,
682  };
683 
684  const Rect r;
689  State state{};
690 };
691 
696 {
697 public:
698  ArcRenderer(const Location& location, const Pen& pen, const Rect& rect, int start_angle, int end_angle)
699  : EllipseRenderer(location, pen, rect), start_angle(normaliseAngle(start_angle)),
700  end_angle(normaliseAngle(end_angle))
701  {
702  }
703 
704  bool execute(Surface& surface) override;
705 
706 protected:
707  void addRectangles1() override;
708  void addRectangles2() override;
709  void final() override;
710 
711 private:
712  /* Input parameters */
713  uint16_t start_angle;
714  uint16_t end_angle;
715 
716  /* arc wedge line end points */
717  Point p0;
718  Point p1;
719  Point p2;
720 };
721 
726 {
727 public:
728  FilledArcRenderer(const Location& location, const Brush& brush, const Rect& rect, int start_angle, int end_angle)
729  : FilledEllipseRenderer(location, brush, rect), start_angle(normaliseAngle(start_angle)),
730  end_angle(normaliseAngle(end_angle))
731  {
732  }
733 
734  bool execute(Surface& surface) override;
735 
736 protected:
737  void doStep(Ellipse::Step step) override;
738  void final() override;
739 
740 private:
741  int16_t start_angle;
742  int16_t end_angle;
743  Point p0;
744  Point p1;
745  Point p2;
746 };
747 
751 class ImageRenderer : public Renderer
752 {
753 public:
754  ImageRenderer(const Location& location, const ImageObject& object) : Renderer(location), object(object)
755  {
756  }
757 
758  bool execute(Surface& surface) override;
759 
760 private:
761  const ImageObject& object;
762  uint8_t bytesPerPixel{0};
763  PixelFormat pixelFormat{};
764 };
765 
771 class SurfaceRenderer : public Renderer
772 {
773 public:
774  SurfaceRenderer(const Location& location, const SurfaceObject& object)
775  : SurfaceRenderer(location, object.surface, object.dest, object.source)
776  {
777  }
778 
779  SurfaceRenderer(const Location& location, Surface& target, const Rect& dest, Point source)
780  : Renderer(location), target(target), dest(dest), source(source)
781  {
782  }
783 
784  bool execute(Surface& surface) override;
785 
786 private:
787  static constexpr uint16_t bufSize{512};
788  ReadBuffer buffers[2];
789  Surface& target;
790  Rect dest;
791  Point source;
792  PixelFormat pixelFormat{};
793  uint8_t bufIndex{0};
794  bool done{false};
795  uint8_t busyCount{0};
796 };
797 
801 class CopyRenderer : public Renderer
802 {
803 public:
804  using Renderer::Renderer;
805 
806  CopyRenderer(const Location& location, const CopyObject& object) : Renderer(location)
807  {
808  Rect src = object.source;
809  Rect dst(object.dest, object.source.size());
810  src += this->location.dest.topLeft();
811  dst += this->location.dest.topLeft();
812  // TODO: Do X/Y separately
813  src.clip(location.dest);
814  dst.clip(location.dest);
815  src.w = dst.w = std::min(src.w, dst.w);
816  src.h = dst.h = std::min(src.h, dst.h);
817  this->location.dest = dst;
818  this->location.source = src;
819  }
820 
821  bool execute(Surface& surface) override;
822 
823 protected:
824  void init();
825  void startRead(Surface& surface);
826 
827  /* Position is given in `location` */
828  virtual void readComplete(uint8_t* data, size_t length)
829  {
830  }
831 
832  PixelFormat pixelFormat{};
834  bool vertical;
835 
836 private:
838  LineBuffer lineBuffers[2];
839  uint16_t lineSize; // Width or height
840  uint16_t lineCount;
841  uint16_t readIndex{0};
842  uint16_t writeIndex{0};
843  TPoint<int8_t> shift{};
844 };
845 
847 {
848 public:
849  ImageCopyRenderer(const Location& location, const ImageObject& image, const Blend* blend)
850  : CopyRenderer({location.dest, location.dest}), image(image), blend(blend)
851  {
852  auto& dst = location.dest;
853  this->location.source.w = this->location.dest.w = std::min(dst.w, image.width());
854  this->location.source.h = this->location.dest.h = std::min(dst.h, image.height());
855  }
856 
857 protected:
858  void readComplete(uint8_t* data, size_t length) override;
859 
860 private:
861  const ImageObject& image;
862  const Blend* blend;
863 };
864 
868 class ScrollRenderer : public Renderer
869 {
870 public:
871  ScrollRenderer(const Location& location, const ScrollObject& object) : Renderer(location), object(object)
872  {
873  }
874 
875  bool execute(Surface& surface) override;
876 
877 private:
878  void init();
879  bool startRead(Surface& surface);
880  int16_t checkx(int16_t x);
881  int16_t checky(int16_t y);
882  void stepx(uint16_t& index, int16_t& x);
883  void stepy(uint16_t& index, int16_t& y);
884 
886 
887  const ScrollObject& object;
888  Rect src{};
889  Rect dst{};
890  int16_t cx;
891  int16_t cy;
892  uint16_t readOffset{0};
893  uint16_t writeOffset{0};
894  LineBuffer lineBuffers[2];
895  uint16_t lineCount;
896  uint16_t readIndex{0};
897  uint16_t writeIndex{0};
898  Rect readArea;
899  Rect writeArea;
900  PackedColor fill;
901  PixelFormat pixelFormat{};
902  uint8_t bytesPerPixel;
903  bool vertical; // If true, copy vertical lines
904  uint8_t state{0};
905 };
906 
910 class BlendRenderer : public Renderer
911 {
912 public:
913  BlendRenderer(const Location& location, const Object& object, const Blend* blend)
914  : Renderer(location), object(object), blend(blend)
915  {
916  }
917 
918  bool execute(Surface& surface) override;
919 
920 private:
921  enum class State {
922  init,
923  draw,
924  done,
925  };
926 
927  const Object& object;
928  std::unique_ptr<Renderer> renderer;
929  std::unique_ptr<MemoryImageObject> image;
930  std::unique_ptr<Surface> imageSurface;
931  PixelFormat pixelFormat;
932  const Blend* blend;
933  State nextState{};
934 };
935 
941 class TextRenderer : public Renderer
942 {
943 public:
944  TextRenderer(const Location& location, const TextObject& object)
945  : Renderer(location), object(object), alphaBuffer(object, location.dest.h - location.pos.y),
946  element(alphaBuffer.element)
947  {
948  this->location.dest += object.bounds.topLeft();
949  this->location.pos = Point{};
950  }
951 
952  bool execute(Surface& surface) override;
953 
954 private:
955  struct AlphaBuffer {
956  const TextObject::Element* element;
957  const TextAsset* text{nullptr};
958  const TextObject::FontElement* font{nullptr};
959  std::unique_ptr<uint8_t[]> data;
960  Size size{};
961  uint16_t charIndex{0};
962  uint16_t x{0};
963  uint16_t xo{0};
964  uint16_t ymax;
965  uint8_t advdiff{0};
966 
967  AlphaBuffer(const TextObject& object, uint16_t ymax) : element{object.elements.head()}, ymax(ymax)
968  {
969  }
970 
971  void init(Size size)
972  {
973  data.reset(new uint8_t[size.w * size.h]{});
974  this->size = size;
975  }
976 
977  void clear()
978  {
979  memset(data.get(), 0, size.w * size.h);
980  }
981 
982  void fill();
983 
984  bool finished()
985  {
986  return element == nullptr;
987  }
988 
989  // Shift content from given position to start of buffer, clear the vacated space
990  void shift(uint16_t count)
991  {
992  count = std::min(count, x);
993  auto row = data.get();
994  for(unsigned i = 0; i < size.h; ++i) {
995  memmove(row, &row[count], size.w - count);
996  memset(&row[size.w - count], 0, count);
997  row += size.w;
998  }
999  xo += count;
1000  x -= count;
1001  }
1002  };
1003 
1004  struct BackBuffer : public ReadStatusBuffer {
1005  static constexpr size_t bufSize{512};
1006 
1007  BackBuffer() : ReadStatusBuffer(PixelFormat::None, bufSize)
1008  {
1009  }
1010 
1011  Rect r{};
1012  Point pos{};
1013  const TextObject::RunElement* run{nullptr};
1014  TextOptions options;
1015  uint16_t glyphPixels;
1016  bool lastRow{false};
1017  };
1018 
1019  void getNextRun();
1020  bool startRead(Surface& surface);
1021  bool renderBuffer(Surface& surface, BackBuffer& backBuffer);
1022 
1023  const TextObject& object;
1024  AlphaBuffer alphaBuffer;
1025  const TextObject::RunElement* run{nullptr};
1026  const TextObject::Element* element;
1027  GlyphObject::Options options;
1028  BackBuffer backBuffers[2];
1029  uint8_t readIndex{0};
1030  uint8_t writeIndex{0};
1031  const TypeFace* typeface{nullptr};
1032  PixelFormat pixelFormat{};
1033  uint8_t bytesPerPixel;
1034  uint8_t busyCount{0};
1035 };
1036 
1037 } // namespace Graphics
A single pixel == 1x1 rectangle.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:174
int32_t d2yt
Definition: Renderer.h:582
ArcRenderer(const Location &location, const Pen &pen, const Rect &rect, int start_angle, int end_angle)
Definition: Renderer.h:698
A filled ellipse.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:480
FilledEllipseRenderer(const Location &location, const Brush &brush, const Rect &rect)
Definition: Renderer.h:656
LineObject line
Definition: Renderer.h:303
Rect r2
Definition: Renderer.h:635
TPoint< int16_t > Point
Definition: Libraries/Graphics/src/include/Graphics/Types.h:280
Describes a copy operation within the same surface.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:1122
ArcRectList rectangles
Definition: Renderer.h:636
Describes a scrolling operation.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:1146
Definition: Renderer.h:846
int32_t dxt
Definition: Renderer.h:579
void renderDone(const Object *object) override
Definition: Renderer.h:178
ArcRectList rectangles
Definition: Renderer.h:685
ImageCopyRenderer(const Location &location, const ImageObject &image, const Blend *blend)
Definition: Renderer.h:849
Draws a circle outline.
Definition: Renderer.h:460
FilledEllipseRenderer(const Location &location, const FilledCircleObject &object)
Definition: Renderer.h:666
State
Definition: Renderer.h:621
Colour in device pixel format.
Definition: Colors.h:339
Definition: Renderer.h:585
Draws a filled ellipse.
Definition: Renderer.h:653
A block of text consisting of zero or more segments.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:902
const Object * getNextObject() override
Definition: Renderer.h:183
Ellipse e
Definition: Renderer.h:686
Base class to render multiple objects.
Definition: Renderer.h:147
Draws 1-pixel lines.
Definition: Renderer.h:197
A drawn line.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:256
int32_t b2
Definition: Renderer.h:575
bool vertical
Definition: Renderer.h:834
uint16_t w
Definition: Libraries/Graphics/src/include/Graphics/Types.h:106
FilledRectRenderer(const Location &location, const Brush &brush, const Rect &rect, std::unique_ptr< Blend > blender)
Definition: Renderer.h:352
uint16_t a
Definition: Renderer.h:570
Move
Definition: Renderer.h:562
Definition: Libraries/Graphics/src/include/Graphics/Object.h:1032
CopyRenderer(const Location &location, const CopyObject &object)
Definition: Renderer.h:806
A circle outline.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:369
Describes a target surface and corresponding source location.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:1095
Renderer(const Location &location)
Constructor.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:75
EllipseRenderer(const Location &location, const Pen &pen, const Rect &rect)
Definition: Renderer.h:603
Rect r2
Definition: Renderer.h:688
void add(const Rect &rect)
Definition: Renderer.h:128
FilledEllipseRenderer(const Location &location, const FilledEllipseObject &object)
Definition: Renderer.h:661
Draws an ellipse outline.
Definition: Renderer.h:600
SceneRenderer(const Location &location, const SceneObject &scene)
Definition: Renderer.h:172
State
Definition: Renderer.h:677
Ellipse(Size size)
Definition: Renderer.h:555
int32_t xcrit
Definition: Renderer.h:576
A filled rectangle.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:226
Location and size of rectangular area (x, y, w, h)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:287
Draws a filled rectangle.
Definition: Renderer.h:349
Definition: Libraries/Graphics/src/include/Graphics/Object.h:932
int32_t dyt
Definition: Renderer.h:580
FilledRectRenderer(const Location &location, const FilledRectObject &object)
Definition: Renderer.h:357
Draws a filled rectangle with rounded corners.
Definition: Renderer.h:434
void add(int16_t x, int16_t y)
Definition: Renderer.h:96
A scene is a list of other objects, so we just iterate through the list and draw each in turn...
Definition: Renderer.h:169
LineRenderer(const Location &location, Pen pen, Point pt1, Point pt2)
Definition: Renderer.h:243
GfxLineRenderer(const Location &location, Pen pen, Point pt1, Point pt2)
Definition: Renderer.h:205
SurfaceRenderer(const Location &location, Surface &target, const Rect &dest, Point source)
Definition: Renderer.h:779
PolylineRenderer(const Location &location, const PolylineObject &object)
Definition: Renderer.h:295
Ellipse()
Definition: Renderer.h:550
int32_t ycrit
Definition: Renderer.h:577
Definition: Asset.h:402
ItemList(uint8_t capacity)
Definition: Renderer.h:41
Rect r1
Definition: Renderer.h:687
Definition: Libraries/Graphics/src/include/Graphics/Object.h:989
PointList(const Rect &bounds, const Brush &brush, uint8_t capacity)
Definition: Renderer.h:91
EllipseRenderer(const Location &location, const CircleObject &object)
Definition: Renderer.h:613
A rectangular outline.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:196
Composite ReadBuffer with status.
Definition: Graphics/src/include/Graphics/Buffer.h:222
void add(T value)
Definition: Renderer.h:46
RectList(const Rect &bounds, const Brush &brush, uint8_t capacity)
Definition: Renderer.h:123
Base class for a loaded typeface, e.g. Sans 16pt bold.
Definition: Asset.h:505
Small list of rectangles, similar to PointList.
Definition: Renderer.h:120
uint16_t W
Definition: Renderer.h:638
const Rect r
Definition: Renderer.h:633
Rect rect
Definition: Libraries/Graphics/src/include/Graphics/Object.h:249
Draws a filled circle.
Definition: Renderer.h:502
bool execute(Surface &surface) override
Called to do some writing to the surface.
Definition: Renderer.h:335
FilledCircleRenderer(const Location &location, const FilledCircleObject &object)
Definition: Renderer.h:505
A Scene containing multiple objects.
Definition: Scene.h:31
EllipseRenderer(const Location &location, const EllipseObject &object)
Definition: Renderer.h:608
Identifies position within bounding rectangle.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:683
Draw a line of text.
Definition: Renderer.h:941
GfxLineRenderer(const Location &location, const LineObject &object)
Definition: Renderer.h:200
Draws lines.
Definition: Renderer.h:235
RectRenderer(const Location &location, const RectObject &object)
Definition: Renderer.h:331
FilledCircleRenderer(const Location &location, const Brush &brush, Point centre, uint16_t radius, uint16_t delta, uint8_t quadrants)
Used to draw rounded parts of a rounded rectangle These are handled by drawing lines between the left...
Definition: Renderer.h:515
A drawable object inherits from this virtual base class.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:96
Perform blending with draw.
Definition: Renderer.h:910
uint16_t h
Definition: Libraries/Graphics/src/include/Graphics/Types.h:107
FilledArcRenderer(const Location &location, const Brush &brush, const Rect &rect, int start_angle, int end_angle)
Definition: Renderer.h:728
uint16_t normaliseAngle(int angle)
Make 0 <= angle < 360.
ScrollRenderer(const Location &location, const ScrollObject &object)
Definition: Renderer.h:871
Virtual base class for an image.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:561
Size of rectangular area (width x height)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:105
Copy an area within the same surface.
Definition: Renderer.h:801
Point pos
Position relative to dest/source top-left corner.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:702
uint8_t bytesPerPixel
Definition: Renderer.h:833
Render an image object.
Definition: Renderer.h:751
TextRenderer(const Location &location, const TextObject &object)
Definition: Renderer.h:944
Rect r1
Definition: Renderer.h:634
int32_t a2
Definition: Renderer.h:574
Manage a set of bit values using enumeration.
Definition: BitSet.h:44
BlendRenderer(const Location &location, const Object &object, const Blend *blend)
Definition: Renderer.h:913
Virtual base class to manage rendering of various types of information to a surface.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:65
Rect dest
Where to write pixels on surface.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:687
std::unique_ptr< Renderer > renderer
Definition: Renderer.h:304
FilledRectRenderer(const Location &location, const PointObject &object)
Definition: Renderer.h:362
uint16_t x
Definition: Renderer.h:572
The source of colour for drawing.
Definition: Asset.h:252
Draws series of lines defined by a PolylineObject
Definition: Renderer.h:292
CircleRenderer(const Location &location, const Pen &pen, Point centre, uint16_t radius, uint16_t delta, uint8_t corners)
Used to draw corners only.
Definition: Renderer.h:475
const Rect r
Definition: Renderer.h:684
ImageRenderer(const Location &location, const ImageObject &object)
Definition: Renderer.h:754
A filled circle.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:410
int32_t t
Definition: Renderer.h:578
Render arc outline with adjustable line width.
Definition: Renderer.h:725
T * next()
Definition: Renderer.h:57
Size size() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:447
An ellipse outline.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:453
State information for tracing an ellipse outline.
Definition: Renderer.h:549
void init(IDataSourceStream *stream)
Application calls this method to set source for graphics resourcess.
uint16_t y
Definition: Renderer.h:573
Definition: Asset.h:665
PixelFormat
Definition: Colors.h:295
Scroll an area.
Definition: Renderer.h:868
void reset()
Definition: Renderer.h:63
const PolylineObject & object
Definition: Renderer.h:302
uint16_t width
Definition: Asset.h:433
Blend operations.
Definition: Blend.h:40
A sequence of lines.
Definition: Libraries/Graphics/src/include/Graphics/Object.h:298
Rect source
Reference source area.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:697
RectRenderer(const Location &location, const Pen &pen, const Rect &rect)
Definition: Renderer.h:314
Interface for a drawing surface.
Definition: Surface.h:41
int32_t d2xt
Definition: Renderer.h:581
Definition: Virtual.h:30
Render arc outline with adjustable line width.
Definition: Renderer.h:695
uint16_t b
Definition: Renderer.h:571
Buffer used for reading pixel data from device.
Definition: Graphics/src/include/Graphics/Buffer.h:186
CircleRenderer(const Location &location, const CircleObject &object)
Definition: Renderer.h:463
Fixed list of types.
Definition: Renderer.h:38
FilledRoundedRectRenderer(const Location &location, const FilledRectObject &object)
Definition: Renderer.h:437
Draws a rectangle outline with rounded corners.
Definition: Renderer.h:404
Point topLeft() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:417
Draws a rectangle as a polyline.
Definition: Renderer.h:311
RoundedRectRenderer(const Location &location, const RectObject &object)
Definition: Renderer.h:407
Definition: Asset.h:452
Small list of points for drawing.
Definition: Renderer.h:86
Rect intersect(Rect r1, const Rect &r2)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:582
Copy an area to another surface.
Definition: Renderer.h:771
SurfaceRenderer(const Location &location, const SurfaceObject &object)
Definition: Renderer.h:774
LineRenderer(const Location &location, const LineObject &object)
Definition: Renderer.h:238
virtual void readComplete(uint8_t *data, size_t length)
Definition: Renderer.h:828
const uint16_t w
Definition: Renderer.h:637