Moving the curve drawing into the nsRenderingContextImpl class.

This commit is contained in:
dcone%netscape.com 2000-04-28 20:46:40 +00:00
Родитель 9edba06799
Коммит 3b48c1c8bf
7 изменённых файлов: 547 добавлений и 45 удалений

Просмотреть файл

@ -668,7 +668,7 @@ public:
* @param aWidth tile width
* @param aHeight tile height
*/
NS_IMETHOD DrawPath(nsPoint aPointArray[],PRInt32 aNumPts) = 0;
NS_IMETHOD DrawPath(nsPathPoint aPointArray[],PRInt32 aNumPts) = 0;
/**
* Copy offscreen pixelmap to this RenderingContext.

Просмотреть файл

@ -62,4 +62,23 @@ struct nsPoint {
}
};
/** ---------------------------------------------------
* A special type of point which also add the capability to tell if a point is on
* the curve.. or off of the curve for a path
* @update 03/29/00 dwc
*/
struct nsPathPoint: public nsPoint{
PRBool mIsOnCurve;
// Constructors
nsPathPoint() {}
nsPathPoint(const nsPathPoint& aPoint) {x = aPoint.x; y = aPoint.y;mIsOnCurve=aPoint.mIsOnCurve;}
nsPathPoint(nscoord aX, nscoord aY) {x = aX; y = aY;mIsOnCurve=PR_TRUE;}
nsPathPoint(nscoord aX, nscoord aY,PRBool aIsOnCurve) {x = aX; y = aY;mIsOnCurve=aIsOnCurve;}
};
#endif /* NSPOINT_H */

Просмотреть файл

@ -28,11 +28,19 @@
class nsRenderingContextImpl : public nsIRenderingContext
{
// CLASS MEMBERS
public:
protected:
nsTransform2D *mTranMatrix; // The rendering contexts transformation matrix
public:
nsRenderingContextImpl();
// CLASS METHODS
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
* @update 03/29/00 dwc
@ -43,7 +51,7 @@ public:
* See documentation in nsIRenderingContext.h
* @update 03/29/00 dwc
*/
NS_IMETHOD DrawPath(nsPoint aPointArray[],PRInt32 aNumPts);
NS_IMETHOD DrawPath(nsPathPoint aPointArray[],PRInt32 aNumPts);
protected:
virtual ~nsRenderingContextImpl();
@ -73,4 +81,66 @@ public:
};
/** ---------------------------------------------------
* Class QBezierCurve, a quadratic bezier curve
* @update 4/27/2000 dwc
*/
class QBezierCurve
{
public:
nsPoint mAnc1;
nsPoint mCon;
nsPoint mAnc2;
QBezierCurve() {mAnc1.x=0;mAnc1.y=0;mCon=mAnc2=mAnc1;}
void SetControls(nsPoint &aAnc1,nsPoint &aCon,nsPoint &aAnc2) { mAnc1 = aAnc1; mCon = aCon; mAnc2 = aAnc2;}
void SetPoints(nscoord a1x,nscoord a1y,nscoord acx,nscoord acy,nscoord a2x,nscoord a2y) {mAnc1.MoveTo(a1x,a1y),mCon.MoveTo(acx,acy),mAnc2.MoveTo(a2x,a2y);}
/** ---------------------------------------------------
* Divide a Quadratic curve into line segments if it is not smaller than a certain size
* else it is so small that it can be approximated by 2 lineto calls
* @param aRenderingContext -- The RenderingContext to use to draw with
* @param aPointArray[] -- A list of points we can put line calls into instead of drawing. If null, lines are drawn
* @param aCurInex -- a pointer to an Integer that tells were to put the points into the array, incremented when finished
* @update 3/26/99 dwc
*/
void SubDivide(nsIRenderingContext *aRenderingContext,nsPoint aPointArray[],PRInt32 *aCurIndex);
/** ---------------------------------------------------
* Divide a Quadratic Bezier curve at the mid-point
* @update 3/26/99 dwc
* @param aCurve1 -- Curve 1 as a result of the division
* @param aCurve2 -- Curve 2 as a result of the division
*/
void MidPointDivide(QBezierCurve *A,QBezierCurve *B);
};
enum eSegType {eUNDEF,eLINE,eQCURVE,eCCURVE};
/** ---------------------------------------------------
* A class to iterate through a nsPathPoint array and return segments
* @update 04/27/00 dwc
*/
class nsPathIter {
public:
enum eSegType {eUNDEF,eLINE,eQCURVE,eCCURVE};
private:
PRUint32 mCurPoint;
PRUint32 mNumPoints;
nsPathPoint *mThePath;
public:
nsPathIter();
nsPathIter(nsPathPoint* aThePath,PRUint32 aNumPts);
PRBool NextSeg(QBezierCurve& TheSegment,eSegType& aCurveType);
};
#endif /* nsRenderingContextImpl */

Просмотреть файл

@ -147,8 +147,39 @@ nsTransform2D *theTransform;
* @update 3/29/00 dwc
*/
NS_IMETHODIMP
nsRenderingContextImpl::DrawPath(nsPoint aPointArray[],PRInt32 aNumPts)
nsRenderingContextImpl::DrawPath(nsPathPoint aPointArray[],PRInt32 aNumPts)
{
PRInt32 i;
nsPathPoint pts[20];
nsPathPoint *pp0,*np,*pp;
QBezierCurve thecurve;
nsPathIter *thePathIter;
nsPathIter::eSegType curveType;
// Transform the points first
if (aNumPts > 20){
pp0 = new nsPathPoint[aNumPts];
} else {
pp0 = &pts[0];
}
pp = pp0;
for ( i= 0; i < aNumPts; i++,np++,pp++){
pp->x = np->x;
pp->y = np->y;
mTranMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
}
thePathIter = new nsPathIter(pp0,aNumPts);
while ( thePathIter->NextSeg(thecurve,curveType) ) {
//thecurve.Display_Graphic(TheProcess,NULL);
}
// Release temporary storage if necessary
if (pp0 != pts)
delete pp0;
return NS_OK;
}
@ -184,3 +215,179 @@ PRInt32 flag = NS_COPYBITS_TO_BACK_BUFFER | NS_COPYBITS_XFORM_DEST_VALUES;
* See documentation in nsRenderingContextImpl.h
* @update 3/29/00 dwc
*/
void
QBezierCurve::SubDivide(nsIRenderingContext *aRenderingContext,nsPoint aPointArray[],PRInt32 *aCurIndex)
{
QBezierCurve curve1,curve2;
PRInt16 fx,fy,smag;
// divide the curve into 2 pieces
MidPointDivide(&curve1,&curve2);
fx = (PRInt16)abs(curve1.mAnc2.x - this->mCon.x);
fy = (PRInt16)abs(curve1.mAnc2.y - this->mCon.y);
smag = fx+fy-(PR_MIN(fx,fy)>>1);
//smag = fx*fx + fy*fy;
if (smag>1){
// split the curve again
curve1.SubDivide(aRenderingContext,aPointArray,aCurIndex);
curve2.SubDivide(aRenderingContext,aPointArray,aCurIndex);
}else{
if(aPointArray ) {
// save the points for further processing
aPointArray[*aCurIndex].x = curve1.mAnc2.x;
aPointArray[*aCurIndex].y = curve1.mAnc2.y;
(*aCurIndex)++;
aPointArray[*aCurIndex].x = curve2.mAnc2.x;
aPointArray[*aCurIndex].y = curve2.mAnc2.y;
(*aCurIndex)++;
}else{
// draw the curve
aRenderingContext->DrawLine(curve1.mAnc1.x,curve1.mAnc1.y,curve1.mAnc2.x,curve1.mAnc2.y);
aRenderingContext->DrawLine(curve1.mAnc2.x,curve1.mAnc2.y,curve2.mAnc2.x,curve2.mAnc2.y);
}
}
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
void
QBezierCurve::MidPointDivide(QBezierCurve *A,QBezierCurve *B)
{
double c1x,c1y,c2x,c2y;
nsPoint a1;
c1x = (mAnc1.x+mCon.x)/2.0;
c1y = (mAnc1.y+mCon.y)/2.0;
c2x = (mAnc2.x+mCon.x)/2.0;
c2y = (mAnc2.y+mCon.y)/2.0;
a1.x = (PRInt32)((c1x + c2x)/2.0);
a1.y = (PRInt32)((c1y + c2y)/2.0);
// put the math into our 2 new curves
A->mAnc1 = this->mAnc1;
A->mCon.x = (PRInt16)c1x;
A->mCon.y = (PRInt16)c1y;
A->mAnc2 = a1;
B->mAnc1 = a1;
B->mCon.x = (PRInt16)c2x;
B->mCon.y = (PRInt16)c2y;
B->mAnc2 = this->mAnc2;
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
nsPathIter::nsPathIter()
{
mCurPoint = 0;
mNumPoints = 0;
mThePath = 0;
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
nsPathIter::nsPathIter(nsPathPoint* aThePath,PRUint32 aNumPts)
{
mCurPoint = 0;
mNumPoints = aNumPts;
mThePath = aThePath;
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
PRBool
nsPathIter::NextSeg(QBezierCurve& TheSegment,eSegType& aCurveType)
{
PRInt8 code=0;
PRBool result = PR_FALSE;
nsPathPoint *pt1,*pt2,*pt3;
nsPathPoint ptAvg,ptAvg1;
if ( mCurPoint < mNumPoints) {
// 1st point
pt1 = &(mThePath[mCurPoint]);
if(PR_TRUE == pt1->mIsOnCurve) {
code += 0x04;
}
// 2nd point
if ( (mCurPoint+1) < mNumPoints) {
pt2 = &(mThePath[mCurPoint+1]);
} else{
pt2 = &(mThePath[0]);
}
if(PR_TRUE == pt2->mIsOnCurve) {
code += 0x02;
}
// 3rd point
if( (mCurPoint+2) < mNumPoints) {
pt3 = &(mThePath[mCurPoint+2]);
} else if ( (mCurPoint+1) < mNumPoints) {
pt3 = &(mThePath[0]);
} else {
pt3 = &(mThePath[1]);
}
if(PR_TRUE == pt3->mIsOnCurve) {
code += 0x01;
}
switch(code) {
case 07: // 111
case 06: // 110
TheSegment.SetPoints(pt1->x,pt1->y,0,0,pt2->x,pt2->y);
aCurveType = eLINE;
mCurPoint++;
break;
case 05: // 101
TheSegment.SetPoints(pt1->x,pt1->y,pt2->x,pt2->y,pt3->x,pt3->y);
aCurveType = eQCURVE;
mCurPoint+=2;
break;
case 04: // 100
ptAvg.x = (nscoord) (((pt2->x+pt3->x)/2.0));
ptAvg.y = (nscoord) (((pt2->y+pt3->y)/2.0));
TheSegment.SetPoints(pt1->x,pt1->y,pt2->x,pt2->y,ptAvg.x,ptAvg.y);
aCurveType = eQCURVE;
mCurPoint++;
case 03: // 011
case 02: // 010
TheSegment.SetPoints(pt1->x,pt1->y,0,0,pt2->x,pt2->y);
aCurveType = eLINE;
mCurPoint++;
case 01: // 001
ptAvg.x = (nscoord) (((pt1->x+pt2->x)/2.0));
ptAvg.y = (nscoord) (((pt1->y+pt2->y)/2.0));
TheSegment.SetPoints(ptAvg.x,ptAvg.y,pt2->x,pt3->y,pt2->x,pt3->y);
aCurveType = eQCURVE;
mCurPoint+=2;
case 00: // 000
ptAvg.x = (nscoord) (((pt1->x+pt2->x)/2.0));
ptAvg.y = (nscoord) (((pt1->y+pt2->y)/2.0));
ptAvg1.x = (nscoord) (((pt2->x+pt3->x)/2.0));
ptAvg1.y = (nscoord) (((pt2->y+pt3->y)/2.0));
TheSegment.SetPoints(ptAvg.x,ptAvg.y,pt2->x,pt2->y,ptAvg1.x,ptAvg1.y);
default:
break;
}
}
return result;
}

Просмотреть файл

@ -147,8 +147,39 @@ nsTransform2D *theTransform;
* @update 3/29/00 dwc
*/
NS_IMETHODIMP
nsRenderingContextImpl::DrawPath(nsPoint aPointArray[],PRInt32 aNumPts)
nsRenderingContextImpl::DrawPath(nsPathPoint aPointArray[],PRInt32 aNumPts)
{
PRInt32 i;
nsPathPoint pts[20];
nsPathPoint *pp0,*np,*pp;
QBezierCurve thecurve;
nsPathIter *thePathIter;
nsPathIter::eSegType curveType;
// Transform the points first
if (aNumPts > 20){
pp0 = new nsPathPoint[aNumPts];
} else {
pp0 = &pts[0];
}
pp = pp0;
for ( i= 0; i < aNumPts; i++,np++,pp++){
pp->x = np->x;
pp->y = np->y;
mTranMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
}
thePathIter = new nsPathIter(pp0,aNumPts);
while ( thePathIter->NextSeg(thecurve,curveType) ) {
//thecurve.Display_Graphic(TheProcess,NULL);
}
// Release temporary storage if necessary
if (pp0 != pts)
delete pp0;
return NS_OK;
}
@ -184,3 +215,179 @@ PRInt32 flag = NS_COPYBITS_TO_BACK_BUFFER | NS_COPYBITS_XFORM_DEST_VALUES;
* See documentation in nsRenderingContextImpl.h
* @update 3/29/00 dwc
*/
void
QBezierCurve::SubDivide(nsIRenderingContext *aRenderingContext,nsPoint aPointArray[],PRInt32 *aCurIndex)
{
QBezierCurve curve1,curve2;
PRInt16 fx,fy,smag;
// divide the curve into 2 pieces
MidPointDivide(&curve1,&curve2);
fx = (PRInt16)abs(curve1.mAnc2.x - this->mCon.x);
fy = (PRInt16)abs(curve1.mAnc2.y - this->mCon.y);
smag = fx+fy-(PR_MIN(fx,fy)>>1);
//smag = fx*fx + fy*fy;
if (smag>1){
// split the curve again
curve1.SubDivide(aRenderingContext,aPointArray,aCurIndex);
curve2.SubDivide(aRenderingContext,aPointArray,aCurIndex);
}else{
if(aPointArray ) {
// save the points for further processing
aPointArray[*aCurIndex].x = curve1.mAnc2.x;
aPointArray[*aCurIndex].y = curve1.mAnc2.y;
(*aCurIndex)++;
aPointArray[*aCurIndex].x = curve2.mAnc2.x;
aPointArray[*aCurIndex].y = curve2.mAnc2.y;
(*aCurIndex)++;
}else{
// draw the curve
aRenderingContext->DrawLine(curve1.mAnc1.x,curve1.mAnc1.y,curve1.mAnc2.x,curve1.mAnc2.y);
aRenderingContext->DrawLine(curve1.mAnc2.x,curve1.mAnc2.y,curve2.mAnc2.x,curve2.mAnc2.y);
}
}
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
void
QBezierCurve::MidPointDivide(QBezierCurve *A,QBezierCurve *B)
{
double c1x,c1y,c2x,c2y;
nsPoint a1;
c1x = (mAnc1.x+mCon.x)/2.0;
c1y = (mAnc1.y+mCon.y)/2.0;
c2x = (mAnc2.x+mCon.x)/2.0;
c2y = (mAnc2.y+mCon.y)/2.0;
a1.x = (PRInt32)((c1x + c2x)/2.0);
a1.y = (PRInt32)((c1y + c2y)/2.0);
// put the math into our 2 new curves
A->mAnc1 = this->mAnc1;
A->mCon.x = (PRInt16)c1x;
A->mCon.y = (PRInt16)c1y;
A->mAnc2 = a1;
B->mAnc1 = a1;
B->mCon.x = (PRInt16)c2x;
B->mCon.y = (PRInt16)c2y;
B->mAnc2 = this->mAnc2;
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
nsPathIter::nsPathIter()
{
mCurPoint = 0;
mNumPoints = 0;
mThePath = 0;
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
nsPathIter::nsPathIter(nsPathPoint* aThePath,PRUint32 aNumPts)
{
mCurPoint = 0;
mNumPoints = aNumPts;
mThePath = aThePath;
}
/** ---------------------------------------------------
* See documentation in nsRenderingContextImpl.h
* @update 4/27/2000 dwc
*/
PRBool
nsPathIter::NextSeg(QBezierCurve& TheSegment,eSegType& aCurveType)
{
PRInt8 code=0;
PRBool result = PR_FALSE;
nsPathPoint *pt1,*pt2,*pt3;
nsPathPoint ptAvg,ptAvg1;
if ( mCurPoint < mNumPoints) {
// 1st point
pt1 = &(mThePath[mCurPoint]);
if(PR_TRUE == pt1->mIsOnCurve) {
code += 0x04;
}
// 2nd point
if ( (mCurPoint+1) < mNumPoints) {
pt2 = &(mThePath[mCurPoint+1]);
} else{
pt2 = &(mThePath[0]);
}
if(PR_TRUE == pt2->mIsOnCurve) {
code += 0x02;
}
// 3rd point
if( (mCurPoint+2) < mNumPoints) {
pt3 = &(mThePath[mCurPoint+2]);
} else if ( (mCurPoint+1) < mNumPoints) {
pt3 = &(mThePath[0]);
} else {
pt3 = &(mThePath[1]);
}
if(PR_TRUE == pt3->mIsOnCurve) {
code += 0x01;
}
switch(code) {
case 07: // 111
case 06: // 110
TheSegment.SetPoints(pt1->x,pt1->y,0,0,pt2->x,pt2->y);
aCurveType = eLINE;
mCurPoint++;
break;
case 05: // 101
TheSegment.SetPoints(pt1->x,pt1->y,pt2->x,pt2->y,pt3->x,pt3->y);
aCurveType = eQCURVE;
mCurPoint+=2;
break;
case 04: // 100
ptAvg.x = (nscoord) (((pt2->x+pt3->x)/2.0));
ptAvg.y = (nscoord) (((pt2->y+pt3->y)/2.0));
TheSegment.SetPoints(pt1->x,pt1->y,pt2->x,pt2->y,ptAvg.x,ptAvg.y);
aCurveType = eQCURVE;
mCurPoint++;
case 03: // 011
case 02: // 010
TheSegment.SetPoints(pt1->x,pt1->y,0,0,pt2->x,pt2->y);
aCurveType = eLINE;
mCurPoint++;
case 01: // 001
ptAvg.x = (nscoord) (((pt1->x+pt2->x)/2.0));
ptAvg.y = (nscoord) (((pt1->y+pt2->y)/2.0));
TheSegment.SetPoints(ptAvg.x,ptAvg.y,pt2->x,pt3->y,pt2->x,pt3->y);
aCurveType = eQCURVE;
mCurPoint+=2;
case 00: // 000
ptAvg.x = (nscoord) (((pt1->x+pt2->x)/2.0));
ptAvg.y = (nscoord) (((pt1->y+pt2->y)/2.0));
ptAvg1.x = (nscoord) (((pt2->x+pt3->x)/2.0));
ptAvg1.y = (nscoord) (((pt2->y+pt3->y)/2.0));
TheSegment.SetPoints(ptAvg.x,ptAvg.y,pt2->x,pt2->y,ptAvg1.x,ptAvg1.y);
default:
break;
}
}
return result;
}

Просмотреть файл

@ -295,7 +295,7 @@ nsRenderingContextWin :: ~nsRenderingContextWin()
NS_RELEASE(mDCOwner);
}
mTMatrix = nsnull;
mTranMatrix = nsnull;
mDC = NULL;
mMainDC = NULL;
}
@ -465,7 +465,7 @@ nsresult nsRenderingContextWin :: CommonInit(void)
float app2dev;
mContext->GetAppUnitsToDevUnits(app2dev);
mTMatrix->AddScale(app2dev, app2dev);
mTranMatrix->AddScale(app2dev, app2dev);
mContext->GetDevUnitsToAppUnits(mP2T);
#ifdef NS_DEBUG
@ -678,7 +678,7 @@ NS_IMETHODIMP nsRenderingContextWin :: PushState(void)
NS_IF_ADDREF(mStates->mNext->mFontMetrics);
}
mTMatrix = &mStates->mMatrix;
mTranMatrix = &mStates->mMatrix;
return NS_OK;
}
@ -701,7 +701,7 @@ NS_IMETHODIMP nsRenderingContextWin :: PopState(PRBool &aClipEmpty)
if (nsnull != mStates)
{
mTMatrix = &mStates->mMatrix;
mTranMatrix = &mStates->mMatrix;
GraphicsState *pstate;
@ -738,7 +738,7 @@ NS_IMETHODIMP nsRenderingContextWin :: PopState(PRBool &aClipEmpty)
SetLineStyle(mStates->mLineStyle);
}
else
mTMatrix = nsnull;
mTranMatrix = nsnull;
}
aClipEmpty = retval;
@ -759,7 +759,7 @@ NS_IMETHODIMP nsRenderingContextWin :: SetClipRect(const nsRect& aRect, nsClipCo
mStates->mLocalClip = aRect;
mTMatrix->TransformCoord(&trect.x, &trect.y,
mTranMatrix->TransformCoord(&trect.x, &trect.y,
&trect.width, &trect.height);
RECT nr;
@ -984,20 +984,20 @@ NS_IMETHODIMP nsRenderingContextWin :: GetFontMetrics(nsIFontMetrics *&aFontMetr
// add the passed in translation to the current translation
NS_IMETHODIMP nsRenderingContextWin :: Translate(nscoord aX, nscoord aY)
{
mTMatrix->AddTranslation((float)aX,(float)aY);
mTranMatrix->AddTranslation((float)aX,(float)aY);
return NS_OK;
}
// add the passed in scale to the current scale
NS_IMETHODIMP nsRenderingContextWin :: Scale(float aSx, float aSy)
{
mTMatrix->AddScale(aSx, aSy);
mTranMatrix->AddScale(aSx, aSy);
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextWin :: GetCurrentTransform(nsTransform2D *&aTransform)
{
aTransform = mTMatrix;
aTransform = mTranMatrix;
return NS_OK;
}
@ -1048,8 +1048,8 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawLine(nscoord aX0, nscoord aY0, nscoor
if (nsLineStyle_kNone == mCurrLineStyle)
return NS_OK;
mTMatrix->TransformCoord(&aX0,&aY0);
mTMatrix->TransformCoord(&aX1,&aY1);
mTranMatrix->TransformCoord(&aX0,&aY0);
mTranMatrix->TransformCoord(&aX1,&aY1);
SetupPen();
@ -1092,7 +1092,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawPolyline(const nsPoint aPoints[], PRI
{
pp->x = np->x;
pp->y = np->y;
mTMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
mTranMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
}
// Draw the polyline
@ -1112,7 +1112,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawRect(const nsRect& aRect)
nsRect tr;
tr = aRect;
mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
mTranMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
nr.left = tr.x;
nr.top = tr.y;
nr.right = tr.x+tr.width;
@ -1127,7 +1127,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawRect(nscoord aX, nscoord aY, nscoord
{
RECT nr;
mTMatrix->TransformCoord(&aX,&aY,&aWidth,&aHeight);
mTranMatrix->TransformCoord(&aX,&aY,&aWidth,&aHeight);
nr.left = aX;
nr.top = aY;
nr.right = aX+aWidth;
@ -1144,7 +1144,7 @@ NS_IMETHODIMP nsRenderingContextWin :: FillRect(const nsRect& aRect)
nsRect tr;
tr = aRect;
mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
mTranMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
ConditionRect(tr, nr);
::FillRect(mDC, &nr, SetupSolidBrush());
@ -1156,7 +1156,7 @@ NS_IMETHODIMP nsRenderingContextWin :: FillRect(nscoord aX, nscoord aY, nscoord
RECT nr;
nsRect tr;
mTMatrix->TransformCoord(&aX,&aY,&aWidth,&aHeight);
mTranMatrix->TransformCoord(&aX,&aY,&aWidth,&aHeight);
nr.left = aX;
nr.top = aY;
nr.right = aX+aWidth;
@ -1173,7 +1173,7 @@ NS_IMETHODIMP nsRenderingContextWin :: InvertRect(const nsRect& aRect)
nsRect tr;
tr = aRect;
mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
mTranMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
ConditionRect(tr, nr);
::InvertRect(mDC, &nr);
@ -1185,7 +1185,7 @@ NS_IMETHODIMP nsRenderingContextWin :: InvertRect(nscoord aX, nscoord aY, nscoor
RECT nr;
nsRect tr;
mTMatrix->TransformCoord(&aX,&aY,&aWidth,&aHeight);
mTranMatrix->TransformCoord(&aX,&aY,&aWidth,&aHeight);
nr.left = aX;
nr.top = aY;
nr.right = aX+aWidth;
@ -1213,7 +1213,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawPolygon(const nsPoint aPoints[], PRIn
{
pp->x = np->x;
pp->y = np->y;
mTMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
mTranMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
}
// Outline the polygon - note we are implicitly ignoring the linestyle here
@ -1247,7 +1247,7 @@ NS_IMETHODIMP nsRenderingContextWin :: FillPolygon(const nsPoint aPoints[], PRIn
{
pp->x = np->x;
pp->y = np->y;
mTMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
mTranMatrix->TransformCoord((int*)&pp->x,(int*)&pp->y);
}
// Fill the polygon
@ -1277,7 +1277,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawEllipse(nscoord aX, nscoord aY, nscoo
if (nsLineStyle_kNone == mCurrLineStyle)
return NS_OK;
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
mTranMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
SetupPen();
@ -1296,7 +1296,7 @@ NS_IMETHODIMP nsRenderingContextWin :: FillEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextWin :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
mTranMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
SetupSolidPen();
SetupSolidBrush();
@ -1321,7 +1321,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawArc(nscoord aX, nscoord aY, nscoord a
PRInt32 quad1, quad2, sx, sy, ex, ey, cx, cy;
float anglerad, distance;
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
mTranMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
SetupPen();
SetupSolidBrush();
@ -1361,7 +1361,7 @@ NS_IMETHODIMP nsRenderingContextWin :: FillArc(nscoord aX, nscoord aY, nscoord a
PRInt32 quad1, quad2, sx, sy, ex, ey, cx, cy;
float anglerad, distance;
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
mTranMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
SetupSolidPen();
SetupSolidBrush();
@ -2285,9 +2285,9 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const char *aString, PRUint32
if (aLength > 500) {
dx0 = new INT[aLength];
}
mTMatrix->ScaleXCoords(aSpacing, aLength, dx0);
mTranMatrix->ScaleXCoords(aSpacing, aLength, dx0);
}
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
::ExtTextOut(mDC, x, y, 0, NULL, aString, aLength, aSpacing ? dx0 : NULL);
if ((nsnull != aSpacing) && (dx0 != dxMem)) {
@ -2322,7 +2322,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUi
PRInt32 x = aX;
PRInt32 y = aY;
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
nsFontMetricsWin* metrics = (nsFontMetricsWin*) mFontMetrics;
nsFontWin* prevFont = nsnull;
@ -2367,7 +2367,7 @@ FoundFont:
// coord where y is constant and transformed once
x = aX;
y = aY;
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
prevFont->DrawString(mDC, x, y, str, 1);
aX += *aSpacing++;
str++;
@ -2425,7 +2425,7 @@ FoundFont:
// coord where y is constant and transformed once
x = aX;
y = aY;
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
prevFont->DrawString(mDC, x, y, str, 1);
aX += *aSpacing++;
str++;
@ -2742,10 +2742,10 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect&
nsRect sr,dr;
sr = aSRect;
mTMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
dr = aDRect;
mTMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
return aImage->Draw(*this, mSurface, sr.x, sr.y, sr.width, sr.height, dr.x, dr.y, dr.width, dr.height);
}
@ -2755,7 +2755,7 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect&
nsRect tr;
tr = aRect;
mTMatrix->TransformCoord(&tr.x, &tr.y, &tr.width, &tr.height);
mTranMatrix->TransformCoord(&tr.x, &tr.y, &tr.width, &tr.height);
return aImage->Draw(*this, mSurface, tr.x, tr.y, tr.width, tr.height);
}
@ -2772,8 +2772,8 @@ nsRenderingContextWin::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord
PRBool didtile = FALSE;
// convert output platform, but no translation.. just scale
mTMatrix->TransformCoord(&aX0,&aY0,&aWidth,&aHeight);
mTMatrix->TransformCoord(&aX1,&aY1);
mTranMatrix->TransformCoord(&aX0,&aY0,&aWidth,&aHeight);
mTranMatrix->TransformCoord(&aX1,&aY1);
if ( PR_TRUE==CanTile(aWidth,aHeight) ) {
didtile = ((nsImageWin*)aImage)->PatBltTile(*this,mSurface,aX0,aY0,aX1,aY1,aWidth,aHeight);
@ -2869,10 +2869,10 @@ NS_IMETHODIMP nsRenderingContextWin :: CopyOffScreenBits(nsDrawingSurface aSrcSu
oldPalette = ::SelectPalette(destdc, (HPALETTE)palInfo.palette, PR_TRUE);
if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES)
mTMatrix->TransformCoord(&drect.x, &drect.y, &drect.width, &drect.height);
mTranMatrix->TransformCoord(&drect.x, &drect.y, &drect.width, &drect.height);
::BitBlt(destdc, drect.x, drect.y,
drect.width, drect.height,
@ -3246,7 +3246,7 @@ NS_IMETHODIMP nsRenderingContextWinA :: DrawString(const PRUnichar *aString, PRU
PRInt32 x = aX;
PRInt32 y = aY;
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
nsFontMetricsWinA* metrics = (nsFontMetricsWinA*) mFontMetrics;
nsFontSubset* prevFont = nsnull;
@ -3296,7 +3296,7 @@ FoundFont:
// coord where y is constant and transformed once
x = aX;
y = aY;
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
prevFont->DrawString(mDC, x, y, str, 1);
aX += *aSpacing++;
str++;
@ -3331,7 +3331,7 @@ FoundFont:
// coord where y is constant and transformed once
x = aX;
y = aY;
mTMatrix->TransformCoord(&x, &y);
mTranMatrix->TransformCoord(&x, &y);
prevFont->DrawString(mDC, x, y, str, 1);
aX += *aSpacing++;
str++;

Просмотреть файл

@ -218,7 +218,6 @@ private:
protected:
nscolor mCurrentColor;
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
nsIFontMetrics *mFontMetrics;
HDC mDC;
HDC mMainDC;