PageRenderTime 163ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/uppdev/ScanLine/ScanLineFiller.cpp

http://upp-mirror.googlecode.com/
C++ | 78 lines | 55 code | 5 blank | 18 comment | 8 complexity | ed72189b2d20577cfe66bf0360e6cd27 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-2-Clause, BSD-3-Clause, LGPL-3.0, GPL-3.0
  1. #include "ScanLine.h"
  2. struct RecScan : Rasterizer::Target {
  3. ScanLine sl;
  4. byte *t;
  5. int x;
  6. virtual void Render(int val);
  7. virtual void Render(int val, int len);
  8. virtual void Start(int x, int len);
  9. void Finish();
  10. };
  11. void RecScan::Start(int xmin, int xmax)
  12. {
  13. sl.data.Alloc((xmax - xmin + 1) * 2);
  14. t = ~sl.data;
  15. sl.xmin = 0;
  16. }
  17. void RecScan::Render(int val)
  18. {
  19. if(val == 0) {
  20. *t++ = 0;
  21. *t++ = 0;
  22. }
  23. else
  24. if(val == 256) {
  25. *t++ = 0;
  26. *t++ = 0;
  27. }
  28. else
  29. *t++ = val;
  30. x++;
  31. }
  32. void RecScan::Render(int val, int len)
  33. {
  34. x += len;
  35. if(val == 256) {
  36. while(len > 0) {
  37. int n = min(len, 128);
  38. *t++ = 0;
  39. *t++ = 128 + n - 1;
  40. len -= n;
  41. }
  42. return;
  43. }
  44. if(val == 0) {
  45. while(len > 0) {
  46. int n = min(len, 128);
  47. *t++ = 0;
  48. *t++ = n - 1;
  49. len -= n;
  50. }
  51. return;
  52. }
  53. while(len--)
  54. *t++ = val;
  55. }
  56. /*
  57. void RecScan::Finish(int cx)
  58. {
  59. cx = cx - x;
  60. while(cx > 0) {
  61. int n = min(cx, 128);
  62. *t++ = 0;
  63. *t++ = n - 1;
  64. cx -= n;
  65. }
  66. sl.datalen = t - ~sl.data;
  67. }
  68. void RecScan::Shrink()
  69. {
  70. if(sl.datalen + 30 <
  71. }
  72. */