Skip to content

Commit c58f3e9

Browse files
author
Hugh Sanderson
committed
Work on lineStyleSoftEdge for hardware polygons
1 parent 20fc2bd commit c58f3e9

11 files changed

+323
-53
lines changed

project/include/Graphics.h

+2
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ struct GraphicsJob
638638
int mDataCount;
639639
bool mIsTileJob;
640640
bool mIsPointJob;
641+
bool mPolyAA;
641642
unsigned char mTileMode;
642643
unsigned char mBlendMode;
643644
};
@@ -691,6 +692,7 @@ class Graphics : public Object
691692
void endFill();
692693
void beginBitmapFill(Surface *bitmapData, const Matrix &inMatrix = Matrix(),
693694
bool inRepeat = true, bool inSmooth = false);
695+
void lineStyleSoftEdge();
694696
void lineStyle(double thickness, unsigned int color = 0, double alpha = 1.0,
695697
bool pixelHinting = false, StrokeScaleMode scaleMode = ssmNormal,
696698
StrokeCaps caps = scRound,

project/include/Hardware.h

+12-11
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,28 @@ enum PrimType { ptTriangleFan, ptTriangleStrip, ptTriangles, ptLineStrip, ptPoin
3030

3131
enum
3232
{
33-
DRAW_HAS_COLOUR = 0x00000001,
34-
DRAW_HAS_NORMAL = 0x00000002,
35-
DRAW_HAS_PERSPECTIVE = 0x00000004,
36-
DRAW_RADIAL = 0x00000008,
37-
38-
DRAW_HAS_TEX = 0x00000010,
39-
DRAW_BMP_REPEAT = 0x00000020,
40-
DRAW_BMP_SMOOTH = 0x00000040,
33+
DRAW_HAS_COLOUR = 0x0001,
34+
DRAW_HAS_NORMAL = 0x0002,
35+
DRAW_HAS_PERSPECTIVE = 0x0004,
36+
DRAW_RADIAL = 0x0008,
37+
38+
DRAW_HAS_TEX = 0x0010,
39+
DRAW_BMP_REPEAT = 0x0020,
40+
DRAW_BMP_SMOOTH = 0x0040,
4141

42-
DRAW_TILE_MOUSE = 0x00000080,
42+
DRAW_TILE_MOUSE = 0x0080,
43+
DRAW_EDGE_DIST = 0x0100,
4344
};
4445

4546

4647

4748
struct DrawElement
4849
{
49-
uint8 mFlags;
50+
unsigned short mFlags;
51+
short mRadialPos;
5052
uint8 mPrimType;
5153
uint8 mBlendMode;
5254
uint8 mScaleMode;
53-
short mRadialPos;
5455

5556
uint8 mStride;
5657
int mCount;

project/include/HardwareImpl.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ enum
2121
PROG_4D_INPUT = 0x0100,
2222
PROG_PREM_ALPHA = 0x0200,
2323
PROG_COMP_ALPHA = 0x0400,
24+
PROG_EDGE_DIST = 0x0800,
2425

25-
PROG_COUNT = 0x0800,
26+
PROG_COUNT = 0x1000,
2627
};
2728

2829
inline unsigned int getProgId( const DrawElement &element, const ColorTransform *ctrans)
@@ -46,6 +47,9 @@ inline unsigned int getProgId( const DrawElement &element, const ColorTransform
4647
if (element.mFlags & DRAW_HAS_NORMAL)
4748
progId |= PROG_NORMAL_DATA;
4849

50+
if (element.mFlags & DRAW_EDGE_DIST)
51+
progId |= PROG_EDGE_DIST;
52+
4953
if (element.mFlags & DRAW_RADIAL)
5054
{
5155
progId |= PROG_RADIAL;

project/src/common/ExternalInterface.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2956,6 +2956,16 @@ void nme_gfx_end_fill(value inGfx)
29562956
}
29572957
DEFINE_PRIME1v(nme_gfx_end_fill);
29582958

2959+
void nme_gfx_line_style_soft_edge(value argGfx)
2960+
{
2961+
Graphics *gfx;
2962+
if (AbstractToObject(argGfx,gfx))
2963+
{
2964+
CHECK_ACCESS("nme_gfx_line_style_soft_edge");
2965+
gfx->lineStyleSoftEdge();
2966+
}
2967+
}
2968+
DEFINE_PRIME1v(nme_gfx_line_style_soft_edge);
29592969

29602970
void nme_gfx_line_style(value argGfx, value argThickness, int argColour, double argAlpha,
29612971
bool argPixelHinting, int argScaleMode,

project/src/common/Graphics.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,21 @@ void Graphics::beginTiles(Surface *bitmapData,bool inSmooth,int inBlendMode, int
384384
OnChanged();
385385
}
386386

387+
void Graphics::lineStyleSoftEdge()
388+
{
389+
lineStyle(-1);
390+
Flush();
391+
mFillJob.mPolyAA = true;
392+
}
393+
387394
void Graphics::lineStyle(double thickness, unsigned int color, double alpha,
388395
bool pixelHinting, StrokeScaleMode scaleMode,
389396
StrokeCaps caps,
390397
StrokeJoints joints, double miterLimit)
391398
{
392399
Flush(true,false,true);
393400
endTiles();
401+
mFillJob.mPolyAA = false;
394402
if (mLineJob.mStroke)
395403
{
396404
mLineJob.mStroke->DecRef();

0 commit comments

Comments
 (0)