more antigrain refactors
This commit is contained in:
parent
e2a29f6c3e
commit
867c17d7a3
|
@ -16,6 +16,7 @@
|
|||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// 25 Jan 2007 - Ported to AGG 2.4 Jerry Evans (jerry@novadsp.com)
|
||||
// 11 Jul 2009 - significant refactors for introduction to desmume
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
@ -67,8 +68,21 @@
|
|||
//+ JME
|
||||
#include "agg_image_accessors.h"
|
||||
|
||||
#define AGG2D_TEMPLATE template<typename PixFormat>
|
||||
#define AGG2D_TEMPLATE_ARG <PixFormat>
|
||||
#define AGG2D_TEMPLATE template<typename PixFormatSet>
|
||||
#define AGG2D_TEMPLATE_WITH_IMAGE template<typename PixFormatSet, typename ImagePixFormatSet>
|
||||
#define AGG2D_TEMPLATE_ARG <PixFormatSet>
|
||||
#define AGG2D_IMAGE_TEMPLATE template<typename ImagePixFormatSet>
|
||||
#define AGG2D_IMAGE_TEMPLATE_ARG <ImagePixFormatSet>
|
||||
#define TIMAGE Agg2DBase :: Image AGG2D_IMAGE_TEMPLATE_ARG
|
||||
|
||||
|
||||
template<typename Main, typename Pre>
|
||||
class PixFormatSet
|
||||
{
|
||||
public:
|
||||
typedef Main PixFormat;
|
||||
typedef Pre PixFormatPre;
|
||||
};
|
||||
|
||||
class Agg2DBase
|
||||
{
|
||||
|
@ -137,11 +151,13 @@ public:
|
|||
double affineMatrix[6];
|
||||
};
|
||||
|
||||
struct Image
|
||||
AGG2D_IMAGE_TEMPLATE struct Image
|
||||
{
|
||||
agg::rendering_buffer renBuf;
|
||||
|
||||
Image() {}
|
||||
Image(const agg::rendering_buffer& srcBuf)
|
||||
: renBuf(srcBuf)
|
||||
{}
|
||||
Image(unsigned char* buf, unsigned width, unsigned height, int stride) :
|
||||
renBuf(buf, width, height, stride) {}
|
||||
void attach(unsigned char* buf, unsigned width, unsigned height, int stride)
|
||||
|
@ -150,8 +166,18 @@ public:
|
|||
}
|
||||
int width() const { return renBuf.width(); }
|
||||
int height() const { return renBuf.height(); }
|
||||
AGG2D_TEMPLATE void premultiply();
|
||||
AGG2D_TEMPLATE void demultiply();
|
||||
AGG2D_TEMPLATE void premultiply()
|
||||
{
|
||||
PixFormat pixf(renBuf);
|
||||
pixf.premultiply();
|
||||
}
|
||||
|
||||
AGG2D_TEMPLATE void demultiply()
|
||||
{
|
||||
PixFormat pixf(renBuf);
|
||||
pixf.demultiply();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
enum ImageFilter
|
||||
|
@ -219,9 +245,12 @@ public:
|
|||
|
||||
};
|
||||
|
||||
AGG2D_TEMPLATE class Agg2D : public Agg2DBase
|
||||
|
||||
template<typename PixFormatSet> class Agg2D : public Agg2DBase
|
||||
{
|
||||
public:
|
||||
typedef typename PixFormatSet::PixFormat PixFormat;
|
||||
typedef Image<PixFormatSet> MyImage;
|
||||
typedef agg::order_bgra ComponentOrder; // Platform dependent!
|
||||
|
||||
typedef agg::rgba8 ColorType;
|
||||
|
@ -238,7 +267,7 @@ public:
|
|||
typedef agg::pixfmt_custom_blend_rgba<BlenderComp,agg::rendering_buffer> PixFormatComp;
|
||||
// JME
|
||||
//typedef agg::pixel_formats_rgba<BlenderPre, agg::pixel32_type> PixFormatPre;
|
||||
typedef agg::pixfmt_bgra32_pre PixFormatPre;
|
||||
typedef typename PixFormatSet::PixFormatPre PixFormatPre;
|
||||
// JME
|
||||
//typedef agg::pixfmt_custom_blend_rgba<BlenderCompPre> PixFormatCompPre;
|
||||
typedef agg::pixfmt_custom_blend_rgba<BlenderCompPre,agg::rendering_buffer> PixFormatCompPre;
|
||||
|
@ -279,7 +308,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
AGG2D_TEMPLATE friend class Agg2DRenderer;
|
||||
AGG2D_TEMPLATE_WITH_IMAGE friend class Agg2DRenderer;
|
||||
|
||||
typedef ColorType Color;
|
||||
|
||||
|
@ -337,7 +366,7 @@ public:
|
|||
// Setup
|
||||
//-----------------------
|
||||
void attach(unsigned char* buf, unsigned width, unsigned height, int stride);
|
||||
void attach(Image& img);
|
||||
void attach(MyImage& img);
|
||||
|
||||
void clipBox(double x1, double y1, double x2, double y2);
|
||||
RectD clipBox() const;
|
||||
|
@ -402,7 +431,7 @@ public:
|
|||
void lineRadialGradient(double x, double y, double r);
|
||||
|
||||
void lineWidth(double w);
|
||||
double lineWidth(double w) const;
|
||||
double lineWidth() const;
|
||||
|
||||
void lineCap(LineCap cap);
|
||||
LineCap lineCap() const;
|
||||
|
@ -540,46 +569,155 @@ public:
|
|||
void imageResample(ImageResample f);
|
||||
ImageResample imageResample() const;
|
||||
|
||||
void transformImage(const Image& img,
|
||||
//---------
|
||||
//if anyone can figure out how to put these in the .inl file, theyre more than welcome to. I couldnt declare them correctly to match
|
||||
//the .h file declaration
|
||||
|
||||
AGG2D_IMAGE_TEMPLATE void transformImage(const TIMAGE& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2);
|
||||
double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(dstX1, dstY1);
|
||||
lineTo(dstX2, dstY1);
|
||||
lineTo(dstX2, dstY2);
|
||||
lineTo(dstX1, dstY2);
|
||||
closePolygon();
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage <ImagePixFormat> (img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
void transformImage(const Image& img,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2);
|
||||
AGG2D_IMAGE_TEMPLATE void transformImage(const TIMAGE& img,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(dstX1, dstY1);
|
||||
lineTo(dstX2, dstY1);
|
||||
lineTo(dstX2, dstY2);
|
||||
lineTo(dstX1, dstY2);
|
||||
closePolygon();
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
void transformImage(const Image& img,
|
||||
|
||||
AGG2D_IMAGE_TEMPLATE void transformImage(const TIMAGE& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
const double* parallelogram);
|
||||
|
||||
void transformImage(const Image& img, const double* parallelogram);
|
||||
const double* parallelogram)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(parallelogram[0], parallelogram[1]);
|
||||
lineTo(parallelogram[2], parallelogram[3]);
|
||||
lineTo(parallelogram[4], parallelogram[5]);
|
||||
lineTo(parallelogram[0] + parallelogram[4] - parallelogram[2],
|
||||
parallelogram[1] + parallelogram[5] - parallelogram[3]);
|
||||
closePolygon();
|
||||
renderImage(img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
|
||||
void transformImagePath(const Image& img,
|
||||
AGG2D_IMAGE_TEMPLATE void transformImage(const TIMAGE& img, const double* parallelogram)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(parallelogram[0], parallelogram[1]);
|
||||
lineTo(parallelogram[2], parallelogram[3]);
|
||||
lineTo(parallelogram[4], parallelogram[5]);
|
||||
lineTo(parallelogram[0] + parallelogram[4] - parallelogram[2],
|
||||
parallelogram[1] + parallelogram[5] - parallelogram[3]);
|
||||
closePolygon();
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AGG2D_IMAGE_TEMPLATE void transformImagePath(const TIMAGE& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2);
|
||||
double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage(img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
void transformImagePath(const Image& img,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2);
|
||||
|
||||
void transformImagePath(const Image& img,
|
||||
AGG2D_IMAGE_TEMPLATE void transformImagePath(const TIMAGE& img,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AGG2D_IMAGE_TEMPLATE void transformImagePath(const TIMAGE& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
const double* parallelogram);
|
||||
const double* parallelogram)
|
||||
{
|
||||
renderImage(img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
|
||||
AGG2D_IMAGE_TEMPLATE void transformImagePath(const TIMAGE& img, const double* parallelogram)
|
||||
{
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
void transformImagePath(const Image& img, const double* parallelogram);
|
||||
|
||||
|
||||
// Image Blending (no transformations available)
|
||||
void blendImage(Image& img,
|
||||
AGG2D_IMAGE_TEMPLATE void blendImage(TIMAGE& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX, double dstY, unsigned alpha=255);
|
||||
void blendImage(Image& img, double dstX, double dstY, unsigned alpha=255);
|
||||
double dstX, double dstY, unsigned alpha=255)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
PixFormat pixF(img.renBuf);
|
||||
// JME
|
||||
//agg::rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
Rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
if(m_blendMode == BlendAlpha)
|
||||
{
|
||||
m_renBasePre.blend_from(pixF, &r, int(dstX)-imgX1, int(dstY)-imgY1, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_renBaseCompPre.blend_from(pixF, &r, int(dstX)-imgX1, int(dstY)-imgY1, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AGG2D_IMAGE_TEMPLATE void blendImage(TIMAGE& img, double dstX, double dstY, unsigned alpha=255)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
PixFormat pixF(img.renBuf);
|
||||
m_renBasePre.blend_from(pixF, 0, int(dstX), int(dstY), alpha);
|
||||
if(m_blendMode == BlendAlpha)
|
||||
{
|
||||
m_renBasePre.blend_from(pixF, 0, int(dstX), int(dstY), alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_renBaseCompPre.blend_from(pixF, 0, int(dstX), int(dstY), alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Copy image directly, together with alpha-channel
|
||||
void copyImage(Image& img,
|
||||
AGG2D_IMAGE_TEMPLATE void copyImage(TIMAGE& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX, double dstY);
|
||||
void copyImage(Image& img, double dstX, double dstY);
|
||||
double dstX, double dstY)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
// JME
|
||||
//agg::rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
Rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
m_renBase.copy_from(img.renBuf, &r, int(dstX)-imgX1, int(dstY)-imgY1);
|
||||
}
|
||||
|
||||
AGG2D_IMAGE_TEMPLATE void copyImage(TIMAGE& img, double dstX, double dstY)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
m_renBase.copy_from(img.renBuf, 0, int(dstX), int(dstY));
|
||||
}
|
||||
|
||||
// State
|
||||
//-----------------------
|
||||
|
@ -596,6 +734,7 @@ public:
|
|||
static double rad2Deg(double v) { return v * 180.0 / agg::pi; }
|
||||
|
||||
PixFormat & pixFormat() { return m_pixFormat; }
|
||||
agg::rendering_buffer & buf() { return m_rbuf; }
|
||||
|
||||
private:
|
||||
void render(bool fillColor);
|
||||
|
@ -606,7 +745,33 @@ private:
|
|||
|
||||
void addLine(double x1, double y1, double x2, double y2);
|
||||
void updateRasterizerGamma();
|
||||
void renderImage(const Image& img, int x1, int y1, int x2, int y2, const double* parl);
|
||||
AGG2D_IMAGE_TEMPLATE void renderImage(const TIMAGE& img, int x1, int y1, int x2, int y2, const double* parl)
|
||||
{
|
||||
agg::trans_affine mtx((double)x1,
|
||||
(double)y1,
|
||||
(double)x2,
|
||||
(double)y2,
|
||||
parl);
|
||||
mtx *= m_transform;
|
||||
mtx.invert();
|
||||
|
||||
m_rasterizer.reset();
|
||||
m_rasterizer.add_path(m_pathTransform);
|
||||
|
||||
typedef agg::span_interpolator_linear<agg::trans_affine> Interpolator;
|
||||
Interpolator interpolator(mtx);
|
||||
|
||||
if(m_blendMode == BlendAlpha)
|
||||
{
|
||||
// JME audit -
|
||||
Agg2DRenderer<PixFormatSet,ImagePixFormatSet>::renderImage(*this, img, m_renBasePre, interpolator);
|
||||
}
|
||||
else
|
||||
{
|
||||
Agg2DRenderer<PixFormatSet,ImagePixFormatSet>::renderImage(*this, img, m_renBaseCompPre, interpolator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void updateTransformations();
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// 25 Jan 2007 - Ported to AGG 2.4 Jerry Evans (jerry@novadsp.com)
|
||||
// 11 Jul 2009 - significant refactors for introduction to desmume
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "GPU.h"
|
||||
|
@ -24,7 +25,7 @@
|
|||
static const double g_approxScale = 2.0;
|
||||
|
||||
#define TAGG2D Agg2D AGG2D_TEMPLATE_ARG
|
||||
#define TAGG2DRENDERER Agg2DRenderer AGG2D_TEMPLATE_ARG
|
||||
#define TAGG2DRENDERER Agg2DRenderer <PixFormatSet,PixFormatSet>
|
||||
|
||||
//AGG2D_TEMPLATE inline bool operator == (const TAGG2D::Color& c1, const TAGG2D::Color& c2)
|
||||
//{
|
||||
|
@ -256,7 +257,7 @@ AGG2D_TEMPLATE void Agg2D AGG2D_TEMPLATE_ARG ::attach(unsigned char* buf, unsign
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void Agg2D AGG2D_TEMPLATE_ARG ::attach(Image& img)
|
||||
AGG2D_TEMPLATE void Agg2D AGG2D_TEMPLATE_ARG ::attach(MyImage& img)
|
||||
{
|
||||
attach(img.renBuf.buf(), img.renBuf.width(), img.renBuf.height(), img.renBuf.stride());
|
||||
}
|
||||
|
@ -824,7 +825,7 @@ AGG2D_TEMPLATE void TAGG2D::lineWidth(double w)
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE double TAGG2D::lineWidth(double w) const
|
||||
AGG2D_TEMPLATE double TAGG2D::lineWidth() const
|
||||
{
|
||||
return m_lineWidth;
|
||||
}
|
||||
|
@ -1573,90 +1574,7 @@ AGG2D_TEMPLATE Agg2DBase::ImageResample TAGG2D::imageResample() const
|
|||
return m_imageResample;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImage(const Image& img, int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(dstX1, dstY1);
|
||||
lineTo(dstX2, dstY1);
|
||||
lineTo(dstX2, dstY2);
|
||||
lineTo(dstX1, dstY2);
|
||||
closePolygon();
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage(img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImage(const Image& img, double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(dstX1, dstY1);
|
||||
lineTo(dstX2, dstY1);
|
||||
lineTo(dstX2, dstY2);
|
||||
lineTo(dstX1, dstY2);
|
||||
closePolygon();
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImage(const Image& img, int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
const double* parallelogram)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(parallelogram[0], parallelogram[1]);
|
||||
lineTo(parallelogram[2], parallelogram[3]);
|
||||
lineTo(parallelogram[4], parallelogram[5]);
|
||||
lineTo(parallelogram[0] + parallelogram[4] - parallelogram[2],
|
||||
parallelogram[1] + parallelogram[5] - parallelogram[3]);
|
||||
closePolygon();
|
||||
renderImage(img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImage(const Image& img, const double* parallelogram)
|
||||
{
|
||||
resetPath();
|
||||
moveTo(parallelogram[0], parallelogram[1]);
|
||||
lineTo(parallelogram[2], parallelogram[3]);
|
||||
lineTo(parallelogram[4], parallelogram[5]);
|
||||
lineTo(parallelogram[0] + parallelogram[4] - parallelogram[2],
|
||||
parallelogram[1] + parallelogram[5] - parallelogram[3]);
|
||||
closePolygon();
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImagePath(const Image& img, int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage(img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImagePath(const Image& img, double dstX1, double dstY1, double dstX2, double dstY2)
|
||||
{
|
||||
double parallelogram[6] = { dstX1, dstY1, dstX2, dstY1, dstX2, dstY2 };
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImagePath(const Image& img, int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
const double* parallelogram)
|
||||
{
|
||||
renderImage(img, imgX1, imgY1, imgX2, imgY2, parallelogram);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::transformImagePath(const Image& img, const double* parallelogram)
|
||||
{
|
||||
renderImage(img, 0, 0, img.renBuf.width(), img.renBuf.height(), parallelogram);
|
||||
}
|
||||
|
||||
//==============moved to .h file===========
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -1708,11 +1626,11 @@ AGG2D_TEMPLATE void TAGG2D::drawPath(DrawPathFlag flag)
|
|||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE class Agg2DRenderer
|
||||
AGG2D_TEMPLATE_WITH_IMAGE class Agg2DRenderer
|
||||
{
|
||||
public:
|
||||
typedef typename TAGG2D::Color Color;
|
||||
typedef typename TAGG2D::Image Image;
|
||||
typedef typename TIMAGE Image;
|
||||
//--------------------------------------------------------------------
|
||||
template<class BaseRenderer, class SolidRenderer>
|
||||
void static render(TAGG2D& gr, BaseRenderer& renBase, SolidRenderer& renSolid, bool fillColor)
|
||||
|
@ -1799,7 +1717,7 @@ public:
|
|||
class SpanConvImageBlend
|
||||
{
|
||||
public:
|
||||
SpanConvImageBlend(Agg2D::BlendMode m, Color c) :
|
||||
SpanConvImageBlend(Agg2DBase::BlendMode m, Color c) :
|
||||
m_mode(m), m_color(c)
|
||||
{}
|
||||
|
||||
|
@ -1896,14 +1814,14 @@ public:
|
|||
//--------------------------------------------------------------------
|
||||
//! JME - this is where the bulk of the changes have taken place.
|
||||
template<class BaseRenderer, class Interpolator>
|
||||
static void renderImage(TAGG2D& gr, const Image& img,
|
||||
static void renderImage(TAGG2D& gr, const TIMAGE& img,
|
||||
BaseRenderer& renBase, Interpolator& interpolator)
|
||||
{
|
||||
//! JME - have not quite figured which part of this is not const-correct
|
||||
// hence the cast.
|
||||
Image& imgc = const_cast<Image&>(img);
|
||||
TAGG2D::PixFormat img_pixf(imgc.renBuf);
|
||||
typedef agg::image_accessor_clone<TAGG2D::PixFormat> img_source_type;
|
||||
ImagePixFormatSet::PixFormat img_pixf(imgc.renBuf);
|
||||
typedef agg::image_accessor_clone<ImagePixFormatSet::PixFormat> img_source_type;
|
||||
img_source_type source(img_pixf);
|
||||
|
||||
SpanConvImageBlend blend(gr.m_imageBlendMode, gr.m_imageBlendColor);
|
||||
|
@ -2017,35 +1935,6 @@ AGG2D_TEMPLATE void TAGG2D::render(FontRasterizer& ras, FontScanline& sl)
|
|||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::renderImage(const Image& img, int x1, int y1, int x2, int y2,
|
||||
const double* parl)
|
||||
{
|
||||
agg::trans_affine mtx((double)x1,
|
||||
(double)y1,
|
||||
(double)x2,
|
||||
(double)y2,
|
||||
parl);
|
||||
mtx *= m_transform;
|
||||
mtx.invert();
|
||||
|
||||
m_rasterizer.reset();
|
||||
m_rasterizer.add_path(m_pathTransform);
|
||||
|
||||
typedef agg::span_interpolator_linear<agg::trans_affine> Interpolator;
|
||||
Interpolator interpolator(mtx);
|
||||
|
||||
if(m_blendMode == BlendAlpha)
|
||||
{
|
||||
// JME audit -
|
||||
Agg2DRenderer::renderImage(*this, img, m_renBasePre, interpolator);
|
||||
}
|
||||
else
|
||||
{
|
||||
Agg2DRenderer::renderImage(*this, img, m_renBaseCompPre, interpolator);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE struct Agg2DRasterizerGamma
|
||||
{
|
||||
|
@ -2067,405 +1956,3 @@ AGG2D_TEMPLATE void TAGG2D::updateRasterizerGamma()
|
|||
m_rasterizer.gamma(Agg2DRasterizerGamma(m_masterAlpha, m_antiAliasGamma));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::blendImage(Image& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX, double dstY, unsigned alpha)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
PixFormat pixF(img.renBuf);
|
||||
// JME
|
||||
//agg::rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
Rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
if(m_blendMode == BlendAlpha)
|
||||
{
|
||||
m_renBasePre.blend_from(pixF, &r, int(dstX)-imgX1, int(dstY)-imgY1, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_renBaseCompPre.blend_from(pixF, &r, int(dstX)-imgX1, int(dstY)-imgY1, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::blendImage(Image& img, double dstX, double dstY, unsigned alpha)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
PixFormat pixF(img.renBuf);
|
||||
m_renBasePre.blend_from(pixF, 0, int(dstX), int(dstY), alpha);
|
||||
if(m_blendMode == BlendAlpha)
|
||||
{
|
||||
m_renBasePre.blend_from(pixF, 0, int(dstX), int(dstY), alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_renBaseCompPre.blend_from(pixF, 0, int(dstX), int(dstY), alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::copyImage(Image& img,
|
||||
int imgX1, int imgY1, int imgX2, int imgY2,
|
||||
double dstX, double dstY)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
// JME
|
||||
//agg::rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
Rect r(imgX1, imgY1, imgX2, imgY2);
|
||||
m_renBase.copy_from(img.renBuf, &r, int(dstX)-imgX1, int(dstY)-imgY1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void TAGG2D::copyImage(Image& img, double dstX, double dstY)
|
||||
{
|
||||
worldToScreen(dstX, dstY);
|
||||
m_renBase.copy_from(img.renBuf, 0, int(dstX), int(dstY));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void Agg2DBase::Image::premultiply()
|
||||
{
|
||||
PixFormat pixf(renBuf);
|
||||
pixf.premultiply();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AGG2D_TEMPLATE void Agg2DBase::Image::demultiply()
|
||||
{
|
||||
PixFormat pixf(renBuf);
|
||||
pixf.demultiply();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
////========================
|
||||
////testing stufff
|
||||
//
|
||||
//int width = 256;
|
||||
//int height = 384;
|
||||
//
|
||||
//Agg2D m_graphics;
|
||||
//
|
||||
//void AGGDraw(unsigned char * buffer)
|
||||
// {
|
||||
// m_graphics.attach(buffer,
|
||||
// 256,
|
||||
// 384,
|
||||
// 512);
|
||||
//
|
||||
// m_graphics.clearAll(255, 255, 255);
|
||||
// //m_graphics.clearAll(0, 0, 0);
|
||||
//
|
||||
// //m_graphics.blendMode(TAGG2D::BlendSub);
|
||||
// //m_graphics.blendMode(TAGG2D::BlendAdd);
|
||||
//
|
||||
// m_graphics.antiAliasGamma(1.4);
|
||||
//
|
||||
// // Set flipText(true) if you have the Y axis upside down.
|
||||
// //m_graphics.flipText(true);
|
||||
//
|
||||
//
|
||||
// // ClipBox.
|
||||
// //m_graphics.clipBox(50, 50, rbuf_window().width() - 50, rbuf_window().height() - 50);
|
||||
//
|
||||
// // Transfornations - Rotate around (300,300) to 5 degree
|
||||
// //m_graphics.translate(-300, -300);
|
||||
// //m_graphics.rotate(TAGG2D::deg2Rad(5.0));
|
||||
// //m_graphics.translate(300, 300);
|
||||
//
|
||||
// // Viewport - set 0,0,600,600 to the actual window size
|
||||
// // preserving aspect ratio and placing the viewport in the center.
|
||||
// // To ignore aspect ratio use TAGG2D::Anisotropic
|
||||
// // Note that the viewport just adds transformations to the current
|
||||
// // affine matrix. So that, set the viewport *after* all transformations!
|
||||
// m_graphics.viewport(0, 0, 600, 600,
|
||||
// 0, 0, width, height,
|
||||
// //TAGG2D::Anisotropic);
|
||||
// TAGG2D::XMidYMid);
|
||||
//
|
||||
//
|
||||
// // Rounded Rect
|
||||
// m_graphics.lineColor(0, 0, 0);
|
||||
// m_graphics.noFill();
|
||||
// m_graphics.roundedRect(0.5, 0.5, 600-0.5, 600-0.5, 20.0);
|
||||
///*
|
||||
//
|
||||
// // Reglar Text
|
||||
// m_graphics.font("Times New Roman", 14.0, false, false);
|
||||
// m_graphics.fillColor(0, 0, 0);
|
||||
// m_graphics.noLine();
|
||||
// m_graphics.text(100, 20, "Regular Raster Text -- Fast, but can't be rotated");
|
||||
//
|
||||
// // Outlined Text
|
||||
// m_graphics.font("Times New Roman", 50.0, false, false, TAGG2D::VectorFontCache);
|
||||
// m_graphics.lineColor(50, 0, 0);
|
||||
// m_graphics.fillColor(180, 200, 100);
|
||||
// m_graphics.lineWidth(1.0);
|
||||
// m_graphics.text(100.5, 50.5, "Outlined Text");
|
||||
//
|
||||
// // Text Alignment
|
||||
// m_graphics.line(250.5-150, 150.5, 250.5+150, 150.5);
|
||||
// m_graphics.line(250.5, 150.5-20, 250.5, 150.5+20);
|
||||
// m_graphics.line(250.5-150, 200.5, 250.5+150, 200.5);
|
||||
// m_graphics.line(250.5, 200.5-20, 250.5, 200.5+20);
|
||||
// m_graphics.line(250.5-150, 250.5, 250.5+150, 250.5);
|
||||
// m_graphics.line(250.5, 250.5-20, 250.5, 250.5+20);
|
||||
// m_graphics.line(250.5-150, 300.5, 250.5+150, 300.5);
|
||||
// m_graphics.line(250.5, 300.5-20, 250.5, 300.5+20);
|
||||
// m_graphics.line(250.5-150, 350.5, 250.5+150, 350.5);
|
||||
// m_graphics.line(250.5, 350.5-20, 250.5, 350.5+20);
|
||||
// m_graphics.line(250.5-150, 400.5, 250.5+150, 400.5);
|
||||
// m_graphics.line(250.5, 400.5-20, 250.5, 400.5+20);
|
||||
// m_graphics.line(250.5-150, 450.5, 250.5+150, 450.5);
|
||||
// m_graphics.line(250.5, 450.5-20, 250.5, 450.5+20);
|
||||
// m_graphics.line(250.5-150, 500.5, 250.5+150, 500.5);
|
||||
// m_graphics.line(250.5, 500.5-20, 250.5, 500.5+20);
|
||||
// m_graphics.line(250.5-150, 550.5, 250.5+150, 550.5);
|
||||
// m_graphics.line(250.5, 550.5-20, 250.5, 550.5+20);
|
||||
//*/
|
||||
///*
|
||||
// m_graphics.fillColor(100, 50, 50);
|
||||
// m_graphics.noLine();
|
||||
// //m_graphics.textHints(false);
|
||||
// m_graphics.font("Times New Roman", 40.0, false, false, TAGG2D::VectorFontCache);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignLeft, TAGG2D::AlignBottom);
|
||||
// m_graphics.text(250.0, 150.0, "Left-Bottom", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignBottom);
|
||||
// m_graphics.text(250.0, 200.0, "Center-Bottom", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignRight, TAGG2D::AlignBottom);
|
||||
// m_graphics.text(250.0, 250.0, "Right-Bottom", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignLeft, TAGG2D::AlignCenter);
|
||||
// m_graphics.text(250.0, 300.0, "Left-Center", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignCenter);
|
||||
// m_graphics.text(250.0, 350.0, "Center-Center", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignRight, TAGG2D::AlignCenter);
|
||||
// m_graphics.text(250.0, 400.0, "Right-Center", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignLeft, TAGG2D::AlignTop);
|
||||
// m_graphics.text(250.0, 450.0, "Left-Top", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignTop);
|
||||
// m_graphics.text(250.0, 500.0, "Center-Top", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignRight, TAGG2D::AlignTop);
|
||||
// m_graphics.text(250.0, 550.0, "Right-Top", true, 0, 0);
|
||||
//
|
||||
//*/
|
||||
// // Gradients (Aqua Buttons)
|
||||
// //=======================================
|
||||
// m_graphics.font("Verdana", 20.0, false, false, TAGG2D::VectorFontCache);
|
||||
// double xb1 = 400;
|
||||
// double yb1 = 80;
|
||||
// double xb2 = xb1 + 150;
|
||||
// double yb2 = yb1 + 36;
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,50,180,180));
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,80, 255));
|
||||
// m_graphics.lineWidth(1.0);
|
||||
// m_graphics.roundedRect(xb1, yb1, xb2, yb2, 12, 18);
|
||||
//
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,0,0));
|
||||
// m_graphics.fillLinearGradient(xb1, yb1, xb1, yb1+30,
|
||||
// TAGG2D::Color(100,200,255,255),
|
||||
// TAGG2D::Color(255,255,255,0));
|
||||
// m_graphics.roundedRect(xb1+3, yb1+2.5, xb2-3, yb1+30, 9, 18, 1, 1);
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,0,50, 200));
|
||||
// m_graphics.noLine();
|
||||
///* m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignCenter);
|
||||
// m_graphics.text((xb1 + xb2) / 2.0, (yb1 + yb2) / 2.0, "Aqua Button", true, 0.0, 0.0);
|
||||
//*/
|
||||
// m_graphics.fillLinearGradient(xb1, yb2-20, xb1, yb2-3,
|
||||
// TAGG2D::Color(0, 0, 255,0),
|
||||
// TAGG2D::Color(100,255,255,255));
|
||||
// m_graphics.roundedRect(xb1+3, yb2-20, xb2-3, yb2-2, 1, 1, 9, 18);
|
||||
//
|
||||
//
|
||||
// // Aqua Button Pressed
|
||||
// xb1 = 400;
|
||||
// yb1 = 30;
|
||||
// xb2 = xb1 + 150;
|
||||
// yb2 = yb1 + 36;
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,50,180,180));
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,0, 255));
|
||||
// m_graphics.lineWidth(2.0);
|
||||
// m_graphics.roundedRect(xb1, yb1, xb2, yb2, 12, 18);
|
||||
//
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,0,0));
|
||||
// m_graphics.fillLinearGradient(xb1, yb1+2, xb1, yb1+25,
|
||||
// TAGG2D::Color(60, 160,255,255),
|
||||
// TAGG2D::Color(100,255,255,0));
|
||||
// m_graphics.roundedRect(xb1+3, yb1+2.5, xb2-3, yb1+30, 9, 18, 1, 1);
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,0,50, 255));
|
||||
// m_graphics.noLine();
|
||||
///* m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignCenter);
|
||||
// m_graphics.text((xb1 + xb2) / 2.0, (yb1 + yb2) / 2.0, "Aqua Pressed", 0.0, 0.0);
|
||||
//*/
|
||||
// m_graphics.fillLinearGradient(xb1, yb2-25, xb1, yb2-5,
|
||||
// TAGG2D::Color(0, 180,255,0),
|
||||
// TAGG2D::Color(0, 200,255,255));
|
||||
// m_graphics.roundedRect(xb1+3, yb2-25, xb2-3, yb2-2, 1, 1, 9, 18);
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Basic Shapes -- Ellipse
|
||||
// //===========================================
|
||||
// m_graphics.lineWidth(3.5);
|
||||
// m_graphics.lineColor(20, 80, 80);
|
||||
// m_graphics.fillColor(200, 255, 80, 200);
|
||||
// m_graphics.ellipse(450, 200, 50, 90);
|
||||
//
|
||||
//
|
||||
// // Paths
|
||||
// //===========================================
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.fillColor(255, 0, 0, 100);
|
||||
// m_graphics.lineColor(0, 0, 255, 100);
|
||||
// m_graphics.lineWidth(2);
|
||||
// m_graphics.moveTo(300/2, 200/2);
|
||||
// m_graphics.horLineRel(-150/2);
|
||||
// m_graphics.arcRel(150/2, 150/2, 0, 1, 0, 150/2, -150/2);
|
||||
// m_graphics.closePolygon();
|
||||
// m_graphics.drawPath();
|
||||
//
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.fillColor(255, 255, 0, 100);
|
||||
// m_graphics.lineColor(0, 0, 255, 100);
|
||||
// m_graphics.lineWidth(2);
|
||||
// m_graphics.moveTo(275/2, 175/2);
|
||||
// m_graphics.verLineRel(-150/2);
|
||||
// m_graphics.arcRel(150/2, 150/2, 0, 0, 0, -150/2, 150/2);
|
||||
// m_graphics.closePolygon();
|
||||
// m_graphics.drawPath();
|
||||
//
|
||||
//
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.noFill();
|
||||
// m_graphics.lineColor(127, 0, 0);
|
||||
// m_graphics.lineWidth(5);
|
||||
// m_graphics.moveTo(600/2, 350/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.arcRel(25/2, 25/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.arcRel(25/2, 50/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.arcRel(25/2, 75/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50, -25);
|
||||
// m_graphics.arcRel(25/2, 100/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.drawPath();
|
||||
//
|
||||
//
|
||||
// // Master Alpha. From now on everything will be translucent
|
||||
// //===========================================
|
||||
// m_graphics.masterAlpha(0.85);
|
||||
//
|
||||
//
|
||||
// // Image Transformations
|
||||
// //===========================================
|
||||
///* TAGG2D::Image img(rbuf_img(0).buf(),
|
||||
// rbuf_img(0).width(),
|
||||
// rbuf_img(0).height(),
|
||||
// rbuf_img(0).stride());
|
||||
// m_graphics.imageFilter(TAGG2D::Bilinear);
|
||||
//
|
||||
// //m_graphics.imageResample(TAGG2D::NoResample);
|
||||
// //m_graphics.imageResample(TAGG2D::ResampleAlways);
|
||||
// m_graphics.imageResample(TAGG2D::ResampleOnZoomOut);
|
||||
//
|
||||
// // Set the initial image blending operation as BlendDst, that actually
|
||||
// // does nothing.
|
||||
// //-----------------
|
||||
// m_graphics.imageBlendMode(TAGG2D::BlendDst);
|
||||
//
|
||||
//
|
||||
// // Transform the whole image to the destination rectangle
|
||||
// //-----------------
|
||||
// //m_graphics.transformImage(img, 450, 200, 595, 350);
|
||||
//
|
||||
// // Transform the rectangular part of the image to the destination rectangle
|
||||
// //-----------------
|
||||
// //m_graphics.transformImage(img, 60, 60, img.width()-60, img.height()-60,
|
||||
// // 450, 200, 595, 350);
|
||||
//
|
||||
// // Transform the whole image to the destination parallelogram
|
||||
// //-----------------
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImage(img, parl);
|
||||
//
|
||||
// // Transform the rectangular part of the image to the destination parallelogram
|
||||
// //-----------------
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImage(img, 60, 60, img.width()-60, img.height()-60, parl);
|
||||
//
|
||||
// // Transform image to the destination path. The scale is determined by a rectangle
|
||||
// //-----------------
|
||||
// //m_graphics.resetPath();
|
||||
// //m_graphics.moveTo(450, 200);
|
||||
// //m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// //m_graphics.lineTo(470, 340);
|
||||
// //m_graphics.transformImagePath(img, 450, 200, 595, 350);
|
||||
//
|
||||
//
|
||||
// // Transform image to the destination path.
|
||||
// // The scale is determined by a rectangle
|
||||
// //-----------------
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.moveTo(450, 200);
|
||||
// m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// m_graphics.lineTo(470, 340);
|
||||
// m_graphics.transformImagePath(img, 60, 60, img.width()-60, img.height()-60,
|
||||
// 450, 200, 595, 350);
|
||||
//
|
||||
// // Transform image to the destination path.
|
||||
// // The transformation is determined by a parallelogram
|
||||
// //m_graphics.resetPath();
|
||||
// //m_graphics.moveTo(450, 200);
|
||||
// //m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// //m_graphics.lineTo(470, 340);
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImagePath(img, parl);
|
||||
//
|
||||
// // Transform the rectangular part of the image to the destination path.
|
||||
// // The transformation is determined by a parallelogram
|
||||
// //m_graphics.resetPath();
|
||||
// //m_graphics.moveTo(450, 200);
|
||||
// //m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// //m_graphics.lineTo(470, 340);
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImagePath(img, 60, 60, img.width()-60, img.height()-60, parl);
|
||||
//*/
|
||||
//
|
||||
// // Add/Sub/Contrast Blending Modes
|
||||
// m_graphics.noLine();
|
||||
// m_graphics.fillColor(70, 70, 0);
|
||||
// m_graphics.blendMode(TAGG2D::BlendAdd);
|
||||
// m_graphics.ellipse(500, 280, 20, 40);
|
||||
//
|
||||
// m_graphics.fillColor(255, 255, 255);
|
||||
// m_graphics.blendMode(TAGG2D::BlendContrast);
|
||||
// m_graphics.ellipse(500+40, 280, 20, 40);
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Radial gradient.
|
||||
// m_graphics.blendMode(TAGG2D::BlendAlpha);
|
||||
// m_graphics.fillRadialGradient(400, 500, 40,
|
||||
// TAGG2D::Color(255, 255, 0, 0),
|
||||
// TAGG2D::Color(0, 0, 127),
|
||||
// TAGG2D::Color(0, 255, 0, 0));
|
||||
// m_graphics.ellipse(400, 500, 40, 40);
|
||||
//
|
||||
// }
|
||||
//
|
|
@ -63,27 +63,27 @@
|
|||
|
||||
#include "agg_span_allocator.h"
|
||||
|
||||
typedef std::map<std::string, const agg::int8u*> TAgg_Font_Table;
|
||||
static TAgg_Font_Table font_table;
|
||||
|
||||
AggDraw_Desmume aggDraw;
|
||||
|
||||
typedef AggDrawTargetImplementation<agg::pixfmt_rgb555> T_AGG_RGB555;
|
||||
typedef AggDrawTargetImplementation<agg::pixfmt_bgra32> T_AGG_RGBA;
|
||||
typedef AggDrawTargetImplementation<PixFormatSet<agg::pixfmt_rgb555,agg::pixfmt_rgb555_pre> > T_AGG_RGB555;
|
||||
typedef AggDrawTargetImplementation<PixFormatSet<agg::pixfmt_bgra32,agg::pixfmt_bgra32_pre> > T_AGG_RGBA;
|
||||
|
||||
T_AGG_RGB555 agg_targetScreen(GPU_screen, 256, 384, 512);
|
||||
|
||||
static u32 luaBuffer[256*192*2];
|
||||
T_AGG_RGBA agg_targetLua((u8*)luaBuffer, 256, 384, 1024);
|
||||
|
||||
static u32 hudBuffer[256*192*2];
|
||||
T_AGG_RGBA agg_targetHud((u8*)hudBuffer, 256, 384, 1024);
|
||||
|
||||
static AggDrawTarget* targets[] = {
|
||||
&agg_targetScreen,
|
||||
&agg_targetLua
|
||||
&agg_targetHud,
|
||||
&agg_targetLua,
|
||||
};
|
||||
|
||||
void Agg_init()
|
||||
{
|
||||
//Agg_init_fonts();
|
||||
aggDraw.target = targets[0];
|
||||
}
|
||||
|
||||
|
@ -94,81 +94,366 @@ void AggDraw_Desmume::setTarget(AggTarget newTarget)
|
|||
|
||||
void AggDraw_Desmume::composite(void* dest)
|
||||
{
|
||||
//!! oh what a mess !!
|
||||
T_AGG_RGBA target((u8*)dest, 256, 384, 1024);
|
||||
|
||||
agg::rendering_buffer rBuf;
|
||||
rBuf.attach((u8*)dest, 256, 384, 1024);
|
||||
|
||||
|
||||
typedef agg::image_accessor_clip<T_AGG_RGBA::pixfmt> img_source_type;
|
||||
|
||||
img_source_type img_src(agg_targetLua.pixFormat(), T_AGG_RGBA::pixfmt::color_type(0,255,0,0));
|
||||
|
||||
agg::trans_affine img_mtx;
|
||||
typedef agg::span_interpolator_linear<> interpolator_type;
|
||||
interpolator_type interpolator(img_mtx);
|
||||
typedef agg::span_image_filter_rgba_nn<img_source_type,interpolator_type> span_gen_type;
|
||||
span_gen_type sg(img_src, interpolator);
|
||||
|
||||
agg::rasterizer_scanline_aa<> ras;
|
||||
//dont know whether this is necessary
|
||||
//ras.clip_box(0, 0, 256,384);
|
||||
agg::scanline_u8 sl;
|
||||
|
||||
//I can't believe we're using a polygon for a rectangle.
|
||||
//there must be a better way
|
||||
agg::path_storage path;
|
||||
path.move_to(0, 0);
|
||||
path.line_to(255, 0);
|
||||
path.line_to(255, 383);
|
||||
path.line_to(0, 383);
|
||||
path.close_polygon();
|
||||
|
||||
|
||||
T_AGG_RGBA::pixfmt pixf(rBuf);
|
||||
T_AGG_RGBA::RendererBase rbase(pixf);
|
||||
agg::span_allocator<T_AGG_RGBA::color_type> sa;
|
||||
|
||||
ras.add_path(path);
|
||||
agg::render_scanlines_bin(ras, sl, rbase, sa, sg);
|
||||
//if lua is nonempty, blend it
|
||||
if(!agg_targetLua.empty)
|
||||
{
|
||||
T_AGG_RGBA::MyImage luaImage(agg_targetLua.buf());
|
||||
target.transformImage(luaImage, 0.5,0.5,256-0.5,384-0.5);
|
||||
}
|
||||
|
||||
//if hud is nonempty, blend it
|
||||
if(!agg_targetHud.empty)
|
||||
{
|
||||
T_AGG_RGBA::MyImage hudImage(agg_targetHud.buf());
|
||||
target.transformImage(hudImage, 0.5,0.5,256-0.5,384-0.5);
|
||||
}
|
||||
}
|
||||
//
|
||||
//static int ctr=0;
|
||||
//
|
||||
////temporary, just for testing the lib
|
||||
void AGGDraw() {
|
||||
//
|
||||
aggDraw.setTarget(AggTarget_Lua);
|
||||
//
|
||||
// aggDraw.target->clear();
|
||||
//
|
||||
// ctr++;
|
||||
//
|
||||
|
||||
|
||||
//temporary, just for testing the lib
|
||||
void AGGDraw() {
|
||||
|
||||
aggDraw.setTarget(AggTarget_Lua);
|
||||
|
||||
aggDraw.target->clear();
|
||||
|
||||
aggDraw.target->lineColor(0, 255, 0, 128);
|
||||
aggDraw.target->noFill();
|
||||
// int add = (int)(40*cos((double)ctr/20.0f));
|
||||
aggDraw.target->roundedRect(0.5, 0.5, 600-0.5, 600-0.5, 20.0);
|
||||
//
|
||||
// aggDraw.target->set_gamma(99999);
|
||||
// aggDraw.target->set_color(255, 64, 64, 128);
|
||||
// aggDraw.target->solid_triangle(0, 60, 200, 170, 100, 310);
|
||||
//
|
||||
// aggDraw.target->set_color(255, 0, 0, 128);
|
||||
// aggDraw.target->solid_ellipse(70, 80, 50, 50);
|
||||
//
|
||||
// aggDraw.target->set_font("verdana18_bold");
|
||||
// aggDraw.target->set_color(255, 0, 255, 255);
|
||||
// aggDraw.target->render_text(60,60, "testing testing testing");
|
||||
//
|
||||
// aggDraw.target->line(60, 90, 100, 100, 4);
|
||||
//
|
||||
// aggDraw.target->marker(200, 200, 40, 4);
|
||||
// aggDraw.target->marker(100, 300, 40, 3);
|
||||
// //
|
||||
// //agg_draw_line_pattern(64, 19, 14, 126, 118, 266, 19, 265, .76, 4.69, "C:\\7.bmp");
|
||||
aggDraw.target->fillColor(0, 255, 0, 128);
|
||||
//aggDraw.target->noFill();
|
||||
aggDraw.target->lineWidth(1.0);
|
||||
aggDraw.target->roundedRect(10,10,256-10,192-10,4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
////========================
|
||||
////testing stufff
|
||||
//
|
||||
//int width = 256;
|
||||
//int height = 384;
|
||||
//
|
||||
//Agg2D m_graphics;
|
||||
//
|
||||
//void AGGDraw(unsigned char * buffer)
|
||||
// {
|
||||
// m_graphics.attach(buffer,
|
||||
// 256,
|
||||
// 384,
|
||||
// 512);
|
||||
//
|
||||
// m_graphics.clearAll(255, 255, 255);
|
||||
// //m_graphics.clearAll(0, 0, 0);
|
||||
//
|
||||
// //m_graphics.blendMode(TAGG2D::BlendSub);
|
||||
// //m_graphics.blendMode(TAGG2D::BlendAdd);
|
||||
//
|
||||
// m_graphics.antiAliasGamma(1.4);
|
||||
//
|
||||
// // Set flipText(true) if you have the Y axis upside down.
|
||||
// //m_graphics.flipText(true);
|
||||
//
|
||||
//
|
||||
// // ClipBox.
|
||||
// //m_graphics.clipBox(50, 50, rbuf_window().width() - 50, rbuf_window().height() - 50);
|
||||
//
|
||||
// // Transfornations - Rotate around (300,300) to 5 degree
|
||||
// //m_graphics.translate(-300, -300);
|
||||
// //m_graphics.rotate(TAGG2D::deg2Rad(5.0));
|
||||
// //m_graphics.translate(300, 300);
|
||||
//
|
||||
// // Viewport - set 0,0,600,600 to the actual window size
|
||||
// // preserving aspect ratio and placing the viewport in the center.
|
||||
// // To ignore aspect ratio use TAGG2D::Anisotropic
|
||||
// // Note that the viewport just adds transformations to the current
|
||||
// // affine matrix. So that, set the viewport *after* all transformations!
|
||||
// m_graphics.viewport(0, 0, 600, 600,
|
||||
// 0, 0, width, height,
|
||||
// //TAGG2D::Anisotropic);
|
||||
// TAGG2D::XMidYMid);
|
||||
//
|
||||
//
|
||||
// // Rounded Rect
|
||||
// m_graphics.lineColor(0, 0, 0);
|
||||
// m_graphics.noFill();
|
||||
// m_graphics.roundedRect(0.5, 0.5, 600-0.5, 600-0.5, 20.0);
|
||||
///*
|
||||
//
|
||||
// // Reglar Text
|
||||
// m_graphics.font("Times New Roman", 14.0, false, false);
|
||||
// m_graphics.fillColor(0, 0, 0);
|
||||
// m_graphics.noLine();
|
||||
// m_graphics.text(100, 20, "Regular Raster Text -- Fast, but can't be rotated");
|
||||
//
|
||||
// // Outlined Text
|
||||
// m_graphics.font("Times New Roman", 50.0, false, false, TAGG2D::VectorFontCache);
|
||||
// m_graphics.lineColor(50, 0, 0);
|
||||
// m_graphics.fillColor(180, 200, 100);
|
||||
// m_graphics.lineWidth(1.0);
|
||||
// m_graphics.text(100.5, 50.5, "Outlined Text");
|
||||
//
|
||||
// // Text Alignment
|
||||
// m_graphics.line(250.5-150, 150.5, 250.5+150, 150.5);
|
||||
// m_graphics.line(250.5, 150.5-20, 250.5, 150.5+20);
|
||||
// m_graphics.line(250.5-150, 200.5, 250.5+150, 200.5);
|
||||
// m_graphics.line(250.5, 200.5-20, 250.5, 200.5+20);
|
||||
// m_graphics.line(250.5-150, 250.5, 250.5+150, 250.5);
|
||||
// m_graphics.line(250.5, 250.5-20, 250.5, 250.5+20);
|
||||
// m_graphics.line(250.5-150, 300.5, 250.5+150, 300.5);
|
||||
// m_graphics.line(250.5, 300.5-20, 250.5, 300.5+20);
|
||||
// m_graphics.line(250.5-150, 350.5, 250.5+150, 350.5);
|
||||
// m_graphics.line(250.5, 350.5-20, 250.5, 350.5+20);
|
||||
// m_graphics.line(250.5-150, 400.5, 250.5+150, 400.5);
|
||||
// m_graphics.line(250.5, 400.5-20, 250.5, 400.5+20);
|
||||
// m_graphics.line(250.5-150, 450.5, 250.5+150, 450.5);
|
||||
// m_graphics.line(250.5, 450.5-20, 250.5, 450.5+20);
|
||||
// m_graphics.line(250.5-150, 500.5, 250.5+150, 500.5);
|
||||
// m_graphics.line(250.5, 500.5-20, 250.5, 500.5+20);
|
||||
// m_graphics.line(250.5-150, 550.5, 250.5+150, 550.5);
|
||||
// m_graphics.line(250.5, 550.5-20, 250.5, 550.5+20);
|
||||
//*/
|
||||
///*
|
||||
// m_graphics.fillColor(100, 50, 50);
|
||||
// m_graphics.noLine();
|
||||
// //m_graphics.textHints(false);
|
||||
// m_graphics.font("Times New Roman", 40.0, false, false, TAGG2D::VectorFontCache);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignLeft, TAGG2D::AlignBottom);
|
||||
// m_graphics.text(250.0, 150.0, "Left-Bottom", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignBottom);
|
||||
// m_graphics.text(250.0, 200.0, "Center-Bottom", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignRight, TAGG2D::AlignBottom);
|
||||
// m_graphics.text(250.0, 250.0, "Right-Bottom", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignLeft, TAGG2D::AlignCenter);
|
||||
// m_graphics.text(250.0, 300.0, "Left-Center", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignCenter);
|
||||
// m_graphics.text(250.0, 350.0, "Center-Center", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignRight, TAGG2D::AlignCenter);
|
||||
// m_graphics.text(250.0, 400.0, "Right-Center", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignLeft, TAGG2D::AlignTop);
|
||||
// m_graphics.text(250.0, 450.0, "Left-Top", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignTop);
|
||||
// m_graphics.text(250.0, 500.0, "Center-Top", true, 0, 0);
|
||||
//
|
||||
// m_graphics.textAlignment(TAGG2D::AlignRight, TAGG2D::AlignTop);
|
||||
// m_graphics.text(250.0, 550.0, "Right-Top", true, 0, 0);
|
||||
//
|
||||
//*/
|
||||
// // Gradients (Aqua Buttons)
|
||||
// //=======================================
|
||||
// m_graphics.font("Verdana", 20.0, false, false, TAGG2D::VectorFontCache);
|
||||
// double xb1 = 400;
|
||||
// double yb1 = 80;
|
||||
// double xb2 = xb1 + 150;
|
||||
// double yb2 = yb1 + 36;
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,50,180,180));
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,80, 255));
|
||||
// m_graphics.lineWidth(1.0);
|
||||
// m_graphics.roundedRect(xb1, yb1, xb2, yb2, 12, 18);
|
||||
//
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,0,0));
|
||||
// m_graphics.fillLinearGradient(xb1, yb1, xb1, yb1+30,
|
||||
// TAGG2D::Color(100,200,255,255),
|
||||
// TAGG2D::Color(255,255,255,0));
|
||||
// m_graphics.roundedRect(xb1+3, yb1+2.5, xb2-3, yb1+30, 9, 18, 1, 1);
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,0,50, 200));
|
||||
// m_graphics.noLine();
|
||||
///* m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignCenter);
|
||||
// m_graphics.text((xb1 + xb2) / 2.0, (yb1 + yb2) / 2.0, "Aqua Button", true, 0.0, 0.0);
|
||||
//*/
|
||||
// m_graphics.fillLinearGradient(xb1, yb2-20, xb1, yb2-3,
|
||||
// TAGG2D::Color(0, 0, 255,0),
|
||||
// TAGG2D::Color(100,255,255,255));
|
||||
// m_graphics.roundedRect(xb1+3, yb2-20, xb2-3, yb2-2, 1, 1, 9, 18);
|
||||
//
|
||||
//
|
||||
// // Aqua Button Pressed
|
||||
// xb1 = 400;
|
||||
// yb1 = 30;
|
||||
// xb2 = xb1 + 150;
|
||||
// yb2 = yb1 + 36;
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,50,180,180));
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,0, 255));
|
||||
// m_graphics.lineWidth(2.0);
|
||||
// m_graphics.roundedRect(xb1, yb1, xb2, yb2, 12, 18);
|
||||
//
|
||||
// m_graphics.lineColor(TAGG2D::Color(0,0,0,0));
|
||||
// m_graphics.fillLinearGradient(xb1, yb1+2, xb1, yb1+25,
|
||||
// TAGG2D::Color(60, 160,255,255),
|
||||
// TAGG2D::Color(100,255,255,0));
|
||||
// m_graphics.roundedRect(xb1+3, yb1+2.5, xb2-3, yb1+30, 9, 18, 1, 1);
|
||||
//
|
||||
// m_graphics.fillColor(TAGG2D::Color(0,0,50, 255));
|
||||
// m_graphics.noLine();
|
||||
///* m_graphics.textAlignment(TAGG2D::AlignCenter, TAGG2D::AlignCenter);
|
||||
// m_graphics.text((xb1 + xb2) / 2.0, (yb1 + yb2) / 2.0, "Aqua Pressed", 0.0, 0.0);
|
||||
//*/
|
||||
// m_graphics.fillLinearGradient(xb1, yb2-25, xb1, yb2-5,
|
||||
// TAGG2D::Color(0, 180,255,0),
|
||||
// TAGG2D::Color(0, 200,255,255));
|
||||
// m_graphics.roundedRect(xb1+3, yb2-25, xb2-3, yb2-2, 1, 1, 9, 18);
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Basic Shapes -- Ellipse
|
||||
// //===========================================
|
||||
// m_graphics.lineWidth(3.5);
|
||||
// m_graphics.lineColor(20, 80, 80);
|
||||
// m_graphics.fillColor(200, 255, 80, 200);
|
||||
// m_graphics.ellipse(450, 200, 50, 90);
|
||||
//
|
||||
//
|
||||
// // Paths
|
||||
// //===========================================
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.fillColor(255, 0, 0, 100);
|
||||
// m_graphics.lineColor(0, 0, 255, 100);
|
||||
// m_graphics.lineWidth(2);
|
||||
// m_graphics.moveTo(300/2, 200/2);
|
||||
// m_graphics.horLineRel(-150/2);
|
||||
// m_graphics.arcRel(150/2, 150/2, 0, 1, 0, 150/2, -150/2);
|
||||
// m_graphics.closePolygon();
|
||||
// m_graphics.drawPath();
|
||||
//
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.fillColor(255, 255, 0, 100);
|
||||
// m_graphics.lineColor(0, 0, 255, 100);
|
||||
// m_graphics.lineWidth(2);
|
||||
// m_graphics.moveTo(275/2, 175/2);
|
||||
// m_graphics.verLineRel(-150/2);
|
||||
// m_graphics.arcRel(150/2, 150/2, 0, 0, 0, -150/2, 150/2);
|
||||
// m_graphics.closePolygon();
|
||||
// m_graphics.drawPath();
|
||||
//
|
||||
//
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.noFill();
|
||||
// m_graphics.lineColor(127, 0, 0);
|
||||
// m_graphics.lineWidth(5);
|
||||
// m_graphics.moveTo(600/2, 350/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.arcRel(25/2, 25/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.arcRel(25/2, 50/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.arcRel(25/2, 75/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50, -25);
|
||||
// m_graphics.arcRel(25/2, 100/2, TAGG2D::deg2Rad(-30), 0, 1, 50/2, -25/2);
|
||||
// m_graphics.lineRel(50/2, -25/2);
|
||||
// m_graphics.drawPath();
|
||||
//
|
||||
//
|
||||
// // Master Alpha. From now on everything will be translucent
|
||||
// //===========================================
|
||||
// m_graphics.masterAlpha(0.85);
|
||||
//
|
||||
//
|
||||
// // Image Transformations
|
||||
// //===========================================
|
||||
///* TAGG2D::Image img(rbuf_img(0).buf(),
|
||||
// rbuf_img(0).width(),
|
||||
// rbuf_img(0).height(),
|
||||
// rbuf_img(0).stride());
|
||||
// m_graphics.imageFilter(TAGG2D::Bilinear);
|
||||
//
|
||||
// //m_graphics.imageResample(TAGG2D::NoResample);
|
||||
// //m_graphics.imageResample(TAGG2D::ResampleAlways);
|
||||
// m_graphics.imageResample(TAGG2D::ResampleOnZoomOut);
|
||||
//
|
||||
// // Set the initial image blending operation as BlendDst, that actually
|
||||
// // does nothing.
|
||||
// //-----------------
|
||||
// m_graphics.imageBlendMode(TAGG2D::BlendDst);
|
||||
//
|
||||
//
|
||||
// // Transform the whole image to the destination rectangle
|
||||
// //-----------------
|
||||
// //m_graphics.transformImage(img, 450, 200, 595, 350);
|
||||
//
|
||||
// // Transform the rectangular part of the image to the destination rectangle
|
||||
// //-----------------
|
||||
// //m_graphics.transformImage(img, 60, 60, img.width()-60, img.height()-60,
|
||||
// // 450, 200, 595, 350);
|
||||
//
|
||||
// // Transform the whole image to the destination parallelogram
|
||||
// //-----------------
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImage(img, parl);
|
||||
//
|
||||
// // Transform the rectangular part of the image to the destination parallelogram
|
||||
// //-----------------
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImage(img, 60, 60, img.width()-60, img.height()-60, parl);
|
||||
//
|
||||
// // Transform image to the destination path. The scale is determined by a rectangle
|
||||
// //-----------------
|
||||
// //m_graphics.resetPath();
|
||||
// //m_graphics.moveTo(450, 200);
|
||||
// //m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// //m_graphics.lineTo(470, 340);
|
||||
// //m_graphics.transformImagePath(img, 450, 200, 595, 350);
|
||||
//
|
||||
//
|
||||
// // Transform image to the destination path.
|
||||
// // The scale is determined by a rectangle
|
||||
// //-----------------
|
||||
// m_graphics.resetPath();
|
||||
// m_graphics.moveTo(450, 200);
|
||||
// m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// m_graphics.lineTo(470, 340);
|
||||
// m_graphics.transformImagePath(img, 60, 60, img.width()-60, img.height()-60,
|
||||
// 450, 200, 595, 350);
|
||||
//
|
||||
// // Transform image to the destination path.
|
||||
// // The transformation is determined by a parallelogram
|
||||
// //m_graphics.resetPath();
|
||||
// //m_graphics.moveTo(450, 200);
|
||||
// //m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// //m_graphics.lineTo(470, 340);
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImagePath(img, parl);
|
||||
//
|
||||
// // Transform the rectangular part of the image to the destination path.
|
||||
// // The transformation is determined by a parallelogram
|
||||
// //m_graphics.resetPath();
|
||||
// //m_graphics.moveTo(450, 200);
|
||||
// //m_graphics.cubicCurveTo(595, 220, 575, 350, 595, 350);
|
||||
// //m_graphics.lineTo(470, 340);
|
||||
// //double parl[6] = { 450, 200, 595, 220, 575, 350 };
|
||||
// //m_graphics.transformImagePath(img, 60, 60, img.width()-60, img.height()-60, parl);
|
||||
//*/
|
||||
//
|
||||
// // Add/Sub/Contrast Blending Modes
|
||||
// m_graphics.noLine();
|
||||
// m_graphics.fillColor(70, 70, 0);
|
||||
// m_graphics.blendMode(TAGG2D::BlendAdd);
|
||||
// m_graphics.ellipse(500, 280, 20, 40);
|
||||
//
|
||||
// m_graphics.fillColor(255, 255, 255);
|
||||
// m_graphics.blendMode(TAGG2D::BlendContrast);
|
||||
// m_graphics.ellipse(500+40, 280, 20, 40);
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Radial gradient.
|
||||
// m_graphics.blendMode(TAGG2D::BlendAlpha);
|
||||
// m_graphics.fillRadialGradient(400, 500, 40,
|
||||
// TAGG2D::Color(255, 255, 0, 0),
|
||||
// TAGG2D::Color(0, 0, 127),
|
||||
// TAGG2D::Color(0, 255, 0, 0));
|
||||
// m_graphics.ellipse(400, 500, 40, 40);
|
||||
//
|
||||
// }
|
||||
//
|
|
@ -44,40 +44,67 @@
|
|||
class AggDrawTarget
|
||||
{
|
||||
public:
|
||||
AggDrawTarget()
|
||||
: empty(true)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void dirty() { empty = false; }
|
||||
void undirty() { empty = true; }
|
||||
|
||||
public:
|
||||
|
||||
bool empty;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void lineColor(unsigned r, unsigned g, unsigned b, unsigned a) = 0;
|
||||
virtual void fillColor(unsigned r, unsigned g, unsigned b, unsigned a) = 0;
|
||||
virtual void noFill() = 0;
|
||||
virtual void noLine() = 0;
|
||||
virtual void lineWidth(double w) = 0;
|
||||
virtual double lineWidth() = 0;
|
||||
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2,double rx_bottom, double ry_bottom,double rx_top, double ry_top) = 0;
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2, double r) = 0;
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2, double rx, double ry) = 0;
|
||||
};
|
||||
|
||||
|
||||
template<typename PIXFMT>
|
||||
class AggDrawTargetImplementation : public AggDrawTarget, public Agg2D<PIXFMT>
|
||||
template<typename PixFormatSet>
|
||||
class AggDrawTargetImplementation : public AggDrawTarget, public Agg2D<PixFormatSet>
|
||||
{
|
||||
public:
|
||||
typedef PIXFMT pixfmt;
|
||||
typedef typename PixFormatSet::PixFormat pixfmt;
|
||||
typedef typename pixfmt::color_type color_type;
|
||||
|
||||
typedef Agg2D<PIXFMT> BASE;
|
||||
typedef Agg2D<PixFormatSet> BASE;
|
||||
AggDrawTargetImplementation(agg::int8u* buf, int width, int height, int stride)
|
||||
{
|
||||
attach(buf,width,height,stride);
|
||||
|
||||
BASE::viewport(0, 0, 600, 600,
|
||||
0, 0, width, height,
|
||||
//TAGG2D::Anisotropic);
|
||||
XMidYMid);
|
||||
BASE::viewport(0, 0, width-1, height-1, 0.5, 0.5, width-0.5, height-0.5, TAGG2D::Anisotropic);
|
||||
}
|
||||
|
||||
virtual void clear() {
|
||||
if(!empty)
|
||||
{
|
||||
BASE::clearAll(0,0,0,0);
|
||||
undirty();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void lineColor(unsigned r, unsigned g, unsigned b, unsigned a) { BASE::lineColor(r,g,b,a); }
|
||||
virtual void fillColor(unsigned r, unsigned g, unsigned b, unsigned a) { BASE::fillColor(r,g,b,a); }
|
||||
virtual void noFill() { BASE::noFill(); }
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2,double rx_bottom, double ry_bottom,double rx_top,double ry_top)
|
||||
{
|
||||
BASE::roundedRect(x1,y1,x2,y2,rx_bottom,ry_bottom,rx_top,ry_top);
|
||||
}
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2, double r) { BASE::roundedRect(x1,y1,x2,y2,r); }
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2, double rx, double ry) { BASE::roundedRect(x1,y1,x2,y2,rx,ry); }
|
||||
virtual void noLine() { BASE::noLine(); }
|
||||
virtual void lineWidth(double w) { BASE::lineWidth(w); }
|
||||
virtual double lineWidth() { return BASE::lineWidth(); }
|
||||
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2,double rx_bottom, double ry_bottom,double rx_top,double ry_top) { dirty(); BASE::roundedRect(x1,y1,x2,y2,rx_bottom,ry_bottom,rx_top,ry_top); }
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2, double r) { dirty(); BASE::roundedRect(x1,y1,x2,y2,r); }
|
||||
virtual void roundedRect(double x1, double y1, double x2, double y2, double rx, double ry) { dirty(); BASE::roundedRect(x1,y1,x2,y2,rx,ry); }
|
||||
};
|
||||
|
||||
class AggDraw
|
||||
|
@ -92,7 +119,8 @@ public:
|
|||
enum AggTarget
|
||||
{
|
||||
AggTarget_Screen = 0,
|
||||
AggTarget_Lua = 1
|
||||
AggTarget_Hud = 1,
|
||||
AggTarget_Lua = 2,
|
||||
};
|
||||
|
||||
//specialized instance for desmume; should eventually move to another file
|
||||
|
|
|
@ -758,6 +758,14 @@
|
|||
RelativePath="..\addons.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\agg2d.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\agg2d.inl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\aggdraw.cpp"
|
||||
>
|
||||
|
|
|
@ -778,7 +778,7 @@ void Display()
|
|||
res = lpBackSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
||||
|
||||
//extern void AGGDraw(); AGGDraw();
|
||||
|
||||
//aggDraw.composite(GPU_screen);
|
||||
|
||||
if (res == DD_OK)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue