shl: move log.[ch] to shl_log.[ch]
[platform/upstream/kmscon.git] / src / text_bbulk.c
index dc1c4b6..3f238c1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * kmscon - Bit-Blitting Bulk Text Renderer Backend
  *
- * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
+ * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@googlemail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files
@@ -36,9 +36,9 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
-#include "log.h"
+#include "shl_log.h"
 #include "text.h"
-#include "uterm.h"
+#include "uterm_video.h"
 
 #define LOG_SUBSYSTEM "text_bbulk"
 
@@ -49,9 +49,6 @@ struct bbulk {
 #define FONT_WIDTH(txt) ((txt)->font->attr.width)
 #define FONT_HEIGHT(txt) ((txt)->font->attr.height)
 
-#define SCREEN_WIDTH(txt) uterm_screen_width((txt)->screen)
-#define SCREEN_HEIGHT(txt) uterm_screen_height((txt)->screen)
-
 static int bbulk_init(struct kmscon_text *txt)
 {
        struct bbulk *bb;
@@ -76,11 +73,15 @@ static int bbulk_set(struct kmscon_text *txt)
        struct bbulk *bb = txt->data;
        unsigned int sw, sh, i, j;
        struct uterm_video_blend_req *req;
+       struct uterm_mode *mode;
 
        memset(bb, 0, sizeof(*bb));
 
-       sw = SCREEN_WIDTH(txt);
-       sh = SCREEN_HEIGHT(txt);
+       mode = uterm_display_get_current(txt->disp);
+       if (!mode)
+               return -EINVAL;
+       sw = uterm_mode_get_width(mode);
+       sh = uterm_mode_get_height(mode);
 
        txt->cols = sw / FONT_WIDTH(txt);
        txt->rows = sh / FONT_HEIGHT(txt);
@@ -111,6 +112,7 @@ static void bbulk_unset(struct kmscon_text *txt)
 
 static int bbulk_draw(struct kmscon_text *txt,
                      uint32_t id, const uint32_t *ch, size_t len,
+                     unsigned int width,
                      unsigned int posx, unsigned int posy,
                      const struct tsm_screen_attr *attr)
 {
@@ -120,6 +122,11 @@ static int bbulk_draw(struct kmscon_text *txt,
        struct uterm_video_blend_req *req;
        struct kmscon_font *font;
 
+       if (!width) {
+               bb->reqs[posy * txt->cols + posx].buf = NULL;
+               return 0;
+       }
+
        if (attr->bold)
                font = txt->bold_font;
        else
@@ -162,12 +169,13 @@ static int bbulk_render(struct kmscon_text *txt)
 {
        struct bbulk *bb = txt->data;
 
-       return uterm_screen_blendv(txt->screen, bb->reqs,
-                                  txt->cols * txt->rows);
+       return uterm_display_fake_blendv(txt->disp, bb->reqs,
+                                        txt->cols * txt->rows);
 }
 
-static const struct kmscon_text_ops kmscon_text_bbulk_ops = {
+struct kmscon_text_ops kmscon_text_bbulk_ops = {
        .name = "bbulk",
+       .owner = NULL,
        .init = bbulk_init,
        .destroy = bbulk_destroy,
        .set = bbulk_set,
@@ -177,21 +185,3 @@ static const struct kmscon_text_ops kmscon_text_bbulk_ops = {
        .render = bbulk_render,
        .abort = NULL,
 };
-
-int kmscon_text_bbulk_load(void)
-{
-       int ret;
-
-       ret = kmscon_text_register(&kmscon_text_bbulk_ops);
-       if (ret) {
-               log_error("cannot register bbulk renderer");
-               return ret;
-       }
-
-       return 0;
-}
-
-void kmscon_text_bbulk_unload(void)
-{
-       kmscon_text_unregister(kmscon_text_bbulk_ops.name);
-}