mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-01 14:22:41 -06:00
Developing rasterizer
git-svn-id: svn://ultimatepp.org/upp/trunk@825 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
00580386fa
commit
0a82b84403
10 changed files with 606 additions and 66 deletions
|
|
@ -99,7 +99,7 @@ ScanLine Pack(int x, const byte *data, int len)
|
|||
String ScanLine::ToString() const
|
||||
{
|
||||
String s;
|
||||
s << "x = " << x << ", len = " << len << ", right = " << len + x << ": ";
|
||||
s << "datalen: " << data.GetCount() << "x = " << x << ", len = " << len << ", right = " << len + x << ": ";
|
||||
for(int i = 0; i < data.GetCount(); i++) {
|
||||
byte val = data[i];
|
||||
if(val > 128) {
|
||||
|
|
@ -111,12 +111,12 @@ String ScanLine::ToString() const
|
|||
else
|
||||
s << (int)val << ", ";
|
||||
}
|
||||
s << "datalen: " << data.GetCount();
|
||||
return s;
|
||||
}
|
||||
|
||||
void Apply(RGBA *t, int len, const RGBA& color, const ScanLine& s)
|
||||
void Apply(RGBA *t, int len, const RGBA& c, const ScanLine& s)
|
||||
{
|
||||
PAINTER_TIMING("Apply");
|
||||
RGBA *e = t + len;
|
||||
const char *q = ~s.data;
|
||||
const char *qe = s.data.End();
|
||||
|
|
@ -125,12 +125,110 @@ void Apply(RGBA *t, int len, const RGBA& color, const ScanLine& s)
|
|||
byte val = *q++;
|
||||
if(val > 128) {
|
||||
RGBA *e1 = min(e, t + val - 128);
|
||||
val = *q++;
|
||||
while(t < e1)
|
||||
AlphaBlendCover7(*t++, color, val);
|
||||
byte val = *q++;
|
||||
if(val == 128 && c.a == 255) {
|
||||
int l = e1 - t;
|
||||
while(l >= 16) {
|
||||
t[0] = c; t[1] = c; t[2] = c; t[3] = c;
|
||||
t[4] = c; t[5] = c; t[6] = c; t[7] = c;
|
||||
t[8] = c; t[9] = c; t[10] = c; t[11] = c;
|
||||
t[12] = c; t[13] = c; t[14] = c; t[15] = c;
|
||||
t += 16;
|
||||
l -= 16;
|
||||
}
|
||||
switch(l) {
|
||||
case 15: t[14] = c;
|
||||
case 14: t[13] = c;
|
||||
case 13: t[12] = c;
|
||||
case 12: t[11] = c;
|
||||
case 11: t[10] = c;
|
||||
case 10: t[9] = c;
|
||||
case 9: t[8] = c;
|
||||
case 8: t[7] = c;
|
||||
case 7: t[6] = c;
|
||||
case 6: t[5] = c;
|
||||
case 5: t[4] = c;
|
||||
case 4: t[3] = c;
|
||||
case 3: t[2] = c;
|
||||
case 2: t[1] = c;
|
||||
case 1: t[0] = c;
|
||||
}
|
||||
t = e1;
|
||||
}
|
||||
else {
|
||||
RGBA c1;
|
||||
if(val != 128)
|
||||
c1 = Mul7(c, val);
|
||||
else
|
||||
c1 = c;
|
||||
while(t < e1)
|
||||
AlphaBlend(*t++, c1);
|
||||
}
|
||||
}
|
||||
else
|
||||
AlphaBlendCover7(*t++, color, val);
|
||||
AlphaBlendCover7(*t++, c, val);
|
||||
// DDUMP(t - e);
|
||||
}
|
||||
}
|
||||
|
||||
struct SolidFiller {
|
||||
RGBA *t;
|
||||
RGBA c;
|
||||
|
||||
void Start(int x) { t += x; }
|
||||
void Render(byte val) { AlphaBlendCover7(*t++, c, val); }
|
||||
void Render(byte val, int len);
|
||||
};
|
||||
|
||||
void SolidFiller::Render(byte val, int len)
|
||||
{
|
||||
if(((val - 128) | (c.a - 255)) == 0) {
|
||||
while(len >= 16) {
|
||||
t[0] = c; t[1] = c; t[2] = c; t[3] = c;
|
||||
t[4] = c; t[5] = c; t[6] = c; t[7] = c;
|
||||
t[8] = c; t[9] = c; t[10] = c; t[11] = c;
|
||||
t[12] = c; t[13] = c; t[14] = c; t[15] = c;
|
||||
t += 16;
|
||||
len -= 16;
|
||||
}
|
||||
switch(len) {
|
||||
case 15: t[14] = c;
|
||||
case 14: t[13] = c;
|
||||
case 13: t[12] = c;
|
||||
case 12: t[11] = c;
|
||||
case 11: t[10] = c;
|
||||
case 10: t[9] = c;
|
||||
case 9: t[8] = c;
|
||||
case 8: t[7] = c;
|
||||
case 7: t[6] = c;
|
||||
case 6: t[5] = c;
|
||||
case 5: t[4] = c;
|
||||
case 4: t[3] = c;
|
||||
case 3: t[2] = c;
|
||||
case 2: t[1] = c;
|
||||
case 1: t[0] = c;
|
||||
}
|
||||
t += len;
|
||||
}
|
||||
else {
|
||||
RGBA c1;
|
||||
if(val != 128)
|
||||
c1 = Mul7(c, val);
|
||||
else
|
||||
c1 = c;
|
||||
RGBA *e = t + len;
|
||||
while(t < e)
|
||||
AlphaBlend(*t++, c1);
|
||||
}
|
||||
}
|
||||
|
||||
void Render(ImageBuffer& ib, Rasterizer& r, const RGBA& color)
|
||||
{
|
||||
Size sz = ib.GetSize();
|
||||
SolidFiller f;
|
||||
f.c = color;
|
||||
for(int y = r.MinY(); y <= r.MaxY(); y++) {
|
||||
f.t = ib[y];
|
||||
r.Render(y, f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue