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: ...@@ -85,6 +85,8 @@ public:
BOOL IsAngleScalable() const; BOOL IsAngleScalable() const;
BOOL IsRectable() const; BOOL IsRectable() const;
float GetAngle() const; float GetAngle() const;
inline void SetBounds(const CDoubleRect& oRect) { Bounds = oRect; }
inline CDoubleRect& GetBounds() { return Bounds; }
protected: protected:
CColor m_colors[2]; CColor m_colors[2];
...@@ -101,6 +103,8 @@ protected: ...@@ -101,6 +103,8 @@ protected:
CMatrix m_matrix; CMatrix m_matrix;
float m_angle; // p1 -> p2 float m_angle; // p1 -> p2
CDoubleRect Bounds;
Aggplus::WrapMode m_wrap; Aggplus::WrapMode m_wrap;
BOOL m_bAngleScalable; // b = arctan( width / height * tan(angle) ); BOOL m_bAngleScalable; // b = arctan( width / height * tan(angle) );
......
...@@ -1114,41 +1114,107 @@ namespace Aggplus ...@@ -1114,41 +1114,107 @@ namespace Aggplus
void CGraphics::DoFillPathGradient(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform) void CGraphics::DoFillPathGradient(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform)
{ {
Aggplus::CColor LinearColor[2]; CDoubleRect& oBounds = pBrush->GetBounds();
pBrush->GetLinearColors( LinearColor );
Aggplus::RectF BrushRect; CMatrix oMatrix;
pBrush->GetRectangle( &BrushRect );
agg::rect_d rect( BrushRect.GetLeft(), BrushRect.GetTop(), BrushRect.GetRight(), BrushRect.GetBottom() ); agg::rect_d rect;
if( pBrush->IsRelativeCoords() ) 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 x = m_rasterizer.get_rasterizer().min_x();
int y = m_rasterizer.get_rasterizer().min_y(); int y = m_rasterizer.get_rasterizer().min_y();
int width = m_rasterizer.get_rasterizer().max_x() - m_rasterizer.get_rasterizer().min_x(); 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(); int height = m_rasterizer.get_rasterizer().max_y() - m_rasterizer.get_rasterizer().min_y();
rect.x1 = rect.x1 * width + x; rect.x1 = x;
rect.x2 = rect.x2 * width + x; rect.x2 = x + width;
rect.y1 = rect.y1 * height + y; rect.y1 = y;
rect.y2 = rect.y2 * height + y; rect.y2 = y + height;
} }
typedef agg::my_span_gradient<agg::rgba8> gradient_span_gen; typedef agg::my_span_gradient<agg::rgba8> gradient_span_gen;
gradient_span_gen 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);
agg::rgba8* pSubColors = NULL;
float* pSubBlends = NULL;
int nCountSubColors = pBrush->GetInterpolationColorsCount();
if( nCountSubColors > 0 )
{
pSubColors = new agg::rgba8[nCountSubColors];
pSubBlends = new float[nCountSubColors];
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 );
}
}
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;
}
if( pBrush->IsRectable() ) void CGraphics::DoFillPathGradient2(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform)
span_gen.SetDirection( rect, (float)dLinearAngle, pBrush->IsAngleScalable() ); {
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 else
span_gen.SetDirection( rect ); {
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();
agg::rgba8 c1(LinearColor[0].GetB(), LinearColor[0].GetG(), LinearColor[0].GetR(), LinearColor[0].GetA()); rect.x1 = x;
agg::rgba8 c2(LinearColor[1].GetB(), LinearColor[1].GetG(), LinearColor[1].GetR(), LinearColor[1].GetA()); 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.SetColors( c1, c2 ); span_gen.SetDirection(rect, oMatrix.m_agg_mtx);
span_gen.SetWrapMode( pBrush->GetWrapMode() & 1 );
agg::rgba8* pSubColors = NULL; agg::rgba8* pSubColors = NULL;
float* pSubBlends = NULL; float* pSubBlends = NULL;
...@@ -1172,10 +1238,6 @@ namespace Aggplus ...@@ -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; typedef agg::span_allocator<gradient_span_gen::color_type> gradient_span_alloc;
gradient_span_alloc span_alloc; gradient_span_alloc span_alloc;
...@@ -1438,14 +1500,14 @@ namespace Aggplus ...@@ -1438,14 +1500,14 @@ namespace Aggplus
} }
} }
} }
else if (Brush->GetType() == BrushTypePathGradient)
{
return;
}
else if (Brush->GetType() == BrushTypeLinearGradient) else if (Brush->GetType() == BrushTypeLinearGradient)
{ {
DoFillPathGradient((CBrushLinearGradient*)Brush); DoFillPathGradient((CBrushLinearGradient*)Brush);
} }
else if (Brush->GetType() == BrushTypePathGradient)
{
DoFillPathGradient2((CBrushLinearGradient*)Brush);
}
} }
// text methods // text methods
......
...@@ -144,102 +144,6 @@ public: ...@@ -144,102 +144,6 @@ public:
virtual BOOL Create(LONG lWidth, LONG lHeight, double dDPIX, double dDPIY) = 0; 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 class CGraphics
{ {
...@@ -397,6 +301,7 @@ protected: ...@@ -397,6 +301,7 @@ protected:
void DoFillPathSolid(CColor dwColor); void DoFillPathSolid(CColor dwColor);
void DoFillPathGradient(CBrushLinearGradient *pBrush, const agg::trans_affine* pGlobalTransform = NULL); 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 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 DoFillPathTextureClampSz2(const CMatrix &mImgMtx, const void *pImgBuff, DWORD dwImgWidth, DWORD dwImgHeight, int nImgStride);
void DoFillPath(const CBrush* Brush); void DoFillPath(const CBrush* Brush);
......
...@@ -60,8 +60,13 @@ namespace Aggplus ...@@ -60,8 +60,13 @@ namespace Aggplus
delete [] pColors; delete [] pColors;
delete [] pBlends; delete [] pBlends;
} }
pNew->SetBounds(pBrush->Bounds);
} }
if (pNew && c_BrushTypePathGradient2 == Type)
pNew->m_bType = BrushTypePathGradient;
return pNew; return pNew;
} }
else else
...@@ -463,6 +468,14 @@ HRESULT CGraphicsRenderer::BrushRect(const BOOL& val, const double& left, const ...@@ -463,6 +468,14 @@ HRESULT CGraphicsRenderer::BrushRect(const BOOL& val, const double& left, const
m_oBrush.Rect.Height = (float)height; m_oBrush.Rect.Height = (float)height;
return S_OK; 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) HRESULT CGraphicsRenderer::put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount)
{ {
m_oBrush.m_arrSubColors.RemoveAll(); m_oBrush.m_arrSubColors.RemoveAll();
...@@ -1025,6 +1038,7 @@ void CGraphicsRenderer::_SetFont() ...@@ -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->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; m_oInstalledFont = m_oFont;
} }
......
...@@ -127,6 +127,7 @@ public: ...@@ -127,6 +127,7 @@ public:
virtual HRESULT get_BrushLinearAngle(double* dAngle); virtual HRESULT get_BrushLinearAngle(double* dAngle);
virtual HRESULT put_BrushLinearAngle(const 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 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); virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
// font ------------------------------------------------------------------------------------- // font -------------------------------------------------------------------------------------
......
...@@ -169,6 +169,7 @@ public: ...@@ -169,6 +169,7 @@ public:
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0; virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
virtual HRESULT put_BrushLinearAngle(const 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 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; virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount) = 0;
......
...@@ -179,6 +179,103 @@ public: ...@@ -179,6 +179,103 @@ public:
typedef RectF_T<REAL> RectF; typedef RectF_T<REAL> RectF;
typedef RectF_T<int> Rect; 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 } //namespace Aggplus
#endif // _AGGPLUSTYPES_H #endif // _AGGPLUSTYPES_H
\ No newline at end of file
...@@ -226,6 +226,7 @@ namespace NSStructures ...@@ -226,6 +226,7 @@ namespace NSStructures
int Rectable; int Rectable;
Aggplus::RectF Rect; Aggplus::RectF Rect;
Aggplus::CDoubleRect Bounds;
double LinearAngle; double LinearAngle;
...@@ -350,6 +351,11 @@ namespace NSStructures ...@@ -350,6 +351,11 @@ namespace NSStructures
Rect.Width = 0.0F; Rect.Width = 0.0F;
Rect.Height = 0.0F; Rect.Height = 0.0F;
Bounds.left = 0;
Bounds.top = 0;
Bounds.right = 0;
Bounds.bottom = 0;
m_arrSubColors.RemoveAll(); m_arrSubColors.RemoveAll();
} }
...@@ -375,6 +381,8 @@ namespace NSStructures ...@@ -375,6 +381,8 @@ namespace NSStructures
Rectable = other.Rectable; Rectable = other.Rectable;
Rect = other.Rect; Rect = other.Rect;
Bounds = other.Bounds;
LinearAngle = other.LinearAngle; LinearAngle = other.LinearAngle;
m_arrSubColors = other.m_arrSubColors; m_arrSubColors = other.m_arrSubColors;
} }
...@@ -393,6 +401,7 @@ namespace NSStructures ...@@ -393,6 +401,7 @@ namespace NSStructures
Rectable = other.Rectable; Rectable = other.Rectable;
Rect = other.Rect; Rect = other.Rect;
Bounds = other.Bounds;
LinearAngle = other.LinearAngle; LinearAngle = other.LinearAngle;
m_arrSubColors = other.m_arrSubColors; 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