sw_engine image: introduced scaled image raster logics.
[platform/core/graphics/tizenvg.git] / src / lib / sw_engine / tvgSwCommon.h
index b90b523..ce69e37 100644 (file)
@@ -98,15 +98,15 @@ struct SwSize
 
 struct SwOutline
 {
-    uint32_t*     cntrs;            //the contour end points
-    uint32_t      cntrsCnt;         //number of contours in glyph
-    uint32_t      reservedCntrsCnt;
     SwPoint*      pts;              //the outline's points
-    uint32_t      ptsCnt;           //number of points in the glyph
-    uint32_t      reservedPtsCnt;
+    uint16_t      ptsCnt;           //number of points in the glyph
+    uint16_t      reservedPtsCnt;
+    uint16_t*     cntrs;            //the contour end points
+    uint16_t      cntrsCnt;         //number of contours in glyph
+    uint16_t      reservedCntrsCnt;
     uint8_t*      types;            //curve type
+    bool*         closed;           //opened or closed path?
     FillRule      fillRule;
-    bool          opened;           //opened path?
 };
 
 struct SwSpan
@@ -142,9 +142,10 @@ struct SwFill
     };
 
     struct SwRadial {
-        float cx, cy;
+        float a11, a12, shiftX;
+        float a21, a22, shiftY;
+        float detSecDeriv;
         float a;
-        float inva;
     };
 
     union {
@@ -154,7 +155,6 @@ struct SwFill
 
     uint32_t* ctable;
     FillSpread spread;
-    float sx, sy;
 
     bool translucent;
 };
@@ -190,7 +190,7 @@ struct SwStroke
     float sx, sy;
 
     bool firstPt;
-    bool openSubPath;
+    bool closedSubPath;
     bool handleWideStrokes;
 };
 
@@ -215,7 +215,7 @@ struct SwShape
     SwRleData*   strokeRle = nullptr;
     SwBBox       bbox;           //Keep it boundary without stroke region. Using for optimal filling.
 
-    bool         rect = false;   //Fast Track: Othogonal rectangle?
+    bool         fastTrack = false;   //Fast Track: axis-aligned rectangle without any clips?
 };
 
 struct SwImage
@@ -223,13 +223,20 @@ struct SwImage
     SwOutline*   outline = nullptr;
     SwRleData*   rle = nullptr;
     uint32_t*    data = nullptr;
-    uint32_t     w, h;
+    uint32_t     w, h, stride;
+    int32_t      ox = 0;         //offset x
+    int32_t      oy = 0;         //offset y
+    float        scale;
+
+    bool         direct = false;  //draw image directly (with offset)
+    bool         scaled = false;  //draw scaled image
 };
 
 struct SwBlender
 {
     uint32_t (*join)(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
     uint32_t (*alpha)(uint32_t rgba);
+    uint32_t (*ialpha)(uint32_t rgba);
 };
 
 struct SwCompositor;
@@ -251,9 +258,9 @@ struct SwCompositor : Compositor
 
 struct SwMpool
 {
-    SwOutline* outline = nullptr;
-    SwOutline* strokeOutline = nullptr;
-    unsigned allocSize = 0;
+    SwOutline* outline;
+    SwOutline* strokeOutline;
+    unsigned allocSize;
 };
 
 static inline SwCoord TO_SWCOORD(float val)
@@ -274,11 +281,6 @@ static inline uint32_t COLOR_INTERPOLATE(uint32_t c1, uint32_t a1, uint32_t c2,
     return (c1 |= t);
 }
 
-static inline uint32_t ALPHA_MULTIPLY(uint32_t c, uint32_t a)
-{
-    return ((c * a + 0xff) >> 8);
-}
-
 static inline SwCoord HALF_STROKE(float width)
 {
     return TO_SWCOORD(width * 0.5f);
@@ -298,12 +300,13 @@ SwFixed mathLength(const SwPoint& pt);
 bool mathSmallCubic(const SwPoint* base, SwFixed& angleIn, SwFixed& angleMid, SwFixed& angleOut);
 SwFixed mathMean(SwFixed angle1, SwFixed angle2);
 SwPoint mathTransform(const Point* to, const Matrix* transform);
-bool mathUpdateOutlineBBox(const SwOutline* outline, const SwBBox& clipRegion, SwBBox& renderRegion);
+bool mathUpdateOutlineBBox(const SwOutline* outline, const SwBBox& clipRegion, SwBBox& renderRegion, bool fastTrack);
+bool mathClipBBox(const SwBBox& clipper, SwBBox& clipee);
 
 void shapeReset(SwShape* shape);
-bool shapePrepare(SwShape* shape, const Shape* sdata, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid);
+bool shapePrepare(SwShape* shape, const Shape* sdata, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool hasComposite);
 bool shapePrepared(const SwShape* shape);
-bool shapeGenRle(SwShape* shape, const Shape* sdata, bool antiAlias, bool hasComposite);
+bool shapeGenRle(SwShape* shape, const Shape* sdata, bool antiAlias);
 void shapeDelOutline(SwShape* shape, SwMpool* mpool, uint32_t tid);
 void shapeResetStroke(SwShape* shape, const Shape* sdata, const Matrix* transform);
 bool shapeGenStrokeRle(SwShape* shape, const Shape* sdata, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid);
@@ -322,7 +325,6 @@ SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid);
 void strokeFree(SwStroke* stroke);
 
 bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid);
-bool imagePrepared(const SwImage* image);
 bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwBBox& renderRegion, bool antiAlias);
 void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid);
 void imageReset(SwImage* image);
@@ -350,11 +352,12 @@ void mpoolRetStrokeOutline(SwMpool* mpool, unsigned idx);
 
 bool rasterCompositor(SwSurface* surface);
 bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id);
-bool rasterSolidShape(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
+bool rasterShape(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
 bool rasterImage(SwSurface* surface, SwImage* image, const Matrix* transform, const SwBBox& bbox, uint32_t opacity);
 bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
 bool rasterGradientStroke(SwSurface* surface, SwShape* shape, unsigned id);
 bool rasterClear(SwSurface* surface);
 void rasterRGBA32(uint32_t *dst, uint32_t val, uint32_t offset, int32_t len);
+void rasterUnpremultiply(SwSurface* surface);
 
 #endif /* _TVG_SW_COMMON_H_ */