/uppdev/ScanLine/ScanLineFiller.cpp
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
- #include "ScanLine.h"
-
- struct RecScan : Rasterizer::Target {
- ScanLine sl;
- byte *t;
- int x;
-
- virtual void Render(int val);
- virtual void Render(int val, int len);
- virtual void Start(int x, int len);
- void Finish();
- };
-
- void RecScan::Start(int xmin, int xmax)
- {
- sl.data.Alloc((xmax - xmin + 1) * 2);
- t = ~sl.data;
- sl.xmin = 0;
- }
-
- void RecScan::Render(int val)
- {
- if(val == 0) {
- *t++ = 0;
- *t++ = 0;
- }
- else
- if(val == 256) {
- *t++ = 0;
- *t++ = 0;
- }
- else
- *t++ = val;
- x++;
- }
-
- void RecScan::Render(int val, int len)
- {
- x += len;
- if(val == 256) {
- while(len > 0) {
- int n = min(len, 128);
- *t++ = 0;
- *t++ = 128 + n - 1;
- len -= n;
- }
- return;
- }
- if(val == 0) {
- while(len > 0) {
- int n = min(len, 128);
- *t++ = 0;
- *t++ = n - 1;
- len -= n;
- }
- return;
- }
- while(len--)
- *t++ = val;
- }
- /*
- void RecScan::Finish(int cx)
- {
- cx = cx - x;
- while(cx > 0) {
- int n = min(cx, 128);
- *t++ = 0;
- *t++ = n - 1;
- cx -= n;
- }
- sl.datalen = t - ~sl.data;
- }
-
- void RecScan::Shrink()
- {
- if(sl.datalen + 30 <
- }
- */