m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2018-05-26 21:02:12 +0200
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2018-05-26 21:02:12 +0200
commit10b6807eb299677daf010288b4bb5bf06b2bb51d (patch)
tree12f59b2e98350c87fba130c4416cb50b10199c5b
parent0e125c3e6d2fafd6c2460e1859c29b9ece8b5eed (diff)
Draw spans
-rw-r--r--harddoomdev.h2
-rw-r--r--surface.c38
2 files changed, 40 insertions, 0 deletions
diff --git a/harddoomdev.h b/harddoomdev.h
index ab7a398..9381fd5 100644
--- a/harddoomdev.h
+++ b/harddoomdev.h
@@ -21,5 +21,7 @@ void copy_rect(struct surface_data *dst_data, struct surface_data *src_data,
struct doomdev_copy_rect rect);
void draw_column(struct surface_data *surface_data,
struct texture_data *texture_data, struct doomdev_column column);
+void draw_span(struct surface_data *surface_data, struct flat_data *flat_data,
+ struct doomdev_span span);
#endif
diff --git a/surface.c b/surface.c
index 688223a..779fd73 100644
--- a/surface.c
+++ b/surface.c
@@ -132,6 +132,42 @@ long draw_columns(struct file *filp, unsigned long arg)
return param->columns_num;
}
+long draw_spans(struct file *filp, unsigned long arg)
+{
+ struct doomdev_surf_ioctl_draw_spans *param;
+ struct surface_data *surface_data;
+ struct flat_data *flat_data;
+ struct doomdev_span *spans;
+ struct fd flat_fds;
+ int i;
+
+ surface_data = filp->private_data;
+
+ param = (struct doomdev_surf_ioctl_draw_spans *) arg;
+
+ flat_fds = fdget(param->flat_fd);
+ flat_data = flat_fds.file->private_data;
+
+ if (surface_data->doom_data != flat_data->doom_data) {
+ p("flat from different device\n");
+ return -EINVAL;
+ }
+
+ spans = (struct doomdev_span *) param->spans_ptr;
+
+ mutex_lock(&surface_data->doom_data->cmd_mutex);
+
+ for (i = 0; i < param->spans_num; i++) {
+ draw_span(surface_data, flat_data, spans[i]);
+ }
+
+ mutex_unlock(&surface_data->doom_data->cmd_mutex);
+
+ fdput(flat_fds);
+
+ return param->spans_num;
+}
+
long surface_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
switch (cmd) {
@@ -143,6 +179,8 @@ long surface_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return copy_rects(filp, arg);
case DOOMDEV_SURF_IOCTL_DRAW_COLUMNS:
return draw_columns(filp, arg);
+ case DOOMDEV_SURF_IOCTL_DRAW_SPANS:
+ return draw_spans(filp, arg);
default:
return -1;
}