Skip to content

Commit

Permalink
Support pfLuma as render target type. Use toolkit link by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsando committed Nov 3, 2023
1 parent ef424fe commit 6497c26
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
28 changes: 28 additions & 0 deletions include/nme/Pixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,24 @@ inline void BlendPixel(AlphaPixel &outA, const RGB &)
outA.a = 255;
}

template<typename T>
inline void BlendPixel( LumaPixel<Uint8> &outLuma, const T &inPixel)
{
if (!inPixel.getAlpha())
{
}
else if (inPixel.getAlpha()==255)
{
outLuma.luma = inPixel.getLuma();
}
else
{
int a = inPixel.getAlpha();
int notA= 255-a;
outLuma.luma = (outLuma.luma*notA + inPixel.getLuma()*inPixel.getAlpha() + 128)>>8;
}
}


template<typename T>
inline void BlendPixel(RGB &outRgb, const T &inPixel)
Expand Down Expand Up @@ -748,6 +766,16 @@ inline AlphaPixel BilinearInterp( AlphaPixel s00, AlphaPixel s01, AlphaPixel s10
return s;
}

inline LumaPixel<Uint8> BilinearInterp( LumaPixel<Uint8> s00, LumaPixel<Uint8> s01, LumaPixel<Uint8> s10, LumaPixel<Uint8> s11, int x_frac, int y_frac)
{
LumaPixel<Uint8> s;

int ca_0 = s00.luma + (((s01.luma-s00.luma)*x_frac) >> 16);
int ca_1 = s10.luma + (((s11.luma-s10.luma)*x_frac) >> 16);
s.luma = ca_0 + (((ca_1-ca_0)*y_frac) >> 16);
return s;
}




Expand Down
6 changes: 6 additions & 0 deletions project/src/common/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ void TStretchSuraceTo(const SimpleSurface *inSurface, const RenderTarget &outTar
case pfAlpha:
TStretchTo<PIXEL,RGB>(inSurface, outTarget, inSrcRect, inDestRect, inFlags);
break;
case pfLuma:
TStretchTo<PIXEL, LumaPixel<Uint8> >(inSurface, outTarget, inSrcRect, inDestRect, inFlags);
break;
default: ;
}
}
Expand All @@ -498,6 +501,9 @@ void SimpleSurface::StretchTo(const RenderTarget &outTarget,
case pfAlpha:
TStretchSuraceTo<RGB>(this, outTarget, inSrcRect, inDestRect,inFlags);
break;
case pfLuma:
TStretchSuraceTo< LumaPixel<Uint8> >(this, outTarget, inSrcRect, inDestRect,inFlags);
break;
default: ;
}
}
Expand Down
2 changes: 0 additions & 2 deletions project/src/software-renderer/PolygonRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ void PolygonRender::HitTestFatCubic(const UserPoint &inP0, const UserPoint &inP1

bool PolygonRender::Render(const RenderTarget &inTarget, const RenderState &inState)
{


Extent2DF extent;
CachedExtentRenderer::GetExtent(inState.mTransform, extent,true);

Expand Down
11 changes: 10 additions & 1 deletion project/src/software-renderer/Render.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,16 @@ void RenderBlend(const AlphaMask &inAlpha, SOURCE_ &inSource, const RenderTarget
DestRender(inAlpha, inSource, dest, inBlend, inState, inTX, inTY);
}
break;
default: ;
case pfLuma:
{
DestSurface<LumaPixel<Uint8> > dest(inDest);
DestRender(inAlpha, inSource, dest, inBlend, inState, inTX, inTY);
}
break;

default:
//printf("Unknown poxel type\n");
;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/nme/StaticNme.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package nme;

@:cppFileCode('extern "C" int nme_register_prims();')
#if toolkit
#if !nmelink
@:build(nme.macros.BuildXml.importRelative("../../../project/ToolkitBuild.xml"))
#else
@:buildXml("
Expand Down

0 comments on commit 6497c26

Please sign in to comment.