summaryrefslogtreecommitdiff
path: root/src/lib/ector/software/ector_software_private.h
blob: a4d12219d09b1b29266adade78d9f38b9cd9c573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef ECTOR_SOFTWARE_PRIVATE_H_
# define ECTOR_SOFTWARE_PRIVATE_H_

#include "sw_ft_raster.h"
#include "sw_ft_stroker.h"

#ifndef DATA32
typedef unsigned int DATA32;
#endif

#ifndef uint
typedef unsigned int uint;
#endif

typedef struct _Ector_Software_Surface_Data Ector_Software_Surface_Data;

#define CHECK_SOFTWARE(Parent) (!(Parent && Parent->software))

// Gradient related structure
typedef struct _Software_Gradient_Linear_Data
{
   float x1, y1, x2, y2;
   float dx, dy, l, off;
} Software_Gradient_Linear_Data;

typedef struct _Software_Gradient_Radial_Data
{
   float cx, cy, fx, fy, cradius, fradius;
   float dx, dy, dr, sqrfr, a, inv2a;
   Eina_Bool extended;
} Software_Gradient_Radial_Data;

typedef struct _Ector_Renderer_Software_Gradient_Data
{
   Ector_Software_Surface_Data *surface;
   Ector_Renderer_Generic_Gradient_Data *gd;
   union {
      Ector_Renderer_Generic_Gradient_Linear_Data *gld;
      Ector_Renderer_Generic_Gradient_Radial_Data *grd;
   };
   union {
      Software_Gradient_Linear_Data linear;
      Software_Gradient_Radial_Data radial;
   };
   Eina_Bool alpha;
   uint* color_table;
} Ector_Renderer_Software_Gradient_Data;


// Rasterizer related structure
typedef struct _Raster_Buffer
{
   int            width;
   int            height;
   DATA32        *buffer;
} Raster_Buffer;

typedef struct _Shape_Rle_Data
{
   Eina_Rectangle   bbox;
   unsigned short   alloc;
   unsigned short   size;
   SW_FT_Span      *spans;// array of Scanlines.
} Shape_Rle_Data;

typedef struct _Clip_Data
{
   Eina_Array           *clips; //Eina_Rectangle
   Shape_Rle_Data       *path;
   unsigned int          enabled : 1;
   unsigned int          has_rect_clip : 1;
   unsigned int          has_path_clip : 1;
} Clip_Data;


typedef enum _Span_Data_Type {
  None,
  Solid,
  LinearGradient,
  RadialGradient,
  Image
} Span_Data_Type;

typedef struct _Span_Data
{
   Raster_Buffer    raster_buffer;

   SW_FT_SpanFunc   blend;
   SW_FT_SpanFunc   unclipped_blend;

   int              offx, offy;
   Clip_Data        clip;
   Eina_Matrix3     inv;
   Span_Data_Type   type;
   Eina_Bool        fast_matrix ;
   DATA32           mul_col;
   Ector_Rop        op;
   union {
      DATA32 color;
      Ector_Renderer_Software_Gradient_Data *gradient;
      //ImageData    texture;
   };
} Span_Data;

struct _Software_Rasterizer
{
   SW_FT_Raster     raster;
   SW_FT_Stroker    stroker;

   Span_Data        fill_data;
   Eina_Matrix3    *transform;
   Eina_Rectangle   system_clip;

};

struct _Ector_Software_Surface_Data
{
   Software_Rasterizer *software;
   int x;
   int y;
};


void ector_software_rasterizer_init(Software_Rasterizer *rasterizer);
void ector_software_rasterizer_done(Software_Rasterizer *rasterizer);

void ector_software_rasterizer_stroke_set(Software_Rasterizer *rasterizer, double width,
                                          Efl_Gfx_Cap cap_style, Efl_Gfx_Join join_style);

void ector_software_rasterizer_transform_set(Software_Rasterizer *rasterizer, Eina_Matrix3 *t);
void ector_software_rasterizer_color_set(Software_Rasterizer *rasterizer, int r, int g, int b, int a);
void ector_software_rasterizer_linear_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *linear);
void ector_software_rasterizer_radial_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *radial);
void ector_software_rasterizer_clip_rect_set(Software_Rasterizer *rasterizer, Eina_Array *clips);
void ector_software_rasterizer_clip_shape_set(Software_Rasterizer *rasterizer, Shape_Rle_Data *clip);



Shape_Rle_Data * ector_software_rasterizer_generate_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline);
Shape_Rle_Data * ector_software_rasterizer_generate_stroke_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline, Eina_Bool closePath);

void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer, int x, int y, uint mul_col, Ector_Rop op, Shape_Rle_Data* rle);

void ector_software_rasterizer_destroy_rle_data(Shape_Rle_Data *rle);



// Gradient Api
void update_color_table(Ector_Renderer_Software_Gradient_Data *gdata);
void destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata);
void fetch_linear_gradient(uint *buffer, Span_Data *data, int y, int x, int length);
void fetch_radial_gradient(uint *buffer, Span_Data *data, int y, int x, int length);

#endif