Skip to content

High CPU load with "fillText" #21

@jvondrus

Description

@jvondrus

Hello to all,
I'm working on my touch screen project on Raspberry Pi with framebuffer at console. It works very well but it has high CPU load.
All my graphic (some PNG import, come Rect and some Circle) take around 20% od CPU, but CPU load come to 80% when I add just 1 line of text with Openvg-canvas. And to full load with more than 5 text field.

Here is part of my code with text print:

// Inicialize
var fs                  = require ('fs');
var frame                   = require ('./node_modules/openvg-canvas/lib/util.js');
var Canvas              = require ('./node_modules/openvg-canvas/lib/canvas.js');
var canvas              = new Canvas(800, 600);
var ctx                 = canvas.getContext('2d');

// Load Background image
imgBck.src      = fs.readFileSync ('background.png');
imgFieldG.src       = fs.readFileSync ('field.png');

// Set text alling
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';

// Start main loop
frame.animate (function (time) {
    oneFrame ();
});


// MAIN FRAME
function oneFrame ()
{
    // Draw background image
    ctx.drawImage (imgBck,      0, 0);

    // Draw image
    ctx.drawImage (imgFieldG, 50, 50);

    // Field name
    ctx.font = 'normal 24px Impact, serif';
    ctx.fillText ("Text field 1",100, 100);
    ctx.fillText ("Text field 2", 100, 200);
    ctx.fillText ("Text field 3", 100, 300);
    ctx.fillText ("Text field 4", 100, 400);
}

What is wrong with text rendering than CPU load going so high?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions