summaryrefslogtreecommitdiff
path: root/xfa/include/fxgraphics/fx_graphics.h
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/include/fxgraphics/fx_graphics.h')
-rw-r--r--xfa/include/fxgraphics/fx_graphics.h241
1 files changed, 103 insertions, 138 deletions
diff --git a/xfa/include/fxgraphics/fx_graphics.h b/xfa/include/fxgraphics/fx_graphics.h
index c22d00995e..c2d22719d9 100644
--- a/xfa/include/fxgraphics/fx_graphics.h
+++ b/xfa/include/fxgraphics/fx_graphics.h
@@ -101,115 +101,96 @@ class CFX_DIBitmap;
class CFX_Font;
class CFX_WideString;
class CFX_PathGenerator;
-class CAGG_Graphics;
class CFX_Graphics;
class CFX_Color;
class CFX_Path;
class CFX_Pattern;
class CFX_Shading;
+
+class CAGG_Graphics {
+ public:
+ CAGG_Graphics();
+ virtual ~CAGG_Graphics();
+
+ FX_ERR Create(CFX_Graphics* owner,
+ int32_t width,
+ int32_t height,
+ FXDIB_Format format);
+
+ private:
+ CFX_Graphics* m_owner;
+};
+
class CFX_Graphics {
public:
CFX_Graphics();
+ virtual ~CFX_Graphics();
FX_ERR Create(CFX_RenderDevice* renderDevice, FX_BOOL isAntialiasing = TRUE);
-
FX_ERR Create(int32_t width,
int32_t height,
FXDIB_Format format,
FX_BOOL isNative = TRUE,
FX_BOOL isAntialiasing = TRUE);
- virtual ~CFX_Graphics();
-
FX_ERR GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal);
FX_ERR IsPrinterDevice(FX_BOOL& isPrinter);
FX_ERR EnableAntialiasing(FX_BOOL isAntialiasing);
FX_ERR SaveGraphState();
-
FX_ERR RestoreGraphState();
- FX_ERR GetLineCap(CFX_GraphStateData::LineCap& lineCap);
+ FX_ERR GetLineCap(CFX_GraphStateData::LineCap& lineCap) const;
+ FX_ERR GetDashCount(int32_t& dashCount) const;
+ FX_ERR GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const;
+ FX_ERR GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const;
+ FX_ERR GetMiterLimit(FX_FLOAT& miterLimit) const;
+ FX_ERR GetLineWidth(FX_FLOAT& lineWidth) const;
+ FX_ERR GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const;
+ FX_ERR GetClipRect(CFX_RectF& rect) const;
+ CFX_Matrix* GetMatrix();
+ CFX_RenderDevice* GetRenderDevice();
FX_ERR SetLineCap(CFX_GraphStateData::LineCap lineCap);
-
- FX_ERR GetDashCount(int32_t& dashCount);
-
- FX_ERR GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray);
-
FX_ERR SetLineDash(FX_FLOAT dashPhase,
FX_FLOAT* dashArray,
int32_t dashCount);
-
FX_ERR SetLineDash(FX_DashStyle dashStyle);
-
- FX_ERR GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin);
-
FX_ERR SetLineJoin(CFX_GraphStateData::LineJoin lineJoin);
-
- FX_ERR GetMiterLimit(FX_FLOAT& miterLimit);
-
FX_ERR SetMiterLimit(FX_FLOAT miterLimit);
-
- FX_ERR GetLineWidth(FX_FLOAT& lineWidth);
-
FX_ERR SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE);
-
- FX_ERR GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment);
-
FX_ERR SetStrokeAlignment(FX_StrokeAlignment strokeAlignment);
-
FX_ERR SetStrokeColor(CFX_Color* color);
-
FX_ERR SetFillColor(CFX_Color* color);
+ FX_ERR SetClipRect(const CFX_RectF& rect);
+ FX_ERR SetFont(CFX_Font* font);
+ FX_ERR SetFontSize(const FX_FLOAT size);
+ FX_ERR SetFontHScale(const FX_FLOAT scale);
+ FX_ERR SetCharSpacing(const FX_FLOAT spacing);
+ FX_ERR SetTextDrawingMode(const int32_t mode);
FX_ERR StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL);
-
FX_ERR FillPath(CFX_Path* path,
FX_FillMode fillMode = FXFILL_WINDING,
CFX_Matrix* matrix = NULL);
-
FX_ERR ClipPath(CFX_Path* path,
FX_FillMode fillMode = FXFILL_WINDING,
CFX_Matrix* matrix = NULL);
-
FX_ERR DrawImage(CFX_DIBSource* source,
const CFX_PointF& point,
CFX_Matrix* matrix = NULL);
-
FX_ERR StretchImage(CFX_DIBSource* source,
const CFX_RectF& rect,
CFX_Matrix* matrix = NULL);
-
FX_ERR ConcatMatrix(const CFX_Matrix* matrix);
-
- CFX_Matrix* GetMatrix();
-
- FX_ERR GetClipRect(CFX_RectF& rect);
-
- FX_ERR SetClipRect(const CFX_RectF& rect);
-
FX_ERR ClearClip();
-
- FX_ERR SetFont(CFX_Font* font);
-
- FX_ERR SetFontSize(const FX_FLOAT size);
-
- FX_ERR SetFontHScale(const FX_FLOAT scale);
-
- FX_ERR SetCharSpacing(const FX_FLOAT spacing);
-
- FX_ERR SetTextDrawingMode(const int32_t mode);
-
FX_ERR ShowText(const CFX_PointF& point,
const CFX_WideString& text,
CFX_Matrix* matrix = NULL);
-
FX_ERR CalcTextRect(CFX_RectF& rect,
const CFX_WideString& text,
FX_BOOL isMultiline = FALSE,
CFX_Matrix* matrix = NULL);
-
FX_ERR Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix);
FX_ERR Transfer(CFX_Graphics* graphics,
FX_FLOAT srcLeft,
@@ -217,44 +198,36 @@ class CFX_Graphics {
const CFX_RectF& dstRect,
const CFX_Matrix* matrix);
- CFX_RenderDevice* GetRenderDevice();
-
FX_ERR InverseRect(const CFX_RectF& rect);
FX_ERR XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
FX_ERR EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect);
private:
FX_ERR RenderDeviceSetLineDash(FX_DashStyle dashStyle);
-
FX_ERR RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix);
-
FX_ERR RenderDeviceFillPath(CFX_Path* path,
FX_FillMode fillMode,
CFX_Matrix* matrix);
-
FX_ERR RenderDeviceDrawImage(CFX_DIBSource* source,
const CFX_PointF& point,
CFX_Matrix* matrix);
-
FX_ERR RenderDeviceStretchImage(CFX_DIBSource* source,
const CFX_RectF& rect,
CFX_Matrix* matrix);
-
FX_ERR RenderDeviceShowText(const CFX_PointF& point,
const CFX_WideString& text,
CFX_Matrix* matrix);
FX_ERR StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix);
-
FX_ERR StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix);
FX_ERR FillPathWithPattern(CFX_Path* path,
FX_FillMode fillMode,
CFX_Matrix* matrix);
-
FX_ERR FillPathWithShading(CFX_Path* path,
FX_FillMode fillMode,
CFX_Matrix* matrix);
+
FX_ERR SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix);
FX_ERR CalcTextInfo(const CFX_WideString& text,
FX_DWORD* charCodes,
@@ -262,57 +235,64 @@ class CFX_Graphics {
CFX_RectF& rect);
protected:
- int32_t _type;
+ int32_t m_type;
private:
struct TInfo {
- CFX_GraphStateData _graphState;
- FX_BOOL _isAntialiasing;
- FX_StrokeAlignment _strokeAlignment;
- CFX_Matrix _CTM;
- FX_BOOL _isActOnDash;
- CFX_Color* _strokeColor;
- CFX_Color* _fillColor;
- CFX_Font* _font;
- FX_FLOAT _fontSize;
- FX_FLOAT _fontHScale;
- FX_FLOAT _fontSpacing;
- } _info;
- CFX_RenderDevice* _renderDevice;
- CFX_PtrArray _infoStack;
- CAGG_Graphics* _aggGraphics;
+ TInfo()
+ : isAntialiasing(TRUE),
+ strokeAlignment(FX_STROKEALIGNMENT_Center),
+ isActOnDash(FALSE),
+ strokeColor(nullptr),
+ fillColor(nullptr),
+ font(nullptr),
+ fontSize(40.0),
+ fontHScale(1.0),
+ fontSpacing(0.0) {}
+ explicit TInfo(const TInfo& info);
+ TInfo& operator=(const TInfo& other);
+
+ CFX_GraphStateData graphState;
+ FX_BOOL isAntialiasing;
+ FX_StrokeAlignment strokeAlignment;
+ CFX_Matrix CTM;
+ FX_BOOL isActOnDash;
+ CFX_Color* strokeColor;
+ CFX_Color* fillColor;
+ CFX_Font* font;
+ FX_FLOAT fontSize;
+ FX_FLOAT fontHScale;
+ FX_FLOAT fontSpacing;
+ } m_info;
+ CFX_RenderDevice* m_renderDevice;
+ CFX_PtrArray m_infoStack;
+ CAGG_Graphics* m_aggGraphics;
friend class CAGG_Graphics;
};
+
class CFX_Path {
public:
CFX_Path();
-
- FX_ERR Create();
-
virtual ~CFX_Path();
+ FX_ERR Create();
FX_ERR MoveTo(FX_FLOAT x, FX_FLOAT y);
-
FX_ERR LineTo(FX_FLOAT x, FX_FLOAT y);
-
FX_ERR BezierTo(FX_FLOAT ctrlX1,
FX_FLOAT ctrlY1,
FX_FLOAT ctrlX2,
FX_FLOAT ctrlY2,
FX_FLOAT toX,
FX_FLOAT toY);
-
FX_ERR ArcTo(FX_FLOAT left,
FX_FLOAT top,
FX_FLOAT width,
FX_FLOAT height,
FX_FLOAT startAngle,
FX_FLOAT sweepAngle);
-
FX_ERR Close();
FX_ERR AddLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2);
-
FX_ERR AddBezier(FX_FLOAT startX,
FX_FLOAT startY,
FX_FLOAT ctrlX1,
@@ -321,116 +301,105 @@ class CFX_Path {
FX_FLOAT ctrlY2,
FX_FLOAT endX,
FX_FLOAT endY);
-
FX_ERR AddRectangle(FX_FLOAT left,
FX_FLOAT top,
FX_FLOAT width,
FX_FLOAT height);
-
FX_ERR AddEllipse(FX_FLOAT left,
FX_FLOAT top,
FX_FLOAT width,
FX_FLOAT height);
-
FX_ERR AddEllipse(const CFX_RectF& rect);
-
FX_ERR AddArc(FX_FLOAT left,
FX_FLOAT top,
FX_FLOAT width,
FX_FLOAT height,
FX_FLOAT startAngle,
FX_FLOAT sweepAngle);
-
FX_ERR AddPie(FX_FLOAT left,
FX_FLOAT top,
FX_FLOAT width,
FX_FLOAT height,
FX_FLOAT startAngle,
FX_FLOAT sweepAngle);
-
FX_ERR AddSubpath(CFX_Path* path);
-
FX_ERR Clear();
FX_BOOL IsEmpty();
-
CFX_PathData* GetPathData();
private:
- CFX_PathGenerator* _generator;
+ CFX_PathGenerator* m_generator;
};
+
class CFX_Color {
public:
CFX_Color();
-
+ // TODO(weili): Remove implicit conversions. Make this explicit.
CFX_Color(const FX_ARGB argb);
-
- CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb = 0x0);
-
- CFX_Color(CFX_Shading* shading);
-
+ explicit CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb = 0x0);
+ explicit CFX_Color(CFX_Shading* shading);
virtual ~CFX_Color();
FX_ERR Set(const FX_ARGB argb);
-
FX_ERR Set(CFX_Pattern* pattern, const FX_ARGB argb = 0x0);
-
FX_ERR Set(CFX_Shading* shading);
private:
- int32_t _type;
+ int32_t m_type;
union {
struct {
- FX_ARGB _argb;
- CFX_Pattern* _pattern;
- };
- CFX_Shading* _shading;
+ FX_ARGB argb;
+ CFX_Pattern* pattern;
+ } m_info;
+ CFX_Shading* m_shading;
};
friend class CFX_Graphics;
};
+
class CFX_Pattern {
public:
CFX_Pattern();
+ virtual ~CFX_Pattern();
FX_ERR Create(CFX_DIBitmap* bitmap,
const FX_FLOAT xStep,
const FX_FLOAT yStep,
CFX_Matrix* matrix = NULL);
-
FX_ERR Create(FX_HatchStyle hatchStyle,
const FX_ARGB foreArgb,
const FX_ARGB backArgb,
CFX_Matrix* matrix = NULL);
- virtual ~CFX_Pattern();
-
private:
- int32_t _type;
- CFX_Matrix _matrix;
+ int32_t m_type;
+ CFX_Matrix m_matrix;
union {
struct {
- CFX_RectF _rect;
- FX_FLOAT _xStep;
- FX_FLOAT _yStep;
- FX_BOOL _isColored;
- };
+ CFX_RectF rect;
+ FX_FLOAT xStep;
+ FX_FLOAT yStep;
+ FX_BOOL isColored;
+ } m_rectInfo;
struct {
- CFX_DIBitmap* _bitmap;
- FX_FLOAT _x1Step;
- FX_FLOAT _y1Step;
- };
+ CFX_DIBitmap* bitmap;
+ FX_FLOAT x1Step;
+ FX_FLOAT y1Step;
+ } m_bitmapInfo;
struct {
- FX_HatchStyle _hatchStyle;
- FX_ARGB _foreArgb;
- FX_ARGB _backArgb;
- };
+ FX_HatchStyle hatchStyle;
+ FX_ARGB foreArgb;
+ FX_ARGB backArgb;
+ } m_hatchInfo;
};
friend class CFX_Graphics;
};
+
class CFX_Shading {
public:
CFX_Shading();
+ virtual ~CFX_Shading();
FX_ERR CreateAxial(const CFX_PointF& beginPoint,
const CFX_PointF& endPoint,
@@ -438,7 +407,6 @@ class CFX_Shading {
FX_BOOL isExtendedEnd,
const FX_ARGB beginArgb,
const FX_ARGB endArgb);
-
FX_ERR CreateRadial(const CFX_PointF& beginPoint,
const CFX_PointF& endPoint,
const FX_FLOAT beginRadius,
@@ -448,22 +416,19 @@ class CFX_Shading {
const FX_ARGB beginArgb,
const FX_ARGB endArgb);
- virtual ~CFX_Shading();
-
private:
FX_ERR InitArgbArray();
- private:
- int32_t _type;
- CFX_PointF _beginPoint;
- CFX_PointF _endPoint;
- FX_FLOAT _beginRadius;
- FX_FLOAT _endRadius;
- FX_BOOL _isExtendedBegin;
- FX_BOOL _isExtendedEnd;
- FX_ARGB _beginArgb;
- FX_ARGB _endArgb;
- FX_ARGB _argbArray[FX_SHADING_Steps];
+ int32_t m_type;
+ CFX_PointF m_beginPoint;
+ CFX_PointF m_endPoint;
+ FX_FLOAT m_beginRadius;
+ FX_FLOAT m_endRadius;
+ FX_BOOL m_isExtendedBegin;
+ FX_BOOL m_isExtendedEnd;
+ FX_ARGB m_beginArgb;
+ FX_ARGB m_endArgb;
+ FX_ARGB m_argbArray[FX_SHADING_Steps];
friend class CFX_Graphics;
};