Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance of large rects vs background #48

Open
skinkie opened this issue Feb 27, 2016 · 1 comment
Open

Performance of large rects vs background #48

skinkie opened this issue Feb 27, 2016 · 1 comment

Comments

@skinkie
Copy link

skinkie commented Feb 27, 2016

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);
}
@ajstarks
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants