This commit is contained in:
Oleg Korshul
2018-04-11 17:20:13 +03:00
parent 935e9396af
commit 290d845d7a
12 changed files with 476 additions and 357 deletions

View File

@ -89,7 +89,7 @@ namespace Aggplus
m_rasterizer.reset();
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
@ -157,7 +157,7 @@ namespace Aggplus
m_rasterizer.reset();
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
@ -206,13 +206,13 @@ namespace Aggplus
m_rasterizer.reset();
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
m_rasterizer.add_path(c_c_path);
m_rasterizer.filling_rule(pPath->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
m_rasterizer.filling_rule(pPath->m_internal->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
m_bIsClip = true;
m_bIsClip2 = false;
@ -229,13 +229,13 @@ namespace Aggplus
agg::rasterizer_scanline_aa<> rasterizer;
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
rasterizer.add_path(c_c_path);
rasterizer.filling_rule(pPath->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
rasterizer.filling_rule(pPath->m_internal->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
scanline_type sl1;
scanline_type sl2;
@ -251,13 +251,13 @@ namespace Aggplus
agg::rasterizer_scanline_aa<> rasterizer;
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
rasterizer.add_path(c_c_path);
rasterizer.filling_rule(pPath->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
rasterizer.filling_rule(pPath->m_internal->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
scanline_type sl1;
scanline_type sl2;
@ -299,4 +299,4 @@ namespace Aggplus
m_bIsClip = false;
m_bIsClip2 = false;
}
}
}

View File

@ -32,7 +32,7 @@
#ifndef _BUILD_CLIP_H_
#define _BUILD_CLIP_H_
#include "GraphicsPath.h"
#include "GraphicsPath_private.h"
#include "../agg-2.4/include/agg_basics.h"
#include "../agg-2.4/include/agg_rendering_buffer.h"
@ -168,4 +168,4 @@ public:
}
#endif // _BUILD_CLIP_H_
#endif // _BUILD_CLIP_H_

View File

@ -477,7 +477,7 @@ namespace Aggplus
Status CGraphics::CombineClip(CGraphicsPath* pPath, agg::sbool_op_e op)
{
Aggplus::CMatrix m;
return InternalClip(pPath, (m_bIntegerGrid || pPath->m_pTransform != NULL) ? &m : &m_oFullTransform, op);
return InternalClip(pPath, (m_bIntegerGrid || pPath->m_internal->m_pTransform != NULL) ? &m : &m_oFullTransform, op);
}
Status CGraphics::InternalClip(CGraphicsPath* pPath, CMatrix* pTransform, agg::sbool_op_e op)
@ -601,7 +601,7 @@ namespace Aggplus
}
double dWidth = pPen->Size;
double dWidthMinSize = 1.0 / sqrt(m_oCoordTransform.m_agg_mtx.determinant());
double dWidthMinSize = 1.0 / sqrt(m_oCoordTransform.m_internal->m_agg_mtx.determinant());
if ((0 == dWidth && !m_bIntegerGrid) || dWidth < dWidthMinSize)
{
@ -610,7 +610,7 @@ namespace Aggplus
double dblMiterLimit = pPen->MiterLimit;
agg::path_storage path_copy(pPath->m_agg_ps);
agg::path_storage path_copy(pPath->m_internal->m_agg_ps);
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
conv_crv_type c_c_path(path_copy);
@ -618,7 +618,7 @@ namespace Aggplus
c_c_path.approximation_method(agg::curve_inc);
DashStyle eStyle = (DashStyle)pPen->DashStyle;
agg::trans_affine* pAffine = &m_oFullTransform.m_agg_mtx;
agg::trans_affine* pAffine = &m_oFullTransform.m_internal->m_agg_mtx;
if (m_bIntegerGrid)
pAffine = new agg::trans_affine();
@ -750,7 +750,7 @@ namespace Aggplus
double dblMiterLimit = 0.5;
agg::path_storage path_copy(pPath->m_agg_ps);
agg::path_storage path_copy(pPath->m_internal->m_agg_ps);
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
conv_crv_type c_c_path(path_copy);
@ -772,7 +772,7 @@ namespace Aggplus
typedef agg::conv_transform<Path_Conv_StrokeN> transStroke;
CMatrix oM;
transStroke trans(pgN, oM.m_agg_mtx);
transStroke trans(pgN, oM.m_internal->m_agg_mtx);
m_rasterizer.get_rasterizer().add_path(trans);
}
else
@ -808,7 +808,7 @@ namespace Aggplus
pgD.miter_limit(dblMiterLimit);
pgD.width(dWidth);
agg::conv_transform<Path_Conv_StrokeD> trans(pgD, m_oFullTransform.m_agg_mtx);
agg::conv_transform<Path_Conv_StrokeD> trans(pgD, m_oFullTransform.m_internal->m_agg_mtx);
m_rasterizer.get_rasterizer().add_path(trans);
}
@ -851,13 +851,13 @@ namespace Aggplus
m_rasterizer.get_rasterizer().reset();
agg::path_storage p2(pPath->m_agg_ps);
agg::path_storage p2(pPath->m_internal->m_agg_ps);
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type* ptrans = NULL;
agg::trans_affine* paffine = NULL;
if (!m_bIntegerGrid)
ptrans = new trans_type(p2, m_oFullTransform.m_agg_mtx);
ptrans = new trans_type(p2, m_oFullTransform.m_internal->m_agg_mtx);
else
{
paffine = new agg::trans_affine();
@ -869,7 +869,7 @@ namespace Aggplus
m_rasterizer.get_rasterizer().add_path(c_c_path);
m_rasterizer.get_rasterizer().filling_rule(pPath->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
m_rasterizer.get_rasterizer().filling_rule(pPath->m_internal->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
if (pBrush->GetType() == Aggplus::BrushTypeTextureFill)
{
@ -1284,7 +1284,7 @@ namespace Aggplus
typedef agg::my_span_gradient<agg::rgba8> gradient_span_gen;
gradient_span_gen span_gen;
span_gen.SetDirection(rect, (double)pBrush->GetAngle(), oMatrix.m_agg_mtx);
span_gen.SetDirection(rect, (double)pBrush->GetAngle(), oMatrix.m_internal->m_agg_mtx);
agg::rgba8* pSubColors = NULL;
float* pSubBlends = NULL;
@ -1362,7 +1362,7 @@ namespace Aggplus
typedef agg::my_span_path_gradient<agg::rgba8> gradient_span_gen;
gradient_span_gen span_gen;
span_gen.SetDirection(rect, oMatrix.m_agg_mtx);
span_gen.SetDirection(rect, oMatrix.m_internal->m_agg_mtx);
agg::rgba8* pSubColors = NULL;
float* pSubBlends = NULL;
@ -1468,7 +1468,7 @@ namespace Aggplus
BYTE* pPattern = new BYTE[HATCH_TX_SIZE * HATCH_TX_SIZE * 4];
agg::GetHatchPattern(pBrush->m_name, (agg::rgba8*)pPattern, c1, c2);
agg::trans_affine mtx_Work(m_oTransform.m_agg_mtx);
agg::trans_affine mtx_Work(m_oTransform.m_internal->m_agg_mtx);
mtx_Work.invert();
span_alloc_type span_allocator;
@ -1513,8 +1513,8 @@ namespace Aggplus
typedef agg::image_accessor_clip<pixfmt> img_source_type;
typedef agg::span_image_filter_rgba_bilinear<img_source_type, interpolator_type_linear> span_gen_type;
typedef agg::renderer_scanline_aa<base_renderer_type, span_alloc_type, span_gen_type> renderer_type;
agg::trans_affine mtx_Work(mImgMtx.m_agg_mtx);
mtx_Work.multiply(m_oFullTransform.m_agg_mtx);
agg::trans_affine mtx_Work(mImgMtx.m_internal->m_agg_mtx);
mtx_Work.multiply(m_oFullTransform.m_internal->m_agg_mtx);
mtx_Work.invert();
interpolator_type_linear interpolator(mtx_Work);
{
@ -1555,7 +1555,7 @@ namespace Aggplus
//double dScaleX = 270.0 / dwImgWidth;
//double dScaleY = 190.0 / dwImgHeight;
agg::trans_affine mtx_Work(mImgMtx.m_agg_mtx);
agg::trans_affine mtx_Work(mImgMtx.m_internal->m_agg_mtx);
//mtx_Work.scale(dScaleX, dScaleY);
//mtx_Work.multiply(m_oFullTransform.m_agg_mtx);
@ -1607,7 +1607,7 @@ namespace Aggplus
//double dScaleX = 270.0 / dwImgWidth;
//double dScaleY = 190.0 / dwImgHeight;
agg::trans_affine mtx_Work(mImgMtx.m_agg_mtx);
agg::trans_affine mtx_Work(mImgMtx.m_internal->m_agg_mtx);
//mtx_Work.scale(dScaleX, dScaleY);
//mtx_Work.multiply(m_oFullTransform.m_agg_mtx);
@ -1652,9 +1652,9 @@ namespace Aggplus
template<class ColorSpacePix>
void CGraphics::DoFillPathTextureClampSz3(const CMatrix &matrix, const void *pImgBuff, DWORD dwImgWidth, DWORD dwImgHeight, int nImgStride, Aggplus::WrapMode wrapmode, BYTE Alpha)
{
agg::trans_affine mtx_Work( matrix.m_agg_mtx );
agg::trans_affine mtx_Work( matrix.m_internal->m_agg_mtx );
agg::trans_affine coords = m_oCoordTransform.m_agg_mtx;
agg::trans_affine coords = m_oCoordTransform.m_internal->m_agg_mtx;
coords.invert();
mtx_Work.premultiply(coords);

View File

@ -29,7 +29,7 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "GraphicsPath.h"
#include "GraphicsPath_private.h"
#include <algorithm>
namespace Aggplus
@ -37,53 +37,54 @@ namespace Aggplus
// GraphicsPath
CGraphicsPath::CGraphicsPath() : ISimpleGraphicsPath()
{
m_bEvenOdd = false;
m_pTransform = NULL;
m_internal = new CGraphicsPath_private();
}
CGraphicsPath::~CGraphicsPath()
{
RELEASEOBJECT(m_internal);
}
CGraphicsPath* CGraphicsPath::Clone()
{
CGraphicsPath* pNew = new CGraphicsPath();
pNew->m_agg_ps = m_agg_ps;
pNew->m_bEvenOdd = m_bEvenOdd;
pNew->m_internal->m_agg_ps = m_internal->m_agg_ps;
pNew->m_internal->m_bEvenOdd = m_internal->m_bEvenOdd;
pNew->m_internal->m_bIsMoveTo = m_internal->m_bIsMoveTo;
return pNew;
}
Status CGraphicsPath::Reset()
{
m_agg_ps.remove_all();
m_bIsMoveTo = false;
m_internal->m_agg_ps.remove_all();
m_internal->m_bIsMoveTo = false;
return Ok;
}
void CGraphicsPath::SetRuler(bool bEvenOdd)
{
m_bEvenOdd = bEvenOdd;
m_internal->m_bEvenOdd = bEvenOdd;
}
Status CGraphicsPath::StartFigure()
{
m_agg_ps.start_new_path();
m_internal->m_agg_ps.start_new_path();
return Ok;
}
Status CGraphicsPath::CloseFigure()
{
m_agg_ps.close_polygon();
m_internal->m_agg_ps.close_polygon();
return Ok;
}
bool CGraphicsPath::Is_poly_closed()
{
if (!m_agg_ps.total_vertices())
if (!m_internal->m_agg_ps.total_vertices())
return true;
double x, y;
unsigned int nTip = m_agg_ps.last_vertex(&x, &y);
unsigned int nTip = m_internal->m_agg_ps.last_vertex(&x, &y);
if (nTip & agg::path_flags_close)
return true;
@ -93,18 +94,18 @@ namespace Aggplus
Status CGraphicsPath::MoveTo(double x, double y)
{
m_bIsMoveTo = true;
m_agg_ps.move_to(x, y);
m_internal->m_bIsMoveTo = true;
m_internal->m_agg_ps.move_to(x, y);
return Ok;
}
Status CGraphicsPath::LineTo(double x, double y)
{
m_agg_ps.line_to(x, y);
m_internal->m_agg_ps.line_to(x, y);
return Ok;
}
Status CGraphicsPath::CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
{
m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
m_internal->m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
return Ok;
}
@ -112,14 +113,14 @@ namespace Aggplus
{
if (Is_poly_closed())
{
m_agg_ps.move_to(x1, y1);
m_internal->m_agg_ps.move_to(x1, y1);
}
else
{
m_agg_ps.line_to(x1, y1);
m_internal->m_agg_ps.line_to(x1, y1);
}
m_agg_ps.line_to(x2, y2);
m_internal->m_agg_ps.line_to(x2, y2);
return Ok;
}
@ -131,7 +132,7 @@ namespace Aggplus
}
int nRet = 0;
if (!m_bIsMoveTo)
if (!m_internal->m_bIsMoveTo)
{
MoveTo(pPoints[0], pPoints[1]);
}
@ -150,7 +151,7 @@ namespace Aggplus
for (int i = 1; i <= n; ++i)
{
const double* points = &pPoints[i * 2];
m_agg_ps.line_to(points[0], points[1]);
m_internal->m_agg_ps.line_to(points[0], points[1]);
}
return Ok;
}
@ -158,11 +159,11 @@ namespace Aggplus
Status CGraphicsPath::AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
{
if (Is_poly_closed())
m_agg_ps.move_to(x1, y1);
m_internal->m_agg_ps.move_to(x1, y1);
else
m_agg_ps.line_to(x1, y1);
m_internal->m_agg_ps.line_to(x1, y1);
m_agg_ps.curve4(x2, y2, x3, y3, x4, y4);
m_internal->m_agg_ps.curve4(x2, y2, x3, y3, x4, y4);
return Ok;
}
Status CGraphicsPath::AddBeziers(double* pPoints, int nCount)
@ -170,7 +171,7 @@ namespace Aggplus
if (8 > nCount)
return InvalidParameter;
if (!m_bIsMoveTo)
if (!m_internal->m_bIsMoveTo)
{
MoveTo(pPoints[0], pPoints[1]);
}
@ -184,11 +185,11 @@ namespace Aggplus
if (Is_poly_closed())
{
m_agg_ps.concat_path(curve, 0);
m_internal->m_agg_ps.concat_path(curve, 0);
}
else
{
m_agg_ps.join_path(curve, 0);
m_internal->m_agg_ps.join_path(curve, 0);
}
int nCountTo = (nCount - 8) / 6;
@ -211,16 +212,16 @@ namespace Aggplus
{
agg::bezier_arc arc(x+width/2.0, y+height/2.0, width/2.0, height/2.0, 0.0, agg::pi2);
//2.3 m_agg_ps.add_path(arc, 0, true);
m_agg_ps.join_path(arc, 0);
m_internal->m_agg_ps.join_path(arc, 0);
return Ok;
}
Status CGraphicsPath::AddRectangle(double x, double y, double width, double height)
{
m_agg_ps.move_to(x, y);
m_agg_ps.line_to(x + width, y);
m_agg_ps.line_to(x + width, y + height);
m_agg_ps.line_to(x, y + height);
m_agg_ps.close_polygon();
m_internal->m_agg_ps.move_to(x, y);
m_internal->m_agg_ps.line_to(x + width, y);
m_internal->m_agg_ps.line_to(x + width, y + height);
m_internal->m_agg_ps.line_to(x, y + height);
m_internal->m_agg_ps.close_polygon();
return Ok;
}
Status CGraphicsPath::AddPolygon(double* pPoints, int nCount)
@ -233,11 +234,11 @@ namespace Aggplus
if (Is_poly_closed())
{
m_agg_ps.move_to(pPoints[0], pPoints[1]);
m_internal->m_agg_ps.move_to(pPoints[0], pPoints[1]);
}
else
{
m_agg_ps.line_to(pPoints[0], pPoints[1]);
m_internal->m_agg_ps.line_to(pPoints[0], pPoints[1]);
}
int n = (nCount / 2) - 1;
@ -245,20 +246,20 @@ namespace Aggplus
for (int i = 1; i < n; ++i)
{
double* points = &pPoints[i * 2];
m_agg_ps.line_to(points[0], points[1]);
m_internal->m_agg_ps.line_to(points[0], points[1]);
}
m_agg_ps.close_polygon();
m_internal->m_agg_ps.close_polygon();
return Ok;
}
Status CGraphicsPath::AddPath(const CGraphicsPath& oPath)
{
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
agg::path_storage p_copy(oPath.m_agg_ps);
agg::path_storage p_copy(oPath.m_internal->m_agg_ps);
conv_crv_type p3(p_copy);
m_agg_ps.join_path(p3, 0);
m_internal->m_agg_ps.join_path(p3, 0);
return Ok;
}
Status CGraphicsPath::AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle)
@ -274,11 +275,11 @@ namespace Aggplus
if (Is_poly_closed())
{
m_agg_ps.concat_path(arc, 0);
m_internal->m_agg_ps.concat_path(arc, 0);
}
else
{
m_agg_ps.join_path(arc, 0);
m_internal->m_agg_ps.join_path(arc, 0);
}
return Ok;
@ -287,13 +288,13 @@ namespace Aggplus
ULONG CGraphicsPath::GetPointCount() const
{
ULONG nPointCount=0;
ULONG nTotal = m_agg_ps.total_vertices();
ULONG nTotal = m_internal->m_agg_ps.total_vertices();
double x, y;
for(ULONG i = 0; i < nTotal; ++i)
{
ULONG nTip = m_agg_ps.vertex(i, &x, &y);
ULONG nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
if(nTip)
{
if (!(nTip & agg::path_flags_close))
@ -307,13 +308,13 @@ namespace Aggplus
Status CGraphicsPath::GetPathPoints(PointF* points, int count) const
{
int nTotal = m_agg_ps.total_vertices();
int nTotal = m_internal->m_agg_ps.total_vertices();
double x, y;
int i = 0, k = 0;
while (k < count && i < nTotal)
{
unsigned int nTip = m_agg_ps.vertex(i, &x, &y);
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
if (nTip)
{
if(!(nTip & agg::path_flags_close))
@ -331,19 +332,19 @@ namespace Aggplus
Status CGraphicsPath::GetLastPoint(double& x, double& y)
{
m_agg_ps.last_vertex(&x, &y);
m_internal->m_agg_ps.last_vertex(&x, &y);
return Ok;
}
Status CGraphicsPath::GetPathPoints(double* points, int count) const
{
int nTotal = m_agg_ps.total_vertices();
int nTotal = m_internal->m_agg_ps.total_vertices();
double x, y;
int i = 0, k = 0;
while (k < count && i < nTotal)
{
unsigned int nTip = m_agg_ps.vertex(i, &x, &y);
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
if (nTip)
{
if(!(nTip & agg::path_flags_close))
@ -361,14 +362,14 @@ namespace Aggplus
void CGraphicsPath::GetBounds(double& left, double& top, double& width, double& height)
{
unsigned int nTotal = m_agg_ps.total_vertices();
unsigned int nTotal = m_internal->m_agg_ps.total_vertices();
if (nTotal)
{
agg::rect_d bounds(1e100, 1e100, -1e100, -1e100);
double x, y;
for(unsigned int i = 0; i < nTotal; i++)
{
unsigned int nTip = m_agg_ps.vertex(i, &x, &y);
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
if(agg::is_vertex(nTip))
{
if(x < bounds.x1) bounds.x1 = x;
@ -396,38 +397,38 @@ namespace Aggplus
{
if (NULL != matrix)
{
agg::path_storage p2(m_agg_ps);
agg::conv_transform<agg::path_storage> trans(p2, matrix->m_agg_mtx);
m_agg_ps.remove_all();
agg::path_storage p2(m_internal->m_agg_ps);
agg::conv_transform<agg::path_storage> trans(p2, matrix->m_internal->m_agg_mtx);
m_internal->m_agg_ps.remove_all();
//2.3 m_agg_ps.add_path(trans, 0, false);
m_agg_ps.concat_path(trans, 0);
m_internal->m_agg_ps.concat_path(trans, 0);
}
return Ok;
}
bool CGraphicsPath::_MoveTo(double x, double y)
{
if (NULL != m_pTransform)
if (NULL != m_internal->m_pTransform)
{
m_pTransform->TransformPoint(x, y);
m_internal->m_pTransform->TransformPoint(x, y);
}
return (Ok == MoveTo(x, y));
}
bool CGraphicsPath::_LineTo(double x, double y)
{
if (NULL != m_pTransform)
if (NULL != m_internal->m_pTransform)
{
m_pTransform->TransformPoint(x, y);
m_internal->m_pTransform->TransformPoint(x, y);
}
return (Ok == LineTo(x, y));
}
bool CGraphicsPath::_CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
{
if (NULL != m_pTransform)
if (NULL != m_internal->m_pTransform)
{
m_pTransform->TransformPoint(x1, y1);
m_pTransform->TransformPoint(x2, y2);
m_pTransform->TransformPoint(x3, y3);
m_internal->m_pTransform->TransformPoint(x1, y1);
m_internal->m_pTransform->TransformPoint(x2, y2);
m_internal->m_pTransform->TransformPoint(x3, y3);
}
return (Ok == CurveTo(x1, y1, x2, y2, x3, y3));
}
@ -466,48 +467,45 @@ namespace Aggplus
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
}
void CGraphicsPath::z_Stroke(const NSStructures::CPen* Pen)
void CGraphicsPath::z_Stroke(const double& size)
{
if (NULL == Pen)
return;
typedef agg::conv_stroke<agg::path_storage> Path_Conv_Stroke;
Path_Conv_Stroke pg(m_agg_ps);
Path_Conv_Stroke pg(m_internal->m_agg_ps);
pg.line_join(agg::round_join);
pg.line_cap(agg::round_cap);
pg.approximation_scale(25.00);
//pg.miter_limit(0.50);
pg.width(Pen->Size);
pg.width(size);
//pg.auto_detect_orientation(true);
agg::path_storage psNew;
//2.3 psNew.add_path(pg, 0, false);
psNew.concat_path(pg, 0);
m_agg_ps = psNew;
m_internal->m_agg_ps = psNew;
}
void CGraphicsPath::Widen(const NSStructures::CPen* Pen, const CMatrix* matrix, float flatness)
void CGraphicsPath::Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness)
{
if (NULL == Pen || NULL == matrix || 0.0f == flatness)
if (NULL == matrix || 0.0f == flatness)
return;
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
typedef agg::conv_contour<conv_crv_type> Path_Conv_Contour;
conv_crv_type crv(m_agg_ps);
conv_crv_type crv(m_internal->m_agg_ps);
Path_Conv_Contour pg(crv);
pg.miter_limit(0.50);
//pg.miter_limit_theta(0.05);
//pg.approximation_scale(2.00);
pg.width(Pen->Size);
pg.width(size);
agg::line_join_e LineJoin;
switch (Pen->LineJoin)
switch (join)
{
case LineJoinMiter : LineJoin=agg::miter_join; break;
case LineJoinBevel : LineJoin=agg::bevel_join; break;
@ -522,13 +520,8 @@ namespace Aggplus
agg::path_storage psNew;
//2.3 psNew.add_path(pg, 0, false);
//m_agg_ps.concat_path(pg, 0);
m_agg_ps.concat_path(pg, 0);
m_agg_ps = psNew;
}
agg::path_storage* CGraphicsPath::z_get_agg_path_storage()
{
return &m_agg_ps;
m_internal->m_agg_ps.concat_path(pg, 0);
m_internal->m_agg_ps = psNew;
}
int CGraphicsPath::EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection)
@ -725,20 +718,21 @@ namespace Aggplus
return Ok;
}
}
namespace Aggplus
{
// Converter
CGraphicsPathSimpleConverter::CGraphicsPathSimpleConverter()
{
m_pRenderer = NULL;
m_bEvenOdd = false;
m_bIsMoveTo = false;
m_bIsClosed = false;
m_internal = new CGraphicsPathSimpleConverter_private();
}
CGraphicsPathSimpleConverter::~CGraphicsPathSimpleConverter()
{
RELEASEINTERFACE(m_pRenderer);
RELEASEOBJECT(m_internal);
}
void CGraphicsPathSimpleConverter::SetRenderer(IRenderer* pRenderer)
@ -784,7 +778,7 @@ namespace Aggplus
int nRet = 0;
if (!m_bIsMoveTo)
if (!m_internal->m_bIsMoveTo)
{
_MoveTo(pData[0], pData[1]);
}
@ -812,7 +806,7 @@ namespace Aggplus
if (8 > lCount)
return false;
if (!m_bIsMoveTo)
if (!m_internal->m_bIsMoveTo)
{
_MoveTo(pData[0], pData[1]);
@ -857,7 +851,7 @@ namespace Aggplus
}
bool CGraphicsPathSimpleConverter::PathCommandGetCurrentPoint(double* fX, double* fY)
{
m_agg_ps.last_vertex(fX, fY);
m_internal->m_agg_ps.last_vertex(fX, fY);
return true;
}
bool CGraphicsPathSimpleConverter::PathCommandText(const std::wstring& bsText, CFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset)
@ -909,14 +903,14 @@ namespace Aggplus
bool CGraphicsPathSimpleConverter::PathCommandGetBounds(double& left, double& top, double& width, double &height)
{
unsigned int nTotal = m_agg_ps.total_vertices();
unsigned int nTotal = m_internal->m_agg_ps.total_vertices();
if (nTotal)
{
agg::rect_d bounds(1e100, 1e100, -1e100, -1e100);
double x, y;
for(unsigned int i = 0; i < nTotal; i++)
{
unsigned int nTip = m_agg_ps.vertex(i, &x, &y);
unsigned int nTip = m_internal->m_agg_ps.vertex(i, &x, &y);
if(agg::is_vertex(nTip))
{
if(x < bounds.x1) bounds.x1 = x;
@ -943,8 +937,8 @@ namespace Aggplus
bool CGraphicsPathSimpleConverter::_MoveTo(double x, double y)
{
m_bIsMoveTo = true;
m_agg_ps.move_to(x, y);
m_internal->m_bIsMoveTo = true;
m_internal->m_agg_ps.move_to(x, y);
if (NULL != m_pRenderer)
{
@ -956,12 +950,12 @@ namespace Aggplus
}
bool CGraphicsPathSimpleConverter::_LineTo(double x, double y)
{
if (!m_bIsMoveTo)
if (!m_internal->m_bIsMoveTo)
{
_MoveTo(x, y);
}
m_agg_ps.line_to(x, y);
m_internal->m_agg_ps.line_to(x, y);
if (NULL != m_pRenderer)
{
@ -974,12 +968,12 @@ namespace Aggplus
}
bool CGraphicsPathSimpleConverter::_CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
{
if (!m_bIsMoveTo)
if (!m_internal->m_bIsMoveTo)
{
_MoveTo(x1, y1);
}
m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
m_internal->m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
if (NULL != m_pRenderer)
{
@ -992,8 +986,8 @@ namespace Aggplus
}
bool CGraphicsPathSimpleConverter::_Close()
{
m_bIsClosed = true;
m_agg_ps.close_polygon();
m_internal->m_bIsClosed = true;
m_internal->m_agg_ps.close_polygon();
if (NULL != m_pRenderer)
{
@ -1005,11 +999,11 @@ namespace Aggplus
}
bool CGraphicsPathSimpleConverter::_Reset()
{
m_bEvenOdd = false;
m_bIsMoveTo = false;
m_bIsClosed = false;
m_internal->m_bEvenOdd = false;
m_internal->m_bIsMoveTo = false;
m_internal->m_bIsClosed = false;
m_agg_ps.remove_all();
m_internal->m_agg_ps.remove_all();
if (NULL != m_pRenderer)
{
@ -1022,7 +1016,7 @@ namespace Aggplus
}
bool CGraphicsPathSimpleConverter::_Start()
{
m_agg_ps.start_new_path();
m_internal->m_agg_ps.start_new_path();
if (NULL != m_pRenderer)
{
@ -1240,11 +1234,11 @@ namespace Aggplus
bool CGraphicsPathSimpleConverter::Is_poly_closed()
{
if (!m_agg_ps.total_vertices())
if (!m_internal->m_agg_ps.total_vertices())
return true;
double x, y;
unsigned int nTip = m_agg_ps.last_vertex(&x, &y);
unsigned int nTip = m_internal->m_agg_ps.last_vertex(&x, &y);
if (nTip & agg::path_flags_close)
return true;

View File

@ -33,162 +33,132 @@
#define _BUILD_GRAPHICSPATH_H_
#include "AggPlusEnums.h"
#include "../agg-2.4/include/agg_basics.h"
#include "../agg-2.4/include/agg_path_storage.h"
#include "../agg-2.4/include/agg_rasterizer_scanline_aa.h"
#include "../agg-2.4/include/agg_conv_transform.h"
#include "../agg-2.4/include/agg_conv_stroke.h"
#include "../agg-2.4/include/agg_conv_contour.h"
#include "../agg-2.4/include/agg_conv_unclose_polygon.h"
#include "../agg-2.4/include/agg_bezier_arc.h"
#include "../agg-2.4/include/agg_conv_curve.h"
#include "../agg-2.4/include/agg_renderer_base.h"
#include "../agg-2.4/include/agg_renderer_scanline.h"
#include "IRenderer.h"
#include "Matrix.h"
#include "structures.h"
#include "../fontengine/FontManager.h"
namespace Aggplus
{
class CGraphicsPath : public ISimpleGraphicsPath
{
friend class CClip;
friend class CFontManager;
friend class CGraphics;
class CGraphicsPath_private;
class CGraphicsPath : public ISimpleGraphicsPath
{
public:
CGraphicsPath();
~CGraphicsPath();
public:
CGraphicsPath();
~CGraphicsPath();
CGraphicsPath* Clone();
CGraphicsPath* Clone();
Status Reset();
void SetRuler(bool bEvenOdd);
Status Reset();
void SetRuler(bool bEvenOdd);
Status StartFigure();
Status CloseFigure();
bool Is_poly_closed();
Status MoveTo(double x, double y);
Status LineTo(double x, double y);
Status CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
Status StartFigure();
Status CloseFigure();
bool Is_poly_closed();
Status MoveTo(double x, double y);
Status LineTo(double x, double y);
Status CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
// методы, которые просто будем сводить к трем основным
Status AddLine(double x1, double y1, double x2, double y2);
Status AddLines(double* pPoints, int nCount);
Status AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
Status AddBeziers(double* pPoints, int nCount);
Status AddCurve(double* pPoints, int nCount);
Status AddEllipse(double x, double y, double width, double height);
Status AddRectangle(double x, double y, double width, double height);
Status AddPolygon(double* pPoints, int nCount);
Status AddPath(const CGraphicsPath& oPath);
Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle);
Status AddLine(double x1, double y1, double x2, double y2);
Status AddLines(double* pPoints, int nCount);
ULONG GetPointCount() const;
Status GetPathPoints(PointF* points, int count) const;
Status GetLastPoint(double& x, double& y);
Status GetPathPoints(double* points, int count) const;
void GetBounds(double& left, double& top, double& width, double& height);
// методы, которые просто будем сводить к трем основным
Status AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
Status AddBeziers(double* pPoints, int nCount);
Status AddCurve(double* pPoints, int nCount);
Status AddEllipse(double x, double y, double width, double height);
Status AddRectangle(double x, double y, double width, double height);
Status AddPolygon(double* pPoints, int nCount);
Status AddPath(const CGraphicsPath& oPath);
Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle);
ULONG GetPointCount() const;
Status GetPathPoints(PointF* points, int count) const;
Status GetLastPoint(double& x, double& y);
Status GetPathPoints(double* points, int count) const;
void GetBounds(double& left, double& top, double& width, double& height);
Status Transform(const CMatrix* matrix);
virtual bool _MoveTo(double x, double y);
virtual bool _LineTo(double x, double y);
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
virtual bool _Close();
Status AddString(const std::wstring& strText, CFontManager* pFont, double x, double y);
Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, CFontManager* pFont, double x, double y);
Status AddStringC(const LONG& lText, CFontManager* pFont, double x, double y);
void z_Stroke(const NSStructures::CPen* Pen);
void Widen(const NSStructures::CPen* Pen, const CMatrix* matrix, float flatness);
agg::path_storage *z_get_agg_path_storage();
Status Transform(const CMatrix* matrix);
virtual bool _MoveTo(double x, double y);
virtual bool _LineTo(double x, double y);
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
virtual bool _Close();
public:
agg::path_storage m_agg_ps;
bool m_bEvenOdd;
bool m_bIsMoveTo;
Status AddString(const std::wstring& strText, CFontManager* pFont, double x, double y);
Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, CFontManager* pFont, double x, double y);
Status AddStringC(const LONG& lText, CFontManager* pFont, double x, double y);
void z_Stroke(const double& size);
void Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness);
CMatrix* m_pTransform;
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE);
int Ellipse(double fX, double fY, double fXRad, double fYRad);
Status AddArc2(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
public:
public:
CGraphicsPath_private* m_internal;
};
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE);
int Ellipse(double fX, double fY, double fXRad, double fYRad);
Status AddArc2(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
};
class CGraphicsPathSimpleConverter_private;
class CGraphicsPathSimpleConverter : public ISimpleGraphicsPath
{
private:
IRenderer* m_pRenderer;
CGraphicsPathSimpleConverter_private* m_internal;
class CGraphicsPathSimpleConverter : public ISimpleGraphicsPath
{
friend class CFontManager;
private:
IRenderer* m_pRenderer;
public:
CGraphicsPathSimpleConverter();
~CGraphicsPathSimpleConverter();
bool m_bEvenOdd;
bool m_bIsMoveTo;
bool m_bIsClosed;
public:
void SetRenderer(IRenderer* pRenderer);
IRenderer* GetRenderer(INT bIsAddref = FALSE);
agg::path_storage m_agg_ps;
public:
bool PathCommandMoveTo(double fX, double fY);
bool PathCommandLineTo(double fX, double fY);
bool PathCommandLinesTo(double* pPoints, LONG lCount);
bool PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3);
bool PathCommandCurvesTo(double* pData, LONG lCount);
bool PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
bool PathCommandClose();
bool PathCommandEnd();
bool PathCommandStart();
bool PathCommandGetCurrentPoint(double* fX, double* fY);
bool PathCommandText(const std::wstring& bsText, CFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset);
bool PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, CFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags);
public:
CGraphicsPathSimpleConverter();
~CGraphicsPathSimpleConverter();
bool PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, CFontManager* pManager,
const double& x, const double& y, const double& w, const double& h);
bool PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, CFontManager* pManager,
const double& x, const double& y, const double& w, const double& h);
public:
void SetRenderer(IRenderer* pRenderer);
IRenderer* GetRenderer(INT bIsAddref = FALSE);
bool PathCommandGetBounds(double& left, double& top, double& width, double &height);
public:
bool PathCommandMoveTo(double fX, double fY);
bool PathCommandLineTo(double fX, double fY);
bool PathCommandLinesTo(double* pPoints, LONG lCount);
bool PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3);
bool PathCommandCurvesTo(double* pData, LONG lCount);
bool PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
bool PathCommandClose();
bool PathCommandEnd();
bool PathCommandStart();
bool PathCommandGetCurrentPoint(double* fX, double* fY);
bool PathCommandText(const std::wstring& bsText, CFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset);
bool PathCommandTextEx(std::wstring& bsText, std::wstring& bsGidText, CFontManager* pManager, double fX, double fY, double fWidth, double fHeight, double fBaseLineOffset, DWORD lFlags);
public:
bool PathCommandText2(const int* pUnicodes, const int* pGids, const int& nCount, CFontManager* pManager,
const double& x, const double& y, const double& w, const double& h);
bool PathCommandText2(const std::wstring& sUnicodes, const int* pGids, const int& nCount, CFontManager* pManager,
const double& x, const double& y, const double& w, const double& h);
virtual bool _MoveTo(double x, double y);
virtual bool _LineTo(double x, double y);
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
virtual bool _Close();
bool _Reset();
bool _Start();
bool PathCommandGetBounds(double& left, double& top, double& width, double &height);
public:
protected:
bool AddString(const std::wstring& bstrText, CFontManager* pFont, double x, double y);
virtual bool _MoveTo(double x, double y);
virtual bool _LineTo(double x, double y);
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
virtual bool _Close();
bool _Reset();
bool _Start();
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE);
int Ellipse(double fX, double fY, double fXRad, double fYRad);
protected:
bool AddString(const std::wstring& bstrText, CFontManager* pFont, double x, double y);
bool AddArc(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection = FALSE);
int Ellipse(double fX, double fY, double fXRad, double fYRad);
bool AddArc(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
bool Is_poly_closed();
};
bool Is_poly_closed();
};
}
#endif // _BUILD_GRAPHICSPATH_H_

View File

@ -0,0 +1,91 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _BUILD_GRAPHICSPATH_PRIVATE_H_
#define _BUILD_GRAPHICSPATH_PRIVATE_H_
#include "../agg-2.4/include/agg_basics.h"
#include "../agg-2.4/include/agg_path_storage.h"
#include "../agg-2.4/include/agg_rasterizer_scanline_aa.h"
#include "../agg-2.4/include/agg_conv_transform.h"
#include "../agg-2.4/include/agg_conv_stroke.h"
#include "../agg-2.4/include/agg_conv_contour.h"
#include "../agg-2.4/include/agg_conv_unclose_polygon.h"
#include "../agg-2.4/include/agg_bezier_arc.h"
#include "../agg-2.4/include/agg_conv_curve.h"
#include "../agg-2.4/include/agg_renderer_base.h"
#include "../agg-2.4/include/agg_renderer_scanline.h"
#include "GraphicsPath.h"
#include "Matrix_private.h"
namespace Aggplus
{
class CGraphicsPath_private
{
public:
agg::path_storage m_agg_ps;
bool m_bEvenOdd;
bool m_bIsMoveTo;
CMatrix* m_pTransform;
public:
CGraphicsPath_private()
{
m_bEvenOdd = false;
m_bIsMoveTo = false;
m_pTransform = NULL;
}
};
class CGraphicsPathSimpleConverter_private
{
public:
bool m_bEvenOdd;
bool m_bIsMoveTo;
bool m_bIsClosed;
agg::path_storage m_agg_ps;
public:
CGraphicsPathSimpleConverter_private()
{
m_bEvenOdd = false;
m_bIsMoveTo = false;
m_bIsClosed = false;
}
};
}
#endif // _BUILD_GRAPHICSPATH_PRIVATE_H_

View File

@ -1132,13 +1132,13 @@ HRESULT CGraphicsRenderer::CommandString(const LONG& lType, const std::wstring&
HRESULT CGraphicsRenderer::StartConvertCoordsToIdentity()
{
m_bUseTransformCoordsToIdentity = true;
m_pPath->m_pTransform = m_pRenderer->GetFullTransform();
m_pPath->m_internal->m_pTransform = m_pRenderer->GetFullTransform();
return S_OK;
}
HRESULT CGraphicsRenderer::EndConvertCoordsToIdentity()
{
m_bUseTransformCoordsToIdentity = false;
m_pPath->m_pTransform = NULL;
m_pPath->m_internal->m_pTransform = NULL;
return S_OK;
}

View File

@ -301,8 +301,8 @@ public:
inline void SetCoordTransformOffset(double dOffsetX, double dOffsetY)
{
Aggplus::CMatrix* pCoord = m_pRenderer->GetCoordTransform();
pCoord->m_agg_mtx.tx = dOffsetX;
pCoord->m_agg_mtx.ty = dOffsetY;
pCoord->m_internal->m_agg_mtx.tx = dOffsetX;
pCoord->m_internal->m_agg_mtx.ty = dOffsetY;
m_pRenderer->CalculateFullTransform();
}

View File

@ -29,36 +29,46 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "Matrix.h"
#include "Matrix_private.h"
namespace Aggplus
{
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy) : m_agg_mtx(m11, m12, m21, m22, dx, dy)
CMatrix::CMatrix(double m11, double m12, double m21, double m22, double dx, double dy)
{
m_internal = new CMatrix_private();
m_internal->m_agg_mtx.sx = m11;
m_internal->m_agg_mtx.shy = m12;
m_internal->m_agg_mtx.shx = m21;
m_internal->m_agg_mtx.sy = m22;
m_internal->m_agg_mtx.tx = dx;
m_internal->m_agg_mtx.ty = dy;
}
CMatrix::CMatrix(const CMatrix& oSrc) : m_agg_mtx()
CMatrix::CMatrix(const CMatrix& oSrc)
{
m_agg_mtx = oSrc.m_agg_mtx;
m_internal = new CMatrix_private();
m_internal->m_agg_mtx = oSrc.m_internal->m_agg_mtx;
}
CMatrix::CMatrix() : m_agg_mtx()
CMatrix::CMatrix()
{
m_internal = new CMatrix_private();
}
CMatrix::~CMatrix()
{
RELEASEOBJECT(m_internal);
}
void CMatrix::Translate(double offsetX, double offsetY, MatrixOrder order)
{
if (order == MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
m_internal->m_agg_mtx.premultiply(agg::trans_affine_translation(offsetX, offsetY));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
m_internal->m_agg_mtx.multiply(agg::trans_affine_translation(offsetX, offsetY));
}
}
@ -66,11 +76,11 @@ namespace Aggplus
{
if (order == MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
m_internal->m_agg_mtx.premultiply(agg::trans_affine_scaling(scaleX, scaleY));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
m_internal->m_agg_mtx.multiply(agg::trans_affine_scaling(scaleX, scaleY));
}
}
@ -78,36 +88,36 @@ namespace Aggplus
{
if (order == MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
m_internal->m_agg_mtx.premultiply(agg::trans_affine_skewing(shearX, shearY));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
m_internal->m_agg_mtx.multiply(agg::trans_affine_skewing(shearX, shearY));
}
}
void CMatrix::TransformVectors(PointF* pts, int count)
{
// Store matrix to an array [6] of double
double M[6]; m_agg_mtx.store_to(M);
double M[6]; m_internal->m_agg_mtx.store_to(M);
for(int i = 0; i < count; ++i)
for (int i = 0; i < count; ++i)
{
double x =pts[i].X;
double y =pts[i].Y;
m_agg_mtx.transform(&x, &y);
pts[i].X =(float)(x-M[4]);
pts[i].Y =(float)(y-M[5]);
double x = pts[i].X;
double y = pts[i].Y;
m_internal->m_agg_mtx.transform(&x, &y);
pts[i].X = (float)(x-M[4]);
pts[i].Y = (float)(y-M[5]);
}
}
void CMatrix::TransformPoints(PointF* pts, int count)
{
for(int i = 0; i < count; ++i)
for (int i = 0; i < count; ++i)
{
double x = pts[i].X;
double y = pts[i].Y;
m_agg_mtx.transform(&x, &y);
m_internal->m_agg_mtx.transform(&x, &y);
pts[i].X = (float)x;
pts[i].Y = (float)y;
}
@ -115,18 +125,18 @@ namespace Aggplus
void CMatrix::TransformPoint(double& x, double& y)
{
m_agg_mtx.transform(&x, &y);
m_internal->m_agg_mtx.transform(&x, &y);
}
void CMatrix::Rotate(double angle, MatrixOrder order)
{
if (order == MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
}
@ -135,11 +145,11 @@ namespace Aggplus
Translate(-center.X, -center.Y, order);
if(order == MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
Translate(center.X, center.Y, order);
return;
@ -150,11 +160,11 @@ namespace Aggplus
Translate(-x, -y, order);
if (order == MatrixOrderPrepend)
{
m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
m_internal->m_agg_mtx.premultiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
else
{
m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
m_internal->m_agg_mtx.multiply(agg::trans_affine_rotation(agg::deg2rad(angle)));
}
Translate(x, y, order);
}
@ -163,28 +173,26 @@ namespace Aggplus
{
if (order == MatrixOrderPrepend)
{
m_agg_mtx.premultiply(matrix->m_agg_mtx);
m_internal->m_agg_mtx.premultiply(matrix->m_internal->m_agg_mtx);
}
else
{
m_agg_mtx.multiply(matrix->m_agg_mtx);
m_internal->m_agg_mtx.multiply(matrix->m_internal->m_agg_mtx);
}
}
double CMatrix::OffsetX() const
{
double M[6]; m_agg_mtx.store_to(M);
return (M[4]);
return m_internal->m_agg_mtx.tx;
}
double CMatrix::OffsetY() const
{
double M[6]; m_agg_mtx.store_to(M);
return (M[5]);
return m_internal->m_agg_mtx.ty;
}
Status CMatrix::GetElements(REAL* m) const
{
double M[6]; m_agg_mtx.store_to(M);
double M[6]; m_internal->m_agg_mtx.store_to(M);
m[0]=(REAL)M[0];
m[1]=(REAL)M[1];
m[2]=(REAL)M[2];
@ -196,28 +204,28 @@ namespace Aggplus
Status CMatrix::GetElements(double* m) const
{
m_agg_mtx.store_to(m);
m_internal->m_agg_mtx.store_to(m);
return Ok;
}
void CMatrix::Reset()
{
m_agg_mtx.reset();
m_internal->m_agg_mtx.reset();
}
const CMatrix& CMatrix::operator=(const CMatrix& Src)
{
m_agg_mtx = Src.m_agg_mtx;
return *this;
m_internal->m_agg_mtx = Src.m_internal->m_agg_mtx;
return *this;
}
Status CMatrix::Invert()
{
double d = m_agg_mtx.determinant();
double d = m_internal->m_agg_mtx.determinant();
if (0.0001 >= fabs(d))
return InvalidParameter;
m_agg_mtx.invert();
m_internal->m_agg_mtx.invert();
return Ok;
}
@ -225,15 +233,16 @@ namespace Aggplus
//Used in X_BrushLinearGradient constructor
double CMatrix::z_Rotation() const
{
return agg::rad2deg(m_agg_mtx.rotation());
return agg::rad2deg(m_internal->m_agg_mtx.rotation());
}
void CMatrix::TransformPoints( PointF* dst, const PointF* src, int count ) const
void CMatrix::TransformPoints( PointF* dst, const PointF* src, int count )
{
agg::trans_affine& m = m_internal->m_agg_mtx;
for(int i = 0; i < count; ++i)
{
double x = src[i].X * m_agg_mtx.sx + src[i].Y * m_agg_mtx.shx + m_agg_mtx.tx;
double y = src[i].Y * m_agg_mtx.sy + src[i].X * m_agg_mtx.shy + m_agg_mtx.ty;
double x = src[i].X * m.sx + src[i].Y * m.shx + m.tx;
double y = src[i].Y * m.sy + src[i].X * m.shy + m.ty;
dst[i].X = (float)x;
dst[i].Y = (float)y;
@ -242,13 +251,14 @@ namespace Aggplus
bool CMatrix::IsIdentity() const
{
return m_agg_mtx.is_identity();
return m_internal->m_agg_mtx.is_identity();
}
bool CMatrix::IsIdentity2() const
{
return agg::is_equal_eps(m_agg_mtx.sx, 1.0, agg::affine_epsilon) &&
agg::is_equal_eps(m_agg_mtx.shy, 0.0, agg::affine_epsilon) &&
agg::is_equal_eps(m_agg_mtx.shx, 0.0, agg::affine_epsilon) &&
agg::is_equal_eps(m_agg_mtx.sy, 1.0, agg::affine_epsilon);
agg::trans_affine& m = m_internal->m_agg_mtx;
return agg::is_equal_eps(m.sx, 1.0, agg::affine_epsilon) &&
agg::is_equal_eps(m.shy, 0.0, agg::affine_epsilon) &&
agg::is_equal_eps(m.shx, 0.0, agg::affine_epsilon) &&
agg::is_equal_eps(m.sy, 1.0, agg::affine_epsilon);
}
}
}

View File

@ -33,61 +33,53 @@
#define _BUILD_MATRIX_H_
#include "AggPlusEnums.h"
#include "../agg-2.4/include/agg_trans_affine.h"
namespace Aggplus
{
class CMatrix_private;
class CMatrix
{
public:
CMatrix(double m11, double m12, double m21, double m22, double dx, double dy);
CMatrix();
CMatrix(const CMatrix& oSrc);
class CMatrix
{
friend class CGraphics;
friend class CGraphicsPath;
~CMatrix();
public:
CMatrix(double m11, double m12, double m21, double m22, double dx, double dy);
CMatrix();
CMatrix(const CMatrix& oSrc);
~CMatrix();
void Translate(double offsetX, double offsetY, MatrixOrder order = MatrixOrderPrepend);
void Scale(double scaleX, double scaleY, MatrixOrder order = MatrixOrderPrepend);
void Shear(double shearX, double shearY, MatrixOrder order = MatrixOrderPrepend);
void Translate(double offsetX, double offsetY, MatrixOrder order = MatrixOrderPrepend);
void Scale(double scaleX, double scaleY, MatrixOrder order = MatrixOrderPrepend);
void Shear(double shearX, double shearY, MatrixOrder order = MatrixOrderPrepend);
void TransformVectors(PointF* pts, int count);
void TransformPoints(PointF* pts, int count);
void TransformPoint(double& x, double& y);
void TransformVectors(PointF* pts, int count);
void TransformPoints(PointF* pts, int count);
void TransformPoint(double& x, double& y);
void TransformPoints(PointF* dst, const PointF* src, int count);
void Rotate(double angle, MatrixOrder order = MatrixOrderPrepend);
void RotateAt(double angle, const PointF &center, MatrixOrder order = MatrixOrderPrepend);
void RotateAt(double angle, double x, double y, MatrixOrder order = MatrixOrderPrepend);
void Rotate(double angle, MatrixOrder order = MatrixOrderPrepend);
void RotateAt(double angle, const PointF &center, MatrixOrder order = MatrixOrderPrepend);
void RotateAt(double angle, double x, double y, MatrixOrder order = MatrixOrderPrepend);
void Multiply(const CMatrix* matrix, MatrixOrder order = MatrixOrderPrepend);
void Multiply(const CMatrix* matrix, MatrixOrder order = MatrixOrderPrepend);
double OffsetX() const;
double OffsetY() const;
Status GetElements(float* m) const;
Status GetElements(double* m) const;
double OffsetX() const;
double OffsetY() const;
void Reset();
bool IsIdentity() const;
bool IsIdentity2() const;
Status GetElements(float* m) const;
Status GetElements(double* m) const;
const CMatrix& operator=(const CMatrix& Src);
void Reset();
bool IsIdentity() const;
bool IsIdentity2() const;
Status Invert();
const CMatrix& operator=(const CMatrix& Src);
//Temp
//Used in X_BrushLinearGradient constructor
double z_Rotation() const;
Status Invert();
void TransformPoints( PointF* dst, const PointF* src, int count ) const;
public:
agg::trans_affine m_agg_mtx;
};
double z_Rotation() const;
public:
CMatrix_private* m_internal;
};
}
#endif // _BUILD_MATRIX_H_
#endif // _BUILD_MATRIX_H_

View File

@ -0,0 +1,52 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _BUILD_MATRIX_PRIVATE_H_
#define _BUILD_MATRIX_PRIVATE_H_
#include "Matrix.h"
#include "../agg-2.4/include/agg_trans_affine.h"
namespace Aggplus
{
class CMatrix_private
{
public:
agg::trans_affine m_agg_mtx;
public:
CMatrix_private() : m_agg_mtx()
{
}
};
}
#endif // _BUILD_MATRIX_PRIVATE_H_

View File

@ -57,6 +57,16 @@ INCLUDEPATH += \
$$LIB_GRAPHICS_PRI_PATH/cximage/png \
$$LIB_GRAPHICS_PRI_PATH/cximage/zlib
HEADERS += \
./../Matrix.h \
./../Matrix_private.h \
./../GraphicsPath.h \
./../GraphicsPath_private.h
SOURCES += \
./../Matrix.cpp \
./../GraphicsPath.cpp
SOURCES += $$PWD/graphics_pri.cpp
SOURCES += $$LIB_GRAPHICS_PRI_PATH/freetype-2.5.2/src/base/ftbbox.c \