Skip to content

Commit

Permalink
Work on lineStyleSoftEdge for hardware polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Sanderson committed Apr 10, 2024
1 parent 20fc2bd commit c58f3e9
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 53 deletions.
2 changes: 2 additions & 0 deletions project/include/Graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ struct GraphicsJob
int mDataCount;
bool mIsTileJob;
bool mIsPointJob;
bool mPolyAA;
unsigned char mTileMode;
unsigned char mBlendMode;
};
Expand Down Expand Up @@ -691,6 +692,7 @@ class Graphics : public Object
void endFill();
void beginBitmapFill(Surface *bitmapData, const Matrix &inMatrix = Matrix(),
bool inRepeat = true, bool inSmooth = false);
void lineStyleSoftEdge();
void lineStyle(double thickness, unsigned int color = 0, double alpha = 1.0,
bool pixelHinting = false, StrokeScaleMode scaleMode = ssmNormal,
StrokeCaps caps = scRound,
Expand Down
23 changes: 12 additions & 11 deletions project/include/Hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,28 @@ enum PrimType { ptTriangleFan, ptTriangleStrip, ptTriangles, ptLineStrip, ptPoin

enum
{
DRAW_HAS_COLOUR = 0x00000001,
DRAW_HAS_NORMAL = 0x00000002,
DRAW_HAS_PERSPECTIVE = 0x00000004,
DRAW_RADIAL = 0x00000008,

DRAW_HAS_TEX = 0x00000010,
DRAW_BMP_REPEAT = 0x00000020,
DRAW_BMP_SMOOTH = 0x00000040,
DRAW_HAS_COLOUR = 0x0001,
DRAW_HAS_NORMAL = 0x0002,
DRAW_HAS_PERSPECTIVE = 0x0004,
DRAW_RADIAL = 0x0008,

DRAW_HAS_TEX = 0x0010,
DRAW_BMP_REPEAT = 0x0020,
DRAW_BMP_SMOOTH = 0x0040,

DRAW_TILE_MOUSE = 0x00000080,
DRAW_TILE_MOUSE = 0x0080,
DRAW_EDGE_DIST = 0x0100,
};



struct DrawElement
{
uint8 mFlags;
unsigned short mFlags;
short mRadialPos;
uint8 mPrimType;
uint8 mBlendMode;
uint8 mScaleMode;
short mRadialPos;

uint8 mStride;
int mCount;
Expand Down
6 changes: 5 additions & 1 deletion project/include/HardwareImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ enum
PROG_4D_INPUT = 0x0100,
PROG_PREM_ALPHA = 0x0200,
PROG_COMP_ALPHA = 0x0400,
PROG_EDGE_DIST = 0x0800,

PROG_COUNT = 0x0800,
PROG_COUNT = 0x1000,
};

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

if (element.mFlags & DRAW_EDGE_DIST)
progId |= PROG_EDGE_DIST;

if (element.mFlags & DRAW_RADIAL)
{
progId |= PROG_RADIAL;
Expand Down
10 changes: 10 additions & 0 deletions project/src/common/ExternalInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2956,6 +2956,16 @@ void nme_gfx_end_fill(value inGfx)
}
DEFINE_PRIME1v(nme_gfx_end_fill);

void nme_gfx_line_style_soft_edge(value argGfx)
{
Graphics *gfx;
if (AbstractToObject(argGfx,gfx))
{
CHECK_ACCESS("nme_gfx_line_style_soft_edge");
gfx->lineStyleSoftEdge();
}
}
DEFINE_PRIME1v(nme_gfx_line_style_soft_edge);

void nme_gfx_line_style(value argGfx, value argThickness, int argColour, double argAlpha,
bool argPixelHinting, int argScaleMode,
Expand Down
8 changes: 8 additions & 0 deletions project/src/common/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,21 @@ void Graphics::beginTiles(Surface *bitmapData,bool inSmooth,int inBlendMode, int
OnChanged();
}

void Graphics::lineStyleSoftEdge()
{
lineStyle(-1);
Flush();
mFillJob.mPolyAA = true;
}

void Graphics::lineStyle(double thickness, unsigned int color, double alpha,
bool pixelHinting, StrokeScaleMode scaleMode,
StrokeCaps caps,
StrokeJoints joints, double miterLimit)
{
Flush(true,false,true);
endTiles();
mFillJob.mPolyAA = false;
if (mLineJob.mStroke)
{
mLineJob.mStroke->DecRef();
Expand Down

0 comments on commit c58f3e9

Please sign in to comment.