commit 745ce8b

Michael Forney  ·  2014-11-02 01:12:07 +0000 UTC
parent c71dc18
Drop wld_draw_next_n

Instead, just document that the caller should pass -1 if the entire string is
to be drawn.
7 files changed,  +25, -26
M wld.h
+5, -2
 1@@ -272,8 +272,8 @@ void renderer_copy_rectangle(struct wld_renderer * base,
 2 
 3 void renderer_draw_text(struct wld_renderer * base,
 4                         struct font * font, uint32_t color,
 5-                        int32_t x, int32_t y, const char * text, int32_t length,
 6-                        struct wld_extents * extents)
 7+                        int32_t x, int32_t y, const char * text,
 8+                        uint32_t length, struct wld_extents * extents)
 9 {
10     struct intel_renderer * renderer = intel_renderer(base);
11     struct intel_buffer * dst = renderer->target;
12@@ -289,6 +289,9 @@ void renderer_draw_text(struct wld_renderer * base,
13     xy_setup_blt(&renderer->batch, true, BLT_RASTER_OPERATION_SRC,
14                  0, color, dst->bo, dst->base.base.pitch);
15 
16+    if (length == -1)
17+        length = strlen(text);
18+
19     while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
20     {
21         text += ret;
+1, -1
1@@ -44,7 +44,7 @@ static void renderer_copy_region(struct wld_renderer * base,
2 static void renderer_draw_text(struct wld_renderer * renderer,
3                                struct font * font, uint32_t color,
4                                int32_t x, int32_t y,
5-                               const char * text, int32_t length,
6+                               const char * text, uint32_t length,
7                                struct wld_extents * extents);
8 static void renderer_flush(struct wld_renderer * renderer);
9 static void renderer_destroy(struct wld_renderer * renderer);
+5, -2
 1@@ -540,8 +540,8 @@ void renderer_copy_rectangle(struct wld_renderer * base,
 2 
 3 void renderer_draw_text(struct wld_renderer * base,
 4                         struct font * font, uint32_t color,
 5-                        int32_t x, int32_t y, const char * text, int32_t length,
 6-                        struct wld_extents * extents)
 7+                        int32_t x, int32_t y, const char * text,
 8+                        uint32_t length, struct wld_extents * extents)
 9 {
10     struct nouveau_renderer * renderer = nouveau_renderer(base);
11     struct nouveau_buffer * dst = renderer->target;
12@@ -572,6 +572,9 @@ void renderer_draw_text(struct wld_renderer * base,
13     if (nouveau_pushbuf_validate(renderer->pushbuf) != 0)
14         return;
15 
16+    if (length == -1)
17+        length = strlen(text);
18+
19     while ((ret = FcUtf8ToUcs4((FcChar8 *) text, &c, length)) > 0 && c != '\0')
20     {
21         text += ret;
+3, -3
 1@@ -328,15 +328,15 @@ static inline uint8_t reverse(uint8_t byte)
 2 
 3 void renderer_draw_text(struct wld_renderer * base,
 4                         struct font * font, uint32_t color,
 5-                        int32_t x, int32_t y, const char * text, int32_t length,
 6-                        struct wld_extents * extents)
 7+                        int32_t x, int32_t y, const char * text,
 8+                        uint32_t length, struct wld_extents * extents)
 9 {
10     struct pixman_renderer * renderer = pixman_renderer(base);
11     int ret;
12     uint32_t c;
13     struct glyph * glyph;
14     FT_UInt glyph_index;
15-    pixman_glyph_t glyphs[length == -1 ? strlen(text) : length];
16+    pixman_glyph_t glyphs[length == -1 ? (length = strlen(text)) : length];
17     uint32_t index = 0, origin_x = 0;
18     pixman_color_t pixman_color = PIXMAN_COLOR(color);
19     pixman_image_t * solid;
+4, -4
 1@@ -137,10 +137,10 @@ void wld_copy_region(struct wld_renderer * renderer,
 2 }
 3 
 4 EXPORT
 5-void wld_draw_text_n(struct wld_renderer * renderer,
 6-                     struct wld_font * font_base, uint32_t color,
 7-                     int32_t x, int32_t y, const char * text, int32_t length,
 8-                     struct wld_extents * extents)
 9+void wld_draw_text(struct wld_renderer * renderer,
10+                   struct wld_font * font_base, uint32_t color,
11+                   int32_t x, int32_t y, const char * text, uint32_t length,
12+                   struct wld_extents * extents)
13 {
14     struct font * font = (void *) font_base;
15 
+1, -1
1@@ -115,7 +115,7 @@ struct wld_renderer_impl
2                          pixman_region32_t * region);
3     void (* draw_text)(struct wld_renderer * renderer,
4                        struct font * font, uint32_t color,
5-                       int32_t x, int32_t y, const char * text, int32_t length,
6+                       int32_t x, int32_t y, const char * text, uint32_t length,
7                        struct wld_extents * extents);
8     void (* flush)(struct wld_renderer * renderer);
9     void (* destroy)(struct wld_renderer * renderer);
M wld.h
+6, -13
 1@@ -267,22 +267,15 @@ void wld_copy_region(struct wld_renderer * renderer,
 2 /**
 3  * Draw a UTF-8 text string to the given buffer.
 4  *
 5- * @param length    The maximum number of bytes in the string to process
 6+ * @param length    The maximum number of bytes in the string to process. If
 7+ *                  length is -1, then draw until a NULL byte is found.
 8  * @param extents   If not NULL, will be initialized to the extents of the
 9  *                  drawn text
10  */
11-void wld_draw_text_n(struct wld_renderer * renderer,
12-                     struct wld_font * font, uint32_t color,
13-                     int32_t x, int32_t y, const char * text, int32_t length,
14-                     struct wld_extents * extents);
15-
16-static inline void wld_draw_text(struct wld_renderer * renderer,
17-                                 struct wld_font * font, uint32_t color,
18-                                 int32_t x, int32_t y, const char * text,
19-                                 struct wld_extents * extents)
20-{
21-    wld_draw_text_n(renderer, font, color, x, y, text, INT32_MAX, extents);
22-}
23+void wld_draw_text(struct wld_renderer * renderer,
24+                   struct wld_font * font, uint32_t color,
25+                   int32_t x, int32_t y, const char * text, uint32_t length,
26+                   struct wld_extents * extents);
27 
28 void wld_flush(struct wld_renderer * renderer);
29