?? drvstrok.cpp
字號:
}
else
{
ptfxLast = pd.pptfx[pd.count-1];
if( ! ( pd.flags & PD_CLOSEFIGURE ) )
break;
fx0 = ptfxLast.x;
fy0 = ptfxLast.y;
fx1 = ptfxStartFigure.x;
fy1 = ptfxStartFigure.y;
}
DEBUGMSG(GPE_ZONE_LINE,(TEXT("Line Seg %d.%d,%d.%d - %d.%d,%d.%d\r\n"),
fx0>>4, fx0&0x000f,
fy0>>4, fy0&0x000f,
fx1>>4, fx1&0x000f,
fy1>>4, fy1&0x000f ));
// Rotate/Flip the line segment into octant 0 ( dX>=0, dY>=0, dX>=dY )
fl = 0;
// if( fx1 < fx0 )
// {
// // Reverse direction of line to make dX>0
// SWAP(fx0,fx1,FIX)
// SWAP(fy0,fy1,FIX)
// fl |= FL_FLIP_H;
// }
if( fx1 < fx0 )
{
// Reflect across x=0 to make dX>0
fx0 = -fx0;
fx1 = -fx1;
fl |= FL_FLIP_H;
}
if( fy1 < fy0 )
{
// Reflect across y=0 to make dY>0
fy0 = -fy0;
fy1 = -fy1;
fl |= FL_FLIP_V;
}
if( ( fy1 - fy0 ) > ( fx1 - fx0 ) )
{
// Reflect across y=x to make dX>=dY
SWAP(fx0,fy0,FIX)
SWAP(fx1,fy1,FIX)
fl |= FL_FLIP_D;
}
dM = fx1 - fx0;
dN = fy1 - fy0;
if( dM == dN )
fl |= FL_FLIP_SLOPE_ONE; // take note of 1:1 slope
// Based on the flips, set FL_H_ROUND_DOWN &/or FL_V_ROUND_DOWN
fl |= gaflRound[ (fl & FL_ROUND_MASK) >>FL_ROUND_SHIFT];
x = fx0>>4;
y = fy0>>4;
M0 = fx0 & 0x000f;
N0 = fy0 & 0x000f;
// Calculate remainder term [ dM * ( N0 + F/2 ) - M0 * dN ]
llGamma = (dM * ( N0 + 8 ) - dN * M0 - ((fl&FL_V_ROUND_DOWN)?1:0)) >> 4;
llBeta = ~llGamma;
//.... N0,M0 are 0..15 so this is ok if dM,dN < about 8 million pixels
// Calculate N1,M1 - the fractional part of the line ends
M1 = ( M0 + dM ) & 0x000f;
N1 = ( N0 + dN ) & 0x000f;
// x0,y0..x1,y1 are the integer parts of the line ends where the origin
// of the line is at 0.M0,0.N0
// Thus x0, and y0 start off as 0 but may become 1 or 2 based on the exact
// starting point of the line to be rendered (and whether the last point
// is excluded)
x1 = ( M0 + dM ) >> 4;
// if( fl & FL_FLIP_H )
// {
// // Unflipped line goes right to left so x1,y1 is start
// x0 = 1;
// if( N1 == 0 )
// {
// if( M1 > ((fl & FL_H_ROUND_DOWN) ? 8 : 7 ) )
// x1++;
// }
// else if ( ((N1<8)?(8-N1):(N1-8)) + M1 > 16 )
// x1++;
// if((fl & (FL_FLIP_SLOPE_ONE | FL_H_ROUND_DOWN)) == FL_FLIP_SLOPE_ONE)
// {
// if(( N1 > 0 ) && ( M1 == N1+8 ))
// x1++;
// if(( N0 > 0 ) && ( M0 == N0+8 ))
// x0 = 2;
// }
// if( x0 != 2 )
// {
// if( N0 == 0 )
// {
// if( M0 > ((fl & FL_H_ROUND_DOWN) ? 8 : 7 ) )
// x0 = 2;
// }
// else if ( ((N0<8)?(8-N0):(N0-8)) + M0 > 16 )
// x0 = 2;
// }
// ulDelta = ( x0 == 2 ) ? dN : 0;
//
// ll = llGamma + ulDelta;
//
// if( ll >= (long)( 2 * dM - dN ) )
// {
// y0 = 2;
// }
// else if( ll >= (long)( dM - dN ) )
// {
// y0 = 1;
// }
// else
// {
// y0 = 0;
// }
// errorTerm=ll;
// while(errorTerm>0)
// errorTerm -= dM;
//
// }
// else
{
// Line is left to right ( x0,y0 is start )
x1--;
if( M1 > 0 )
{
if( N1 == 0 )
{
if( M1 > ((fl & FL_H_ROUND_DOWN) ? 8 : 7 ) )
x1++;
}
else if ( ((N1<8)?(8-N1):(N1-8)) <= M1 )
x1++;
}
x0 = 0;
if((fl & (FL_FLIP_SLOPE_ONE|FL_H_ROUND_DOWN))
== (FL_FLIP_SLOPE_ONE|FL_H_ROUND_DOWN))
{
if(( M1 > 0 ) && ( N1 == M1+8 ))
x1--;
if(( M0 > 0 ) && ( N0 == M0+8 ))
goto left_to_right_compute_y0;
}
if( M0 > 0 )
{
if( N0 == 0 )
{
if( M0 > ((fl & FL_H_ROUND_DOWN) ? 8 : 7 ) )
x0 = 1;
}
else if ( ((N0<8)?(8-N0):(N0-8)) <= M0 )
x0 = 1;
}
left_to_right_compute_y0:
if( llGamma >= (long)(dM-(dN&(-(long)x0))) )
{
errorTerm = llGamma + ( dN & ~(x0-1) ) - 2 * dM;
y0 = 1;
}
else
{
errorTerm = llGamma + ( dN & ~(x0-1) ) - dM;
y0 = 0;
}
}
llGamma = errorTerm;
llBeta = ~llGamma;
// if( ( fl & FL_FLIP_H ) || ( fl & FL_FLIP_D ) || ( fl & FL_FLIP_SLOPE_ONE ) || ( fl & FL_FLIP_V ) )
// if( ( fl & FL_FLIP_H ) )
// continue;
// Calculate length of unclipped line in pixels for style tracking
cStylePels = x1 - x0 + 1;
if( cStylePels <= 0 )
continue; // This line segment was too short to be visible!
// Normalize cliprect to origin
prclFlipped = &arclClip[(fl&FL_RECTLCLIP_MASK) >> FL_RECTLCLIP_SHIFT];
if( fl & FL_FLIP_H )
prclFlipped += 4;
xRight = prclFlipped->right - x;
xLeft = prclFlipped->left - x;
yTop = prclFlipped->top - y;
yBottom = prclFlipped->bottom - y;
// Clip line to cliprect
DEBUGMSG(GPE_ZONE_LINE,(TEXT("x0,y0=%d,%d x1=%d. Clip: %d,%d - %d,%d. llGamma = %d, llBeta = %d\r\n"),
x0,y0,x1, xLeft,yTop,xRight,yBottom, llGamma, llBeta ));
if( (long)y0 >= yBottom || (long)x0 >= xRight || (long)x1 < xLeft )
continue; // totally clipped ( note, we don't know y1 yet )
if( (long)x1 >= xRight )
x1 = xRight - 1;
if( dM == 0 || dN == 0 )
{
DEBUGMSG(GPE_ZONE_LINE,(TEXT("Horizontal or Vertical\r\n")));
if( (long)x0 < xLeft )
x0 = (unsigned long)xLeft;
if( (long)y0 < yTop )
continue;
y1 = y0;
}
else
{
#if DEBUGTEMP
orig_x0 = (int)x0;
orig_x1 = (int)x1;
orig_y0 = (int)y0;
#endif
if( (long)x0 < xLeft )
{
y0 = y0 + (unsigned long)( ( xLeft - (long)x0 ) * dN + llGamma + dM ) / dM;
x0 = (unsigned long)xLeft;
DEBUGMSG(GPE_ZONE_LINE,(TEXT("new y0 = %d\r\n"),y0));
if( (long)y0 >= yBottom )
continue;
}
#if DEBUGTEMP
x0_v1 = (int)x0;
y0_v1 = (int)y0;
#endif
if( (long)y0 < yTop )
{
x0 = 1 + x0 + (unsigned long)( (yTop-(long)y0-1) * dM - llGamma - 1 ) / dN;
y0 = (unsigned long)yTop;
DEBUGMSG(GPE_ZONE_LINE,(TEXT("new x0 = %d\r\n"),x0));
if( (long)x0 >= xRight )
continue;
}
#if DEBUGTEMP
x0_v2 = (int)x0;
y0_v2 = (int)y0;
#endif
y1 = y0 + (unsigned long)(((long)( (x1-x0) * dN ) + llGamma + dM ) / dM);
#if DEBUGTEMP
orig_y1 = (int) y1;
#endif
if( (long)y1 < yTop )
continue;
DEBUGMSG(GPE_ZONE_LINE,(TEXT("y1 = %d\r\n"),y1));
if( (long)y1 >= yBottom )
{
y1 = (unsigned long)(yBottom-1);
x1 = (unsigned long)( x0 + ( (long)( y1 - y0 ) * dM - llGamma - 1 ) / dN );
if( (long)x1 < xLeft )
continue;
}
#if DEBUGTEMP
x1_v3 = (int)x1;
y1_v3 = (int)y1;
dM_v = (int)dM;
dN_v = (int)dN;
llGamma_v = (int)llGamma;
#endif
}
// Unflip the endpoint coordinates
xStart = x + x0;
yStart = y + y0;
if( fl & FL_FLIP_D )
{
SWAP( xStart,yStart,LONG )
}
if( fl & FL_FLIP_V )
yStart = -yStart;
if( fl & FL_FLIP_H )
xStart = -xStart;
iDir = ( ( fl & FL_FLIP_V ) ? 7 : 0 ) ^ ( ( fl & FL_FLIP_D ) ? 1 : 0 ) ^ ( ( fl & FL_FLIP_H ) ? 3 : 0 );
cPels = x1 - x0 + 1;
if( cPels <= 0 ) // this can happen if line just touches cliprect
continue;
DEBUGMSG(GPE_ZONE_LINE,(TEXT("X,Y=%d,%d dM,dN=%d,%d llGamma=%d errorTerm = %d cPels=%d\r\n"),
xStart,yStart,dM,dN,llGamma,errorTerm,cPels));
parms.xStart = xStart;
parms.yStart = yStart;
parms.cPels = cPels;
parms.dM = dM;
parms.dN = dN;
parms.llGamma = errorTerm;
parms.iDir = iDir;
parms.prclClip = prclCurr;
if( FAILED((pGPE->*(parms.pLine))(&parms)))
{
DEBUGMSG(GPE_ZONE_ENTER,(TEXT("Leaving DrvStrokePath\r\n")));
return FALSE;
}
parms.styleState = ( parms.styleState + cStylePels ) & 31;
}
} while ( morePointLists );
}
pGPE->Line( &parms, gpeComplete );
return TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -