commit fc99add

Michael Forney  ·  2013-09-07 00:12:39 +0000 UTC
parent 134e4da
Add write operation
5 files changed,  +31, -0
M wld.h
+5, -0
 1@@ -106,6 +106,11 @@ void wld_destroy_drawable(struct wld_drawable * drawable)
 2     drawable->interface->destroy(drawable);
 3 }
 4 
 5+void wld_write(struct wld_drawable * drawable, const void * data, size_t size)
 6+{
 7+    drawable->interface->write(drawable, data, size);
 8+}
 9+
10 void wld_flush(struct wld_drawable * drawable)
11 {
12     drawable->interface->flush(drawable);
+11, -0
 1@@ -62,6 +62,8 @@ static void intel_draw_text_utf8(struct wld_drawable * drawable,
 2                                  int32_t x, int32_t y,
 3                                  const char * text, int32_t length,
 4                                  struct wld_extents * extents);
 5+static void intel_write(struct wld_drawable * drawable,
 6+                        const void * data, size_t size);
 7 static void intel_flush(struct wld_drawable * drawable);
 8 static void intel_destroy(struct wld_drawable * drawable);
 9 
10@@ -86,6 +88,7 @@ const static struct wld_draw_interface intel_draw = {
11     .copy_rectangle = &intel_copy_rectangle,
12     .copy_region = &default_copy_region,
13     .draw_text_utf8 = &intel_draw_text_utf8,
14+    .write = &intel_write,
15     .flush = &intel_flush,
16     .destroy = &intel_destroy
17 };
18@@ -300,6 +303,14 @@ static void intel_draw_text_utf8(struct wld_drawable * drawable,
19         extents->advance = origin_x - x;
20 }
21 
22+static void intel_write(struct wld_drawable * drawable,
23+                        const void * data, size_t size)
24+{
25+    struct intel_drawable * intel = (void *) drawable;
26+
27+    drm_intel_bo_subdata(intel->bo, 0, size, data);
28+}
29+
30 static void intel_flush(struct wld_drawable * drawable)
31 {
32     struct intel_drawable * intel = (void *) drawable;
+11, -0
 1@@ -65,6 +65,8 @@ static void pixman_draw_text_utf8(struct wld_drawable * drawable,
 2                                   int32_t x, int32_t y,
 3                                   const char * text, int32_t length,
 4                                   struct wld_extents * extents);
 5+static void pixman_write(struct wld_drawable * drawable,
 6+                         const void * data, size_t size);
 7 static void pixman_flush(struct wld_drawable * drawable);
 8 static void pixman_destroy(struct wld_drawable * drawable);
 9 
10@@ -74,6 +76,7 @@ const static struct wld_draw_interface pixman_draw = {
11     .copy_rectangle = &pixman_copy_rectangle,
12     .copy_region = &pixman_copy_region,
13     .draw_text_utf8 = &pixman_draw_text_utf8,
14+    .write = &pixman_write,
15     .flush = &pixman_flush,
16     .destroy = &pixman_destroy
17 };
18@@ -301,6 +304,14 @@ static void pixman_draw_text_utf8(struct wld_drawable * drawable,
19         extents->advance = origin_x;
20 }
21 
22+static void pixman_write(struct wld_drawable * drawable,
23+                         const void * data, size_t size)
24+{
25+    struct pixman_drawable * pixman = (void *) drawable;
26+
27+    memcpy(pixman_image_get_data(pixman->image), data, size);
28+}
29+
30 static void pixman_flush(struct wld_drawable * drawable)
31 {
32 }
+2, -0
1@@ -96,6 +96,8 @@ struct wld_draw_interface
2                             int32_t x, int32_t y,
3                             const char * text, int32_t length,
4                             struct wld_extents * extents);
5+    void (* write)(struct wld_drawable * drawable,
6+                   const void * data, size_t size);
7     void (* flush)(struct wld_drawable * drawable);
8     void (* destroy)(struct wld_drawable * drawable);
9 };
M wld.h
+2, -0
1@@ -161,6 +161,8 @@ static inline void wld_draw_text_utf8(struct wld_drawable * drawable,
2     wld_draw_text_utf8_n(drawable, font, color, x, y, text, INT32_MAX, extents);
3 }
4 
5+void wld_write(struct wld_drawable * drawable, const void * data, size_t size);
6+
7 void wld_flush(struct wld_drawable * drawable);
8 
9 #endif