You.i Engine
YiPolygonFill.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_POLYGON_FILL_H_
3 #define _YI_POLYGON_FILL_H_
4 
5 #include "framework/YiPredef.h"
6 #include <glm/gtc/type_ptr.hpp>
7 
8 class CYIBitmap;
9 class CYIColor;
10 class CYIGradient;
11 
21 {
22  float x;
23  float y;
25  YI_POLYGON_VERTEX() : x(0), y(0), bStartOfSegment(false) {}
26 };
27 
32 typedef std::vector<YI_POLYGON_VERTEX> CYIPolygonData;
33 
45 {
46 
47 public:
48  static const uint32_t MAX_EDGES = 1000;
49 
51  virtual ~CYIPolygonFill();
52 
56  bool Create(int32_t nWidth, int32_t nHeight);
57 
61  void Destroy();
62 
75  void Fill(CYIBitmap *pBitmap, const CYIPolygonData *pPolygonData, const glm::vec4 &bounds, const CYIColor &Color, CYIGradient *pGradient, bool bNonZeroFill);
76 
83  static void PolygonDataBounds(const CYIPolygonData &polygonDataIn, glm::vec4 &polygonBounds);
84 
85 private:
86 
87  typedef struct
88  {
89  int32_t nFirstLine;
90  int32_t nLastLine;
91  float fxX;
92  float fxSlope;
93  int32_t nWinding;
94  }
95  YI_POLY_EDGE;
96 
97  uint32_t GetEdges(const CYIPolygonData *pPolygonData, uint32_t nVertexStart);
98 
99  void MaskEdge(YI_POLY_EDGE *pEdge, bool bNonZeroFill);
100  void InternalFill(CYIBitmap *pBitmap, const CYIColor &Color, CYIGradient *pGradient, bool bNonZeroFill);
101 
102  uint32_t *m_pMask;
103  int32_t *m_pWinding;
104  uint32_t *m_pGradientLUT;
105  int32_t m_nGradientLUTSize;
106  YI_POLY_EDGE *m_pEdges;
107  int32_t m_nWidth;
108  int32_t m_nHeight;
109  glm::vec4 m_Bounds;
110 
112 };
113 
118 #endif // _YI_POLYGON_FILL_H_
#define YI_DISALLOW_COPY_AND_ASSIGN(TypeName)
Delete the copy constructor and assignment operator (and consequently the move constructor as well) ...
Definition: YiPredef.h:114
bool bStartOfSegment
Definition: YiPolygonFill.h:24
The core bitmap container class used by You.i Engine.
Definition: YiBitmap.h:20
std::vector< YI_POLYGON_VERTEX > CYIPolygonData
A type representing multiple vertices of a polygon.
Definition: YiPolygonFill.h:32
Contains information on how a gradient will be drawn.
Definition: YiGradient.h:18
A structure that describe a single vertex of a polygon.
Definition: YiPolygonFill.h:20
float x
Definition: YiPolygonFill.h:22
YI_POLYGON_VERTEX()
Definition: YiPolygonFill.h:25
A class used to represent a color value.
Definition: YiColor.h:31
float y
Definition: YiPolygonFill.h:23
A class that contains information on how to fill a polygon.
Definition: YiPolygonFill.h:44