aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_buffer.c')
-rw-r--r--libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_buffer.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_buffer.c b/libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_buffer.c
new file mode 100644
index 0000000..7ef9211
--- /dev/null
+++ b/libraries/evas/src/modules/engines/software_ddraw/evas_ddraw_buffer.c
@@ -0,0 +1,92 @@
1#include <string.h>
2
3#include "evas_common.h"
4#include "evas_engine.h"
5
6
7DD_Output_Buffer *
8evas_software_ddraw_output_buffer_new(int depth,
9 int width,
10 int height,
11 void *data)
12{
13 DD_Output_Buffer *ddob;
14
15 ddob = calloc(1, sizeof(DD_Output_Buffer));
16 if (!ddob) return NULL;
17
18 ddob->data = data;
19 ddob->depth = depth;
20 ddob->width = width;
21 ddob->height = height;
22 ddob->pitch = width * depth / 8;
23 ddob->psize = ddob->pitch * height;
24
25 if (!ddob->data)
26 {
27 ddob->data = malloc(ddob->pitch * height);
28 if (!ddob->data)
29 {
30 free(ddob);
31 return NULL;
32 }
33 }
34
35 return ddob;
36}
37
38void
39evas_software_ddraw_output_buffer_free(DD_Output_Buffer *ddob)
40{
41 if (ddob->data) free(ddob->data);
42 free(ddob);
43}
44
45void
46evas_software_ddraw_output_buffer_paste(DD_Output_Buffer *ddob,
47 void *ddraw_data,
48 int ddraw_width,
49 int ddraw_height,
50 int ddraw_pitch,
51 int ddraw_depth,
52 int x,
53 int y)
54{
55 DATA8 *dd_data;
56 DATA8 *evas_data;
57 int width;
58 int height;
59 int pitch;
60 int j;
61
62 if ((x >= ddraw_width) || (y >= ddraw_height))
63 return;
64
65 /* compute the size of the data to copy on the back surface */
66 width = ((x + ddob->width) > ddraw_width)
67 ? ddraw_width - x
68 : ddob->width;
69 height = ((y + ddob->height) > ddraw_height)
70 ? ddraw_height - y
71 : ddob->height;
72 pitch = width * ddob->depth / 8;
73
74 dd_data = (DATA8 *)ddraw_data + y * ddraw_pitch + x * ddraw_depth;
75 evas_data = (unsigned char *)ddob->data;
76 for (j = 0; j < height; j++, evas_data += ddob->pitch, dd_data += ddraw_pitch)
77 memcpy(dd_data, evas_data, pitch);
78}
79
80DATA8 *
81evas_software_ddraw_output_buffer_data(DD_Output_Buffer *ddob,
82 int *bytes_per_line_ret)
83{
84 if (bytes_per_line_ret) *bytes_per_line_ret = ddob->pitch;
85 return ddob->data;
86}
87
88int
89evas_software_ddraw_output_buffer_depth(DD_Output_Buffer *ddob)
90{
91 return ddob->depth;
92}