diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2012-02-05 13:27:07 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2012-02-05 13:27:07 +0400 |
commit | 6cb2939b677159a85147c6500835c194ee1ccf86 (patch) | |
tree | 54994b57d8df3203b276d15ee73c46d227ea6826 /src/Subtitles/libssf/Rasterizer.cpp | |
parent | e736ccc10964dfcd571d1b0f07327819c31a63a9 (diff) |
apply astyle
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@4039 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/Subtitles/libssf/Rasterizer.cpp')
-rw-r--r-- | src/Subtitles/libssf/Rasterizer.cpp | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/src/Subtitles/libssf/Rasterizer.cpp b/src/Subtitles/libssf/Rasterizer.cpp index c7c9c3382..02ad744ee 100644 --- a/src/Subtitles/libssf/Rasterizer.cpp +++ b/src/Subtitles/libssf/Rasterizer.cpp @@ -58,7 +58,7 @@ namespace ssf void Rasterizer::_TrashOverlay()
{
- if(mpOverlayBuffer) {
+ if (mpOverlayBuffer) {
delete [] mpOverlayBuffer;
}
mpOverlayBuffer = NULL;
@@ -72,7 +72,7 @@ namespace ssf void Rasterizer::_EvaluateBezier(const CPoint& p0, const CPoint& p1, const CPoint& p2, const CPoint& p3)
{
- if(abs(p0.x + p2.x - p1.x*2) +
+ if (abs(p0.x + p2.x - p1.x*2) +
abs(p0.y + p2.y - p1.y*2) +
abs(p1.x + p3.x - p2.x*2) +
abs(p1.y + p3.y - p2.y*2) <= max(2, 1<<FONT_AA)) {
@@ -100,11 +100,11 @@ namespace ssf void Rasterizer::_EvaluateLine(CPoint p0, CPoint p1)
{
- if(lastp != p0) {
+ if (lastp != p0) {
_EvaluateLine(lastp, p0);
}
- if(!fFirstSet) {
+ if (!fFirstSet) {
firstp = p0;
fFirstSet = true;
}
@@ -113,7 +113,7 @@ namespace ssf // TODO: ((1<<FONT_SCALE)/2+-1)
- if(p1.y > p0.y) { // down
+ if (p1.y > p0.y) { // down
int xacc = p0.x << (8 - FONT_SCALE);
// prestep p0.y down
@@ -124,16 +124,16 @@ namespace ssf p1.y = (p1.y - ((1<<FONT_SCALE)/2+1)) >> FONT_SCALE;
- if(iy <= p1.y) {
+ if (iy <= p1.y) {
int invslope = ((p1.x - p0.x) << 8) / dy;
- while(mEdgeNext + p1.y + 1 - iy > mEdgeHeapSize) {
+ while (mEdgeNext + p1.y + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
}
xacc += (invslope * (y - p0.y)) >> FONT_SCALE;
- while(iy <= p1.y) {
+ while (iy <= p1.y) {
int ix = (xacc + 128) >> 8;
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -145,7 +145,7 @@ namespace ssf xacc += invslope;
}
}
- } else if(p1.y < p0.y) { // up
+ } else if (p1.y < p0.y) { // up
int xacc = p1.x << (8 - FONT_SCALE);
// prestep p1.y down
@@ -156,16 +156,16 @@ namespace ssf p0.y = (p0.y - ((1<<FONT_SCALE)/2+1)) >> FONT_SCALE;
- if(iy <= p0.y) {
+ if (iy <= p0.y) {
int invslope = ((p0.x - p1.x) << 8) / dy;
- while(mEdgeNext + p0.y + 1 - iy > mEdgeHeapSize) {
+ while (mEdgeNext + p0.y + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
}
xacc += (invslope * (y - p1.y)) >> FONT_SCALE;
- while(iy <= p0.y) {
+ while (iy <= p0.y) {
int ix = (xacc + 128) >> 8;
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -187,7 +187,7 @@ namespace ssf mOutline.RemoveAll();
mWideOutline.RemoveAll();
- if(path.types.IsEmpty() || path.points.IsEmpty() || bbox.IsRectEmpty()) {
+ if (path.types.IsEmpty() || path.points.IsEmpty() || bbox.IsRectEmpty()) {
mPathOffsetX = mPathOffsetY = 0;
mWidth = mHeight = 0;
return 0;
@@ -200,7 +200,7 @@ namespace ssf path.MovePoints(CPoint(-minx*(1<<FONT_SCALE), -miny*(1<<FONT_SCALE)));
- if(minx > maxx || miny > maxy) {
+ if (minx > maxx || miny > maxy) {
mWidth = mHeight = 0;
mPathOffsetX = mPathOffsetY = 0;
return true;
@@ -238,10 +238,10 @@ namespace ssf BYTE* type = path.types.GetData();
POINT* pt = path.points.GetData();
- for(size_t i = 0, j = path.types.GetCount(); i < j; i++) {
- switch(type[i] & ~PT_CLOSEFIGURE) {
+ for (size_t i = 0, j = path.types.GetCount(); i < j; i++) {
+ switch (type[i] & ~PT_CLOSEFIGURE) {
case PT_MOVETO:
- if(lastmoveto >= 0 && firstp != lastp) {
+ if (lastmoveto >= 0 && firstp != lastp) {
_EvaluateLine(lastp, firstp);
}
lastmoveto = int(i);
@@ -249,12 +249,12 @@ namespace ssf lastp = pt[i];
break;
case PT_LINETO:
- if(j - (i-1) >= 2) {
+ if (j - (i-1) >= 2) {
_EvaluateLine(pt[i-1], pt[i]);
}
break;
case PT_BEZIERTO:
- if(j - (i-1) >= 4) {
+ if (j - (i-1) >= 4) {
_EvaluateBezier(pt[i-1], pt[i], pt[i+1], pt[i+2]);
}
i += 2;
@@ -262,7 +262,7 @@ namespace ssf }
}
- if(lastmoveto >= 0 && firstp != lastp) {
+ if (lastmoveto >= 0 && firstp != lastp) {
_EvaluateLine(lastp, firstp);
}
@@ -276,12 +276,12 @@ namespace ssf mOutline.SetCount(0, mEdgeNext / 2);
- for(int y = 0; y < mHeight; y++) {
+ for (int y = 0; y < mHeight; y++) {
int count = 0;
// Detangle scanline into edge heap.
- for(unsigned int ptr = mpScanBuffer[y]; ptr; ptr = mpEdgeBuffer[ptr].next) {
+ for (unsigned int ptr = mpScanBuffer[y]; ptr; ptr = mpEdgeBuffer[ptr].next) {
heap.push_back(mpEdgeBuffer[ptr].posandflag);
}
@@ -299,23 +299,23 @@ namespace ssf int x1 = 0;
- for(; itX1 != itX2; ++itX1) {
+ for (; itX1 != itX2; ++itX1) {
int x = *itX1;
- if(!count) {
+ if (!count) {
x1 = x >> 1;
}
- if(x&1) {
+ if (x&1) {
++count;
} else {
--count;
}
- if(!count) {
+ if (!count) {
int x2 = x >> 1;
- if(x2 > x1) {
+ if (x2 > x1) {
Span s(x1, y, x2, y);
s.first += 0x4000000040000000i64;
s.second += 0x4000000040000000i64;
@@ -350,10 +350,10 @@ namespace ssf o.first -= dx;
o.second += dx;
- while(a != ae && b != be) {
+ while (a != ae && b != be) {
Span x;
- if(b->first + o.first < a->first) {
+ if (b->first + o.first < a->first) {
// B span is earlier. Use it.
x.first = b->first + o.first;
@@ -363,30 +363,30 @@ namespace ssf // B spans don't overlap, so begin merge loop with A first.
- for(;;) {
+ for (;;) {
// If we run out of A spans or the A span doesn't overlap,
// then the next B span can't either (because B spans don't
// overlap) and we exit.
- if(a == ae || a->first > x.second) {
+ if (a == ae || a->first > x.second) {
break;
}
do {
x.second = mymax(x.second, a->second);
- } while(++a != ae && a->first <= x.second);
+ } while (++a != ae && a->first <= x.second);
// If we run out of B spans or the B span doesn't overlap,
// then the next A span can't either (because A spans don't
// overlap) and we exit.
- if(b == be || b->first + o.first > x.second) {
+ if (b == be || b->first + o.first > x.second) {
break;
}
do {
x.second = mymax(x.second, b->second + o.second);
- } while(++b != be && b->first + o.first <= x.second);
+ } while (++b != be && b->first + o.first <= x.second);
}
} else {
// A span is earlier. Use it.
@@ -397,30 +397,30 @@ namespace ssf // A spans don't overlap, so begin merge loop with B first.
- for(;;) {
+ for (;;) {
// If we run out of B spans or the B span doesn't overlap,
// then the next A span can't either (because A spans don't
// overlap) and we exit.
- if(b == be || b->first + o.first > x.second) {
+ if (b == be || b->first + o.first > x.second) {
break;
}
do {
x.second = mymax(x.second, b->second + o.second);
- } while(++b != be && b->first + o.first <= x.second);
+ } while (++b != be && b->first + o.first <= x.second);
// If we run out of A spans or the A span doesn't overlap,
// then the next B span can't either (because B spans don't
// overlap) and we exit.
- if(a == ae || a->first > x.second) {
+ if (a == ae || a->first > x.second) {
break;
}
do {
x.second = mymax(x.second, a->second);
- } while(++a != ae && a->first <= x.second);
+ } while (++a != ae && a->first <= x.second);
}
}
@@ -433,20 +433,20 @@ namespace ssf dst.Append(a, ae - a);
- for(; b != be; b++) {
+ for (; b != be; b++) {
dst.Add(Span(b->first + o.first, b->second + o.second));
}
}
bool Rasterizer::CreateWidenedRegion(int r)
{
- if(r < 0) {
+ if (r < 0) {
r = 0;
}
r >>= FONT_SCALE;
- for(int y = -r; y <= r; ++y) {
+ for (int y = -r; y <= r; ++y) {
int x = (int)(0.5f + sqrt(float(r*r - y*y)));
_OverlapRegion(mWideOutline, mOutline, x, y);
@@ -461,7 +461,7 @@ namespace ssf {
_TrashOverlay();
- if(!mWidth || !mHeight) {
+ if (!mWidth || !mHeight) {
mOverlayWidth = mOverlayHeight = 0;
return true;
}
@@ -480,7 +480,7 @@ namespace ssf int border = ((mWideBorder + ((1<<FONT_AA)-1)) & ~((1<<FONT_AA)-1)) + (1<<FONT_AA)*4;
- if(!mWideOutline.IsEmpty()) {
+ if (!mWideOutline.IsEmpty()) {
width += 2*border;
height += 2*border;
@@ -499,27 +499,27 @@ namespace ssf Array<Span>* pOutline[2] = {&mOutline, &mWideOutline};
- for(int i = 0; i < countof(pOutline); i++) {
+ for (int i = 0; i < countof(pOutline); i++) {
const Span* s = pOutline[i]->GetData();
- for(size_t j = 0, k = pOutline[i]->GetCount(); j < k; j++) {
+ for (size_t j = 0, k = pOutline[i]->GetCount(); j < k; j++) {
int y = s[j].y1 - 0x40000000 + ysub;
int x1 = s[j].x1 - 0x40000000 + xsub;
int x2 = s[j].x2 - 0x40000000 + xsub;
- if(x2 > x1) {
+ if (x2 > x1) {
int first = x1 >> FONT_AA;
int last = (x2-1) >> FONT_AA;
BYTE* dst = mpOverlayBuffer + 4*(mOverlayWidth * (y >> FONT_AA) + first) + i;
- if(first == last) {
+ if (first == last) {
*dst += x2 - x1;
} else {
*dst += (((first+1) << FONT_AA) - x1) << (6 - FONT_AA*2);
dst += 4;
- while(++first < last) {
+ while (++first < last) {
*dst += (1 << FONT_AA) << (6 - FONT_AA*2);
dst += 4;
}
@@ -530,11 +530,11 @@ namespace ssf }
}
- if(!mWideOutline.IsEmpty()) {
+ if (!mWideOutline.IsEmpty()) {
BYTE* p = mpOverlayBuffer;
- for(int j = 0; j < mOverlayHeight; j++, p += mOverlayWidth*4) {
- for(int i = 0; i < mOverlayWidth; i++) {
+ for (int j = 0; j < mOverlayHeight; j++, p += mOverlayWidth*4) {
+ for (int i = 0; i < mOverlayWidth; i++) {
p[i*4+2] = min(p[i*4+1], (1<<6) - p[i*4]); // TODO: sse2
}
}
@@ -545,7 +545,7 @@ namespace ssf void Rasterizer::Blur(float n, int plane)
{
- if(n <= 0 || !mOverlayWidth || !mOverlayHeight || !mpOverlayBuffer) {
+ if (n <= 0 || !mOverlayWidth || !mOverlayHeight || !mpOverlayBuffer) {
return;
}
@@ -554,14 +554,14 @@ namespace ssf int pitch = w*4;
BYTE* q0 = DNew BYTE[w*h];
- for(int pass = 0; pass < n; pass++) {
+ for (int pass = 0; pass < n; pass++) {
BYTE* p = mpOverlayBuffer + plane;
BYTE* q = q0;
- for(int y = 0; y < h; y++, p += pitch, q += w) {
+ for (int y = 0; y < h; y++, p += pitch, q += w) {
q[0] = (2*p[0] + p[4]) >> 2;
int x = 0;
- for(x = 1; x < w-1; x++) {
+ for (x = 1; x < w-1; x++) {
q[x] = (p[(x-1)*4] + 2*p[x*4] + p[(x+1)*4]) >> 2;
}
q[x] = (p[(x-1)*4] + 2*p[x*4]) >> 2;
@@ -570,10 +570,10 @@ namespace ssf p = mpOverlayBuffer + plane;
q = q0;
- for(int x = 0; x < w; x++, p += 4, q++) {
+ for (int x = 0; x < w; x++, p += 4, q++) {
p[0] = (2*q[0] + q[w]) >> 2;
int y = 0, yp, yq;
- for(y = 1, yp = y*pitch, yq = y*w; y < h-1; y++, yp += pitch, yq += w) {
+ for (y = 1, yp = y*pitch, yq = y*w; y < h-1; y++, yp += pitch, yq += w) {
p[yp] = (q[yq-w] + 2*q[yq] + q[yq+w]) >> 2;
}
p[yp] = (q[yq-w] + 2*q[yq]) >> 2;
@@ -628,7 +628,7 @@ namespace ssf {
CRect bbox(0, 0, 0, 0);
- if(!switchpts) {
+ if (!switchpts) {
return bbox;
}
@@ -646,24 +646,24 @@ namespace ssf int h = mOverlayHeight;
unsigned int xo = 0, yo = 0;
- if(x < r.left) {
+ if (x < r.left) {
xo = r.left - x;
w -= r.left - x;
x = r.left;
}
- if(y < r.top) {
+ if (y < r.top) {
yo = r.top - y;
h -= r.top - y;
y = r.top;
}
- if(x+w > r.right) {
+ if (x+w > r.right) {
w = r.right - x;
}
- if(y+h > r.bottom) {
+ if (y+h > r.bottom) {
h = r.bottom - y;
}
- if(w <= 0 || h <= 0) {
+ if (w <= 0 || h <= 0) {
return bbox;
}
@@ -679,21 +679,21 @@ namespace ssf bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- while(h--) {
- if(switchpts[1] == 0xffffffff) {
- if(fSSE2) for(int wt=0; wt<w; ++wt) {
+ while (h--) {
+ if (switchpts[1] == 0xffffffff) {
+ if (fSSE2) for (int wt=0; wt<w; ++wt) {
pixmix_sse2(&dst[wt], color, src[wt*4]);
}
- else for(int wt=0; wt<w; ++wt) {
+ else for (int wt=0; wt<w; ++wt) {
pixmix_c(&dst[wt], color, src[wt*4]);
}
} else {
const DWORD* sw = switchpts;
- if(fSSE2)
- for(unsigned int wt=0; wt<(unsigned int)w; ++wt) {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1]) {
+ if (fSSE2)
+ for (unsigned int wt=0; wt<(unsigned int)w; ++wt) {
+ if (wt+xo >= sw[1]) {
+ while (wt+xo >= sw[1]) {
sw += 2;
}
color = sw[-2];
@@ -701,9 +701,9 @@ namespace ssf pixmix_sse2(&dst[wt], color, src[wt*4]);
}
else
- for(unsigned int wt=0; wt<(unsigned int)w; ++wt) {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1]) {
+ for (unsigned int wt=0; wt<(unsigned int)w; ++wt) {
+ if (wt+xo >= sw[1]) {
+ while (wt+xo >= sw[1]) {
sw += 2;
}
color = sw[-2];
|