46
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Graphics Extension Library source file
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "GfxStrokeRendererP.h"
|
|
20 |
#include "GfxPolygonRendererP.h"
|
|
21 |
#include "GfxPaint.h"
|
|
22 |
#include "GfxColor.h"
|
|
23 |
#include "GfxRendererInfoP.h"
|
|
24 |
#include "GfxEdgeListP.h"
|
|
25 |
|
|
26 |
#include <fbs.h>
|
|
27 |
|
|
28 |
|
|
29 |
// ---------------------------------------------------------------------------
|
|
30 |
// Constructor
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// --------------------------------------------------------------------------
|
|
33 |
// TGfxStrokeRendererP::TGfxStrokeRendererP() : iStrokeColor( 0 )
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
TGfxStrokeRendererP::TGfxStrokeRendererP() : iStrokeColor( 0 )
|
|
36 |
{
|
|
37 |
}
|
|
38 |
|
|
39 |
// --------------------------------------------------------------------------
|
|
40 |
// void TGfxStrokeRendererP::InitializeP( CGfxEdgeListP* aEdgeList,
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
void TGfxStrokeRendererP::InitializeP( CGfxEdgeListP* aEdgeList,
|
|
43 |
TGfxRendererInfoP* aRenderInfo,
|
|
44 |
TGfxColor aColor )
|
|
45 |
{
|
|
46 |
iEdgeList = aEdgeList;
|
|
47 |
iRenderInfo = aRenderInfo;
|
|
48 |
iStrokeColor = aColor;
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// Draw one pixel width stroke
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
// --------------------------------------------------------------------------
|
|
56 |
// void TGfxStrokeRendererP::RenderScanlineL( TInt aY, TUint32 /* aAlpha */ )
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
void TGfxStrokeRendererP::RenderScanlineL( TInt aY, TUint32 /* aAlpha */ )
|
|
59 |
{
|
|
60 |
if ( iRenderInfo->iClipMinY > aY || aY > iRenderInfo->iClipMaxY )
|
|
61 |
return;
|
|
62 |
|
|
63 |
if ( iStrokeColor.Value() == KGfxColorNull )
|
|
64 |
return;
|
|
65 |
|
|
66 |
TGfxSegEdge* edges = iEdgeList->iEdges;
|
|
67 |
TInt edgeCount = iEdgeList->iEdgesCount;
|
|
68 |
|
|
69 |
// ************ Buffer is 2 bytes per pixel **********
|
|
70 |
TUint16* fb;
|
|
71 |
fb = ( ( TUint16 * ) iRenderInfo->iDstBuf ) +
|
|
72 |
aY * iRenderInfo->iWidth;
|
|
73 |
|
|
74 |
TUint16 strokeCol = iStrokeColor.ColorRgb();
|
|
75 |
|
|
76 |
for ( TInt i = 0; i < edgeCount; i++ )
|
|
77 |
{
|
|
78 |
if ( !edges[i].iOnlyForFill )
|
|
79 |
{
|
|
80 |
TInt32 pbufXmin, pbufXmax;
|
|
81 |
TInt32 fbXmin, fbXmax;
|
|
82 |
pbufXmin = edges[i].iStart;
|
|
83 |
pbufXmax = edges[i].iEnd;
|
|
84 |
fbXmin = pbufXmin + iEdgeList->iMinX;
|
|
85 |
fbXmax = pbufXmax + iEdgeList->iMinX;
|
|
86 |
if ( fbXmax >= iRenderInfo->iClipMinX &&
|
|
87 |
fbXmin < iRenderInfo->iClipMaxX ) // inside clipping
|
|
88 |
{
|
|
89 |
if ( fbXmin < iRenderInfo->iClipMinX )
|
|
90 |
{
|
|
91 |
pbufXmin += iRenderInfo->iClipMinX - fbXmin; // equivalent to 'pbufXmin += -fbXmin;'
|
|
92 |
fbXmin = iRenderInfo->iClipMinX;
|
|
93 |
}
|
|
94 |
if ( iRenderInfo->iClipMaxX <= fbXmax )
|
|
95 |
{
|
|
96 |
pbufXmax -= fbXmax - iRenderInfo->iClipMaxX;
|
|
97 |
fbXmax = iRenderInfo->iClipMaxX - 1;
|
|
98 |
}
|
|
99 |
TUint16* fbb =& fb[fbXmin];
|
|
100 |
TInt fbw = fbXmax - fbXmin;
|
|
101 |
if ( fbw > 10 )
|
|
102 |
{
|
|
103 |
TGfxPolygonRendererP::DrawHLine( fbb,
|
|
104 |
strokeCol,
|
|
105 |
fbXmin,
|
|
106 |
fbw );
|
|
107 |
}
|
|
108 |
else
|
|
109 |
{
|
|
110 |
for ( TInt j = fbXmin; j <= fbXmax ; j++ )
|
|
111 |
*fbb++ = strokeCol;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|
|
115 |
}
|
|
116 |
}
|