Commit 1522ea30 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54926 954022d7-b5bf-4e40-9824-e11837661b57
parent 285175d0
......@@ -85,6 +85,8 @@ public:
BOOL IsAngleScalable() const;
BOOL IsRectable() const;
float GetAngle() const;
inline void SetBounds(const CDoubleRect& oRect) { Bounds = oRect; }
inline CDoubleRect& GetBounds() { return Bounds; }
protected:
CColor m_colors[2];
......@@ -101,10 +103,12 @@ protected:
CMatrix m_matrix;
float m_angle; // p1 -> p2
CDoubleRect Bounds;
Aggplus::WrapMode m_wrap;
BOOL m_bAngleScalable; // b = arctan( width / height * tan(angle) );
BOOL m_bRectable; //
BOOL m_bAngleScalable; // b = arctan( width / height * tan(angle) );
BOOL m_bRectable; //
BOOL m_bRelativeCoords; //
};
......
......@@ -1114,41 +1114,107 @@ namespace Aggplus
void CGraphics::DoFillPathGradient(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform)
{
Aggplus::CColor LinearColor[2];
pBrush->GetLinearColors( LinearColor );
CDoubleRect& oBounds = pBrush->GetBounds();
Aggplus::RectF BrushRect;
pBrush->GetRectangle( &BrushRect );
CMatrix oMatrix;
agg::rect_d rect( BrushRect.GetLeft(), BrushRect.GetTop(), BrushRect.GetRight(), BrushRect.GetBottom() );
if( pBrush->IsRelativeCoords() )
agg::rect_d rect;
if (oBounds.GetWidth() > FLT_EPSILON || oBounds.GetHeight() > FLT_EPSILON)
{
rect.x1 = oBounds.left;
rect.y1 = oBounds.top;
rect.x2 = oBounds.right;
rect.y2 = oBounds.bottom;
oMatrix = m_oFullTransform;
oMatrix.Invert();
}
else
{
int x = m_rasterizer.get_rasterizer().min_x();
int y = m_rasterizer.get_rasterizer().min_y();
int width = m_rasterizer.get_rasterizer().max_x() - m_rasterizer.get_rasterizer().min_x();
int height = m_rasterizer.get_rasterizer().max_y() - m_rasterizer.get_rasterizer().min_y();
rect.x1 = rect.x1 * width + x;
rect.x2 = rect.x2 * width + x;
rect.y1 = rect.y1 * height + y;
rect.y2 = rect.y2 * height + y;
rect.x1 = x;
rect.x2 = x + width;
rect.y1 = y;
rect.y2 = y + height;
}
typedef agg::my_span_gradient<agg::rgba8> gradient_span_gen;
gradient_span_gen span_gen;
double dLinearAngle = m_oTransform.z_Rotation() + pBrush->GetAngle();
span_gen.SetDirection(rect, (double)pBrush->GetAngle(), oMatrix.m_agg_mtx);
if( pBrush->IsRectable() )
span_gen.SetDirection( rect, (float)dLinearAngle, pBrush->IsAngleScalable() );
else
span_gen.SetDirection( rect );
agg::rgba8* pSubColors = NULL;
float* pSubBlends = NULL;
int nCountSubColors = pBrush->GetInterpolationColorsCount();
if( nCountSubColors > 0 )
{
pSubColors = new agg::rgba8[nCountSubColors];
pSubBlends = new float[nCountSubColors];
agg::rgba8 c1(LinearColor[0].GetB(), LinearColor[0].GetG(), LinearColor[0].GetR(), LinearColor[0].GetA());
agg::rgba8 c2(LinearColor[1].GetB(), LinearColor[1].GetG(), LinearColor[1].GetR(), LinearColor[1].GetA());
if( pSubColors && pSubBlends )
{
for( int i = 0; i < nCountSubColors; i++ )
{
CColor c;
pBrush->GetSubColor( i, &c, &pSubBlends[i] );
pSubColors[i] = agg::rgba8(c.GetB(), c.GetG(), c.GetR(), c.GetA());
}
span_gen.SetSubColors( pSubColors, pSubBlends, nCountSubColors );
}
}
span_gen.SetColors( c1, c2 );
span_gen.SetWrapMode( pBrush->GetWrapMode() & 1 );
typedef agg::span_allocator<gradient_span_gen::color_type> gradient_span_alloc;
gradient_span_alloc span_alloc;
typedef agg::renderer_scanline_aa<base_renderer_type, gradient_span_alloc, gradient_span_gen> renderer_gradient_type;
renderer_gradient_type ren_gradient( m_frame_buffer.ren_base(), span_alloc, span_gen );
render_scanlines(ren_gradient);
if( pSubColors ) delete [] pSubColors;
if( pSubBlends ) delete [] pSubBlends;
}
void CGraphics::DoFillPathGradient2(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform)
{
CDoubleRect& oBounds = pBrush->GetBounds();
CMatrix oMatrix;
agg::rect_d rect;
if (oBounds.GetWidth() > FLT_EPSILON || oBounds.GetHeight() > FLT_EPSILON)
{
rect.x1 = oBounds.left;
rect.y1 = oBounds.top;
rect.x2 = oBounds.right;
rect.y2 = oBounds.bottom;
oMatrix = m_oFullTransform;
oMatrix.Invert();
}
else
{
int x = m_rasterizer.get_rasterizer().min_x();
int y = m_rasterizer.get_rasterizer().min_y();
int width = m_rasterizer.get_rasterizer().max_x() - m_rasterizer.get_rasterizer().min_x();
int height = m_rasterizer.get_rasterizer().max_y() - m_rasterizer.get_rasterizer().min_y();
rect.x1 = x;
rect.x2 = x + width;
rect.y1 = y;
rect.y2 = y + height;
}
typedef agg::my_span_path_gradient<agg::rgba8> gradient_span_gen;
gradient_span_gen span_gen;
span_gen.SetDirection(rect, oMatrix.m_agg_mtx);
agg::rgba8* pSubColors = NULL;
float* pSubBlends = NULL;
......@@ -1172,10 +1238,6 @@ namespace Aggplus
}
}
//agg::rgba8 clrs[5] = {c1, agg::rgba8( 0, 255, 0, 255 ), agg::rgba8( 255, 255, 0, 255 ), agg::rgba8( 128, 0, 128, 255 ), c2};
//float pos[5] = {0.f, 0.25f, 0.5f, 0.75f, 1.f};
//span_gen.SetSubColors( clrs, pos, 5 );
typedef agg::span_allocator<gradient_span_gen::color_type> gradient_span_alloc;
gradient_span_alloc span_alloc;
......@@ -1438,14 +1500,14 @@ namespace Aggplus
}
}
}
else if (Brush->GetType() == BrushTypePathGradient)
{
return;
}
else if (Brush->GetType() == BrushTypeLinearGradient)
{
DoFillPathGradient((CBrushLinearGradient*)Brush);
}
else if (Brush->GetType() == BrushTypePathGradient)
{
DoFillPathGradient2((CBrushLinearGradient*)Brush);
}
}
// text methods
......
......@@ -144,102 +144,6 @@ public:
virtual BOOL Create(LONG lWidth, LONG lHeight, double dDPIX, double dDPIY) = 0;
};
class CDoublePoint
{
public:
double x;
double y;
public:
CDoublePoint()
{
x = 0;
y = 0;
}
CDoublePoint(double dx, double dy)
{
x = dx;
y = dy;
}
CDoublePoint& operator=(const CDoublePoint& oSrc)
{
x = oSrc.x;
y = oSrc.y;
return *this;
}
CDoublePoint(const CDoublePoint& oSrc)
{
*this = oSrc;
}
};
class CDoubleRect
{
public:
double left;
double top;
double right;
double bottom;
public:
CDoubleRect()
{
left = 0;
top = 0;
right = 0;
bottom = 0;
}
CDoubleRect& operator=(const CDoubleRect& oSrc)
{
left = oSrc.left;
top = oSrc.top;
right = oSrc.right;
bottom = oSrc.bottom;
return *this;
}
CDoubleRect(const CDoubleRect& oSrc)
{
*this = oSrc;
}
inline double GetWidth() const
{
return right - left;
}
inline double GetHeight() const
{
return bottom - top;
}
inline void Offset(double dX, double dY)
{
left += dX;
top += dY;
right += dX;
bottom += dY;
}
inline double GetCentreX() const
{
return (left + right) / 2.0;
}
inline double GetCentreY() const
{
return (top + bottom) / 2.0;
}
inline BOOL IsPointInside(const CDoublePoint& oPoint)
{
return IsPointInside(oPoint.x, oPoint.y);
}
BOOL IsPointInside(const double& pointX, const double& pointY)
{
return ((left <= pointX) && (right >= pointX) &&
(top <= pointY) && (bottom >= pointY));
}
};
class CGraphics
{
......@@ -397,6 +301,7 @@ protected:
void DoFillPathSolid(CColor dwColor);
void DoFillPathGradient(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform = NULL);
void DoFillPathGradient2(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform = NULL);
void DoFillPathTextureClampSz(const CMatrix &mImgMtx, const void *pImgBuff, DWORD dwImgWidth, DWORD dwImgHeight, int nImgStride);
void DoFillPathTextureClampSz2(const CMatrix &mImgMtx, const void *pImgBuff, DWORD dwImgWidth, DWORD dwImgHeight, int nImgStride);
void DoFillPath(const CBrush* Brush);
......
......@@ -60,8 +60,13 @@ namespace Aggplus
delete [] pColors;
delete [] pBlends;
}
pNew->SetBounds(pBrush->Bounds);
}
if (pNew && c_BrushTypePathGradient2 == Type)
pNew->m_bType = BrushTypePathGradient;
return pNew;
}
else
......@@ -463,6 +468,14 @@ HRESULT CGraphicsRenderer::BrushRect(const BOOL& val, const double& left, const
m_oBrush.Rect.Height = (float)height;
return S_OK;
}
HRESULT CGraphicsRenderer::BrushBounds(const double& left, const double& top, const double& width, const double& height)
{
m_oBrush.Bounds.left = left;
m_oBrush.Bounds.top = top;
m_oBrush.Bounds.right = left + width;
m_oBrush.Bounds.bottom = top + height;
return S_OK;
}
HRESULT CGraphicsRenderer::put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount)
{
m_oBrush.m_arrSubColors.RemoveAll();
......@@ -1025,6 +1038,7 @@ void CGraphicsRenderer::_SetFont()
{
m_pFontManager->LoadFontFromFile(m_oFont.Path, m_oFont.FaceIndex, m_oFont.Size, m_pRenderer->GetDpiX(), m_pRenderer->GetDpiY());
}
m_pFontManager->m_oString.ResetCTM();
m_oInstalledFont = m_oFont;
}
......
......@@ -127,6 +127,7 @@ public:
virtual HRESULT get_BrushLinearAngle(double* dAngle);
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
virtual HRESULT BrushRect(const BOOL& val, const double& left, const double& top, const double& width, const double& height);
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
// font -------------------------------------------------------------------------------------
......
......@@ -169,6 +169,7 @@ public:
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
virtual HRESULT BrushRect(const BOOL& val, const double& left, const double& top, const double& width, const double& height) = 0;
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount) = 0;
......
......@@ -179,6 +179,103 @@ public:
typedef RectF_T<REAL> RectF;
typedef RectF_T<int> Rect;
class CDoublePoint
{
public:
double x;
double y;
public:
CDoublePoint()
{
x = 0;
y = 0;
}
CDoublePoint(double dx, double dy)
{
x = dx;
y = dy;
}
CDoublePoint& operator=(const CDoublePoint& oSrc)
{
x = oSrc.x;
y = oSrc.y;
return *this;
}
CDoublePoint(const CDoublePoint& oSrc)
{
*this = oSrc;
}
};
class CDoubleRect
{
public:
double left;
double top;
double right;
double bottom;
public:
CDoubleRect()
{
left = 0;
top = 0;
right = 0;
bottom = 0;
}
CDoubleRect& operator=(const CDoubleRect& oSrc)
{
left = oSrc.left;
top = oSrc.top;
right = oSrc.right;
bottom = oSrc.bottom;
return *this;
}
CDoubleRect(const CDoubleRect& oSrc)
{
*this = oSrc;
}
inline double GetWidth() const
{
return right - left;
}
inline double GetHeight() const
{
return bottom - top;
}
inline void Offset(double dX, double dY)
{
left += dX;
top += dY;
right += dX;
bottom += dY;
}
inline double GetCentreX() const
{
return (left + right) / 2.0;
}
inline double GetCentreY() const
{
return (top + bottom) / 2.0;
}
inline BOOL IsPointInside(const CDoublePoint& oPoint)
{
return IsPointInside(oPoint.x, oPoint.y);
}
BOOL IsPointInside(const double& pointX, const double& pointY)
{
return ((left <= pointX) && (right >= pointX) &&
(top <= pointY) && (bottom >= pointY));
}
};
} //namespace Aggplus
#endif // _AGGPLUSTYPES_H
\ No newline at end of file
......@@ -225,7 +225,8 @@ namespace NSStructures
long TextureMode;
int Rectable;
Aggplus::RectF Rect;
Aggplus::RectF Rect;
Aggplus::CDoubleRect Bounds;
double LinearAngle;
......@@ -350,6 +351,11 @@ namespace NSStructures
Rect.Width = 0.0F;
Rect.Height = 0.0F;
Bounds.left = 0;
Bounds.top = 0;
Bounds.right = 0;
Bounds.bottom = 0;
m_arrSubColors.RemoveAll();
}
......@@ -375,6 +381,8 @@ namespace NSStructures
Rectable = other.Rectable;
Rect = other.Rect;
Bounds = other.Bounds;
LinearAngle = other.LinearAngle;
m_arrSubColors = other.m_arrSubColors;
}
......@@ -393,6 +401,7 @@ namespace NSStructures
Rectable = other.Rectable;
Rect = other.Rect;
Bounds = other.Bounds;
LinearAngle = other.LinearAngle;
m_arrSubColors = other.m_arrSubColors;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment