os/graphics/graphicsdeviceinterface/directgdiadaptation/swsrc/swdirectgdiroundrec.cpp
Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "swdirectgdiengine.h"
17 #include "swdirectgdiellipse.h"
20 @see MDirectGdiEngine::DrawRoundRect()
22 void CSwDirectGdiEngine::DrawRoundRect(const TRect& aRect, const TSize& aCornerSize)
24 TSize cornerSize(aCornerSize);
25 cornerSize.iWidth <<= 1;
26 cornerSize.iHeight <<= 1;
32 cornerSize.iWidth = Min(rcpy.Width(),cornerSize.iWidth);
33 cornerSize.iHeight = Min(rcpy.Height(),cornerSize.iHeight);
35 TRect targetRect(rcpy);
36 targetRect.Grow((iPenSize.iWidth >> 1) + 1,(iPenSize.iHeight >> 1) + 1);
38 if (iBrushStyle != DirectGdi::ENullBrush)
40 RoundRectFill(rcpy,cornerSize);
43 if ((iPenStyle != DirectGdi::ENullPen) && ((iPenSize.iWidth > 0) && (iPenSize.iHeight > 0)))
45 RoundRectOutline(rcpy, cornerSize);
52 void CSwDirectGdiEngine::RoundRectFill(const TRect& aRect, const TSize& aCornerSize)
55 if (iPenSize.iWidth < 1 || iPenSize.iHeight < 1)
60 TInt xoff = rcpy.Width() - aCornerSize.iWidth;
61 TInt yoff = rcpy.Height() - aCornerSize.iHeight;
62 TPoint tl, tr, bl, br;
66 TRect clipRect(0,0,0,0);
67 const TInt limit = iDefaultRegionPtr->Count();
68 for (TInt count = 0; count < limit; count++)
70 clipRect = (*iDefaultRegionPtr)[count];
71 if (!clipRect.Intersects(aRect))
77 clipRect.Intersection(aRect);
79 TSwDirectGdiEllipse ellipse;
80 ellipse.Construct(TRect(rcpy.iTl,rcpy.iTl + aCornerSize));
81 ellipse.SingleStep(tl, tr, bl, br);
84 while (!ellipse.SingleStep(tl, tr, bl, br))
98 ClipFillLine(tl, tr,clipRect);
99 ClipFillLine(bl, br,clipRect);
104 iDrawDevice->UpdateRegion(clipRect);
123 RectFill(TRect(tl,br));
129 void CSwDirectGdiEngine::RoundRectOutline(const TRect& aRect, const TSize& aCornerSize)
132 const TInt halfpenwidth = (iPenSize.iWidth + 1) >> 1;
133 const TInt halfpenheight = (iPenSize.iHeight + 1) >> 1;
134 rcpy.Grow(halfpenwidth,halfpenheight);
136 TPoint tl, tr, bl, br;
137 const TInt xoff = aRect.Width() - aCornerSize.iWidth;
138 const TInt yoff = aRect.Height() - aCornerSize.iHeight;
139 const TInt dotparam = iDotParam;
141 TRect clipRect(0,0,0,0);
142 const TInt limit = iDefaultRegionPtr->Count();
143 for (TInt count = 0; count < limit; count++)
145 clipRect = (*iDefaultRegionPtr)[count];
146 if (!clipRect.Intersects(rcpy))
150 clipRect.Intersection(rcpy);
152 iDotParam = Max(iPenSize.iWidth >> 1,iPenSize.iHeight >> 1);
153 TInt column = aRect.iTl.iX + (aCornerSize.iWidth >> 1);
154 TInt lastcolumn = aRect.iTl.iX + xoff + (aCornerSize.iWidth >> 1);
156 for (; column < lastcolumn; column++)
158 PenDrawClipped(TPoint(column,aRect.iTl.iY), clipRect);
159 PenDrawClipped(TPoint(column,aRect.iBr.iY - 1), clipRect);
160 iDotParam += iDotDirection;
163 TSwDirectGdiEllipse ellipse;
164 ellipse.Construct(TRect(aRect.iTl,aRect.iTl + aCornerSize));
165 while (!ellipse.SingleStep(tl,tr,bl,br))
172 PenDrawClipped(tl, clipRect);
173 PenDrawClipped(tr, clipRect);
174 PenDrawClipped(bl, clipRect);
175 PenDrawClipped(br, clipRect);
177 iDotParam += iDotDirection;
188 for (column = tl.iY + 1; column < bl.iY; column++)
190 PenDrawClipped(TPoint(aRect.iTl.iX,column), clipRect);
191 PenDrawClipped(TPoint(aRect.iBr.iX - 1,column), clipRect);
192 iDotParam += iDotDirection;
195 iDrawDevice->UpdateRegion(clipRect);
198 iDotParam = dotparam;