openvg icon indicating copy to clipboard operation
openvg copied to clipboard

Performance of large rects vs background

Open skinkie opened this issue 8 years ago • 1 comments

I am benchmarking the visual bahavior of tickers on different platforms. A ticker can be seen as a HTML Marquee element and is found in clip.c. I am implementing a small visual interface around it and noticed some unexpected behavior.

Consider 3 rects. A small header, a flat content area and a small footer. A ticker is running in the footer. I noticed that drawing the background of the content area manually the ticker starts to tear and stutter. When I color this section by means of Background. I get the same visual appearance and smooth linear motion of the text.

I have tried to change the order of rendering, but it doesn't seem to affect the behavior. Is this a direct limitation in OpenVG? If so, can it be overcome via OpenGL for example by buffering the Text operation, or a "more efficient" rect fill?

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "shapes.h"

int main() {
        int  w, h, fontsize, cy0;
        char *message = "Now is";
        char s[3];
        init(&w, &h);
        fontsize = w / 50;
        float x = w;
        VGfloat tw = TextWidth(message, SansTypeface, fontsize);

        while ((x + tw) >= 0.0) {
                x -= 2.0;
                Start(w, h);

                Background(213, 43, 30);
/*              Background(255, 255, 255); */

                Fill(255, 255, 255, 1);
                Rect(0.0, 0.0, (float) w, (float) (fontsize * 2));
                Translate(x, (float) (fontsize / 2));
                Fill(0, 0, 0, 1);
                Text(0, 0, message, SansTypeface, fontsize);
                Translate(-x, (float) -(fontsize / 2));
/*              Fill(213, 43, 30, 1);
                Rect(0.0, (float) (fontsize * 2), (float) w, (float) (h - (fontsize * 4)));*/
                Fill(255, 255, 255, 1);
                Rect(0.0, (float) (h - (fontsize * 2)), (float) w, (float) (fontsize * 2));
                End();
        }
        fgets(s, 2, stdin);
        finish();
        exit(0);
}

skinkie avatar Feb 27 '16 03:02 skinkie

The Rect call has the overhead of using and destroying paths.

ajstarks avatar Feb 27 '16 12:02 ajstarks